From 755a8d40eb5f9e0a12b98e4f84332891a3d63b1a Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sat, 2 Sep 2000 18:53:58 +0000 Subject: Updates. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@641 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/servers.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/core/servers.c') diff --git a/src/core/servers.c b/src/core/servers.c index b8168f05..2abc7434 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -20,6 +20,7 @@ #include "module.h" #include "signals.h" +#include "commands.h" #include "line-split.h" #include "net-nonblock.h" #include "net-sendbuffer.h" @@ -28,6 +29,7 @@ #include "settings.h" #include "servers.h" +#include "servers-reconnect.h" #include "servers-redirect.h" #include "servers-setup.h" #include "channels.h" @@ -397,10 +399,49 @@ void server_connect_free(SERVER_CONNECT_REC *conn) g_free(conn); } +/* `optlist' should contain only one key - the server tag. + returns NULL if there was unknown -option */ +SERVER_REC *cmd_options_get_server(const char *cmd, + GHashTable *optlist, + SERVER_REC *defserver) +{ + SERVER_REC *server; + GSList *list, *tmp, *next; + + /* get all the options, then remove the known ones. there should + be only one left - the server tag. */ + list = hashtable_get_keys(optlist); + 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), + server == NULL ? list->data : list->next->data); + signal_stop(); + + server = NULL; + } + + g_slist_free(list); + return server; +} + void servers_init(void) { lookup_servers = servers = NULL; + servers_reconnect_init(); servers_redirect_init(); servers_setup_init(); } @@ -414,6 +455,7 @@ void servers_deinit(void) servers_setup_deinit(); servers_redirect_deinit(); + servers_reconnect_deinit(); module_uniq_destroy("SERVER"); module_uniq_destroy("SERVER CONNECT"); -- cgit v1.2.3