Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 968:d3bfa9e9d88c
Use split_arg() in do_roster()
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 29 Sep 2006 21:50:28 +0200 |
parents | 303408ef5e5d |
children | 36f7753dfb59 |
comparison
equal
deleted
inserted
replaced
967:303408ef5e5d | 968:d3bfa9e9d88c |
---|---|
425 /* All these do_*() functions will be called with a "arg" parameter */ | 425 /* All these do_*() functions will be called with a "arg" parameter */ |
426 /* (with arg not null) */ | 426 /* (with arg not null) */ |
427 | 427 |
428 static void do_roster(char *arg) | 428 static void do_roster(char *arg) |
429 { | 429 { |
430 if (!strcasecmp(arg, "top")) { | 430 char **paramlst; |
431 char *subcmd; | |
432 | |
433 paramlst = split_arg(arg, 2, 1); // subcmd, arg | |
434 subcmd = *paramlst; | |
435 arg = *(paramlst+1); | |
436 | |
437 if (!subcmd || !*subcmd) { | |
438 scr_LogPrint(LPRINT_NORMAL, "Missing parameter."); | |
439 free_arg_lst(paramlst); | |
440 return; | |
441 } | |
442 | |
443 if (!strcasecmp(subcmd, "top")) { | |
431 scr_RosterTop(); | 444 scr_RosterTop(); |
432 update_roster = TRUE; | 445 update_roster = TRUE; |
433 } else if (!strcasecmp(arg, "bottom")) { | 446 } else if (!strcasecmp(subcmd, "bottom")) { |
434 scr_RosterBottom(); | 447 scr_RosterBottom(); |
435 update_roster = TRUE; | 448 update_roster = TRUE; |
436 } else if (!strcasecmp(arg, "hide")) { | 449 } else if (!strcasecmp(subcmd, "hide")) { |
437 scr_RosterVisibility(0); | 450 scr_RosterVisibility(0); |
438 } else if (!strcasecmp(arg, "show")) { | 451 } else if (!strcasecmp(subcmd, "show")) { |
439 scr_RosterVisibility(1); | 452 scr_RosterVisibility(1); |
440 } else if (!strcasecmp(arg, "toggle")) { | 453 } else if (!strcasecmp(subcmd, "toggle")) { |
441 scr_RosterVisibility(-1); | 454 scr_RosterVisibility(-1); |
442 } else if (!strcasecmp(arg, "hide_offline")) { | 455 } else if (!strcasecmp(subcmd, "hide_offline")) { |
443 buddylist_set_hide_offline_buddies(TRUE); | 456 buddylist_set_hide_offline_buddies(TRUE); |
444 if (current_buddy) | 457 if (current_buddy) |
445 buddylist_build(); | 458 buddylist_build(); |
446 update_roster = TRUE; | 459 update_roster = TRUE; |
447 } else if (!strcasecmp(arg, "show_offline")) { | 460 } else if (!strcasecmp(subcmd, "show_offline")) { |
448 buddylist_set_hide_offline_buddies(FALSE); | 461 buddylist_set_hide_offline_buddies(FALSE); |
449 buddylist_build(); | 462 buddylist_build(); |
450 update_roster = TRUE; | 463 update_roster = TRUE; |
451 } else if (!strcasecmp(arg, "toggle_offline")) { | 464 } else if (!strcasecmp(subcmd, "toggle_offline")) { |
452 buddylist_set_hide_offline_buddies(-1); | 465 buddylist_set_hide_offline_buddies(-1); |
453 buddylist_build(); | 466 buddylist_build(); |
454 update_roster = TRUE; | 467 update_roster = TRUE; |
455 } else if (!strcasecmp(arg, "unread_first")) { | 468 } else if (!strcasecmp(subcmd, "unread_first")) { |
456 scr_RosterUnreadMessage(0); | 469 scr_RosterUnreadMessage(0); |
457 } else if (!strcasecmp(arg, "unread_next")) { | 470 } else if (!strcasecmp(subcmd, "unread_next")) { |
458 scr_RosterUnreadMessage(1); | 471 scr_RosterUnreadMessage(1); |
459 } else if (!strcasecmp(arg, "alternate")) { | 472 } else if (!strcasecmp(subcmd, "alternate")) { |
460 scr_RosterJumpAlternate(); | 473 scr_RosterJumpAlternate(); |
461 } else if (!strncasecmp(arg, "search", 6)) { | 474 } else if (!strncasecmp(subcmd, "search", 6)) { |
462 char *string = arg+6; | 475 char *string = subcmd+6; |
463 if (*string && (*string != ' ')) { | 476 if (*string && (*string != ' ')) { |
464 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | 477 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
478 free_arg_lst(paramlst); | |
465 return; | 479 return; |
466 } | 480 } |
467 while (*string == ' ') | 481 while (*string == ' ') |
468 string++; | 482 string++; |
469 if (!*string) { | 483 if (!*string) { |
470 scr_LogPrint(LPRINT_NORMAL, "What name or JID are you looking for?"); | 484 scr_LogPrint(LPRINT_NORMAL, "What name or JID are you looking for?"); |
485 free_arg_lst(paramlst); | |
471 return; | 486 return; |
472 } | 487 } |
473 scr_RosterSearch(string); | 488 scr_RosterSearch(string); |
474 update_roster = TRUE; | 489 update_roster = TRUE; |
475 } else if (!strcasecmp(arg, "up")) { | 490 } else if (!strcasecmp(subcmd, "up")) { |
476 scr_RosterUp(); | 491 scr_RosterUp(); |
477 } else if (!strcasecmp(arg, "down")) { | 492 } else if (!strcasecmp(subcmd, "down")) { |
478 scr_RosterDown(); | 493 scr_RosterDown(); |
479 } else | 494 } else |
480 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); | 495 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); |
496 free_arg_lst(paramlst); | |
481 } | 497 } |
482 | 498 |
483 // setstatus(recipient, arg) | 499 // setstatus(recipient, arg) |
484 // Set your Jabber status. | 500 // Set your Jabber status. |
485 // - if recipient is not NULL, the status is sent to this contact only | 501 // - if recipient is not NULL, the status is sent to this contact only |