diff options
author | Timo Sirainen <cras@irssi.org> | 2000-08-12 02:16:52 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-08-12 02:16:52 +0000 |
commit | 308e84bbc44db92fbb1fe0c2e177ae981865b788 (patch) | |
tree | 999d7f2daadda55483c4ccf3df3d938095d7429d /src/irc/core | |
parent | 81af47808b0d9ef1a0a7637ae3e296054215a2a2 (diff) | |
download | irssi-308e84bbc44db92fbb1fe0c2e177ae981865b788.zip |
WJOIN -> /JOIN -window
WQUERY -> /QUERY -window.
Added support for /QUERY -<server tag>.
Added aliases for WJOIN and WQUERY to default config file.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@590 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/core')
-rw-r--r-- | src/irc/core/irc-commands.c | 28 | ||||
-rw-r--r-- | src/irc/core/irc-commands.h | 4 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/irc/core/irc-commands.c b/src/irc/core/irc-commands.c index 323d922b..b067dda9 100644 --- a/src/irc/core/irc-commands.c +++ b/src/irc/core/irc-commands.c @@ -47,19 +47,33 @@ static int knockout_tag; /* `optlist' should contain only one key - the server tag. returns NULL if there was unknown -option */ -IRC_SERVER_REC *irccmd_options_get_server(GHashTable *optlist, IRC_SERVER_REC *defserver) +IRC_SERVER_REC *irccmd_options_get_server(const char *cmd, + GHashTable *optlist, + IRC_SERVER_REC *defserver) { SERVER_REC *server; - GSList *list; + GSList *list, *tmp, *next; - /* -<server tag> */ + /* get all the options, then remove the known ones. there should + be only one left - the server tag. */ list = hashtable_get_keys(optlist); - if (list == NULL) return defserver; + for (tmp = list; tmp != NULL; tmp = next) { + char *option = tmp->data; + next = tmp->next; + + if (command_have_option(cmd, option)) + list = g_slist_remove(list, option); + } + + if (list == NULL) + return defserver; server = server_find_tag(list->data); if (server == NULL || list->next != NULL) { /* unknown option (not server tag) */ - signal_emit("error command", 2, GINT_TO_POINTER(CMDERR_OPTION_UNKNOWN), list->data); + signal_emit("error command", 2, + GINT_TO_POINTER(CMDERR_OPTION_UNKNOWN), + server == NULL ? list->data : list->next->data); server = NULL; } @@ -244,7 +258,7 @@ static void cmd_msg(const char *data, IRC_SERVER_REC *server, WI_IRC_REC *item) return; if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - server = irccmd_options_get_server(optlist, server); + server = irccmd_options_get_server("msg", optlist, server); if (server == NULL || !server->connected || !irc_server_check(server)) cmd_param_error(CMDERR_NOT_CONNECTED); @@ -349,7 +363,7 @@ static void cmd_join(const char *data, IRC_SERVER_REC *server) channels_join(server, server->last_invite, FALSE); } else { /* -<server tag> */ - server = irccmd_options_get_server(optlist, server); + server = irccmd_options_get_server("join", optlist, server); if (server != NULL) channels_join(server, channels, FALSE); } diff --git a/src/irc/core/irc-commands.h b/src/irc/core/irc-commands.h index 6d4535a0..900a7765 100644 --- a/src/irc/core/irc-commands.h +++ b/src/irc/core/irc-commands.h @@ -3,6 +3,8 @@ /* `optlist' should contain only one key - the server tag. returns NULL if there was unknown -option */ -IRC_SERVER_REC *irccmd_options_get_server(GHashTable *optlist, IRC_SERVER_REC *defserver); +IRC_SERVER_REC *irccmd_options_get_server(const char *cmd, + GHashTable *optlist, + IRC_SERVER_REC *defserver); #endif |