/********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * * Copyright 2002-2013 Wilmer van der Gaast and others * \********************************************************************/ /* User manager (root) commands */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License with the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; if not, write to the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor, Boston, MA 02110-1301 USA */ #define BITLBEE_CORE #include "commands.h" #include "bitlbee.h" #include "help.h" #include "ipc.h" void root_command_string(irc_t *irc, char *command) { root_command(irc, split_command_parts(command, 0)); } #define MIN_ARGS(x, y ...) \ do \ { \ int blaat; \ for (blaat = 0; blaat <= x; blaat++) { \ if (cmd[blaat] == NULL) \ { \ irc_rootmsg(irc, "Not enough parameters given (need %d).", x); \ return y; \ } } \ } while (0) void root_command(irc_t *irc, char *cmd[]) { int i, len; if (!cmd[0]) { return; } len = strlen(cmd[0]); for (i = 0; root_commands[i].command; i++) { if (g_strncasecmp(root_commands[i].command, cmd[0], len) == 0) { if (root_commands[i + 1].command && g_strncasecmp(root_commands[i + 1].command, cmd[0], len) == 0) { /* Only match on the first letters if the match is unique. */ break; } MIN_ARGS(root_commands[i].required_parameters); root_commands[i].execute(irc, cmd); return; } } irc_rootmsg(irc, "Unknown command: %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[0]); } static void cmd_help(irc_t *irc, char **cmd) { char param[80]; int i; char *s; memset(param, 0, sizeof(param)); for (i = 1; (cmd[i] != NULL && (strlen(param) < (sizeof(param) - 1))); i++) { if (i != 1) { // prepend space except for the first parameter strcat(param, " "); } strncat(param, cmd[i], sizeof(param) - strlen(param) - 1); } s = help_get(&(global.help), param); if (!s) { s = help_get(&(global.help), ""); } if (s) { irc_rootmsg(irc, "%s", s); g_free(s); } else { irc_rootmsg(irc, "Error opening helpfile."); } } static void cmd_account(irc_t *irc, char **cmd); static void bitlbee_whatsnew(irc_t *irc); static void cmd_identify(irc_t *irc, char **cmd) { storage_status_t status; gboolean load = TRUE; char *password = cmd[1]; if (irc->status & USTATUS_IDENTIFIED) { irc_rootmsg(irc, "You're already logged in."); return; } if (cmd[1] == NULL) { } else if (strncmp(cmd[1], "-no", 3) == 0) { load = FALSE; password = cmd[2]; if (password == NULL) { irc->status |= OPER_HACK_IDENTIFY_NOLOAD; } } else if (strncmp(cmd[1], "-force", 6) == 0) { password = cmd[2]; if (password == NULL) { irc->status |= OPER_HACK_IDENTIFY_FORCE; } } else if (irc->b->accounts != NULL) { irc_rootmsg(irc, "You're trying to identify yourself, but already have " "at least one IM account set up. " "Use \x02identify -noload\x02 or \x02identify -force\x02 " "instead (see \x02help identify\x02)."); return; } if (password == NULL) { irc_rootmsg(irc, "About to identify, use /OPER to enter the password"); irc->status |= OPER_HACK_IDENTIFY; return; } status = auth_check_pass(irc, irc->user->nick, password); if (load && (statu
/***************************************************************************\
* *
* BitlBee - An IRC to IM gateway *
* Utility functions for file transfer *
* *
* Copyright 2008 Uli Meis <a.sporto+bee@gmail.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
\***************************************************************************/
#ifndef AI_NUMERICSERV
#define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
#endif
/* Some ifdefs for ulibc and apparently also BSD (Thanks to Whoopie) */
#ifndef HOST_NAME_MAX
#include <sys/param.h>
#ifdef MAXHOSTNAMELEN
#define HOST_NAME_MAX MAXHOSTNAMELEN
#else
#define HOST_NAME_MAX 255
#endif
#endif
/* This function should be used with care. host should be AT LEAST a
char[HOST_NAME_MAX+1] and port AT LEAST a char[6]. */
int ft_listen( struct sockaddr_storage *saddr_ptr, char *host, char *port, int copy_fd, int for_bitlbee_client, char **errptr );