diff options
author | Timo Sirainen <cras@irssi.org> | 2001-11-02 01:05:14 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-11-02 01:05:14 +0000 |
commit | f354fe54c71485516b76fdd149891191993f60b5 (patch) | |
tree | 1231e8f5e1126c4fa9544a9ce40ce54ace6e05d1 /src/core/rawlog.c | |
parent | 95b94ed83c1372fae4eb14bf8109847bdc65a8d2 (diff) | |
download | irssi-f354fe54c71485516b76fdd149891191993f60b5.zip |
Moved some stuff from irc to core. Added command_bind_proto() function to
bind protocol-specific commands. Added #define command_bind_irc() for easier
access. CMD_IRC_SERVER(server) check should be done at the beginning of each
command requiring IRC server as active server, it handles it correctly the
cases when it is not. Did some other cleanups as well.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1955 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/rawlog.c')
-rw-r--r-- | src/core/rawlog.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/core/rawlog.c b/src/core/rawlog.c index 4e47040c..138875ea 100644 --- a/src/core/rawlog.c +++ b/src/core/rawlog.c @@ -22,10 +22,13 @@ #include "rawlog.h" #include "modules.h" #include "signals.h" +#include "commands.h" #include "misc.h" #include "write-buffer.h" #include "settings.h" +#include "servers.h" + static int rawlog_lines; static int signal_rawlog; static int log_file_create_mode; @@ -158,6 +161,40 @@ static void read_settings(void) log_file_create_mode = octal2dec(settings_get_int("log_create_mode")); } +static void cmd_rawlog(const char *data, SERVER_REC *server, void *item) +{ + command_runsub("rawlog", data, server, item); +} + +/* SYNTAX: RAWLOG SAVE <file> */ +static void cmd_rawlog_save(const char *data, SERVER_REC *server) +{ + g_return_if_fail(data != NULL); + if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); + + if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS); + rawlog_save(server->rawlog, data); +} + +/* SYNTAX: RAWLOG OPEN <file> */ +static void cmd_rawlog_open(const char *data, SERVER_REC *server) +{ + g_return_if_fail(data != NULL); + if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); + + if (*data == '\0') cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS); + rawlog_open(server->rawlog, data); +} + +/* SYNTAX: RAWLOG CLOSE */ +static void cmd_rawlog_close(const char *data, SERVER_REC *server) +{ + g_return_if_fail(data != NULL); + if (server == NULL || !server->connected) cmd_return_error(CMDERR_NOT_CONNECTED); + + rawlog_close(server->rawlog); +} + void rawlog_init(void) { signal_rawlog = signal_get_uniq_id("rawlog"); @@ -166,9 +203,19 @@ void rawlog_init(void) read_settings(); signal_add("setup changed", (SIGNAL_FUNC) read_settings); + + command_bind("rawlog", NULL, (SIGNAL_FUNC) cmd_rawlog); + command_bind("rawlog save", NULL, (SIGNAL_FUNC) cmd_rawlog_save); + command_bind("rawlog open", NULL, (SIGNAL_FUNC) cmd_rawlog_open); + command_bind("rawlog close", NULL, (SIGNAL_FUNC) cmd_rawlog_close); } void rawlog_deinit(void) { signal_remove("setup changed", (SIGNAL_FUNC) read_settings); + + command_unbind("rawlog", (SIGNAL_FUNC) cmd_rawlog); + command_unbind("rawlog save", (SIGNAL_FUNC) cmd_rawlog_save); + command_unbind("rawlog open", (SIGNAL_FUNC) cmd_rawlog_open); + command_unbind("rawlog close", (SIGNAL_FUNC) cmd_rawlog_close); } |