Changeset f73b969


Ignore:
Timestamp:
2006-01-20T15:15:49Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
54879ab, f1d38f2
Parents:
55ec2d6
Message:

Renamed commands.c, got rid of return values in all command functions.

Files:
10 edited
1 moved

Legend:

Unmodified
Added
Removed
  • Makefile

    r55ec2d6 rf73b969  
    1010
    1111# Program variables
    12 objects = account.o bitlbee.o commands.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.o
     12objects = 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
    1313subdirs = protocols
    1414
  • bitlbee.c

    r55ec2d6 rf73b969  
    167167        }
    168168       
    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 );
    173175                return FALSE;
    174176        }
  • bitlbee.h

    r55ec2d6 rf73b969  
    129129gboolean bitlbee_io_current_client_write( GIOChannel *source, GIOCondition condition, gpointer data );
    130130
    131 int root_command_string( irc_t *irc, user_t *u, char *command, int flags );
    132 int root_command( irc_t *irc, char *command[] );
     131void root_command_string( irc_t *irc, user_t *u, char *command, int flags );
     132void root_command( irc_t *irc, char *command[] );
    133133void bitlbee_shutdown( gpointer data );
    134134double gettime( void );
  • commands.h

    r55ec2d6 rf73b969  
    3333        char *command;
    3434        int required_parameters;
    35         int (*execute)(irc_t *, char **args);
     35        void (*execute)(irc_t *, char **args);
    3636        int flags;
    3737} command_t;
  • ipc.c

    r55ec2d6 rf73b969  
    3232
    3333
    34 static int ipc_master_cmd_client( irc_t *data, char **cmd )
     34static void ipc_master_cmd_client( irc_t *data, char **cmd )
    3535{
    3636        struct bitlbee_child *child = (void*) data;
     
    4545        ipc_to_children_str( "OPERMSG :Client connecting (PID=%d): %s@%s (%s)\r\n",
    4646                             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
     49static void ipc_master_cmd_die( irc_t *data, char **cmd )
    5250{
    5351        if( global.conf->runmode == RUNMODE_FORKDAEMON )
     
    5553       
    5654        bitlbee_shutdown( NULL );
    57        
    58         return 1;
    59 }
    60 
    61 int ipc_master_cmd_rehash( irc_t *data, char **cmd )
     55}
     56
     57void ipc_master_cmd_rehash( irc_t *data, char **cmd )
    6258{
    6359        runmode_t oldmode;
     
    7672        if( global.conf->runmode == RUNMODE_FORKDAEMON )
    7773                ipc_to_children( cmd );
    78        
    79         return 1;
    8074}
    8175
     
    9286
    9387
    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 )
     88static void ipc_child_cmd_die( irc_t *irc, char **cmd )
     89{
     90        irc_abort( irc, 1, "Shutdown requested by operator" );
     91}
     92
     93static void ipc_child_cmd_wallops( irc_t *irc, char **cmd )
    10594{
    10695        if( irc->status < USTATUS_LOGGED_IN )
    107                 return 1;
     96                return;
    10897       
    10998        if( strchr( irc->umode, 'w' ) )
    11099                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
     102static void ipc_child_cmd_lilo( irc_t *irc, char **cmd )
    116103{
    117104        if( irc->status < USTATUS_LOGGED_IN )
    118                 return 1;
     105                return;
    119106       
    120107        if( strchr( irc->umode, 's' ) )
    121108                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
     111static void ipc_child_cmd_opermsg( irc_t *irc, char **cmd )
    127112{
    128113        if( irc->status < USTATUS_LOGGED_IN )
    129                 return 1;
     114                return;
    130115       
    131116        if( strchr( irc->umode, 'o' ) )
    132117                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
     120static void ipc_child_cmd_rehash( irc_t *irc, char **cmd )
    138121{
    139122        runmode_t oldmode;
     
    145128       
    146129        global.conf->runmode = oldmode;
    147        
    148         return 1;
    149 }
    150 
    151 static int ipc_child_cmd_kill( irc_t *irc, char **cmd )
     130}
     131
     132static void ipc_child_cmd_kill( irc_t *irc, char **cmd )
    152133{
    153134        if( irc->status < USTATUS_LOGGED_IN )
    154                 return 1;
     135                return;
    155136       
    156137        if( nick_cmp( cmd[1], irc->nick ) != 0 )
    157                 return 1;       /* It's not for us. */
     138                return;         /* It's not for us. */
    158139       
    159140        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] );
    164142}
    165143
  • ipc.h

    r55ec2d6 rf73b969  
    5252
    5353/* We need this function in inetd mode, so let's just make it non-static. */
    54 int ipc_master_cmd_rehash( irc_t *data, char **cmd );
     54void ipc_master_cmd_rehash( irc_t *data, char **cmd );
    5555
    5656
  • irc.c

    r55ec2d6 rf73b969  
    152152}
    153153
     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. */
    154157void irc_abort( irc_t *irc, int immed, char *format, ... )
    155158{
    156         va_list params;
    157        
    158159        if( format != NULL )
    159160        {
     161                va_list params;
    160162                char *reason;
    161163               
    162164                va_start( params, format );
    163                 reason = g_strdup_printf( format, params );
     165                reason = g_strdup_vprintf( format, params );
    164166                va_end( params );
    165167               
     
    168170               
    169171                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 );
    171173               
    172174                g_free( reason );
     
    178180               
    179181                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" );
    181183        }
    182184       
     
    339341}
    340342
    341 int irc_process( irc_t *irc )
     343void irc_process( irc_t *irc )
    342344{
    343345        char **lines, *temp, **cmd;
     
    361363                        if( ( cmd = irc_parse_line( lines[i] ) ) == NULL )
    362364                                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 );
    369366                       
    370367                        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                        }
    371375                }
    372376               
     
    379383                g_free( lines );
    380384        }
    381        
    382         return 1;       
    383385}
    384386
     
    972974               
    973975                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                }
    975980        }
    976981        else if( c && c->gc && c->gc->prpl )
     
    9981003}
    9991004
    1000 int buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )
    1001 {
    1002         if( !u || !u->gc ) return( 0 );
     1005void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags )
     1006{
     1007        if( !u || !u->gc ) return;
    10031008       
    10041009        if( set_getint( irc, "buddy_sendbuffer" ) && set_getint( irc, "buddy_sendbuffer_delay" ) > 0 )
     
    10361041                        g_source_remove( u->sendbuf_timer );
    10371042                u->sendbuf_timer = g_timeout_add( delay, buddy_send_handler_delayed, u );
    1038                
    1039                 return( 1 );
    10401043        }
    10411044        else
    10421045        {
    1043                 return( serv_send_im( irc, u, msg, flags ) );
     1046                serv_send_im( irc, u, msg, flags );
    10441047        }
    10451048}
     
    11461149        if( rv > 0 )
    11471150        {
    1148                 irc_abort( irc, "ERROR :Closing Link: Ping Timeout: %d seconds", rv );
     1151                irc_abort( irc, 0, "Ping Timeout: %d seconds", rv );
    11491152                return FALSE;
    11501153        }
  • irc.h

    r55ec2d6 rf73b969  
    108108void irc_free( irc_t *irc );
    109109
    110 int irc_exec( irc_t *irc, char **cmd );
    111 int irc_process( irc_t *irc );
     110void irc_exec( irc_t *irc, char **cmd );
     111void irc_process( irc_t *irc );
    112112char **irc_parse_line( char *line );
    113113char *irc_build_line( char **cmd );
     
    134134void irc_invite( irc_t *irc, char *nick, char *channel );
    135135void irc_whois( irc_t *irc, char *nick );
    136 int irc_away( irc_t *irc, char *away );
    137136void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */
    138137
     
    142141int irc_noticefrom( irc_t *irc, char *nick, char *msg );
    143142
    144 int buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags );
     143void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags );
    145144
    146145#endif
  • irc_commands.c

    r55ec2d6 rf73b969  
    2828#include "ipc.h"
    2929
    30 static int irc_cmd_pass( irc_t *irc, char **cmd )
     30static void irc_cmd_pass( irc_t *irc, char **cmd )
    3131{
    3232        if( global.conf->auth_pass && strcmp( cmd[1], global.conf->auth_pass ) == 0 )
     
    3939                irc_reply( irc, 464, ":Incorrect password" );
    4040        }
    41        
    42         return( 1 );
    43 }
    44 
    45 static int irc_cmd_user( irc_t *irc, char **cmd )
     41}
     42
     43static void irc_cmd_user( irc_t *irc, char **cmd )
    4644{
    4745        irc->user = g_strdup( cmd[1] );
     
    4947       
    5048        irc_check_login( irc );
    51        
    52         return( 1 );
    53 }
    54 
    55 static int irc_cmd_nick( irc_t *irc, char **cmd )
     49}
     50
     51static void irc_cmd_nick( irc_t *irc, char **cmd )
    5652{
    5753        if( irc->nick )
     
    7571                irc_check_login( irc );
    7672        }
    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
     75static 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
     83static void irc_cmd_ping( irc_t *irc, char **cmd )
    9084{
    9185        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
     88static void irc_cmd_oper( irc_t *irc, char **cmd )
    9789{
    9890        if( global.conf->oper_pass && strcmp( cmd[2], global.conf->oper_pass ) == 0 )
     
    10597                irc_reply( irc, 432, ":Incorrect password" );
    10698        }
    107        
    108         return( 1 );
    109 }
    110 
    111 static int irc_cmd_mode( irc_t *irc, char **cmd )
     99}
     100
     101static void irc_cmd_mode( irc_t *irc, char **cmd )
    112102{
    113103        if( *cmd[1] == '#' || *cmd[1] == '&' )
     
    133123                        irc_reply( irc, 502, ":Don't touch their modes" );
    134124        }
    135        
    136         return( 1 );
    137 }
    138 
    139 static int irc_cmd_names( irc_t *irc, char **cmd )
     125}
     126
     127static void irc_cmd_names( irc_t *irc, char **cmd )
    140128{
    141129        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
     132static void irc_cmd_part( irc_t *irc, char **cmd )
    147133{
    148134        struct conversation *c;
     
    172158                irc_reply( irc, 403, "%s :No such channel", cmd[1] );
    173159        }
    174        
    175         return( 1 );
    176 }
    177 
    178 static int irc_cmd_join( irc_t *irc, char **cmd )
     160}
     161
     162static void irc_cmd_join( irc_t *irc, char **cmd )
    179163{
    180164        if( g_strcasecmp( cmd[1], irc->channel ) == 0 )
     
    210194                }
    211195        }
    212        
    213         return( 1 );
    214 }
    215 
    216 static int irc_cmd_invite( irc_t *irc, char **cmd )
     196}
     197
     198static void irc_cmd_invite( irc_t *irc, char **cmd )
    217199{
    218200        char *nick = cmd[1], *channel = cmd[2];
     
    225207                        c->gc->prpl->chat_invite( c->gc, c->id, "", u->handle );
    226208                        irc_reply( irc, 341, "%s %s", nick, channel );
    227                         return( 1 );
     209                        return;
    228210                }
    229211       
    230212        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
     215static void irc_cmd_privmsg( irc_t *irc, char **cmd )
    236216{
    237217        if ( !cmd[2] )
     
    283263                irc_send( irc, cmd[1], cmd[2], ( g_strcasecmp( cmd[0], "NOTICE" ) == 0 ) ? IM_FLAG_AWAY : 0 );
    284264        }
    285        
    286         return( 1 );
    287 }
    288 
    289 static int irc_cmd_who( irc_t *irc, char **cmd )
     265}
     266
     267static void irc_cmd_who( irc_t *irc, char **cmd )
    290268{
    291269        char *channel = cmd[1];
     
    317295       
    318296        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
     299static void irc_cmd_userhost( irc_t *irc, char **cmd )
    324300{
    325301        user_t *u;
     
    340316                                irc_reply( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host );
    341317                }
    342        
    343         return( 1 );
    344 }
    345 
    346 static int irc_cmd_ison( irc_t *irc, char **cmd )
     318}
     319
     320static void irc_cmd_ison( irc_t *irc, char **cmd )
    347321{
    348322        user_t *u;
     
    383357       
    384358        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
     361static void irc_cmd_watch( irc_t *irc, char **cmd )
    390362{
    391363        int i;
     
    430402                }
    431403        }
    432        
    433         return( 1 );
    434 }
    435 
    436 static int irc_cmd_topic( irc_t *irc, char **cmd )
     404}
     405
     406static void irc_cmd_topic( irc_t *irc, char **cmd )
    437407{
    438408        if( cmd[2] )
     
    440410        else
    441411                irc_topic( irc, cmd[1] );
    442        
    443         return( 1 );
    444 }
    445 
    446 static int irc_cmd_away( irc_t *irc, char **cmd )
     412}
     413
     414static void irc_cmd_away( irc_t *irc, char **cmd )
    447415{
    448416        user_t *u = user_find( irc, irc->nick );
     
    450418        char *away = cmd[1];
    451419       
    452         if( !u ) return( 1 );
     420        if( !u ) return;
    453421       
    454422        if( away && *away )
     
    482450                c = c->next;
    483451        }
    484        
    485         return( 1 );
    486 }
    487 
    488 static int irc_cmd_whois( irc_t *irc, char **cmd )
     452}
     453
     454static void irc_cmd_whois( irc_t *irc, char **cmd )
    489455{
    490456        char *nick = cmd[1];
     
    512478                irc_reply( irc, 401, "%s :Nick does not exist", nick );
    513479        }
    514        
    515         return( 1 );
    516 }
    517 
    518 static int irc_cmd_whowas( irc_t *irc, char **cmd )
     480}
     481
     482static void irc_cmd_whowas( irc_t *irc, char **cmd )
    519483{
    520484        /* For some reason irssi tries a whowas when whois fails. We can
     
    525489        irc_reply( irc, 406, "%s :Nick does not exist", cmd[1] );
    526490        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
     493static void irc_cmd_nickserv( irc_t *irc, char **cmd )
    532494{
    533495        /* [SH] This aliases the NickServ command to PRIVMSG root */
    534496        /* [TV] This aliases the NS command to PRIVMSG root as well */
    535497        root_command( irc, cmd + 1 );
    536        
    537         return( 1 );
    538 }
    539 
    540 static int irc_cmd_motd( irc_t *irc, char **cmd )
     498}
     499
     500static void irc_cmd_motd( irc_t *irc, char **cmd )
    541501{
    542502        irc_motd( irc );
    543        
    544         return( 1 );
    545 }
    546 
    547 static int irc_cmd_pong( irc_t *irc, char **cmd )
     503}
     504
     505static void irc_cmd_pong( irc_t *irc, char **cmd )
    548506{
    549507        /* We could check the value we get back from the user, but in
     
    551509        irc->last_pong = gettime();
    552510        irc->pinging = 0;
    553        
    554         return( 1 );
    555 }
    556 
    557 static int irc_cmd_completions( irc_t *irc, char **cmd )
     511}
     512
     513static void irc_cmd_completions( irc_t *irc, char **cmd )
    558514{
    559515        user_t *u = user_find( irc, irc->mynick );
     
    574530       
    575531        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
     534static void irc_cmd_rehash( irc_t *irc, char **cmd )
    581535{
    582536        if( global.conf->runmode == RUNMODE_INETD )
     
    586540       
    587541        irc_reply( irc, 382, "%s :Rehashing", CONF_FILE );
    588        
    589         return( 1 );
    590542}
    591543
     
    625577};
    626578
    627 int irc_exec( irc_t *irc, char *cmd[] )
     579void irc_exec( irc_t *irc, char *cmd[] )
    628580{       
    629         int i, j;
     581        int i;
    630582       
    631583        if( !cmd[0] )
    632                 return( 1 );
     584                return;
    633585       
    634586        for( i = 0; irc_commands[i].command; i++ )
     
    638590                        {
    639591                                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 )
    643594                        {
    644595                                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' ) )
    648598                        {
    649599                                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                        {
    661607                                /* IPC doesn't make sense in inetd mode,
    662608                                    but the function will catch that. */
    663609                                ipc_to_master( cmd );
     610                        }
    664611                        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  
    3232#include <string.h>
    3333
    34 int root_command_string( irc_t *irc, user_t *u, char *command, int flags )
     34void root_command_string( irc_t *irc, user_t *u, char *command, int flags )
    3535{
    3636        char *cmd[IRC_MAX_ARGS];
     
    6464        cmd[k] = NULL;
    6565       
    66         return( root_command( irc, cmd ) );
    67 }
    68 
    69 int root_command( irc_t *irc, char *cmd[] )
     66        root_command( irc, cmd );
     67}
     68
     69void root_command( irc_t *irc, char *cmd[] )
    7070{       
    7171        int i;
    7272       
    7373        if( !cmd[0] )
    74                 return( 0 );
     74                return;
    7575       
    7676        for( i = 0; commands[i].command; i++ )
     
    8080                        {
    8181                                irc_usermsg( irc, "Not enough parameters given (need %d)", commands[i].required_parameters );
    82                                 return( 0 );
     82                                return;
    8383                        }
    8484                        commands[i].execute( irc, cmd );
    85                         return( 1 );
     85                        return;
    8686                }
    8787       
    8888        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
     91static void cmd_help( irc_t *irc, char **cmd )
    9492{
    9593        char param[80];
     
    111109                irc_usermsg( irc, "%s", s );
    112110                g_free( s );
    113                 return( 1 );
    114111        }
    115112        else
    116113        {
    117114                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
     118static void cmd_identify( irc_t *irc, char **cmd )
    123119{
    124120        storage_status_t status = storage_load( irc->nick, cmd[1], irc );
     
    139135                break;
    140136        }
    141 
    142         return( 0 );
    143 }
    144 
    145 static int cmd_register( irc_t *irc, char **cmd )
     137}
     138
     139static void cmd_register( irc_t *irc, char **cmd )
    146140{
    147141        if( global.conf->authmode == AUTHMODE_REGISTERED )
    148142        {
    149143                irc_usermsg( irc, "This server does not allow registering new accounts" );
    150                 return( 0 );
     144                return;
    151145        }
    152146
     
    166160                        break;
    167161        }
    168        
    169         return( 0 );
    170 }
    171 
    172 static int cmd_drop( irc_t *irc, char **cmd )
     162}
     163
     164static void cmd_drop( irc_t *irc, char **cmd )
    173165{
    174166        storage_status_t status;
     
    178170        case STORAGE_NO_SUCH_USER:
    179171                irc_usermsg( irc, "That account does not exist" );
    180                 return( 0 );
     172                break;
    181173        case STORAGE_INVALID_PASSWORD:
    182174                irc_usermsg( irc, "Password invalid" );
    183                 return( 0 );
     175                break;
    184176        case STORAGE_OK:
    185177                irc_setpass( irc, NULL );
     
    187179                irc_umode_set( irc, "-R", 1 );
    188180                irc_usermsg( irc, "Account `%s' removed", irc->nick );
    189                 return( 0 );
     181                break;
    190182        default:
    191183                irc_usermsg( irc, "Error: '%d'", status );
    192                 return( 0 );
    193         }
    194 }
    195 
    196 static int cmd_account( irc_t *irc, char **cmd )
     184                break;
     185        }
     186}
     187
     188static void cmd_account( irc_t *irc, char **cmd )
    197189{
    198190        account_t *a;
     
    201193        {
    202194                irc_usermsg( irc, "This server only accepts registered users" );
    203                 return( 0 );
     195                return;
    204196        }
    205197       
     
    211203                {
    212204                        irc_usermsg( irc, "Not enough parameters" );
    213                         return( 0 );
     205                        return;
    214206                }
    215207               
     
    219211                {
    220212                        irc_usermsg( irc, "Unknown protocol" );
    221                         return( 0 );
     213                        return;
    222214                }
    223215
     
    281273                                {
    282274                                        irc_usermsg( irc, "Account already online" );
    283                                         return( 0 );
     275                                        return;
    284276                                }
    285277                                else
     
    291283                        {
    292284                                irc_usermsg( irc, "Invalid account" );
    293                                 return( 0 );
     285                                return;
    294286                        }
    295287                }
     
    337329                        {
    338330                                irc_usermsg( irc, "Account already offline" );
    339                                 return( 0 );
     331                                return;
    340332                        }
    341333                }
     
    343335                {
    344336                        irc_usermsg( irc, "Invalid account" );
    345                         return( 0 );
     337                        return;
    346338                }
    347339        }
     
    350342                irc_usermsg( irc, "Unknown command: account %s. Please use \x02help commands\x02 to get a list of available commands.", cmd[1] );
    351343        }
    352        
    353         return( 1 );
    354 }
    355 
    356 static int cmd_add( irc_t *irc, char **cmd )
     344}
     345
     346static void cmd_add( irc_t *irc, char **cmd )
    357347{
    358348        account_t *a;
     
    361351        {
    362352                irc_usermsg( irc, "Invalid account" );
    363                 return( 1 );
     353                return;
    364354        }
    365355        else if( !( a->gc && ( a->gc->flags & OPT_LOGGED_IN ) ) )
    366356        {
    367357                irc_usermsg( irc, "That account is not on-line" );
    368                 return( 1 );
     358                return;
    369359        }
    370360       
     
    374364                {
    375365                        irc_usermsg( irc, "The requested nick `%s' is invalid", cmd[3] );
    376                         return( 0 );
     366                        return;
    377367                }
    378368                else if( user_find( irc, cmd[3] ) )
    379369                {
    380370                        irc_usermsg( irc, "The requested nick `%s' already exists", cmd[3] );
    381                         return( 0 );
     371                        return;
    382372                }
    383373                else
     
    390380       
    391381        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
     384static void cmd_info( irc_t *irc, char **cmd )
    397385{
    398386        struct gaim_connection *gc;
     
    405393                {
    406394                        irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] );
    407                         return( 1 );
     395                        return;
    408396                }
    409397                gc = u->gc;
     
    413401        {
    414402                irc_usermsg( irc, "Invalid account" );
    415                 return( 1 );
     403                return;
    416404        }
    417405        else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) )
    418406        {
    419407                irc_usermsg( irc, "That account is not on-line" );
    420                 return( 1 );
     408                return;
    421409        }
    422410       
     
    424412        {
    425413                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 int cmd_rename( irc_t *irc, char **cmd )
     414        }
     415        else
     416        {
     417                gc->prpl->get_info( gc, cmd[2] );
     418        }
     419}
     420
     421static void cmd_rename( irc_t *irc, char **cmd )
    434422{
    435423        user_t *u;
     
    438426        {
    439427                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 ) )
    443430        {
    444431                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] ) )
    448434        {
    449435                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] ) ) )
    453438        {
    454439                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 int cmd_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
     459static void cmd_remove( irc_t *irc, char **cmd )
    475460{
    476461        user_t *u;
     
    480465        {
    481466                irc_usermsg( irc, "Buddy `%s' not found", cmd[1] );
    482                 return( 1 );
     467                return;
    483468        }
    484469        s = g_strdup( u->handle );
     
    491476        g_free( s );
    492477       
    493         return( 0 );
    494 }
    495 
    496 static int cmd_block( irc_t *irc, char **cmd )
     478        return;
     479}
     480
     481static void cmd_block( irc_t *irc, char **cmd )
    497482{
    498483        struct gaim_connection *gc;
     
    505490                {
    506491                        irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] );
    507                         return( 1 );
     492                        return;
    508493                }
    509494                gc = u->gc;
     
    513498        {
    514499                irc_usermsg( irc, "Invalid account" );
    515                 return( 1 );
     500                return;
    516501        }
    517502        else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) )
    518503        {
    519504                irc_usermsg( irc, "That account is not on-line" );
    520                 return( 1 );
     505                return;
    521506        }
    522507       
     
    531516                irc_usermsg( irc, "Buddy `%s' moved from your permit- to your deny-list", cmd[2] );
    532517        }
    533        
    534         return( 0 );
    535 }
    536 
    537 static int cmd_allow( irc_t *irc, char **cmd )
     518}
     519
     520static void cmd_allow( irc_t *irc, char **cmd )
    538521{
    539522        struct gaim_connection *gc;
     
    546529                {
    547530                        irc_usermsg( irc, "Nick `%s' does not exist", cmd[1] );
    548                         return( 1 );
     531                        return;
    549532                }
    550533                gc = u->gc;
     
    554537        {
    555538                irc_usermsg( irc, "Invalid account" );
    556                 return( 1 );
     539                return;
    557540        }
    558541        else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) )
    559542        {
    560543                irc_usermsg( irc, "That account is not on-line" );
    561                 return( 1 );
     544                return;
    562545        }
    563546       
     
    573556                irc_usermsg( irc, "Buddy `%s' moved from your deny- to your permit-list", cmd[2] );
    574557        }
    575        
    576         return( 0 );
    577 }
    578 
    579 static int cmd_yesno( irc_t *irc, char **cmd )
     558}
     559
     560static void cmd_yesno( irc_t *irc, char **cmd )
    580561{
    581562        query_t *q = NULL;
     
    585566        {
    586567                irc_usermsg( irc, "Did I ask you something?" );
    587                 return( 0 );
     568                return;
    588569        }
    589570       
     
    595576                {
    596577                        irc_usermsg( irc, "Invalid query number" );
    597                         return( 0 );
     578                        return;
    598579                }
    599580               
     
    605586                {
    606587                        irc_usermsg( irc, "Uhm, I never asked you something like that..." );
    607                         return( 0 );
     588                        return;
    608589                }
    609590        }
     
    613594        else if( g_strcasecmp( cmd[0], "no" ) == 0 )
    614595                query_answer( irc, q, 0 );
    615        
    616         return( 1 );
    617 }
    618 
    619 static int cmd_set( irc_t *irc, char **cmd )
     596}
     597
     598static void cmd_set( irc_t *irc, char **cmd )
    620599{
    621600        if( cmd[1] && cmd[2] )
     
    639618                }
    640619        }
    641        
    642         return( 0 );
    643 }
    644 
    645 static int cmd_save( irc_t *irc, char **cmd )
     620}
     621
     622static void cmd_save( irc_t *irc, char **cmd )
    646623{
    647624        if( storage_save( irc, TRUE ) == STORAGE_OK )
     
    649626        else
    650627                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
     630static void cmd_blist( irc_t *irc, char **cmd )
    656631{
    657632        int online = 0, away = 0, offline = 0;
     
    695670       
    696671        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
     674static void cmd_nick( irc_t *irc, char **cmd )
    702675{
    703676        account_t *a;
     
    731704                        a->gc->prpl->set_info( a->gc, cmd[2] );
    732705        }
    733        
    734         return( 1 );
    735 }
    736 
    737 static int cmd_qlist( irc_t *irc, char **cmd )
     706}
     707
     708static void cmd_qlist( irc_t *irc, char **cmd )
    738709{
    739710        query_t *q = irc->queries;
     
    743714        {
    744715                irc_usermsg( irc, "There are no pending questions." );
    745                 return( 0 );
     716                return;
    746717        }
    747718       
     
    753724                else
    754725                        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
     728static void cmd_import_buddies( irc_t *irc, char **cmd )
    760729{
    761730        struct gaim_connection *gc;
     
    766735        {
    767736                irc_usermsg( irc, "Invalid account" );
    768                 return( 0 );
     737                return;
    769738        }
    770739        else if( !( ( gc = a->gc ) && ( a->gc->flags & OPT_LOGGED_IN ) ) )
    771740        {
    772741                irc_usermsg( irc, "That account is not on-line" );
    773                 return( 0 );
     742                return;
    774743        }
    775744       
     
    792761                {
    793762                        irc_usermsg( irc, "Invalid argument: %s", cmd[2] );
    794                         return( 0 );
     763                        return;
    795764                }
    796765        }
     
    806775       
    807776        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 );
    810777}
    811778
  • user.h

    r55ec2d6 rf73b969  
    4545        int sendbuf_flags;
    4646       
    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 );
    4848       
    4949        struct __USER *next;
Note: See TracChangeset for help on using the changeset viewer.