diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-04-08 14:29:12 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-04-08 14:29:12 +0200 |
commit | 45c0cc7e7e3de9cdfc6293df9ea6edbe3968f1d4 (patch) | |
tree | f8dace78ba938cfdd61d57e547453c766d4cbbcb /src/plugins/alias | |
parent | 3fc11807f9662327b57a8911fb4cb9314c1599dd (diff) | |
download | weechat-45c0cc7e7e3de9cdfc6293df9ea6edbe3968f1d4.zip |
Define list of default aliases as an array
Diffstat (limited to 'src/plugins/alias')
-rw-r--r-- | src/plugins/alias/alias-config.c | 107 |
1 files changed, 46 insertions, 61 deletions
diff --git a/src/plugins/alias/alias-config.c b/src/plugins/alias/alias-config.c index 75719c5c7..d1b4c5720 100644 --- a/src/plugins/alias/alias-config.c +++ b/src/plugins/alias/alias-config.c @@ -31,6 +31,40 @@ struct t_config_file *alias_config_file = NULL; struct t_config_section *alias_config_section_cmd = NULL; struct t_config_section *alias_config_section_completion = NULL; +char *alias_default_list[][2] = +{ { "AAWAY", "allserv /away" }, + { "AME", "allchan /me" }, + { "AMSG", "allchan /msg *" }, + { "ANICK", "allserv /nick" }, + { "BYE", "quit" }, + { "C", "buffer clear" }, + { "CL", "buffer clear" }, + { "CLOSE", "buffer close" }, + { "CHAT", "dcc chat" }, + { "EXIT", "quit" }, + { "IG", "ignore" }, + { "J", "join" }, + { "K", "kick" }, + { "KB", "kickban" }, + { "LEAVE", "part" }, + { "M", "msg" }, + { "MUB", "unban *" }, + { "N", "names" }, + { "Q", "query" }, + { "REDRAW", "window refresh" }, + { "SAY", "msg *" }, + { "SIGNOFF", "quit" }, + { "T", "topic" }, + { "UB", "unban" }, + { "V", "command core version" }, + { "W", "who" }, + { "WC", "window merge" }, + { "WI", "whois" }, + { "WII", "whois $1 $1" }, + { "WW", "whowas" }, + { NULL, NULL }, +}; + /* * alias_config_cmd_change_cb: callback called when alias option is modified @@ -149,72 +183,21 @@ alias_config_cmd_write_default_cb (void *data, struct t_config_file *config_file, const char *section_name) { + int i; + /* make C compiler happy */ (void) data; if (!weechat_config_write_line (config_file, section_name, NULL)) return WEECHAT_CONFIG_WRITE_ERROR; - - if (!weechat_config_write_line (config_file, "AAWAY", "%s", "\"allserv /away\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "AME", "%s", "\"allchan /me\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "AMSG", "%s", "\"allchan /msg *\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "ANICK", "%s", "\"allserv /nick\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "BYE", "%s", "\"quit\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "C", "%s", "\"buffer clear\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "CL", "%s", "\"buffer clear\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "CLOSE", "%s", "\"buffer close\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "CHAT", "%s", "\"dcc chat\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "EXIT", "%s", "\"quit\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "IG", "%s", "\"ignore\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "J", "%s", "\"join\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "K", "%s", "\"kick\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "KB", "%s", "\"kickban\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "LEAVE", "%s", "\"part\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "M", "%s", "\"msg\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "MUB", "%s", "\"unban *\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "N", "%s", "\"names\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "Q", "%s", "\"query\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "REDRAW", "%s", "\"window refresh\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "SAY", "%s", "\"msg *\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "SIGNOFF", "%s", "\"quit\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "T", "%s", "\"topic\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "UB", "%s", "\"unban\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "V", "%s", "\"command core version\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "W", "%s", "\"who\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "WC", "%s", "\"window merge\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "WI", "%s", "\"whois\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "WII", "%s", "\"whois $1 $1\"")) - return WEECHAT_CONFIG_WRITE_ERROR; - if (!weechat_config_write_line (config_file, "WW", "%s", "\"whowas\"")) - return WEECHAT_CONFIG_WRITE_ERROR; + + for (i = 0; alias_default_list[i][0]; i++) + { + if (!weechat_config_write_line (config_file, + alias_default_list[i][0], + "\"%s\"", alias_default_list[i][1])) + return WEECHAT_CONFIG_WRITE_ERROR; + } return WEECHAT_CONFIG_WRITE_OK; } @@ -349,6 +332,7 @@ alias_config_init () if (!alias_config_file) return 0; + /* cmd */ ptr_section = weechat_config_new_section (alias_config_file, "cmd", 1, 1, NULL, NULL, @@ -363,6 +347,7 @@ alias_config_init () } alias_config_section_cmd = ptr_section; + /* completion */ ptr_section = weechat_config_new_section (alias_config_file, "completion", 1, 1, NULL, NULL, |