From a5d31a195d1e3b682cd57d88a5db7ef0ffa5d492 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 18 Jun 2000 01:18:12 +0000 Subject: Changed option handling in /commands. Irssi will now complain about unknown options and missing option arguments. Renamed /SERVER -add, -remove and -list to /SERVER ADD, REMOVE and LIST. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@365 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/notifylist/notify-commands.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/irc/notifylist') diff --git a/src/irc/notifylist/notify-commands.c b/src/irc/notifylist/notify-commands.c index af022dcd..0bef6d23 100644 --- a/src/irc/notifylist/notify-commands.c +++ b/src/irc/notifylist/notify-commands.c @@ -30,41 +30,47 @@ static void cmd_notify(gchar *data) { - char *params, *mask, *ircnets, *args, *idletime; + GHashTable *optlist; + char *mask, *ircnets, *idletime; + void *free_arg; int away_check, idle_check_time; g_return_if_fail(data != NULL); - args = "@idle"; - params = cmd_get_params(data, 4 | PARAM_FLAG_MULTIARGS | PARAM_FLAG_GETREST, &args, &idletime, &mask, &ircnets); + if (!cmd_get_params(data, &free_arg, 2 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST, + "notify", &optlist, &mask, &ircnets)) + return; if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - if (stristr(args, "-idle") == NULL) + idletime = g_hash_table_lookup(optlist, "idle"); + if (idletime == NULL) idle_check_time = 0; else { idle_check_time = is_numeric(idletime, 0) ? (atoi(idletime)*60) : (settings_get_int("notify_idle_time")*60); } - away_check = stristr(args, "-away") != NULL; + away_check = g_hash_table_lookup(optlist, "away") != NULL; notifylist_remove(mask); notifylist_add(mask, ircnets, away_check, idle_check_time); - g_free(params); + cmd_params_free(free_arg); } static void cmd_unnotify(const char *data) { - char *params, *mask; + char *mask; + void *free_arg; g_return_if_fail(data != NULL); - params = cmd_get_params(data, 1, &mask); + if (!cmd_get_params(data, &free_arg, 1, &mask)) + return; if (*mask == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); notifylist_remove(mask); - g_free(params); + cmd_params_free(free_arg); } void notifylist_commands_init(void) @@ -72,6 +78,8 @@ void notifylist_commands_init(void) settings_add_int("misc", "notify_idle_time", DEFAULT_NOTIFY_IDLE_TIME); command_bind("notify", NULL, (SIGNAL_FUNC) cmd_notify); command_bind("unnotify", NULL, (SIGNAL_FUNC) cmd_unnotify); + + command_set_options("notify", "@idle away"); } void notifylist_commands_deinit(void) -- cgit v1.2.3