Changeset f73b969 for root_commands.c
- Timestamp:
- 2006-01-20T15:15:49Z (18 years ago)
- Branches:
- master
- Children:
- 54879ab, f1d38f2
- Parents:
- 55ec2d6
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.