Changeset f73b969
- Timestamp:
- 2006-01-20T15:15:49Z (19 years ago)
- Branches:
- master
- Children:
- 54879ab, f1d38f2
- Parents:
- 55ec2d6
- Files:
-
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r55ec2d6 rf73b969 10 10 11 11 # Program variables 12 objects = account.o bitlbee.o co mmands.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o set.o storage.o storage_text.o unix.o url.o user.o util.o12 objects = account.o bitlbee.o conf.o crypting.o help.o ini.o ipc.o irc.o irc_commands.o log.o nick.o query.o root_commands.o set.o storage.o storage_text.o unix.o url.o user.o util.o 13 13 subdirs = protocols 14 14 -
bitlbee.c
r55ec2d6 rf73b969 167 167 } 168 168 169 if( !irc_process( irc ) ) 170 { 171 log_message( LOGLVL_INFO, "Destroying connection with fd %d.", irc->fd ); 172 irc_abort( irc ); 169 irc_process( irc ); 170 171 /* Normally, irc_process() shouldn't call irc_free() but irc_abort(). Just in case: */ 172 if( !g_slist_find( irc_connection_list, irc ) ) 173 { 174 log_message( LOGLVL_WARNING, "Abnormal termination of connection with fd %d.", irc->fd ); 173 175 return FALSE; 174 176 } -
bitlbee.h
r55ec2d6 rf73b969 129 129 gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data ); 130 130 131 introot_command_string( irc_t *irc, user_t *u, char *command, int flags );132 introot_command( irc_t *irc, char *command[] );131 void root_command_string( irc_t *irc, user_t *u, char *command, int flags ); 132 void root_command( irc_t *irc, char *command[] ); 133 133 void bitlbee_shutdown( gpointer data ); 134 134 double gettime( void ); -
commands.h
r55ec2d6 rf73b969 33 33 char *command; 34 34 int required_parameters; 35 int(*execute)(irc_t *, char **args);35 void (*execute)(irc_t *, char **args); 36 36 int flags; 37 37 } command_t; -
ipc.c
r55ec2d6 rf73b969 32 32 33 33 34 static intipc_master_cmd_client( irc_t *data, char **cmd )34 static void ipc_master_cmd_client( irc_t *data, char **cmd ) 35 35 { 36 36 struct bitlbee_child *child = (void*) data; … … 45 45 ipc_to_children_str( "OPERMSG :Client connecting (PID=%d): %s@%s (%s)\r\n", 46 46 child ? child->pid : -1, cmd[2], cmd[1], cmd[3] ); 47 48 return 1; 49 } 50 51 static int ipc_master_cmd_die( irc_t *data, char **cmd ) 47 } 48 49 static void ipc_master_cmd_die( irc_t *data, char **cmd ) 52 50 { 53 51 if( global.conf->runmode == RUNMODE_FORKDAEMON ) … … 55 53 56 54 bitlbee_shutdown( NULL ); 57 58 return 1; 59 } 60 61 int ipc_master_cmd_rehash( irc_t *data, char **cmd ) 55 } 56 57 void ipc_master_cmd_rehash( irc_t *data, char **cmd ) 62 58 { 63 59 runmode_t oldmode; … … 76 72 if( global.conf->runmode == RUNMODE_FORKDAEMON ) 77 73 ipc_to_children( cmd ); 78 79 return 1;80 74 } 81 75 … … 92 86 93 87 94 static int ipc_child_cmd_die( irc_t *irc, char **cmd ) 95 { 96 if( irc->status >= USTATUS_LOGGED_IN ) 97 irc_write( irc, "ERROR :Operator requested server shutdown, bye bye!" ); 98 99 irc_abort( irc ); 100 101 return 1; 102 } 103 104 static int ipc_child_cmd_wallops( irc_t *irc, char **cmd ) 88 static void ipc_child_cmd_die( irc_t *irc, char **cmd ) 89 { 90 irc_abort( irc, 1, "Shutdown requested by operator" ); 91 } 92 93 static void ipc_child_cmd_wallops( irc_t *irc, char **cmd ) 105 94 { 106 95 if( irc->status < USTATUS_LOGGED_IN ) 107 return 1;96 return; 108 97 109 98 if( strchr( irc->umode, 'w' ) ) 110 99 irc_write( irc, ":%s WALLOPS :%s", irc->myhost, cmd[1] ); 111 112 return 1; 113 } 114 115 static int ipc_child_cmd_lilo( irc_t *irc, char **cmd ) 100 } 101 102 static void ipc_child_cmd_lilo( irc_t *irc, char **cmd ) 116 103 { 117 104 if( irc->status < USTATUS_LOGGED_IN ) 118 return 1;105 return; 119 106 120 107 if( strchr( irc->umode, 's' ) ) 121 108 irc_write( irc, ":%s NOTICE %s :%s", irc->myhost, irc->nick, cmd[1] ); 122 123 return 1; 124 } 125 126 static int ipc_child_cmd_opermsg( irc_t *irc, char **cmd ) 109 } 110 111 static void ipc_child_cmd_opermsg( irc_t *irc, char **cmd ) 127 112 { 128 113 if( irc->status < USTATUS_LOGGED_IN ) 129 return 1;114 return; 130 115 131 116 if( strchr( irc->umode, 'o' ) ) 132 117 irc_write( irc, ":%s NOTICE %s :*** OperMsg *** %s", irc->myhost, irc->nick, cmd[1] ); 133 134 return 1; 135 } 136 137 static int ipc_child_cmd_rehash( irc_t *irc, char **cmd ) 118 } 119 120 static void ipc_child_cmd_rehash( irc_t *irc, char **cmd ) 138 121 { 139 122 runmode_t oldmode; … … 145 128 146 129 global.conf->runmode = oldmode; 147 148 return 1; 149 } 150 151 static int ipc_child_cmd_kill( irc_t *irc, char **cmd ) 130 } 131 132 static void ipc_child_cmd_kill( irc_t *irc, char **cmd ) 152 133 { 153 134 if( irc->status < USTATUS_LOGGED_IN ) 154 return 1;135 return; 155 136 156 137 if( nick_cmp( cmd[1], irc->nick ) != 0 ) 157 return 1;/* It's not for us. */138 return; /* It's not for us. */ 158 139 159 140 irc_write( irc, ":%s!%s@%s KILL %s :%s", irc->mynick, irc->mynick, irc->myhost, irc->nick, cmd[2] ); 160 irc_abort( irc ); 161 /* g_io_channel_close( irc->io_channel ); */ 162 163 return 0; 141 irc_abort( irc, 0, "Killed by operator: %s", cmd[2] ); 164 142 } 165 143 -
ipc.h
r55ec2d6 rf73b969 52 52 53 53 /* We need this function in inetd mode, so let's just make it non-static. */ 54 intipc_master_cmd_rehash( irc_t *data, char **cmd );54 void ipc_master_cmd_rehash( irc_t *data, char **cmd ); 55 55 56 56 -
irc.c
r55ec2d6 rf73b969 152 152 } 153 153 154 /* immed=1 makes this function pretty much equal to irc_free(), except that 155 this one will "log". In case the connection is already broken and we 156 shouldn't try to write to it. */ 154 157 void irc_abort( irc_t *irc, int immed, char *format, ... ) 155 158 { 156 va_list params;157 158 159 if( format != NULL ) 159 160 { 161 va_list params; 160 162 char *reason; 161 163 162 164 va_start( params, format ); 163 reason = g_strdup_ printf( format, params );165 reason = g_strdup_vprintf( format, params ); 164 166 va_end( params ); 165 167 … … 168 170 169 171 ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n", 170 irc->nick , irc->host, reason");172 irc->nick ? irc->nick : "(NONE)", irc->host, reason ); 171 173 172 174 g_free( reason ); … … 178 180 179 181 ipc_to_master_str( "OPERMSG :Client exiting: %s@%s [%s]\r\n", 180 irc->nick , irc->host, "No reason given" );182 irc->nick ? irc->nick : "(NONE)", irc->host, "No reason given" ); 181 183 } 182 184 … … 339 341 } 340 342 341 intirc_process( irc_t *irc )343 void irc_process( irc_t *irc ) 342 344 { 343 345 char **lines, *temp, **cmd; … … 361 363 if( ( cmd = irc_parse_line( lines[i] ) ) == NULL ) 362 364 continue; 363 if( !irc_exec( irc, cmd ) ) 364 { 365 g_free( cmd ); 366 g_free( lines ); 367 return 0; 368 } 365 irc_exec( irc, cmd ); 369 366 370 367 g_free( cmd ); 368 369 /* Shouldn't really happen, but just in case... */ 370 if( !g_slist_find( irc_connection_list, irc ) ) 371 { 372 g_free( lines ); 373 return; 374 } 371 375 } 372 376 … … 379 383 g_free( lines ); 380 384 } 381 382 return 1;383 385 } 384 386 … … 972 974 973 975 if( u->send_handler ) 974 return( u->send_handler( irc, u, s, flags ) ); 976 { 977 u->send_handler( irc, u, s, flags ); 978 return 1; 979 } 975 980 } 976 981 else if( c && c->gc && c->gc->prpl ) … … 998 1003 } 999 1004 1000 intbuddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )1001 { 1002 if( !u || !u->gc ) return ( 0 );1005 void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags ) 1006 { 1007 if( !u || !u->gc ) return; 1003 1008 1004 1009 if( set_getint( irc, "buddy_sendbuffer" ) && set_getint( irc, "buddy_sendbuffer_delay" ) > 0 ) … … 1036 1041 g_source_remove( u->sendbuf_timer ); 1037 1042 u->sendbuf_timer = g_timeout_add( delay, buddy_send_handler_delayed, u ); 1038 1039 return( 1 );1040 1043 } 1041 1044 else 1042 1045 { 1043 return( serv_send_im( irc, u, msg, flags ));1046 serv_send_im( irc, u, msg, flags ); 1044 1047 } 1045 1048 } … … 1146 1149 if( rv > 0 ) 1147 1150 { 1148 irc_abort( irc, "ERROR :Closing Link:Ping Timeout: %d seconds", rv );1151 irc_abort( irc, 0, "Ping Timeout: %d seconds", rv ); 1149 1152 return FALSE; 1150 1153 } -
irc.h
r55ec2d6 rf73b969 108 108 void irc_free( irc_t *irc ); 109 109 110 intirc_exec( irc_t *irc, char **cmd );111 intirc_process( irc_t *irc );110 void irc_exec( irc_t *irc, char **cmd ); 111 void irc_process( irc_t *irc ); 112 112 char **irc_parse_line( char *line ); 113 113 char *irc_build_line( char **cmd ); … … 134 134 void irc_invite( irc_t *irc, char *nick, char *channel ); 135 135 void irc_whois( irc_t *irc, char *nick ); 136 int irc_away( irc_t *irc, char *away );137 136 void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */ 138 137 … … 142 141 int irc_noticefrom( irc_t *irc, char *nick, char *msg ); 143 142 144 intbuddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags );143 void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags ); 145 144 146 145 #endif -
irc_commands.c
r55ec2d6 rf73b969 28 28 #include "ipc.h" 29 29 30 static intirc_cmd_pass( irc_t *irc, char **cmd )30 static void irc_cmd_pass( irc_t *irc, char **cmd ) 31 31 { 32 32 if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 ) … … 39 39 irc_reply( irc, 464, ":Incorrect password" ); 40 40 } 41 42 return( 1 ); 43 } 44 45 static int irc_cmd_user( irc_t *irc, char **cmd ) 41 } 42 43 static void irc_cmd_user( irc_t *irc, char **cmd ) 46 44 { 47 45 irc->user = g_strdup( cmd[1] ); … … 49 47 50 48 irc_check_login( irc ); 51 52 return( 1 ); 53 } 54 55 static int irc_cmd_nick( irc_t *irc, char **cmd ) 49 } 50 51 static void irc_cmd_nick( irc_t *irc, char **cmd ) 56 52 { 57 53 if( irc->nick ) … … 75 71 irc_check_login( irc ); 76 72 } 77 78 return( 1 ); 79 } 80 81 static int irc_cmd_quit( irc_t *irc, char **cmd ) 82 { 83 irc_write( irc, "ERROR :%s%s", cmd[1]?"Quit: ":"", cmd[1]?cmd[1]:"Client Quit" ); 84 /* g_io_channel_close( irc->io_channel ); */ 85 86 return( 0 ); 87 } 88 89 static int irc_cmd_ping( irc_t *irc, char **cmd ) 73 } 74 75 static void irc_cmd_quit( irc_t *irc, char **cmd ) 76 { 77 if( cmd[1] && *cmd[1] ) 78 irc_abort( irc, 0, "Quit: %s", cmd[1] ); 79 else 80 irc_abort( irc, 0, "Leaving..." ); 81 } 82 83 static void irc_cmd_ping( irc_t *irc, char **cmd ) 90 84 { 91 85 irc_write( irc, ":%s PONG %s :%s", irc->myhost, irc->myhost, cmd[1]?cmd[1]:irc->myhost ); 92 93 return( 1 ); 94 } 95 96 static int irc_cmd_oper( irc_t *irc, char **cmd ) 86 } 87 88 static void irc_cmd_oper( irc_t *irc, char **cmd ) 97 89 { 98 90 if( global.conf->oper_pass && strcmp( cmd[2], global.conf->oper_pass ) == 0 ) … … 105 97 irc_reply( irc, 432, ":Incorrect password" ); 106 98 } 107 108 return( 1 ); 109 } 110 111 static int irc_cmd_mode( irc_t *irc, char **cmd ) 99 } 100 101 static void irc_cmd_mode( irc_t *irc, char **cmd ) 112 102 { 113 103 if( *cmd[1] == '#' || *cmd[1] == '&' ) … … 133 123 irc_reply( irc, 502, ":Don't touch their modes" ); 134 124 } 135 136 return( 1 ); 137 } 138 139 static int irc_cmd_names( irc_t *irc, char **cmd ) 125 } 126 127 static void irc_cmd_names( irc_t *irc, char **cmd ) 140 128 { 141 129 irc_names( irc, cmd[1]?cmd[1]:irc->channel ); 142 143 return( 1 ); 144 } 145 146 static int irc_cmd_part( irc_t *irc, char **cmd ) 130 } 131 132 static void irc_cmd_part( irc_t *irc, char **cmd ) 147 133 { 148 134 struct conversation *c; … … 172 158 irc_reply( irc, 403, "%s :No such channel", cmd[1] ); 173 159 } 174 175 return( 1 ); 176 } 177 178 static int irc_cmd_join( irc_t *irc, char **cmd ) 160 } 161 162 static void irc_cmd_join( irc_t *irc, char **cmd ) 179 163 { 180 164 if( g_strcasecmp( cmd[1], irc->channel ) == 0 ) … … 210 194 } 211 195 } 212 213 return( 1 ); 214 } 215 216 static int irc_cmd_invite( irc_t *irc, char **cmd ) 196 } 197 198 static void irc_cmd_invite( irc_t *irc, char **cmd ) 217 199 { 218 200 char *nick = cmd[1], *channel = cmd[2]; … … 225 207 c->gc->prpl->chat_invite( c->gc, c->id, "", u->handle ); 226 208 irc_reply( irc, 341, "%s %s", nick, channel ); 227 return ( 1 );209 return; 228 210 } 229 211 230 212 irc_reply( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel ); 231 232 return( 1 ); 233 } 234 235 static int irc_cmd_privmsg( irc_t *irc, char **cmd ) 213 } 214 215 static void irc_cmd_privmsg( irc_t *irc, char **cmd ) 236 216 { 237 217 if ( !cmd[2] ) … … 283 263 irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? IM_FLAG_AWAY : 0 ); 284 264 } 285 286 return( 1 ); 287 } 288 289 static int irc_cmd_who( irc_t *irc, char **cmd ) 265 } 266 267 static void irc_cmd_who( irc_t *irc, char **cmd ) 290 268 { 291 269 char *channel = cmd[1]; … … 317 295 318 296 irc_reply( irc, 315, "%s :End of /WHO list", channel?channel:"**" ); 319 320 return( 1 ); 321 } 322 323 static int irc_cmd_userhost( irc_t *irc, char **cmd ) 297 } 298 299 static void irc_cmd_userhost( irc_t *irc, char **cmd ) 324 300 { 325 301 user_t *u; … … 340 316 irc_reply( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host ); 341 317 } 342 343 return( 1 ); 344 } 345 346 static int irc_cmd_ison( irc_t *irc, char **cmd ) 318 } 319 320 static void irc_cmd_ison( irc_t *irc, char **cmd ) 347 321 { 348 322 user_t *u; … … 383 357 384 358 irc_reply( irc, 303, ":%s", buff ); 385 386 return( 1 ); 387 } 388 389 static int irc_cmd_watch( irc_t *irc, char **cmd ) 359 } 360 361 static void irc_cmd_watch( irc_t *irc, char **cmd ) 390 362 { 391 363 int i; … … 430 402 } 431 403 } 432 433 return( 1 ); 434 } 435 436 static int irc_cmd_topic( irc_t *irc, char **cmd ) 404 } 405 406 static void irc_cmd_topic( irc_t *irc, char **cmd ) 437 407 { 438 408 if( cmd[2] ) … … 440 410 else 441 411 irc_topic( irc, cmd[1] ); 442 443 return( 1 ); 444 } 445 446 static int irc_cmd_away( irc_t *irc, char **cmd ) 412 } 413 414 static void irc_cmd_away( irc_t *irc, char **cmd ) 447 415 { 448 416 user_t *u = user_find( irc, irc->nick ); … … 450 418 char *away = cmd[1]; 451 419 452 if( !u ) return ( 1 );420 if( !u ) return; 453 421 454 422 if( away && *away ) … … 482 450 c = c->next; 483 451 } 484 485 return( 1 ); 486 } 487 488 static int irc_cmd_whois( irc_t *irc, char **cmd ) 452 } 453 454 static void irc_cmd_whois( irc_t *irc, char **cmd ) 489 455 { 490 456 char *nick = cmd[1]; … … 512 478 irc_reply( irc, 401, "%s :Nick does not exist", nick ); 513 479 } 514 515 return( 1 ); 516 } 517 518 static int irc_cmd_whowas( irc_t *irc, char **cmd ) 480 } 481 482 static void irc_cmd_whowas( irc_t *irc, char **cmd ) 519 483 { 520 484 /* For some reason irssi tries a whowas when whois fails. We can … … 525 489 irc_reply( irc, 406, "%s :Nick does not exist", cmd[1] ); 526 490 irc_reply( irc, 369, "%s :End of WHOWAS", cmd[1] ); 527 528 return( 1 ); 529 } 530 531 static int irc_cmd_nickserv( irc_t *irc, char **cmd ) 491 } 492 493 static void irc_cmd_nickserv( irc_t *irc, char **cmd ) 532 494 { 533 495 /* [SH] This aliases the NickServ command to PRIVMSG root */ 534 496 /* [TV] This aliases the NS command to PRIVMSG root as well */ 535 497 root_command( irc, cmd + 1 ); 536 537 return( 1 ); 538 } 539 540 static int irc_cmd_motd( irc_t *irc, char **cmd ) 498 } 499 500 static void irc_cmd_motd( irc_t *irc, char **cmd ) 541 501 { 542 502 irc_motd( irc ); 543 544 return( 1 ); 545 } 546 547 static int irc_cmd_pong( irc_t *irc, char **cmd ) 503 } 504 505 static void irc_cmd_pong( irc_t *irc, char **cmd ) 548 506 { 549 507 /* We could check the value we get back from the user, but in … … 551 509 irc->last_pong = gettime(); 552 510 irc->pinging = 0; 553 554 return( 1 ); 555 } 556 557 static int irc_cmd_completions( irc_t *irc, char **cmd ) 511 } 512 513 static void irc_cmd_completions( irc_t *irc, char **cmd ) 558 514 { 559 515 user_t *u = user_find( irc, irc->mynick ); … … 574 530 575 531 irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS ", "END" ); 576 577 return( 1 ); 578 } 579 580 static int irc_cmd_rehash( irc_t *irc, char **cmd ) 532 } 533 534 static void irc_cmd_rehash( irc_t *irc, char **cmd ) 581 535 { 582 536 if( global.conf->runmode == RUNMODE_INETD ) … … 586 540 587 541 irc_reply( irc, 382, "%s :Rehashing", CONF_FILE ); 588 589 return( 1 );590 542 } 591 543 … … 625 577 }; 626 578 627 intirc_exec( irc_t *irc, char *cmd[] )579 void irc_exec( irc_t *irc, char *cmd[] ) 628 580 { 629 int i , j;581 int i; 630 582 631 583 if( !cmd[0] ) 632 return ( 1 );584 return; 633 585 634 586 for( i = 0; irc_commands[i].command; i++ ) … … 638 590 { 639 591 irc_reply( irc, 462, ":Only allowed before logging in" ); 640 return( 1 ); 641 } 642 if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN ) 592 } 593 else if( irc_commands[i].flags & IRC_CMD_LOGGED_IN && irc->status < USTATUS_LOGGED_IN ) 643 594 { 644 595 irc_reply( irc, 451, ":Register first" ); 645 return( 1 ); 646 } 647 if( irc_commands[i].flags & IRC_CMD_OPER_ONLY && !strchr( irc->umode, 'o' ) ) 596 } 597 else if( irc_commands[i].flags & IRC_CMD_OPER_ONLY && !strchr( irc->umode, 'o' ) ) 648 598 { 649 599 irc_reply( irc, 481, ":Permission denied - You're not an IRC operator" ); 650 return( 1 ); 651 } 652 653 for( j = 1; j <= irc_commands[i].required_parameters; j ++ ) 654 if( !cmd[j] ) 655 { 656 irc_reply( irc, 461, "%s :Need more parameters", cmd[0] ); 657 return( 1 ); 658 } 659 660 if( irc_commands[i].flags & IRC_CMD_TO_MASTER ) 600 } 601 else if( !cmd[irc_commands[i].required_parameters] ) 602 { 603 irc_reply( irc, 461, "%s :Need more parameters", cmd[0] ); 604 } 605 else if( irc_commands[i].flags & IRC_CMD_TO_MASTER ) 606 { 661 607 /* IPC doesn't make sense in inetd mode, 662 608 but the function will catch that. */ 663 609 ipc_to_master( cmd ); 610 } 664 611 else 665 return irc_commands[i].execute( irc, cmd ); 666 } 667 668 return( 1 ); 669 } 612 { 613 irc_commands[i].execute( irc, cmd ); 614 } 615 616 break; 617 } 618 } -
root_commands.c
r55ec2d6 rf73b969 32 32 #include <string.h> 33 33 34 introot_command_string( irc_t *irc, user_t *u, char *command, int flags )34 void root_command_string( irc_t *irc, user_t *u, char *command, int flags ) 35 35 { 36 36 char *cmd[IRC_MAX_ARGS]; … … 64 64 cmd[k] = NULL; 65 65 66 r eturn( root_command( irc, cmd ));67 } 68 69 introot_command( irc_t *irc, char *cmd[] )66 root_command( irc, cmd ); 67 } 68 69 void root_command( irc_t *irc, char *cmd[] ) 70 70 { 71 71 int i; 72 72 73 73 if( !cmd[0] ) 74 return ( 0 );74 return; 75 75 76 76 for( i = 0; commands[i].command; i++ ) … … 80 80 { 81 81 irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters ); 82 return ( 0 );82 return; 83 83 } 84 84 commands[i].execute( irc, cmd ); 85 return ( 1 );85 return; 86 86 } 87 87 88 88 irc_usermsg( irc, "Unknown command: %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[0] ); 89 90 return( 1 ); 91 } 92 93 static int cmd_help( irc_t *irc, char **cmd ) 89 } 90 91 static void cmd_help( irc_t *irc, char **cmd ) 94 92 { 95 93 char param[80]; … … 111 109 irc_usermsg( irc, "%s", s ); 112 110 g_free( s ); 113 return( 1 );114 111 } 115 112 else 116 113 { 117 114 irc_usermsg( irc, "Error opening helpfile." ); 118 return( 0 ); 119 } 120 } 121 122 static int cmd_identify( irc_t *irc, char **cmd ) 115 } 116 } 117 118 static void cmd_identify( irc_t *irc, char **cmd ) 123 119 { 124 120 storage_status_t status = storage_load( irc->nick, cmd[1], irc ); … … 139 135 break; 140 136 } 141 142 return( 0 ); 143 } 144 145 static int cmd_register( irc_t *irc, char **cmd ) 137 } 138 139 static void cmd_register( irc_t *irc, char **cmd ) 146 140 { 147 141 if( global.conf->authmode == AUTHMODE_REGISTERED ) 148 142 { 149 143 irc_usermsg( irc, "This server does not allow registering new accounts" ); 150 return ( 0 );144 return; 151 145 } 152 146 … … 166 160 break; 167 161 } 168 169 return( 0 ); 170 } 171 172 static int cmd_drop( irc_t *irc, char **cmd ) 162 } 163 164 static void cmd_drop( irc_t *irc, char **cmd ) 173 165 { 174 166 storage_status_t status; … … 178 170 case STORAGE_NO_SUCH_USER: 179 171 irc_usermsg( irc, "That account does not exist" ); 180 return( 0 );172 break; 181 173 case STORAGE_INVALID_PASSWORD: 182 174 irc_usermsg( irc, "Password invalid" ); 183 return( 0 );175 break; 184 176 case STORAGE_OK: 185 177 irc_setpass( irc, NULL ); … … 187 179 irc_umode_set( irc, "-R", 1 ); 188 180 irc_usermsg( irc, "Account `%s' removed", irc->nick ); 189 return( 0 );181 break; 190 182 default: 191 183 irc_usermsg( irc, "Error: '%d'", status ); 192 return( 0 );193 } 194 } 195 196 static intcmd_account( irc_t *irc, char **cmd )184 break; 185 } 186 } 187 188 static void cmd_account( irc_t *irc, char **cmd ) 197 189 { 198 190 account_t *a; … … 201 193 { 202 194 irc_usermsg( irc, "This server only accepts registered users" ); 203 return ( 0 );195 return; 204 196 } 205 197 … … 211 203 { 212 204 irc_usermsg( irc, "Not enough parameters" ); 213 return ( 0 );205 return; 214 206 } 215 207 … … 219 211 { 220 212 irc_usermsg( irc, "Unknown protocol" ); 221 return ( 0 );213 return; 222 214 } 223 215 … … 281 273 { 282 274 irc_usermsg( irc, "Account already online" ); 283 return ( 0 );275 return; 284 276 } 285 277 else … … 291 283 { 292 284 irc_usermsg( irc, "Invalid account" ); 293 return ( 0 );285 return; 294 286 } 295 287 } … … 337 329 { 338 330 irc_usermsg( irc, "Account already offline" ); 339 return ( 0 );331 return; 340 332 } 341 333 } … … 343 335 { 344 336 irc_usermsg( irc, "Invalid account" ); 345 return ( 0 );337 return; 346 338 } 347 339 } … … 350 342 irc_usermsg( irc, "Unknown command: account %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[1] ); 351 343 } 352 353 return( 1 ); 354 } 355 356 static int cmd_add( irc_t *irc, char **cmd ) 344 } 345 346 static void cmd_add( irc_t *irc, char **cmd ) 357 347 { 358 348 account_t *a; … … 361 351 { 362 352 irc_usermsg( irc, "Invalid account" ); 363 return ( 1 );353 return; 364 354 } 365 355 else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) ) 366 356 { 367 357 irc_usermsg( irc, "That account is not on-line" ); 368 return ( 1 );358 return; 369 359 } 370 360 … … 374 364 { 375 365 irc_usermsg( irc, "The requested nick `%s' is invalid", cmd[3] ); 376 return ( 0 );366 return; 377 367 } 378 368 else if( user_find( irc, cmd[3] ) ) 379 369 { 380 370 irc_usermsg( irc, "The requested nick `%s' already exists", cmd[3] ); 381 return ( 0 );371 return; 382 372 } 383 373 else … … 390 380 391 381 irc_usermsg( irc, "User `%s' added to your contact list as `%s'", cmd[2], user_findhandle( a->gc, cmd[2] )->nick ); 392 393 return( 0 ); 394 } 395 396 static int cmd_info( irc_t *irc, char **cmd ) 382 } 383 384 static void cmd_info( irc_t *irc, char **cmd ) 397 385 { 398 386 struct gaim_connection *gc; … … 405 393 { 406 394 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 407 return ( 1 );395 return; 408 396 } 409 397 gc = u->gc; … … 413 401 { 414 402 irc_usermsg( irc, "Invalid account" ); 415 return ( 1 );403 return; 416 404 } 417 405 else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) 418 406 { 419 407 irc_usermsg( irc, "That account is not on-line" ); 420 return ( 1 );408 return; 421 409 } 422 410 … … 424 412 { 425 413 irc_usermsg( irc, "Command `%s' not supported by this protocol", cmd[0] ); 426 return( 1 );427 }428 gc->prpl->get_info( gc, cmd[2] );429 430 return( 0 );431 } 432 433 static intcmd_rename( irc_t *irc, char **cmd )414 } 415 else 416 { 417 gc->prpl->get_info( gc, cmd[2] ); 418 } 419 } 420 421 static void cmd_rename( irc_t *irc, char **cmd ) 434 422 { 435 423 user_t *u; … … 438 426 { 439 427 irc_usermsg( irc, "Nick `%s' can't be changed", cmd[1] ); 440 return( 1 ); 441 } 442 if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) 428 } 429 else if( user_find( irc, cmd[2] ) && ( nick_cmp( cmd[1], cmd[2] ) != 0 ) ) 443 430 { 444 431 irc_usermsg( irc, "Nick `%s' already exists", cmd[2] ); 445 return( 1 ); 446 } 447 if( !nick_ok( cmd[2] ) ) 432 } 433 else if( !nick_ok( cmd[2] ) ) 448 434 { 449 435 irc_usermsg( irc, "Nick `%s' is invalid", cmd[2] ); 450 return( 1 ); 451 } 452 if( !( u = user_find( irc, cmd[1] ) ) ) 436 } 437 else if( !( u = user_find( irc, cmd[1] ) ) ) 453 438 { 454 439 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 455 return( 1 );456 }457 user_rename( irc, cmd[1], cmd[2] );458 irc_write( irc, ":%s!%s@%s NICK %s", cmd[1], u->user, u->host, cmd[2] );459 if( g_strcasecmp( cmd[1], irc->mynick ) == 0 )460 {461 g_free( irc->mynick );462 irc->mynick = g_strdup( cmd[2]);463 }464 else if( u->send_handler == buddy_send_handler )465 {466 nick_set( irc, u->handle, u->gc->prpl, cmd[2] );467 }468 469 irc_usermsg( irc, "Nick successfully changed" );470 471 return( 0 );472 } 473 474 static intcmd_remove( irc_t *irc, char **cmd )440 } 441 else 442 { 443 user_rename( irc, cmd[1], cmd[2] ); 444 irc_write( irc, ":%s!%s@%s NICK %s", cmd[1], u->user, u->host, cmd[2] ); 445 if( g_strcasecmp( cmd[1], irc->mynick ) == 0 ) 446 { 447 g_free( irc->mynick ); 448 irc->mynick = g_strdup( cmd[2] ); 449 } 450 else if( u->send_handler == buddy_send_handler ) 451 { 452 nick_set( irc, u->handle, u->gc->prpl, cmd[2] ); 453 } 454 455 irc_usermsg( irc, "Nick successfully changed" ); 456 } 457 } 458 459 static void cmd_remove( irc_t *irc, char **cmd ) 475 460 { 476 461 user_t *u; … … 480 465 { 481 466 irc_usermsg( irc, "Buddy `%s' not found", cmd[1] ); 482 return ( 1 );467 return; 483 468 } 484 469 s = g_strdup( u->handle ); … … 491 476 g_free( s ); 492 477 493 return ( 0 );494 } 495 496 static intcmd_block( irc_t *irc, char **cmd )478 return; 479 } 480 481 static void cmd_block( irc_t *irc, char **cmd ) 497 482 { 498 483 struct gaim_connection *gc; … … 505 490 { 506 491 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 507 return ( 1 );492 return; 508 493 } 509 494 gc = u->gc; … … 513 498 { 514 499 irc_usermsg( irc, "Invalid account" ); 515 return ( 1 );500 return; 516 501 } 517 502 else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) 518 503 { 519 504 irc_usermsg( irc, "That account is not on-line" ); 520 return ( 1 );505 return; 521 506 } 522 507 … … 531 516 irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] ); 532 517 } 533 534 return( 0 ); 535 } 536 537 static int cmd_allow( irc_t *irc, char **cmd ) 518 } 519 520 static void cmd_allow( irc_t *irc, char **cmd ) 538 521 { 539 522 struct gaim_connection *gc; … … 546 529 { 547 530 irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] ); 548 return ( 1 );531 return; 549 532 } 550 533 gc = u->gc; … … 554 537 { 555 538 irc_usermsg( irc, "Invalid account" ); 556 return ( 1 );539 return; 557 540 } 558 541 else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) 559 542 { 560 543 irc_usermsg( irc, "That account is not on-line" ); 561 return ( 1 );544 return; 562 545 } 563 546 … … 573 556 irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] ); 574 557 } 575 576 return( 0 ); 577 } 578 579 static int cmd_yesno( irc_t *irc, char **cmd ) 558 } 559 560 static void cmd_yesno( irc_t *irc, char **cmd ) 580 561 { 581 562 query_t *q = NULL; … … 585 566 { 586 567 irc_usermsg( irc, "Did I ask you something?" ); 587 return ( 0 );568 return; 588 569 } 589 570 … … 595 576 { 596 577 irc_usermsg( irc, "Invalid query number" ); 597 return ( 0 );578 return; 598 579 } 599 580 … … 605 586 { 606 587 irc_usermsg( irc, "Uhm, I never asked you something like that..." ); 607 return ( 0 );588 return; 608 589 } 609 590 } … … 613 594 else if( g_strcasecmp( cmd[0], "no" ) == 0 ) 614 595 query_answer( irc, q, 0 ); 615 616 return( 1 ); 617 } 618 619 static int cmd_set( irc_t *irc, char **cmd ) 596 } 597 598 static void cmd_set( irc_t *irc, char **cmd ) 620 599 { 621 600 if( cmd[1] && cmd[2] ) … … 639 618 } 640 619 } 641 642 return( 0 ); 643 } 644 645 static int cmd_save( irc_t *irc, char **cmd ) 620 } 621 622 static void cmd_save( irc_t *irc, char **cmd ) 646 623 { 647 624 if( storage_save( irc, TRUE ) == STORAGE_OK ) … … 649 626 else 650 627 irc_usermsg( irc, "Configuration could not be saved!" ); 651 652 return( 0 ); 653 } 654 655 static int cmd_blist( irc_t *irc, char **cmd ) 628 } 629 630 static void cmd_blist( irc_t *irc, char **cmd ) 656 631 { 657 632 int online = 0, away = 0, offline = 0; … … 695 670 696 671 irc_usermsg( irc, "%d buddies (%d available, %d away, %d offline)", n_online + n_away + n_offline, n_online, n_away, n_offline ); 697 698 return( 0 ); 699 } 700 701 static int cmd_nick( irc_t *irc, char **cmd ) 672 } 673 674 static void cmd_nick( irc_t *irc, char **cmd ) 702 675 { 703 676 account_t *a; … … 731 704 a->gc->prpl->set_info( a->gc, cmd[2] ); 732 705 } 733 734 return( 1 ); 735 } 736 737 static int cmd_qlist( irc_t *irc, char **cmd ) 706 } 707 708 static void cmd_qlist( irc_t *irc, char **cmd ) 738 709 { 739 710 query_t *q = irc->queries; … … 743 714 { 744 715 irc_usermsg( irc, "There are no pending questions." ); 745 return ( 0 );716 return; 746 717 } 747 718 … … 753 724 else 754 725 irc_usermsg( irc, "%d, BitlBee: %s", num, q->question ); 755 756 return( 0 ); 757 } 758 759 static int cmd_import_buddies( irc_t *irc, char **cmd ) 726 } 727 728 static void cmd_import_buddies( irc_t *irc, char **cmd ) 760 729 { 761 730 struct gaim_connection *gc; … … 766 735 { 767 736 irc_usermsg( irc, "Invalid account" ); 768 return ( 0 );737 return; 769 738 } 770 739 else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) ) 771 740 { 772 741 irc_usermsg( irc, "That account is not on-line" ); 773 return ( 0 );742 return; 774 743 } 775 744 … … 792 761 { 793 762 irc_usermsg( irc, "Invalid argument: %s", cmd[2] ); 794 return ( 0 );763 return; 795 764 } 796 765 } … … 806 775 807 776 irc_usermsg( irc, "Sent all add requests. Please wait for a while, the server needs some time to handle all the adds." ); 808 809 return( 0 );810 777 } 811 778 -
user.h
r55ec2d6 rf73b969 45 45 int sendbuf_flags; 46 46 47 int(*send_handler) ( irc_t *irc, struct __USER *u, char *msg, int flags );47 void (*send_handler) ( irc_t *irc, struct __USER *u, char *msg, int flags ); 48 48 49 49 struct __USER *next;
Note: See TracChangeset
for help on using the changeset viewer.