diff options
author | Timo Sirainen <cras@irssi.org> | 2001-11-12 22:15:04 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-11-12 22:15:04 +0000 |
commit | e66ec6cf8bede7a87b3dc4a8a9cf0cc0fab3d039 (patch) | |
tree | 2ff1fb823bb9783da5367743dfab1bc27c110d01 /src/irc/core/servers-redirect.c | |
parent | 167324649763786e018f6794a7f4fcdfd25734e2 (diff) | |
download | irssi-e66ec6cf8bede7a87b3dc4a8a9cf0cc0fab3d039.zip |
Redirection fixes - added count parameter.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1999 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/core/servers-redirect.c')
-rw-r--r-- | src/irc/core/servers-redirect.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/irc/core/servers-redirect.c b/src/irc/core/servers-redirect.c index f2c1777f..31191400 100644 --- a/src/irc/core/servers-redirect.c +++ b/src/irc/core/servers-redirect.c @@ -38,9 +38,10 @@ typedef struct { struct _REDIRECT_REC { REDIRECT_CMD_REC *cmd; time_t created; - int destroyed; + int destroyed; char *arg; + int count; int remote; char *failure_signal, *default_signal; GSList *signals; /* event, signal, ... */ @@ -160,7 +161,7 @@ void server_redirect_register_list(const char *command, } void server_redirect_event(IRC_SERVER_REC *server, const char *command, - const char *arg, int remote, + int count, const char *arg, int remote, const char *failure_signal, ...) { GSList *signals; @@ -183,12 +184,12 @@ void server_redirect_event(IRC_SERVER_REC *server, const char *command, va_end(va); - server_redirect_event_list(server, command, arg, remote, + server_redirect_event_list(server, command, count, arg, remote, failure_signal, signals); } void server_redirect_event_list(IRC_SERVER_REC *server, const char *command, - const char *arg, int remote, + int count, const char *arg, int remote, const char *failure_signal, GSList *signals) { REDIRECT_CMD_REC *cmdrec; @@ -200,11 +201,6 @@ void server_redirect_event_list(IRC_SERVER_REC *server, const char *command, g_return_if_fail(command != NULL); g_return_if_fail((g_slist_length(signals) & 1) == 0); - if (server->redirect_next != NULL) { - server_redirect_destroy(server->redirect_next); - server->redirect_next = NULL; - } - cmdrec = g_hash_table_lookup(command_redirects, command); if (cmdrec == NULL) { g_warning("Unknown redirection command: %s", command); @@ -217,6 +213,7 @@ void server_redirect_event_list(IRC_SERVER_REC *server, const char *command, rec->created = time(NULL); rec->cmd = cmdrec; rec->arg = g_strdup(arg); + rec->count = count; rec->remote = remote != -1 ? remote : cmdrec->remote; rec->failure_signal = g_strdup(failure_signal); @@ -231,6 +228,8 @@ void server_redirect_event_list(IRC_SERVER_REC *server, const char *command, } rec->signals = signals; + if (server->redirect_next != NULL) + server_redirect_destroy(server->redirect_next); server->redirect_next = rec; } @@ -243,12 +242,12 @@ void server_redirect_command(IRC_SERVER_REC *server, const char *command, g_return_if_fail(command != NULL); if (redirect == NULL) { + /* no redirection wanted, but still register the command + so future redirections wont get messed up. */ cmdrec = redirect_cmd_find(command); if (cmdrec == NULL) return; - /* no redirection wanted, but still register the command - so future redirections wont get messed up. */ redirect_cmd_ref(cmdrec); redirect = g_new0(REDIRECT_REC, 1); @@ -454,7 +453,8 @@ const char *server_redirect_get_signal(IRC_SERVER_REC *server, /* stop event - remove this redirection next time this function is called (can't destroy now or our return value would be corrupted) */ - redirect->destroyed = TRUE; + if (--redirect->count <= 0) + redirect->destroyed = TRUE; server->redirect_continue = NULL; } @@ -482,7 +482,7 @@ static void sig_disconnected(IRC_SERVER_REC *server) g_slist_free(server->redirects); if (server->redirect_next != NULL) - server_redirect_destroy(server->redirect_next); + server_redirect_destroy(server->redirect_next); } static void cmd_redirect_destroy(char *key, REDIRECT_CMD_REC *cmd) |