Changeset f73b969 for root_commands.c


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.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.