/********************************************************************\ * BitlBee -- An IRC to other IM-networks gateway * * * * Copyright 2002-2006 Wilmer van der Gaast and others * \********************************************************************/ /* IRC 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define BITLBEE_CORE #include "bitlbee.h" #include "ipc.h" #include "chat.h" static void irc_cmd_pass( irc_t *irc, char **cmd ) { if( irc->status & USTATUS_LOGGED_IN ) { char *send_cmd[] = { "identify", cmd[1], NULL }; /* We're already logged in, this client seems to send the PASS command last. (Possibly it won't send it at all if it turns out we don't require it, which will break this feature.) Try to identify using the given password. */ return root_command( irc, send_cmd ); } /* Handling in pre-logged-in state, first see if this server is password-protected: */ else if( global.conf->auth_pass && ( strncmp( global.conf->auth_pass, "md5:", 4 ) == 0 ? md5_verify_password( cmd[1], global.conf->auth_pass + 4 ) == 0 : strcmp( cmd[1], global.conf->auth_pass ) == 0 ) ) { irc->status |= USTATUS_AUTHORIZED; irc_check_login( irc ); } else if( global.conf->auth_pass ) { irc_reply( irc, 464, ":Incorrect password" ); } else { /* Remember the password and try to identify after USER/NICK. */ irc_setpass( irc, cmd[1] ); irc_check_login( irc ); } } static void irc_cmd_user( irc_t *irc, char **cmd ) { irc->user = g_strdup( cmd[1] ); irc->realname = g_strdup( cmd[4] ); irc_check_login( irc ); } static void irc_cmd_nick( irc_t *irc, char **cmd ) { if( irc->nick ) { irc_reply( irc, 438, ":The hand of the deity is upon thee, thy nick may not change" ); } /* This is not clean, but for now it'll have to be like this... */ else if( ( nick_cmp( cmd[1], irc->mynick ) == 0 ) || ( nick_cmp( cmd[1], NS_NICK ) == 0 ) ) { irc_reply( irc, 433, ":This nick is already in use" ); } else if( !nick_ok( cmd[1] ) ) { /* [SH] Invalid characters. */ irc_reply( irc, 432, ":This nick contains invalid characters" ); } else { irc->nick = g_strdup( cmd[1] ); irc_check_login( irc ); } } static void irc_cmd_quit( irc_t *irc, char **cmd ) { if( cmd[1] && *cmd[1] ) irc_abort( irc, 0, "Quit: %s", cmd[1] ); else irc_abort( irc, 0, "Leaving..." ); } static void irc_cmd_ping( irc_t *irc, char **cmd ) { irc_write( irc, ":%s PONG %s :%s", irc->myhost, irc->myhost, cmd[1]?cmd[1]:irc->myhost ); } static void irc_cmd_oper( irc_t *irc, char **cmd ) { if( global.conf->oper_pass && ( strncmp( global.conf->oper_pass, "md5:", 4 ) == 0 ? md5_verify_password( cmd[2], global.conf->oper_pass + 4 ) == 0 : strcmp( cmd[2], global.conf->oper_pass ) == 0 ) ) { irc_umode_set( irc, "+o", 1 ); irc_reply( irc, 381, ":Password accepted" ); } else { irc_reply( irc, 432, ":Incorrect password" ); } } static void irc_cmd_mode( irc_t *irc, char **cmd ) { if( strchr( CTYPES, *cmd[1] ) ) { if( cmd[2] ) { if( *cmd[2] == '+' || *cmd[2] == '-' ) irc_reply( irc, 477, "%s :Can't change channel modes", cmd[1] ); else if( *cmd[2] == 'b' ) irc_reply( irc, 368, "%s :No bans possible", cmd[1] ); } else irc_reply( irc, 324, "%s +%s", cmd[1], CMODE ); } else { if( nick_cmp( cmd[1], irc->nick ) == 0 ) { if( cmd[2] ) irc_umode_set( irc, cmd[2], 0 ); else irc_reply( irc, 221, "+%s", irc->umode ); } else irc_reply( irc, 502, ":Don't touch their modes" ); } } static void irc_cmd_names( irc_t *irc, char **cmd ) { irc_names( irc, cmd[1]?cmd[1]:irc->channel ); } static void irc_cmd_part( irc_t *irc, char **cmd ) { struct groupchat *c; if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) { user_t *u = user_find( irc, irc->nick ); /* Not allowed to leave control channel */ irc_part( irc, u, irc->channel ); irc_join( irc, u, irc->channel ); } else if( ( c = irc_chat_by_channel( irc, cmd[1] ) ) ) { user_t *u = user_find( irc, irc->nick ); irc_part( irc, u, c->channel ); if( c->ic ) { c->joined = 0; c->ic->acc->prpl->chat_leave( c ); } } else { irc_reply( irc, 403, "%s :No such channel", cmd[1] ); } } static void irc_cmd_join( irc_t *irc, char **cmd ) { if( g_strcasecmp( cmd[1], irc->channel ) == 0
/* --------------------------------------------------------------------------
*
* License
*
* The contents of this file are subject to the Jabber Open Source License
* Version 1.0 (the "JOSL"). You may not copy or use this file, in either
* source code or executable form, except in compliance with the JOSL. You
* may obtain a copy of the JOSL at http://www.jabber.org/ or at
* http://www.opensource.org/.
*
* Software distributed under the JOSL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the JOSL
* for the specific language governing rights and limitations under the
* JOSL.
*
* Copyrights
*
* Portions created by or assigned to Jabber.com, Inc. are
* Copyright (c) 1999-2002 Jabber.com, Inc. All Rights Reserved. Contact
* information for Jabber.com, Inc. is available at http://www.jabber.com/.
*
* Portions Copyright (c) 1998-1999 Jeremie Miller.
*
* Acknowledgements
*
* Special thanks to the Jabber Open Source Contributors for their
* suggestions and support of Jabber.
*
* Alternatively, the contents of this file may be used under the terms of the
* GNU General Public License Version 2 or later (the "GPL"), in which case
* the provisions of the GPL are applicable instead of those above. If you
* wish to allow use of your version of this file only under the terms of the
* GPL and not to allow others to use your version of this file under the JOSL,
* indicate your decision by deleting the provisions above and replace them
* with the notice and other provisions required by the GPL. If you do not
* delete the provisions above, a recipient may use your version of this file
* under either the JOSL or the GPL.
*
*
* --------------------------------------------------------------------------*/
#include "lib.h"
#include <glib.h>
void xmlnode_put_expat_attribs(xmlnode owner, const char** atts)
{
int i = 0;
if (atts == NULL) return;
while (atts[i] != '\0')
{
xmlnode_put_attrib(owner, atts[i], atts[i+1]);
i += 2;
}
}