diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-12-16 14:16:03 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-12-16 14:16:03 +0000 |
commit | d5b58ff068c601906c83524b91b7d5aea666faa0 (patch) | |
tree | 6d9f81116be9b339ba3a2e695c4bb67f374da70d /src | |
parent | 6eabc3aa61c7f0d6be44c2d9e88a8611ff0cc9f3 (diff) | |
download | weechat-d5b58ff068c601906c83524b91b7d5aea666faa0.zip |
Added completion system for plugins/scripts commands, fixed plugins autoload
Diffstat (limited to 'src')
-rw-r--r-- | src/common/command.c | 48 | ||||
-rw-r--r-- | src/common/command.h | 14 | ||||
-rw-r--r-- | src/common/completion.c | 1147 | ||||
-rw-r--r-- | src/common/completion.h | 32 | ||||
-rw-r--r-- | src/gui/gui-action.c | 2 | ||||
-rw-r--r-- | src/gui/gui-common.c | 2 | ||||
-rw-r--r-- | src/irc/irc-commands.c | 657 | ||||
-rw-r--r-- | src/irc/irc.h | 244 | ||||
-rw-r--r-- | src/plugins/plugins-interface.c | 2 | ||||
-rw-r--r-- | src/plugins/plugins.c | 102 | ||||
-rw-r--r-- | src/plugins/plugins.h | 1 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 4 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 9 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby.c | 19 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 3 |
15 files changed, 1179 insertions, 1107 deletions
diff --git a/src/common/command.c b/src/common/command.c index 1c76fa02f..ff497169a 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -46,7 +46,7 @@ t_weechat_command weechat_commands[] = N_("[alias_name [command [arguments]]"), N_("alias_name: name of alias\ncommand: command name (WeeChat " "or IRC command, without first '/')\n" "arguments: arguments for command"), - 0, MAX_ARGS, NULL, weechat_cmd_alias }, + "%- %A", 0, MAX_ARGS, NULL, weechat_cmd_alias }, { "buffer", N_("manage buffers"), N_("[action | number | [[server] [channel]]]"), N_("action: action to do:\n" @@ -56,39 +56,40 @@ t_weechat_command weechat_commands[] = " notify: set notify level for buffer (0=never, 1=highlight, 2=1+msg, 3=2+join/part)\n" "server,channel: jump to buffer by server and/or channel name\n" "number: jump to buffer by number"), - 0, MAX_ARGS, weechat_cmd_buffer, NULL }, + "move|close|list|notify", 0, MAX_ARGS, weechat_cmd_buffer, NULL }, { "charset", N_("change charset for server or channel"), N_("[(decode_iso | decode_utf | encode) charset]"), N_("decode_iso: charset used for decoding ISO\n" "decode_utf: charset used for decoding UTF\n" " encode: charset used for encoding messages\n" " charset: charset to use (for example: ISO-8859-15, UTF-8,..)"), - 0, 2, weechat_cmd_charset, NULL }, + "decode_iso|decode_utf|encode", 0, 2, weechat_cmd_charset, NULL }, { "clear", N_("clear window(s)"), N_("[-all]"), N_("-all: clear all windows"), - 0, 1, weechat_cmd_clear, NULL }, + "-all", 0, 1, weechat_cmd_clear, NULL }, { "connect", N_("connect to a server"), N_("[servername]"), N_("servername: server name to connect"), - 0, 1, weechat_cmd_connect, NULL }, + "%S", 0, 1, weechat_cmd_connect, NULL }, { "disconnect", N_("disconnect from a server"), N_("[servername]"), N_("servername: server name to disconnect"), - 0, 1, weechat_cmd_disconnect, NULL }, + "%S", 0, 1, weechat_cmd_disconnect, NULL }, { "debug", N_("print debug messages"), N_("dump | windows"), N_("dump: save memory dump in WeeChat log file (same dump is written when WeeChat crashes)\n" "windows: display windows tree"), - 1, 1, weechat_cmd_debug, NULL }, + "dump|windows", 1, 1, weechat_cmd_debug, NULL }, { "help", N_("display help about commands"), - N_("[command]"), N_("command: name of a WeeChat or IRC command"), - 0, 1, weechat_cmd_help, NULL }, + N_("[command]"), + N_("command: name of a WeeChat or IRC command"), + "%w|%i|%h", 0, 1, weechat_cmd_help, NULL }, { "history", N_("show buffer command history"), N_("[clear | value]"), N_("clear: clear history\n" "value: number of history entries to show"), - 0, 1, weechat_cmd_history, NULL }, + "clear", 0, 1, weechat_cmd_history, NULL }, { "ignore", N_("ignore IRC messages and/or hosts"), N_("[mask [[type | command] [channel [server]]]]"), N_(" mask: nick or host mask to ignore\n" @@ -98,19 +99,20 @@ t_weechat_command weechat_commands[] = " server: name of server for ignore\n\n" "For each argument, '*' means all.\n" "Without argument, /ignore command lists all defined ignore."), + "*|%n *|action|ctcp|dcc|pv|%I *|%c *|%s", 0, 4, weechat_cmd_ignore, NULL }, { "key", N_("bind/unbind keys"), N_("[key function/command] [unbind key] [functions] [reset -yes]"), N_("key: bind this key to an internal function or a command (beginning by \"/\")\n" - "unbind: unbind a key (if \"all\", default bindings are restored)\n" + "unbind: unbind a key\n" "functions: list internal functions for key bindings\n" "reset: restore bindings to the default values and delete ALL personal binding (use carefully!)"), - 0, MAX_ARGS, NULL, weechat_cmd_key }, + "unbind|functions|reset %k", 0, MAX_ARGS, NULL, weechat_cmd_key }, { "plugin", N_("list/load/unload plugins"), N_("[load filename] | [autoload] | [reload] | [unload]"), N_("filename: WeeChat plugin (file) to load\n\n" "Without argument, /plugin command lists all loaded plugins."), - 0, 2, weechat_cmd_plugin, NULL }, + "load|autoload|reload|unload", 0, 2, weechat_cmd_plugin, NULL }, { "server", N_("list, add or remove servers"), N_("[servername] | " "[servername hostname port [-auto | -noauto] [-ipv6] [-ssl] [-pwd password] [-nicks nick1 " @@ -128,19 +130,19 @@ t_weechat_command weechat_commands[] = "nick3: second alternate nick for server\n" "username: user name\n" "realname: real name of user"), - 0, MAX_ARGS, weechat_cmd_server, NULL }, + NULL, 0, MAX_ARGS, weechat_cmd_server, NULL }, { "save", N_("save config to disk"), N_("[file]"), N_("file: filename for writing config"), - 0, 1, weechat_cmd_save, NULL }, + NULL, 0, 1, weechat_cmd_save, NULL }, { "set", N_("set config parameters"), N_("[option [ = value]]"), N_("option: name of an option (if name is full " "and no value is given, then help is displayed on option)\n" "value: value for option"), - 0, MAX_ARGS, NULL, weechat_cmd_set }, + "%o = %v", 0, MAX_ARGS, NULL, weechat_cmd_set }, { "unalias", N_("remove an alias"), N_("alias_name"), N_("alias_name: name of alias to remove"), - 1, 1, NULL, weechat_cmd_unalias }, + "%a", 1, 1, NULL, weechat_cmd_unalias }, { "unignore", N_("unignore IRC messages and/or hosts"), N_("[number | [mask [[type | command] [channel [server]]]]]"), N_(" number: # of ignore to unignore (number is displayed by list of ignore)\n" @@ -151,15 +153,14 @@ t_weechat_command weechat_commands[] = " server: name of server for unignore\n\n" "For each argument, '*' means all.\n" "Without argument, /unignore command lists all defined ignore."), + "*|%n *|action|ctcp|dcc|pv|%I *|%c *|%s", 0, 4, weechat_cmd_unignore, NULL }, - { "upgrade", N_("upgrade WeeChat without disconnecting from servers"), - "", - "", - 0, 0, weechat_cmd_upgrade, NULL }, + { "upgrade", N_("upgrade WeeChat without disconnecting from servers"), "", "", + NULL, 0, 0, weechat_cmd_upgrade, NULL }, { "uptime", N_("show WeeChat uptime"), N_("[-o]"), N_("-o: send uptime on current channel as an IRC message"), - 0, 1, weechat_cmd_uptime, NULL }, + "-o", 0, 1, weechat_cmd_uptime, NULL }, { "window", N_("manage windows"), N_("[list | -1 | +1 | b# | up | down | left | right | splith [pct] " "| splitv [pct] | resize pct | merge [all]]"), @@ -178,8 +179,9 @@ t_weechat_command weechat_commands[] = "For splith and splitv, pct is a pourcentage which represents " "size of new window, computed with current window as size reference. " "For example 25 means create a new window with size = current_size / 4"), + "list|-1|+1|up|down|left|right|splith|splitv|resize|merge all", 0, 2, weechat_cmd_window, NULL }, - { NULL, NULL, NULL, NULL, 0, 0, NULL, NULL } + { NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL } }; t_weechat_alias *weechat_alias = NULL; diff --git a/src/common/command.h b/src/common/command.h index 10cd44c86..4d9d7fcd0 100644 --- a/src/common/command.h +++ b/src/common/command.h @@ -31,13 +31,17 @@ typedef struct t_weechat_command t_weechat_command; struct t_weechat_command { - char *command_name; - char *command_description; - char *arguments; - char *arguments_description; - int min_arg, max_arg; + char *command_name; /* WeeChat (internal) command name */ + char *command_description; /* command description (for /help) */ + char *arguments; /* command arguments (for /help) */ + char *arguments_description; /* arguments description (for /help) */ + char *completion_template; /* template for completion */ + /* NULL=no completion, ""=default (nick) */ + int min_arg, max_arg; /* min & max number of arguments */ int (*cmd_function_args)(t_gui_window *, int, char **); + /* function called when user enters cmd */ int (*cmd_function_1arg)(t_gui_window *, char *); + /* function called when user enters cmd */ }; typedef struct t_weechat_alias t_weechat_alias; diff --git a/src/common/completion.c b/src/common/completion.c index c4202997f..a09cfd51b 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -45,8 +45,10 @@ */ void -completion_init (t_completion *completion) +completion_init (t_completion *completion, void *server, void *channel) { + completion->server = server; + completion->channel = channel; completion->context = COMPLETION_NULL; completion->base_command = NULL; completion->base_command_arg = 0; @@ -97,684 +99,637 @@ completion_stop (t_completion *completion) } /* - * completion_build_list: build data list according to command and argument # + * completion_get_command_infos: return completion template and max arg for command */ void -completion_build_list (t_completion *completion, void *server, void *channel) +completion_get_command_infos (t_completion *completion, + char **template, int *max_arg) { - t_weelist *ptr_list; - int i, j, length; - t_irc_server *ptr_server; - t_irc_channel *ptr_channel; - t_irc_nick *ptr_nick; - char *pos, option_name[256], *string, *string2; - t_weechat_alias *ptr_alias; - t_config_option *option; - void *option_value; - char option_string[2048]; + int i; #ifdef PLUGINS t_weechat_plugin *ptr_plugin; t_plugin_handler *ptr_handler; #endif - /* WeeChat internal commands */ + *template = NULL; + *max_arg = MAX_ARGS; - /* no completion for some commands */ - if ((ascii_strcasecmp (completion->base_command, "server") == 0) - || (ascii_strcasecmp (completion->base_command, "save") == 0)) +#ifdef PLUGINS + /* look for plugin command handler */ + for (ptr_plugin = weechat_plugins; ptr_plugin; + ptr_plugin = ptr_plugin->next_plugin) { - completion_stop (completion); - return; + for (ptr_handler = ptr_plugin->handlers; + ptr_handler; ptr_handler = ptr_handler->next_handler) + { + if ((ptr_handler->type == HANDLER_COMMAND) + && (ascii_strcasecmp (ptr_handler->command, + completion->base_command) == 0)) + { + *template = ptr_handler->completion_template; + *max_arg = MAX_ARGS; + return; + } + } } - if ((ascii_strcasecmp (completion->base_command, "alias") == 0) - && (completion->base_command_arg == 1)) +#endif + + /* look for WeeChat internal command */ + for (i = 0; weechat_commands[i].command_name; i++) { - for (ptr_list = index_commands; ptr_list; ptr_list = ptr_list->next_weelist) + if (ascii_strcasecmp (weechat_commands[i].command_name, + completion->base_command) == 0) { - weelist_add (&completion->completion_list, - &completion->last_completion, - ptr_list->data); + *template = weechat_commands[i].completion_template; + *max_arg = weechat_commands[i].max_arg; + return; } - return; } - if ((ascii_strcasecmp (completion->base_command, "buffer") == 0) - && (completion->base_command_arg == 1)) + + /* look for IRC command */ + for (i = 0; irc_commands[i].command_name; i++) + { + if ((irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) + && (ascii_strcasecmp (irc_commands[i].command_name, + completion->base_command) == 0)) + { + *template = irc_commands[i].completion_template; + *max_arg = irc_commands[i].max_arg; + return; + } + } + + return; +} + +/* + * completion_list_add_alias: add alias to completion list + */ + +void +completion_list_add_alias (t_completion *completion) +{ + t_weechat_alias *ptr_alias; + + for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias) { weelist_add (&completion->completion_list, &completion->last_completion, - "close"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "list"); + ptr_alias->alias_name); + } +} + +/* + * completion_list_add_alias_cmd: add alias and comands to completion list + */ + +void +completion_list_add_alias_cmd (t_completion *completion) +{ + t_weelist *ptr_list; + + for (ptr_list = index_commands; ptr_list; ptr_list = ptr_list->next_weelist) + { weelist_add (&completion->completion_list, &completion->last_completion, - "move"); + ptr_list->data); + } +} + +/* + * completion_list_add_channel: add current channel to completion list + */ + +void +completion_list_add_channel (t_completion *completion) +{ + if (completion->channel) weelist_add (&completion->completion_list, &completion->last_completion, - "notify"); - return; - } - if (ascii_strcasecmp (completion->base_command, "charset") == 0) + ((t_irc_channel *)(completion->channel))->name); +} + +/* + * completion_list_add_server_channels: add server channels to completion list + */ + +void +completion_list_add_server_channels (t_completion *completion) +{ + t_irc_channel *ptr_channel; + + if (completion->server) { - if (completion->base_command_arg == 1) + for (ptr_channel = ((t_irc_server *)(completion->server))->channels; + ptr_channel; ptr_channel = ptr_channel->next_channel) { weelist_add (&completion->completion_list, &completion->last_completion, - "decode_iso"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "decode_utf"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "encode"); + ptr_channel->name); } - else if (completion->base_command_arg == 2) + } +} + +/* + * completion_list_add_filename: add filename to completion list + */ + +void +completion_list_add_filename (t_completion *completion) +{ + /* TODO: add filename completion */ + completion_stop (completion); +} + +/* + * completion_list_add_plugin_cmd: add plugin command handlers to completion list + */ + +void +completion_list_add_plugin_cmd (t_completion *completion) +{ +#ifdef PLUGINS + t_weechat_plugin *ptr_plugin; + t_plugin_handler *ptr_handler; + + for (ptr_plugin = weechat_plugins; ptr_plugin; + ptr_plugin = ptr_plugin->next_plugin) + { + for (ptr_handler = ptr_plugin->handlers; + ptr_handler; ptr_handler = ptr_handler->next_handler) { - if (!server) - { - completion_stop (completion); - return; - } - pos = strchr (completion->args, ' '); - if (pos) - pos[0] = '\0'; - string2 = NULL; - if (ascii_strcasecmp (completion->args, "decode_iso") == 0) - { - config_option_list_get_value (&(((t_irc_server *)server)->charset_decode_iso), - (channel) ? ((t_irc_channel *)channel)->name : "server", - &string, &length); - if (string && (length > 0)) - { - string2 = strdup (string); - string2[length] = '\0'; - } - } - else if (ascii_strcasecmp (completion->args, "decode_utf") == 0) - { - config_option_list_get_value (&(((t_irc_server *)server)->charset_decode_utf), - (channel) ? ((t_irc_channel *)channel)->name : "server", - &string, &length); - if (string && (length > 0)) - { - string2 = strdup (string); - string2[length] = '\0'; - } - } - else if (ascii_strcasecmp (completion->args, "encode") == 0) - { - config_option_list_get_value (&(((t_irc_server *)server)->charset_encode), - (channel) ? ((t_irc_channel *)channel)->name : "server", - &string, &length); - if (string && (length > 0)) - { - string2 = strdup (string); - string2[length] = '\0'; - } - } - - if (string2) - { + if (ptr_handler->type == HANDLER_COMMAND) weelist_add (&completion->completion_list, &completion->last_completion, - string2); - free (string2); - } - else - completion_stop (completion); - - if (pos) - pos[0] = ' '; + ptr_handler->command); } - else - completion_stop (completion); - return; } - if ((ascii_strcasecmp (completion->base_command, "clear") == 0) - && (completion->base_command_arg == 1)) +#else + /* make gcc happy */ + (void) completion; +#endif +} + +/* + * completion_list_add_irc_cmd_sent: add IRC command (sent) to completion list + */ + +void +completion_list_add_irc_cmd_sent (t_completion *completion) +{ + int i; + + for (i = 0; irc_commands[i].command_name; i++) + { + if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) + weelist_add (&completion->completion_list, + &completion->last_completion, + irc_commands[i].command_name); + } +} + +/* + * completion_list_add_irc_cmd_recv: add IRC command (received) to completion list + */ + +void +completion_list_add_irc_cmd_recv (t_completion *completion) +{ + int i; + + for (i = 0; irc_commands[i].command_name; i++) + { + if (irc_commands[i].recv_function) + weelist_add(&completion->completion_list, + &completion->last_completion, + irc_commands[i].command_name); + } +} + +/* + * completion_list_add_key_cmd: add key commands/functions to completion list + */ + +void +completion_list_add_key_cmd (t_completion *completion) +{ + int i; + + for (i = 0; gui_key_functions[i].function_name; i++) { weelist_add (&completion->completion_list, &completion->last_completion, - "-all"); - return; + gui_key_functions[i].function_name); } - if ((ascii_strcasecmp (completion->base_command, "connect") == 0) - || (ascii_strcasecmp (completion->base_command, "disconnect") == 0)) +} + +/* + * completion_list_add_channel_nicks: add channel nicks to completion list + */ + +void +completion_list_add_channel_nicks (t_completion *completion) +{ + t_irc_nick *ptr_nick; + + if (completion->channel) { - if (completion->base_command_arg == 1) + if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_CHANNEL) { - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) + for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks; + ptr_nick; ptr_nick = ptr_nick->next_nick) { weelist_add (&completion->completion_list, &completion->last_completion, - ptr_server->name); + ptr_nick->nick); } - return; - } - else - { - completion_stop (completion); - return; } - } - if (ascii_strcasecmp (completion->base_command, "debug") == 0) - { - if (completion->base_command_arg == 1) + if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE) { weelist_add (&completion->completion_list, &completion->last_completion, - "dump"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "windows"); + ((t_irc_channel *)(completion->channel))->name); } - else - completion_stop (completion); - return; - } - if ((ascii_strcasecmp (completion->base_command, "help") == 0) - && (completion->base_command_arg == 1)) - { - for (i = 0; weechat_commands[i].command_name; i++) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - weechat_commands[i].command_name); - } - for (i = 0; irc_commands[i].command_name; i++) - { - if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) - weelist_add (&completion->completion_list, - &completion->last_completion, - irc_commands[i].command_name); - } -#ifdef PLUGINS - for (ptr_plugin = weechat_plugins; ptr_plugin; - ptr_plugin = ptr_plugin->next_plugin) - { - for (ptr_handler = ptr_plugin->handlers; - ptr_handler; ptr_handler = ptr_handler->next_handler) - { - if (ptr_handler->type == HANDLER_COMMAND) - weelist_add (&completion->completion_list, - &completion->last_completion, - ptr_handler->command); - } - } -#endif - return; } - if (ascii_strcasecmp (completion->base_command, "history") == 0) - { - if (completion->base_command_arg == 1) - weelist_add (&completion->completion_list, - &completion->last_completion, - "clear"); - else - completion_stop (completion); - return; - } - if (ascii_strcasecmp (completion->base_command, "ignore") == 0) +} + +/* + * completion_list_add_option: add config option to completion list + */ + +void +completion_list_add_option (t_completion *completion) +{ + int i, j; + t_irc_server *ptr_server; + char option_name[256]; + + for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) { - /* arg 1: nicks of current channel and "*" */ - if (completion->base_command_arg == 1) + if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS) + && (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER)) { - weelist_add (&completion->completion_list, - &completion->last_completion, - "*"); - if (channel) - { - if (((t_irc_channel *)channel)->type == CHANNEL_TYPE_CHANNEL) - { - for (ptr_nick = ((t_irc_channel *)channel)->nicks; ptr_nick; - ptr_nick = ptr_nick->next_nick) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - ptr_nick->nick); - } - } - if (((t_irc_channel *)channel)->type == CHANNEL_TYPE_PRIVATE) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - ((t_irc_channel *)channel)->name); - } - } - return; - } - - /* arg 2: type / command and "*" */ - if (completion->base_command_arg == 2) - { - weelist_add(&completion->completion_list, - &completion->last_completion, - "*"); - i = 0; - while (ignore_types[i]) + for (j = 0; weechat_options[i][j].option_name; j++) { weelist_add (&completion->completion_list, &completion->last_completion, - ignore_types[i]); - i++; - } - i = 0; - while (irc_commands[i].command_name) - { - if (irc_commands[i].recv_function) - weelist_add(&completion->completion_list, - &completion->last_completion, - irc_commands[i].command_name); - i++; + weechat_options[i][j].option_name); } - return; - } - - /* arg 3: channel and "*" */ - if (completion->base_command_arg == 3) - { - weelist_add(&completion->completion_list, - &completion->last_completion, - "*"); - if (((t_irc_channel *)channel)->type == CHANNEL_TYPE_CHANNEL) - weelist_add(&completion->completion_list, - &completion->last_completion, - ((t_irc_channel *)channel)->name); - return; - } - - /* arg 4: server */ - if (completion->base_command_arg == 4) - { - weelist_add(&completion->completion_list, - &completion->last_completion, - "*"); - if (SERVER(gui_current_window->buffer)) - weelist_add(&completion->completion_list, - &completion->last_completion, - SERVER(gui_current_window->buffer)->name); - return; } } - if (ascii_strcasecmp (completion->base_command, "key") == 0) + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) { - if (completion->base_command_arg == 1) + for (i = 0; weechat_options[CONFIG_SECTION_SERVER][i].option_name; i++) { + snprintf (option_name, sizeof (option_name), "%s.%s", + ptr_server->name, + weechat_options[CONFIG_SECTION_SERVER][i].option_name); weelist_add (&completion->completion_list, &completion->last_completion, - "unbind"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "functions"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "reset"); - return; - } - if (completion->base_command_arg == 2) - { - i = 0; - while (gui_key_functions[i].function_name) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - gui_key_functions[i].function_name); - i++; - } - return; + option_name); } } - if ((ascii_strcasecmp (completion->base_command, "plugin") == 0) - && (completion->base_command_arg == 1)) - { +} + +/* + * completion_list_add_part: add part message to completion list + */ + +void +completion_list_add_part (t_completion *completion) +{ + if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0]) weelist_add (&completion->completion_list, &completion->last_completion, - "load"); + cfg_irc_default_msg_part); +} + +/* + * completion_list_add_quit: add quit message to completion list + */ + +void +completion_list_add_quit (t_completion *completion) +{ + if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0]) weelist_add (&completion->completion_list, &completion->last_completion, - "autoload"); + cfg_irc_default_msg_quit); +} + +/* + * completion_list_add_server: add current server to completion list + */ + +void +completion_list_add_server (t_completion *completion) +{ + if (completion->server) weelist_add (&completion->completion_list, &completion->last_completion, - "reload"); + ((t_irc_server *)(completion->server))->name); +} + +/* + * completion_list_add_servers: add all servers to completion list + */ + +void +completion_list_add_servers (t_completion *completion) +{ + t_irc_server *ptr_server; + + for (ptr_server = irc_servers; ptr_server; + ptr_server = ptr_server->next_server) + { weelist_add (&completion->completion_list, &completion->last_completion, - "unload"); - return; + ptr_server->name); } - if (ascii_strcasecmp (completion->base_command, "set") == 0) +} + +/* + * completion_list_add_topic: add topic to completion list + */ + +void +completion_list_add_topic (t_completion *completion) +{ + char *string, *string2; + + if (!completion->server || !completion->channel + || !((t_irc_channel *)(completion->channel))->topic + || !((t_irc_channel *)(completion->channel))->topic[0]) + completion_stop (completion); + else + { + if (cfg_irc_colors_send) + string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)(completion->channel))->topic); + else + string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)(completion->channel))->topic, 0); + string2 = channel_iconv_decode ((t_irc_server *)(completion->server), + (t_irc_channel *)(completion->channel), + (string) ? string : ((t_irc_channel *)(completion->channel))->topic); + weelist_add (&completion->completion_list, + &completion->last_completion, + (string2) ? string2 : ((string) ? string : ((t_irc_channel *)(completion->channel))->topic)); + if (string) + free (string); + if (string2) + free (string2); + } +} + +/* + * completion_list_add_option_value: add option value to completion list + */ + +void +completion_list_add_option_value (t_completion *completion) +{ + char *pos; + t_config_option *option; + void *option_value; + char option_string[2048]; + + if (completion->args) { - if (completion->base_command_arg == 1) + pos = strchr (completion->args, ' '); + if (pos) + pos[0] = '\0'; + option = NULL; + option_value = NULL; + config_option_search_option_value (completion->args, &option, &option_value); + if (option && option_value) { - for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++) + switch (option->option_type) { - if ((i != CONFIG_SECTION_KEYS) && (i != CONFIG_SECTION_ALIAS) - && (i != CONFIG_SECTION_IGNORE) && (i != CONFIG_SECTION_SERVER)) - { - for (j = 0; weechat_options[i][j].option_name; j++) - { + case OPTION_TYPE_BOOLEAN: + if (option_value && (*((int *)(option_value)))) weelist_add (&completion->completion_list, &completion->last_completion, - weechat_options[i][j].option_name); - } - } - } - for (ptr_server = irc_servers; ptr_server; - ptr_server = ptr_server->next_server) - { - for (i = 0; weechat_options[CONFIG_SECTION_SERVER][i].option_name; i++) - { - snprintf (option_name, sizeof (option_name), "%s.%s", - ptr_server->name, - weechat_options[CONFIG_SECTION_SERVER][i].option_name); + "on"); + else + weelist_add (&completion->completion_list, + &completion->last_completion, + "off"); + break; + case OPTION_TYPE_INT: + snprintf (option_string, sizeof (option_string) - 1, + "%d", (option_value) ? *((int *)(option_value)) : option->default_int); weelist_add (&completion->completion_list, &completion->last_completion, - option_name); - } + option_string); + break; + case OPTION_TYPE_INT_WITH_STRING: + weelist_add (&completion->completion_list, + &completion->last_completion, + (option_value) ? + option->array_values[*((int *)(option_value))] : + option->array_values[option->default_int]); + break; + case OPTION_TYPE_COLOR: + weelist_add (&completion->completion_list, + &completion->last_completion, + (option_value) ? + gui_get_color_name (*((int *)(option_value))) : + option->default_string); + break; + case OPTION_TYPE_STRING: + snprintf (option_string, sizeof (option_string) - 1, + "\"%s\"", + (option_value) ? + *((char **)(option_value)) : + option->default_string); + weelist_add (&completion->completion_list, + &completion->last_completion, + option_string); + break; } } - else if (completion->base_command_arg == 3) + if (pos) + pos[0] = ' '; + } +} + +/* + * completion_list_add_weechat_cmd: add WeeChat commands to completion list + */ + +void +completion_list_add_weechat_cmd (t_completion *completion) +{ + int i; + + for (i = 0; weechat_commands[i].command_name; i++) + { + weelist_add (&completion->completion_list, + &completion->last_completion, + weechat_commands[i].command_name); + } +} + +/* + * completion_list_add_away: add away message to completion list + */ + +void +completion_list_add_away (t_completion *completion) +{ + if (cfg_irc_default_msg_away && cfg_irc_default_msg_away[0]) + weelist_add (&completion->completion_list, + &completion->last_completion, + cfg_irc_default_msg_away); +} + +/* + * completion_build_list_template: build data list according to a template + */ + +void +completion_build_list_template (t_completion *completion, char *template) +{ + char *word, *pos; + int word_offset; + + word = strdup (template); + word_offset = 0; + pos = template; + while (pos) + { + switch (pos[0]) { - if (completion->args) - { - pos = strchr (completion->args, ' '); - if (pos) - pos[0] = '\0'; - option = NULL; - option_value = NULL; - config_option_search_option_value (completion->args, &option, &option_value); - if (option && option_value) + case '\0': + case ' ': + case '|': + if (word_offset > 0) + { + word[word_offset] = '\0'; + weelist_add (&completion->completion_list, + &completion->last_completion, + word); + } + word_offset = 0; + break; + case '%': + pos++; + if (pos && pos[0]) { - switch (option->option_type) + switch (pos[0]) { - case OPTION_TYPE_BOOLEAN: - if (option_value && (*((int *)(option_value)))) - weelist_add (&completion->completion_list, - &completion->last_completion, - "on"); - else - weelist_add (&completion->completion_list, - &completion->last_completion, - "off"); + case '-': /* stop completion */ + completion_stop (completion); + free (word); + return; + break; + case 'a': /* alias */ + completion_list_add_alias (completion); break; - case OPTION_TYPE_INT: - snprintf (option_string, sizeof (option_string) - 1, - "%d", (option_value) ? *((int *)(option_value)) : option->default_int); - weelist_add (&completion->completion_list, - &completion->last_completion, - option_string); + case 'A': /* alias or any command */ + completion_list_add_alias_cmd (completion); break; - case OPTION_TYPE_INT_WITH_STRING: - weelist_add (&completion->completion_list, - &completion->last_completion, - (option_value) ? - option->array_values[*((int *)(option_value))] : - option->array_values[option->default_int]); + case 'c': /* current channel */ + completion_list_add_channel (completion); break; - case OPTION_TYPE_COLOR: - weelist_add (&completion->completion_list, - &completion->last_completion, - (option_value) ? - gui_get_color_name (*((int *)(option_value))) : - option->default_string); + case 'C': /* all channels */ + completion_list_add_server_channels (completion); break; - case OPTION_TYPE_STRING: - snprintf (option_string, sizeof (option_string) - 1, - "\"%s\"", - (option_value) ? - *((char **)(option_value)) : - option->default_string); - weelist_add (&completion->completion_list, - &completion->last_completion, - option_string); + case 'f': /* filename */ + completion_list_add_filename (completion); + break; + case 'h': /* plugin command handlers */ + completion_list_add_plugin_cmd (completion); + break; + case 'i': /* IRC command (sent) */ + completion_list_add_irc_cmd_sent (completion); + break; + case 'I': /* IRC command (received) */ + completion_list_add_irc_cmd_recv (completion); + break; + case 'k': /* key cmd/funtcions*/ + completion_list_add_key_cmd (completion); + break; + case 'n': /* channel nicks */ + completion_list_add_channel_nicks (completion); + break; + case 'o': /* config option */ + completion_list_add_option (completion); + break; + case 'p': /* part message */ + completion_list_add_part (completion); + break; + case 'q': /* quit message */ + completion_list_add_quit (completion); + break; + case 's': /* current server */ + completion_list_add_server (completion); + break; + case 'S': /* all servers */ + completion_list_add_servers (completion); + break; + case 't': /* topic */ + completion_list_add_topic (completion); + break; + case 'v': /* value of config option */ + completion_list_add_option_value (completion); + break; + case 'w': /* WeeChat commands */ + completion_list_add_weechat_cmd (completion); + break; + case 'y': /* away message */ + completion_list_add_away (completion); break; } } - if (pos) - pos[0] = ' '; - } + break; + default: + word[word_offset++] = pos[0]; } + /* end of argument in template? */ + if (!pos[0] || (pos[0] == ' ')) + pos = NULL; else - completion_stop (completion); - return; - } - if ((ascii_strcasecmp (completion->base_command, "unalias") == 0) - && (completion->base_command_arg == 1)) - { - for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - ptr_alias->alias_name); - } - return; - } - if (ascii_strcasecmp (completion->base_command, "window") == 0) - { - if (completion->base_command_arg == 1) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - "list"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "splith"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "splitv"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "resize"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "merge"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "up"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "down"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "left"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "right"); - return; - } - - if (completion->base_command_arg == 2) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - "down"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "up"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "left"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "right"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "all"); - return; - } - - completion_stop (completion); - return; + pos++; } + free (word); +} + +/* + * completion_build_list: build data list according to command and argument # + */ + +void +completion_build_list (t_completion *completion) +{ + char *template, *pos_space; + int max_arg, i; - /* IRC commands */ - - /* no completion for some commands */ - if ((ascii_strcasecmp (completion->base_command, "admin") == 0) - || (ascii_strcasecmp (completion->base_command, "die") == 0) - || (ascii_strcasecmp (completion->base_command, "info") == 0) - || (ascii_strcasecmp (completion->base_command, "join") == 0) - || (ascii_strcasecmp (completion->base_command, "links") == 0) - || (ascii_strcasecmp (completion->base_command, "list") == 0) - || (ascii_strcasecmp (completion->base_command, "lusers") == 0) - || (ascii_strcasecmp (completion->base_command, "motd") == 0) - || (ascii_strcasecmp (completion->base_command, "oper") == 0) - || (ascii_strcasecmp (completion->base_command, "rehash") == 0) - || (ascii_strcasecmp (completion->base_command, "restart") == 0) - || (ascii_strcasecmp (completion->base_command, "service") == 0) - || (ascii_strcasecmp (completion->base_command, "servlist") == 0) - || (ascii_strcasecmp (completion->base_command, "squery") == 0) - || (ascii_strcasecmp (completion->base_command, "squit") == 0) - || (ascii_strcasecmp (completion->base_command, "stats") == 0) - || (ascii_strcasecmp (completion->base_command, "summon") == 0) - || (ascii_strcasecmp (completion->base_command, "time") == 0) - || (ascii_strcasecmp (completion->base_command, "trace") == 0) - || (ascii_strcasecmp (completion->base_command, "users") == 0) - || (ascii_strcasecmp (completion->base_command, "wallops") == 0) - || (ascii_strcasecmp (completion->base_command, "who") == 0)) + completion_get_command_infos (completion, &template, &max_arg); + if (!template || (completion->base_command_arg > max_arg)) { completion_stop (completion); return; } - if ((ascii_strcasecmp (completion->base_command, "away") == 0) - && (completion->base_command_arg == 1)) - { - if (cfg_irc_default_msg_away && cfg_irc_default_msg_away[0]) - weelist_add (&completion->completion_list, - &completion->last_completion, - cfg_irc_default_msg_away); - return; - } - if ((ascii_strcasecmp (completion->base_command, "ctcp") == 0) - && (completion->base_command_arg == 2)) + i = 1; + while (template && template[0]) { - weelist_add (&completion->completion_list, - &completion->last_completion, - "action"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "ping"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "version"); - return; - } - if ((ascii_strcasecmp (completion->base_command, "dcc") == 0) - && (completion->base_command_arg == 1)) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - "chat"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "send"); - weelist_add (&completion->completion_list, - &completion->last_completion, - "close"); - return; - } - if (ascii_strcasecmp (completion->base_command, "invite") == 0) - { - /* arg1: nickname */ - if (completion->base_command_arg == 1) - return; - - /* arg > 2: not allowed */ - if (completion->base_command_arg > 2) + pos_space = strchr (template, ' '); + if (i == completion->base_command_arg) { - completion_stop (completion); + completion_build_list_template (completion, template); return; } - - /* arg2: channel */ - if (SERVER(gui_current_window->buffer)) + if (pos_space) { - for (ptr_channel = SERVER(gui_current_window->buffer)->channels; - ptr_channel; ptr_channel = ptr_channel->next_channel) - { - weelist_add (&completion->completion_list, - &completion->last_completion, - ptr_channel->name); - } - } - return; - } - if (ascii_strcasecmp (completion->base_command, "kick") == 0) - { - if (completion->base_command_arg != 1) - completion_stop (completion); - return; - } - if (ascii_strcasecmp (completion->base_command, "kill") == 0) - { - if (completion->base_command_arg != 1) - completion_stop (completion); - return; - } - if (ascii_strcasecmp (completion->base_command, "me") == 0) - { - completion->context = COMPLETION_NICK; - return; - } - if (ascii_strcasecmp (completion->base_command, "notice") == 0) - { - if (completion->base_command_arg != 1) - completion_stop (completion); - return; - } - if ((ascii_strcasecmp (completion->base_command, "part") == 0) - && (completion->base_command_arg == 1)) - { - if (cfg_irc_default_msg_part && cfg_irc_default_msg_part[0]) - weelist_add (&completion->completion_list, - &completion->last_completion, - cfg_irc_default_msg_part); - return; - } - if (ascii_strcasecmp (completion->base_command, "query") == 0) - { - if (completion->base_command_arg != 1) - completion_stop (completion); - return; - } - if ((ascii_strcasecmp (completion->base_command, "quit") == 0) - && (completion->base_command_arg == 1)) - { - if (cfg_irc_default_msg_quit && cfg_irc_default_msg_quit[0]) - weelist_add (&completion->completion_list, - &completion->last_completion, - cfg_irc_default_msg_quit); - return; - } - if (ascii_strcasecmp (completion->base_command, "topic") == 0) - { - if (completion->base_command_arg == 1) - { - if (!channel || !((t_irc_channel *)channel)->topic - || !((t_irc_channel *)channel)->topic[0]) - completion_stop (completion); - else - { - if (cfg_irc_colors_send) - string = (char *)gui_color_decode_for_user_entry ((unsigned char *)((t_irc_channel *)channel)->topic); - else - string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)channel)->topic, 0); - string2 = channel_iconv_decode ((t_irc_server *)server, - (t_irc_channel *)channel, - (string) ? string : ((t_irc_channel *)channel)->topic); - weelist_add (&completion->completion_list, - &completion->last_completion, - (string2) ? string2 : ((t_irc_channel *)channel)->topic); - if (string) - free (string); - if (string2) - free (string2); - } + template = pos_space; + while (template[0] == ' ') + template++; } else - completion_stop (completion); - return; + template = NULL; + i++; } } @@ -783,8 +738,7 @@ completion_build_list (t_completion *completion, void *server, void *channel) */ void -completion_find_context (t_completion *completion, void *server, void *channel, - char *buffer, int size, int pos) +completion_find_context (t_completion *completion, char *buffer, int size, int pos) { int i, command, command_arg, pos_start, pos_end; @@ -821,7 +775,7 @@ completion_find_context (t_completion *completion, void *server, void *channel, } else { - if (channel) + if (completion->channel) completion->context = COMPLETION_NICK; else completion->context = COMPLETION_NULL; @@ -894,7 +848,7 @@ completion_find_context (t_completion *completion, void *server, void *channel, for (i = pos_start; i <= pos_end; i++) completion->base_command[i - pos_start] = buffer[i]; completion->base_command[pos_end - pos_start + 1] = '\0'; - completion_build_list (completion, server, channel); + completion_build_list (completion); } } @@ -907,18 +861,18 @@ completion_find_context (t_completion *completion, void *server, void *channel, return; } - if (!completion->completion_list && channel && - (((t_irc_channel *)channel)->type == CHANNEL_TYPE_PRIVATE) + if (!completion->completion_list && completion->channel && + (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE) && (completion->context == COMPLETION_NICK)) { /* nick completion in private (only other nick and self) */ completion->context = COMPLETION_NICK; weelist_add (&completion->completion_list, &completion->last_completion, - ((t_irc_channel *)channel)->name); + ((t_irc_channel *)(completion->channel))->name); weelist_add (&completion->completion_list, &completion->last_completion, - SERVER(gui_current_window->buffer)->nick); + ((t_irc_server *)(completion->server))->nick); } } @@ -1043,8 +997,7 @@ completion_nickncmp (char *base_word, char *nick, int max) */ void -completion_command_arg (t_completion *completion, t_irc_channel *channel, - int nick_completion) +completion_command_arg (t_completion *completion, int nick_completion) { int length, word_found_seen, other_completion; t_weelist *ptr_weelist, *ptr_weelist2; @@ -1086,7 +1039,7 @@ completion_command_arg (t_completion *completion, t_irc_channel *channel, if (completion->word_found) { completion->word_found = NULL; - completion_command_arg (completion, channel, nick_completion); + completion_command_arg (completion, nick_completion); } } @@ -1095,24 +1048,25 @@ completion_command_arg (t_completion *completion, t_irc_channel *channel, */ void -completion_nick (t_completion *completion, t_irc_channel *channel) +completion_nick (t_completion *completion) { int length, word_found_seen, other_completion; t_irc_nick *ptr_nick, *ptr_nick2; - if (!channel) + if (!completion->channel) return; - if (((t_irc_channel *)channel)->type == CHANNEL_TYPE_PRIVATE) + if (((t_irc_channel *)(completion->channel))->type == CHANNEL_TYPE_PRIVATE) { - completion_command_arg (completion, channel, 1); + completion_command_arg (completion, 1); return; } length = strlen (completion->base_word); word_found_seen = 0; other_completion = 0; - for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) + for (ptr_nick = ((t_irc_channel *)(completion->channel))->nicks; + ptr_nick; ptr_nick = ptr_nick->next_nick) { if (completion_nickncmp (completion->base_word, ptr_nick->nick, length) == 0) { @@ -1143,7 +1097,7 @@ completion_nick (t_completion *completion, t_irc_channel *channel) if (completion->word_found) { completion->word_found = NULL; - completion_nick (completion, channel); + completion_nick (completion); } } @@ -1152,8 +1106,7 @@ completion_nick (t_completion *completion, t_irc_channel *channel) */ void -completion_search (t_completion *completion, void *server, void *channel, - char *buffer, int size, int pos) +completion_search (t_completion *completion, char *buffer, int size, int pos) { char *old_word_found; @@ -1161,7 +1114,7 @@ completion_search (t_completion *completion, void *server, void *channel, if (pos != completion->position) { completion->word_found = NULL; - completion_find_context (completion, server, channel, buffer, size, pos); + completion_find_context (completion, buffer, size, pos); } /* completion */ @@ -1172,8 +1125,8 @@ completion_search (t_completion *completion, void *server, void *channel, /* should never be executed */ return; case COMPLETION_NICK: - if (channel) - completion_nick (completion, (t_irc_channel *)channel); + if (completion->channel) + completion_nick (completion); else return; break; @@ -1182,9 +1135,9 @@ completion_search (t_completion *completion, void *server, void *channel, break; case COMPLETION_COMMAND_ARG: if (completion->completion_list) - completion_command_arg (completion, (t_irc_channel *)channel, 0); + completion_command_arg (completion, 0); else - completion_nick (completion, (t_irc_channel *)channel); + completion_nick (completion); break; } if (completion->word_found) diff --git a/src/common/completion.h b/src/common/completion.h index 56464a3f7..32850dc2a 100644 --- a/src/common/completion.h +++ b/src/common/completion.h @@ -33,27 +33,29 @@ typedef struct t_completion t_completion; struct t_completion { /* completion context */ - int context; /* context: null, nick, command, cmd arg */ - char *base_command; /* command with arg to complete (can be NULL) */ - int base_command_arg; /* # arg to complete (if context is cmd arg) */ - char *base_word; /* word to complete (when Tab was pressed) */ - int base_word_pos; /* beggining of base word */ - int position; /* position where Tab was pressed */ - char *args; /* command line args (including base word) */ + void *server; /* server pointer */ + void *channel; /* channel pointer */ + int context; /* context: null, nick, command, cmd arg */ + char *base_command; /* command with arg to complete (can be NULL) */ + int base_command_arg; /* # arg to complete (if context is cmd arg) */ + char *base_word; /* word to complete (when Tab was pressed) */ + int base_word_pos; /* beggining of base word */ + int position; /* position where Tab was pressed */ + char *args; /* command line args (including base word) */ /* for command argument completion */ - t_weelist *completion_list; /* data list for completion */ - t_weelist *last_completion; /* last data element for completion */ + t_weelist *completion_list; /* data list for completion */ + t_weelist *last_completion; /* last data element for completion */ /* completion found */ - char *word_found; /* word found (to replace base word) */ - int position_replace; /* position where word has to be replaced */ - int diff_size; /* size difference (< 0 = char(s) deleted) */ - int diff_length; /* length difference (<= diff_size) */ + char *word_found; /* word found (to replace base word) */ + int position_replace; /* position where word has to be replaced */ + int diff_size; /* size difference (< 0 = char(s) deleted) */ + int diff_length; /* length difference (<= diff_size) */ }; -extern void completion_init (t_completion *); +extern void completion_init (t_completion *, void *, void *); extern void completion_free (t_completion *); -extern void completion_search (t_completion *, void *, void *, char *, int, int); +extern void completion_search (t_completion *, char *, int, int); #endif /* completion.h */ diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index e68e883f1..f84af7ced 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -126,8 +126,6 @@ gui_action_tab (t_gui_window *window) if (window->buffer->has_input) { completion_search (&(window->buffer->completion), - SERVER(window->buffer), - CHANNEL(window->buffer), window->buffer->input_buffer, window->buffer->input_buffer_size, utf8_real_pos (window->buffer->input_buffer, diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 53bca6cc8..5f67d2ce7 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -474,7 +474,7 @@ gui_buffer_new (t_gui_window *window, void *server, void *channel, int dcc, new_buffer->input_buffer_1st_display = 0; /* init completion */ - completion_init (&(new_buffer->completion)); + completion_init (&(new_buffer->completion), server, channel); /* init history */ new_buffer->history = NULL; diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index c14a096c9..413197a46 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -34,462 +34,541 @@ t_irc_command irc_commands[] = { { "admin", N_("find information about the administrator of the server"), N_("[target]"), N_("target: server"), - 0, 1, 1, NULL, irc_cmd_send_admin, NULL }, + NULL, 0, 1, 1, NULL, irc_cmd_send_admin, NULL }, { "ame", N_("send a CTCP action to all channels of all connected servers"), N_("message"), N_("message: message to send"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_ame, NULL }, + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_ame, NULL }, { "amsg", N_("send message to all channels of all connected servers"), N_("text"), N_("text: text to send"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_amsg, NULL }, + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_amsg, NULL }, { "away", N_("toggle away status"), N_("[-all] [message]"), N_("-all: toggle away status on all connected servers\n" - "message: message for away (if no message is given, away status is removed)"), - 0, MAX_ARGS, 1, NULL, irc_cmd_send_away, NULL }, + "message: message for away (if no message is given, away status is removed)"), + "%y", 0, MAX_ARGS, 1, NULL, irc_cmd_send_away, NULL }, { "ban", N_("bans nicks or hosts"), N_("[channel] [nickname [nickname ...]]"), N_("channel: channel for ban\n" "nickname: user or host to ban"), - 0, MAX_ARGS, 1, NULL, irc_cmd_send_ban, NULL }, + "", 0, MAX_ARGS, 1, NULL, irc_cmd_send_ban, NULL }, { "ctcp", N_("send a CTCP message (Client-To-Client Protocol)"), N_("nickname type [arguments]"), N_("nickname: user to send CTCP to\n" "type: CTCP type (examples: \"version\", \"ping\", ..)\n" "arguments: arguments for CTCP"), - 2, MAX_ARGS, 1, NULL, irc_cmd_send_ctcp, NULL }, + "%n action|ping|version", 2, MAX_ARGS, 1, NULL, irc_cmd_send_ctcp, NULL }, { "dcc", N_("starts DCC (file or chat) or close chat"), N_("action [nickname [file]]"), N_("action: 'send' (file) or 'chat' or 'close' (chat)\n" - "nickname: nickname to send file or chat\n" - "file: filename (on local host)"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL }, + "nickname: nickname to send file or chat\n" + "file: filename (on local host)"), + "chat|send|close %n %f", 1, MAX_ARGS, 1, NULL, irc_cmd_send_dcc, NULL }, { "dehalfop", N_("removes half channel operator status from nickname(s)"), N_("[nickname [nickname]]"), "", - 0, MAX_ARGS, 1, irc_cmd_send_dehalfop, NULL, NULL }, + "", 0, MAX_ARGS, 1, irc_cmd_send_dehalfop, NULL, NULL }, { "deop", N_("removes channel operator status from nickname(s)"), N_("[nickname [nickname]]"), "", - 0, MAX_ARGS, 1, irc_cmd_send_deop, NULL, NULL }, + "", 0, MAX_ARGS, 1, irc_cmd_send_deop, NULL, NULL }, { "devoice", N_("removes voice from nickname(s)"), N_("[nickname [nickname]]"), "", - 0, MAX_ARGS, 1, irc_cmd_send_devoice, NULL, NULL }, - { "die", N_("shutdown the server"), - "", "", - 0, 0, 1, NULL, irc_cmd_send_die, NULL }, - { "error", N_("error received from IRC server"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_error }, + "", 0, MAX_ARGS, 1, irc_cmd_send_devoice, NULL, NULL }, + { "die", N_("shutdown the server"), "", "", + NULL, 0, 0, 1, NULL, irc_cmd_send_die, NULL }, + { "error", N_("error received from IRC server"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_error }, { "halfop", N_("gives half channel operator status to nickname(s)"), N_("[nickname [nickname]]"), "", - 0, MAX_ARGS, 1, irc_cmd_send_halfop, NULL, NULL }, + "", 0, MAX_ARGS, 1, irc_cmd_send_halfop, NULL, NULL }, { "info", N_("get information describing the server"), N_("[target]"), N_("target: server name"), - 0, 1, 1, NULL, irc_cmd_send_info, NULL }, + NULL, 0, 1, 1, NULL, irc_cmd_send_info, NULL }, { "invite", N_("invite a nick on a channel"), N_("nickname channel"), N_("nickname: nick to invite\n" "channel: channel to invite"), - 1, 2, 1, irc_cmd_send_invite, NULL, irc_cmd_recv_invite }, + "%n %c", 1, 2, 1, irc_cmd_send_invite, NULL, irc_cmd_recv_invite }, { "ison", N_("check if a nickname is currently on IRC"), N_("nickname [nickname ...]"), N_("nickname: nickname"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_ison, NULL }, + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_ison, NULL }, { "join", N_("join a channel"), N_("channel[,channel] [key[,key]]"), N_("channel: channel name to join\n" "key: key to join the channel"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_join, irc_cmd_recv_join }, + NULL, 1, MAX_ARGS, 1, NULL, irc_cmd_send_join, irc_cmd_recv_join }, { "kick", N_("forcibly remove a user from a channel"), N_("[channel] nickname [comment]"), N_("channel: channel where user is\n" "nickname: nickname to kick\n" "comment: comment for kick"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_kick, irc_cmd_recv_kick }, + "%n %-", 1, MAX_ARGS, 1, NULL, irc_cmd_send_kick, irc_cmd_recv_kick }, { "kickban", N_("kicks and bans a nick from a channel"), N_("[channel] nickname [comment]"), N_("channel: channel where user is\n" "nickname: nickname to kick and ban\n" "comment: comment for kick"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_kickban, NULL }, + "%n %-", 1, MAX_ARGS, 1, NULL, irc_cmd_send_kickban, NULL }, { "kill", N_("close client-server connection"), N_("nickname comment"), N_("nickname: nickname\n" "comment: comment for kill"), - 2, MAX_ARGS, 1, NULL, irc_cmd_send_kill, irc_cmd_recv_kill }, + "%n %-", 2, MAX_ARGS, 1, NULL, irc_cmd_send_kill, irc_cmd_recv_kill }, { "links", N_("list all servernames which are known by the server answering the query"), N_("[[server] server_mask]"), N_("server: this server should answer the query\n" - "server_mask: list of servers must match this mask"), - 0, 2, 1, NULL, irc_cmd_send_links, NULL }, + "server_mask: list of servers must match this mask"), + NULL, 0, 2, 1, NULL, irc_cmd_send_links, NULL }, { "list", N_("list channels and their topic"), N_("[channel[,channel] [server]]"), N_("channel: channel to list\nserver: server name"), - 0, MAX_ARGS, 1, NULL, irc_cmd_send_list, NULL }, + NULL, 0, MAX_ARGS, 1, NULL, irc_cmd_send_list, NULL }, { "lusers", N_("get statistics about the size of the IRC network"), N_("[mask [target]]"), N_("mask: servers matching the mask only\n" - "target: server for forwarding request"), - 0, 2, 1, NULL, irc_cmd_send_lusers, NULL }, + "target: server for forwarding request"), + NULL, 0, 2, 1, NULL, irc_cmd_send_lusers, NULL }, { "me", N_("send a CTCP action to the current channel"), N_("message"), N_("message: message to send"), - 0, MAX_ARGS, 1, NULL, irc_cmd_send_me, NULL }, + "", 0, MAX_ARGS, 1, NULL, irc_cmd_send_me, NULL }, { "mode", N_("change channel or user mode"), N_("{ channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask] } | " - "{ nickname {[+|-]|i|w|s|o} }"), + "{ nickname {[+|-]|i|w|s|o} }"), N_("channel modes:\n" - " channel: channel name to modify\n" - " o: give/take channel operator privileges\n" - " p: private channel flag\n" - " s: secret channel flag\n" - " i: invite-only channel flag\n" - " t: topic settable by channel operator only flag\n" - " n: no messages to channel from clients on the outside\n" - " m: moderated channel\n" - " l: set the user limit to channel\n" - " b: set a ban mask to keep users out\n" - " e: set exception mask\n" - " v: give/take the ability to speak on a moderated channel\n" - " k: set a channel key (password)\n" - "user modes:\n" - " nickname: nickname to modify\n" - " i: mark a user as invisible\n" - " s: mark a user for receive server notices\n" - " w: user receives wallops\n" - " o: operator flag"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode }, + " channel: channel name to modify\n" + " o: give/take channel operator privileges\n" + " p: private channel flag\n" + " s: secret channel flag\n" + " i: invite-only channel flag\n" + " t: topic settable by channel operator only flag\n" + " n: no messages to channel from clients on the outside\n" + " m: moderated channel\n" + " l: set the user limit to channel\n" + " b: set a ban mask to keep users out\n" + " e: set exception mask\n" + " v: give/take the ability to speak on a moderated channel\n" + " k: set a channel key (password)\n" + "user modes:\n" + " nickname: nickname to modify\n" + " i: mark a user as invisible\n" + " s: mark a user for receive server notices\n" + " w: user receives wallops\n" + " o: operator flag"), + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode }, { "motd", N_("get the \"Message Of The Day\""), N_("[target]"), N_("target: server name"), - 0, 1, 1, NULL, irc_cmd_send_motd, NULL }, + NULL, 0, 1, 1, NULL, irc_cmd_send_motd, NULL }, { "msg", N_("send message to a nick or channel"), N_("receiver[,receiver] text"), N_("receiver: nick or channel (may be mask, '*' = current channel)\n" - "text: text to send"), - 2, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL }, + "text: text to send"), + "", 2, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL }, { "names", N_("list nicknames on channels"), - N_("[channel[,channel]]"), N_("channel: channel name"), - 0, 1, 1, NULL, irc_cmd_send_names, NULL }, + N_("[channel[,channel]]"), + N_("channel: channel name"), + NULL, 0, 1, 1, NULL, irc_cmd_send_names, NULL }, { "nick", N_("change current nickname"), N_("[-all] nickname"), N_("-all: set new nickname for all connected servers\n" - "nickname: new nickname"), - 1, 2, 0, irc_cmd_send_nick, NULL, irc_cmd_recv_nick }, + "nickname: new nickname"), + NULL, 1, 2, 0, irc_cmd_send_nick, NULL, irc_cmd_recv_nick }, { "notice", N_("send notice message to user"), - N_("nickname text"), N_("nickname: user to send notice to\ntext: text to send"), - 2, MAX_ARGS, 1, NULL, irc_cmd_send_notice, irc_cmd_recv_notice }, + N_("nickname text"), + N_("nickname: user to send notice to\ntext: text to send"), + "%n %-", 2, MAX_ARGS, 1, NULL, irc_cmd_send_notice, irc_cmd_recv_notice }, { "op", N_("gives channel operator status to nickname(s)"), N_("nickname [nickname]"), "", - 1, MAX_ARGS, 1, irc_cmd_send_op, NULL, NULL }, + "", 1, MAX_ARGS, 1, irc_cmd_send_op, NULL, NULL }, { "oper", N_("get operator privileges"), N_("user password"), N_("user/password: used to get privileges on current IRC server"), - 2, 2, 1, NULL, irc_cmd_send_oper, NULL }, + NULL, 2, 2, 1, NULL, irc_cmd_send_oper, NULL }, { "part", N_("leave a channel"), N_("[channel[,channel]] [part_message]"), N_("channel: channel name to leave\n" "part_message: part message (displayed to other users)"), - 0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part }, + "%p", 0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part }, { "ping", N_("ping server"), N_("server1 [server2]"), N_("server1: server to ping\nserver2: forward ping to this server"), - 1, 2, 1, NULL, irc_cmd_send_ping, irc_cmd_recv_ping }, + NULL, 1, 2, 1, NULL, irc_cmd_send_ping, irc_cmd_recv_ping }, { "pong", N_("answer to a ping message"), N_("daemon [daemon2]"), N_("daemon: daemon who has responded to Ping message\n" "daemon2: forward message to this daemon"), - 1, 2, 1, NULL, irc_cmd_send_pong, irc_cmd_recv_pong }, - { "privmsg", N_("message received"), - "", "", - 0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg }, + NULL, 1, 2, 1, NULL, irc_cmd_send_pong, irc_cmd_recv_pong }, + { "privmsg", N_("message received"), "", "", + "", 0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg }, { "query", N_("send a private message to a nick"), N_("nickname [text]"), N_("nickname: nickname for private conversation\n" - "text: text to send"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_query, NULL }, + "text: text to send"), + "%n %-", 1, MAX_ARGS, 1, NULL, irc_cmd_send_query, NULL }, { "quit", N_("close all connections & quit"), N_("[quit_message]"), N_("quit_message: quit message (displayed to other users)"), - 0, MAX_ARGS, 0, NULL, irc_cmd_send_quit, irc_cmd_recv_quit }, + "%q", 0, MAX_ARGS, 0, NULL, irc_cmd_send_quit, irc_cmd_recv_quit }, { "quote", N_("send raw data to server without parsing"), N_("data"), N_("data: raw data to send"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_quote, NULL }, - { "rehash", N_("tell the server to reload its config file"), - "", "", - 0, 0, 1, NULL, irc_cmd_send_rehash, NULL }, - { "restart", N_("tell the server to restart itself"), - "", "", - 0, 0, 1, NULL, irc_cmd_send_restart, NULL }, + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_quote, NULL }, + { "rehash", N_("tell the server to reload its config file"), "", "", + NULL, 0, 0, 1, NULL, irc_cmd_send_rehash, NULL }, + { "restart", N_("tell the server to restart itself"), "", "", + NULL, 0, 0, 1, NULL, irc_cmd_send_restart, NULL }, { "service", N_("register a new service"), N_("nickname reserved distribution type reserved info"), N_("distribution: visibility of service\n" - "type: reserved for future usage"), - 6, 6, 1, NULL, irc_cmd_send_service, NULL }, + "type: reserved for future usage"), + NULL, 6, 6, 1, NULL, irc_cmd_send_service, NULL }, { "servlist", N_("list services currently connected to the network"), N_("[mask [type]]"), N_("mask: list only services matching this mask\n" "type: list only services of this type"), - 0, 2, 1, NULL, irc_cmd_send_servlist, NULL }, + NULL, 0, 2, 1, NULL, irc_cmd_send_servlist, NULL }, { "squery", N_("deliver a message to a service"), N_("service text"), N_("service: name of service\ntext: text to send"), - 2, 2, 1, NULL, irc_cmd_send_squery, NULL }, + NULL, 2, 2, 1, NULL, irc_cmd_send_squery, NULL }, { "squit", N_("disconnect server links"), N_("server comment"), N_("server: server name\ncomment: comment for quit"), - 2, 2, 1, NULL, irc_cmd_send_squit, NULL }, + NULL, 2, 2, 1, NULL, irc_cmd_send_squit, NULL }, { "stats", N_("query statistics about server"), N_("[query [server]]"), - N_("query: c/h/i/k/l/m/o/y/u (see RFC1459)\nserver: server name"), - 0, 2, 1, NULL, irc_cmd_send_stats, NULL }, + N_("query: c/h/i/k/l/m/o/y/u (see RFC1459)\n" + "server: server name"), + NULL, 0, 2, 1, NULL, irc_cmd_send_stats, NULL }, { "summon", N_("give users who are on a host running an IRC server a message " "asking them to please join IRC"), N_("user [target [channel]]"), N_("user: username\ntarget: server name\n" "channel: channel name"), - 1, 3, 1, NULL, irc_cmd_send_summon, NULL }, + NULL, 1, 3, 1, NULL, irc_cmd_send_summon, NULL }, { "time", N_("query local time from server"), - N_("[target]"), N_("target: query time from specified server"), - 0, 1, 1, NULL, irc_cmd_send_time, NULL }, + N_("[target]"), + N_("target: query time from specified server"), + NULL, 0, 1, 1, NULL, irc_cmd_send_time, NULL }, { "topic", N_("get/set channel topic"), N_("[channel] [topic]"), N_("channel: channel name\ntopic: new topic for channel " "(if topic is \"-delete\" then topic is deleted)"), - 0, MAX_ARGS, 1, NULL, irc_cmd_send_topic, irc_cmd_recv_topic }, + "%t", 0, MAX_ARGS, 1, NULL, irc_cmd_send_topic, irc_cmd_recv_topic }, { "trace", N_("find the route to specific server"), - N_("[target]"), N_("target: server"), - 0, 1, 1, NULL, irc_cmd_send_trace, NULL }, + N_("[target]"), + N_("target: server"), + NULL, 0, 1, 1, NULL, irc_cmd_send_trace, NULL }, { "unban", N_("unbans nicks or hosts"), N_("[channel] nickname [nickname ...]"), N_("channel: channel for unban\n" "nickname: user or host to unban"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_unban, NULL }, + "%n", 1, MAX_ARGS, 1, NULL, irc_cmd_send_unban, NULL }, { "userhost", N_("return a list of information about nicknames"), - N_("nickname [nickname ...]"), N_("nickname: nickname"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_userhost, NULL }, + N_("nickname [nickname ...]"), + N_("nickname: nickname"), + NULL, 1, MAX_ARGS, 1, NULL, irc_cmd_send_userhost, NULL }, { "users", N_("list of users logged into the server"), - N_("[target]"), N_("target: server"), - 0, 1, 1, NULL, irc_cmd_send_users, NULL }, + N_("[target]"), + N_("target: server"), + NULL, 0, 1, 1, NULL, irc_cmd_send_users, NULL }, { "version", N_("gives the version info of nick or server (current or specified)"), N_("[server | nickname]"), N_("server: server name\n" "nickname: nickname"), - 0, 1, 1, NULL, irc_cmd_send_version, NULL }, + NULL, 0, 1, 1, NULL, irc_cmd_send_version, NULL }, { "voice", N_("gives voice to nickname(s)"), N_("[nickname [nickname]]"), "", - 0, MAX_ARGS, 1, irc_cmd_send_voice, NULL, NULL }, + "", 0, MAX_ARGS, 1, irc_cmd_send_voice, NULL, NULL }, { "wallops", N_("send a message to all currently connected users who have " "set the 'w' user mode for themselves"), - N_("text"), N_("text to send"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_wallops, NULL }, + N_("text"), + N_("text to send"), + NULL, 1, MAX_ARGS, 1, NULL, irc_cmd_send_wallops, NULL }, { "who", N_("generate a query which returns a list of information"), N_("[mask [\"o\"]]"), N_("mask: only information which match this mask\n" "o: only operators are returned according to the mask supplied"), - 0, 2, 1, NULL, irc_cmd_send_who, NULL }, + "%C", 0, 2, 1, NULL, irc_cmd_send_who, NULL }, { "whois", N_("query information about user(s)"), N_("[server] nickname[,nickname]"), N_("server: server name\n" "nickname: nickname (may be a mask)"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_whois, NULL }, + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_whois, NULL }, { "whowas", N_("ask for information about a nickname which no longer exists"), N_("nickname [,nickname [,nickname ...]] [count [target]]"), N_("nickname: nickname to search\n" "count: number of replies to return (full search if negative number)\n" "target: reply should match this mask"), - 1, MAX_ARGS, 1, NULL, irc_cmd_send_whowas, NULL }, - { "001", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "002", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "003", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "004", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_004 }, - { "005", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "008", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "020", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "042", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "212", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "219", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "221", N_("user mode string"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_221 }, - { "250", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "251", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "252", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "253", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "254", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "255", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "256", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "257", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "258", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "259", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "260", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "261", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "262", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "263", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "264", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "265", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "266", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "267", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "268", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "269", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "301", N_("away message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_301 }, - { "302", N_("userhost"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_302 }, - { "303", N_("ison"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_303 }, - { "305", N_("unaway"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_305 }, - { "306", N_("now away"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_306 }, - { "307", N_("whois (registered nick)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_307 }, - { "311", N_("whois (user)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_311 }, - { "312", N_("whois (server)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_312 }, - { "313", N_("whois (operator)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_313 }, - { "314", N_("whowas"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_314 }, - { "315", N_("end of /who list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_315 }, - { "317", N_("whois (idle)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_317 }, - { "318", N_("whois (end)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_318 }, - { "319", N_("whois (channels)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_319 }, - { "320", N_("whois (identified user)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_320 }, - { "321", N_("/list start"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_321 }, - { "322", N_("channel (for /list)"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_322 }, - { "323", N_("/list end"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_323 }, - { "324", N_("channel mode"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_324 }, - { "329", "???", "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_329 }, - { "331", N_("no topic for channel"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_331 }, + "", 1, MAX_ARGS, 1, NULL, irc_cmd_send_whowas, NULL }, + { "001", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "002", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "003", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "004", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_004 }, + { "005", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "008", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "020", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "042", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "212", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "219", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "221", N_("user mode string"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_221 }, + { "250", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "251", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "252", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "253", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "254", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "255", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "256", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "257", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "258", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "259", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "260", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "261", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "262", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "263", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "264", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "265", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "266", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "267", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "268", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "269", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "301", N_("away message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_301 }, + { "302", N_("userhost"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_302 }, + { "303", N_("ison"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_303 }, + { "305", N_("unaway"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_305 }, + { "306", N_("now away"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_306 }, + { "307", N_("whois (registered nick)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_307 }, + { "311", N_("whois (user)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_311 }, + { "312", N_("whois (server)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_312 }, + { "313", N_("whois (operator)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_313 }, + { "314", N_("whowas"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_314 }, + { "315", N_("end of /who list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_315 }, + { "317", N_("whois (idle)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_317 }, + { "318", N_("whois (end)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_318 }, + { "319", N_("whois (channels)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_319 }, + { "320", N_("whois (identified user)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_320 }, + { "321", N_("/list start"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_321 }, + { "322", N_("channel (for /list)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_322 }, + { "323", N_("/list end"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_323 }, + { "324", N_("channel mode"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_324 }, + { "329", "???", "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_329 }, + { "331", N_("no topic for channel"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_331 }, { "332", N_("topic of channel"), N_("channel :topic"), N_("channel: name of channel\n" "topic: topic of the channel"), - 2, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_332 }, - { "333", N_("infos about topic (nick & date changed)"), - "", "", - 0, 0, 1, NULL, NULL, irc_cmd_recv_333 }, - { "341", N_("inviting"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_341 }, - { "344", N_("channel reop"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_344 }, - { "345", N_("end of channel reop list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_345 }, - { "348", N_("channel exception list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_348 }, - { "349", N_("end of channel exception list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_349 }, - { "351", N_("server version"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_351 }, - { "352", N_("who"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_352 }, + NULL, 2, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_332 }, + { "333", N_("infos about topic (nick & date changed)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_333 }, + { "341", N_("inviting"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_341 }, + { "344", N_("channel reop"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_344 }, + { "345", N_("end of channel reop list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_345 }, + { "348", N_("channel exception list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_348 }, + { "349", N_("end of channel exception list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_349 }, + { "351", N_("server version"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_351 }, + { "352", N_("who"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_352 }, { "353", N_("list of nicks on channel"), N_("channel :[[@|+]nick ...]"), N_("channel: name of channel\n" "nick: nick on the channel"), - 2, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_353 }, - { "364", N_("links"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "365", N_("end of /links list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "366", N_("end of /names list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_366 }, - { "367", N_("banlist"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_367 }, - { "368", N_("end of banlist"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_368 }, - { "369", N_("end of /whowas list"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "371", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "372", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "373", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "374", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "375", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "376", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "381", N_("you are now an IRC operator"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "382", N_("rehashing"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "391", N_("server local time"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "401", N_("no such nick/channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "402", N_("no such server"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "403", N_("no such channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "404", N_("cannot send to channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "405", N_("too many channels"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "406", N_("was no such nick"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "407", N_("was no such nick"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "409", N_("no origin"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "410", N_("no services"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "411", N_("no recipient"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "412", N_("no text to send"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "413", N_("no toplevel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "414", N_("wilcard in toplevel domain"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "421", N_("unknown command"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "422", N_("MOTD is missing"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "423", N_("no administrative info"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "424", N_("file error"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "431", N_("no nickname given"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "432", N_("erroneous nickname"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "433", N_("nickname already in use"), - "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_433 }, - { "436", N_("nickname collision"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "438", N_("not authorized to change nickname"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_438 }, - { "441", N_("user not in channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "442", N_("not on channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "443", N_("user already on channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "444", N_("user not logged in"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "445", N_("summon has been disabled"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "446", N_("users has been disabled"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "451", N_("you are not registered"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "461", N_("not enough parameters"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "462", N_("you may not register"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "463", N_("your host isn't among the privileged"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "464", N_("password incorrect"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "465", N_("you are banned from this server"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "467", N_("channel key already set"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "470", N_("forwarding to another channel"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "471", N_("channel is already full"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "472", N_("unknown mode char to me"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "473", N_("cannot join channel (invite only)"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "474", N_("cannot join channel (banned from channel)"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "475", N_("cannot join channel (bad channel key)"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "476", N_("bad channel mask"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "477", N_("channel doesn't support modes"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "481", N_("you're not an IRC operator"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "482", N_("you're not channel operator"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "483", N_("you can't kill a server!"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "484", N_("your connection is restricted!"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "485", N_("user is immune from kick/deop"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "491", N_("no O-lines for your host"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "501", N_("unknown mode flag"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "502", N_("can't change mode for other users"), - "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, - { "505", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, - { "671", N_("whois (secure connection)"), - "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_671 }, - { NULL, NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL } + NULL, 2, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_353 }, + { "364", N_("links"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "365", N_("end of /links list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "366", N_("end of /names list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_366 }, + { "367", N_("banlist"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_367 }, + { "368", N_("end of banlist"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_368 }, + { "369", N_("end of /whowas list"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "371", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "372", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "373", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "374", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "375", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "376", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "381", N_("you are now an IRC operator"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "382", N_("rehashing"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "391", N_("server local time"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "401", N_("no such nick/channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "402", N_("no such server"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "403", N_("no such channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "404", N_("cannot send to channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "405", N_("too many channels"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "406", N_("was no such nick"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "407", N_("was no such nick"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "409", N_("no origin"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "410", N_("no services"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "411", N_("no recipient"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "412", N_("no text to send"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "413", N_("no toplevel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "414", N_("wilcard in toplevel domain"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "421", N_("unknown command"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "422", N_("MOTD is missing"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "423", N_("no administrative info"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "424", N_("file error"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "431", N_("no nickname given"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "432", N_("erroneous nickname"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "433", N_("nickname already in use"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_433 }, + { "436", N_("nickname collision"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "438", N_("not authorized to change nickname"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_438 }, + { "441", N_("user not in channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "442", N_("not on channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "443", N_("user already on channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "444", N_("user not logged in"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "445", N_("summon has been disabled"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "446", N_("users has been disabled"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "451", N_("you are not registered"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "461", N_("not enough parameters"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "462", N_("you may not register"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "463", N_("your host isn't among the privileged"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "464", N_("password incorrect"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "465", N_("you are banned from this server"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "467", N_("channel key already set"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "470", N_("forwarding to another channel"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "471", N_("channel is already full"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "472", N_("unknown mode char to me"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "473", N_("cannot join channel (invite only)"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "474", N_("cannot join channel (banned from channel)"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "475", N_("cannot join channel (bad channel key)"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "476", N_("bad channel mask"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "477", N_("channel doesn't support modes"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "481", N_("you're not an IRC operator"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "482", N_("you're not channel operator"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "483", N_("you can't kill a server!"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "484", N_("your connection is restricted!"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "485", N_("user is immune from kick/deop"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "491", N_("no O-lines for your host"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "501", N_("unknown mode flag"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "502", N_("can't change mode for other users"), "", "", + NULL, 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, + { "505", N_("a server message"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "671", N_("whois (secure connection)"), "", "", + NULL, 0, 0, 1, NULL, NULL, irc_cmd_recv_671 }, + { NULL, NULL, NULL, NULL, NULL, 0, 0, 1, NULL, NULL, NULL } }; diff --git a/src/irc/irc.h b/src/irc/irc.h index 28a10b13f..0b736fd47 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -66,12 +66,12 @@ typedef struct t_irc_nick t_irc_nick; struct t_irc_nick { - char *nick; /* nickname */ - int flags; /* chanowner/chanadmin (unrealircd), */ - /* op, halfop, voice, away */ - int color; /* color for nickname in chat window */ - t_irc_nick *prev_nick; /* link to previous nick on the channel */ - t_irc_nick *next_nick; /* link to next nick on the channel */ + char *nick; /* nickname */ + int flags; /* chanowner/chanadmin (unrealircd), */ + /* op, halfop, voice, away */ + int color; /* color for nickname in chat window */ + t_irc_nick *prev_nick; /* link to previous nick on the channel */ + t_irc_nick *next_nick; /* link to next nick on the channel */ }; /* channel types */ @@ -100,20 +100,20 @@ typedef struct t_irc_channel t_irc_channel; struct t_irc_channel { - int type; /* channel type */ - void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */ - char *name; /* name of channel (exemple: "#abc") */ - char *topic; /* topic of channel (host for private) */ - char *modes; /* channel modes */ - int limit; /* user limit (0 is limit not set) */ - char *key; /* channel key (NULL if no key is set) */ - int nicks_count; /* # nicks on channel (0 if dcc/pv) */ - int checking_away; /* = 1 if checking away with WHO cmd */ - t_irc_nick *nicks; /* nicks on the channel */ - t_irc_nick *last_nick; /* last nick on the channel */ - t_gui_buffer *buffer; /* GUI buffer allocated for channel */ - t_irc_channel *prev_channel; /* link to previous channel */ - t_irc_channel *next_channel; /* link to next channel */ + int type; /* channel type */ + void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */ + char *name; /* name of channel (exemple: "#abc") */ + char *topic; /* topic of channel (host for private) */ + char *modes; /* channel modes */ + int limit; /* user limit (0 is limit not set) */ + char *key; /* channel key (NULL if no key is set) */ + int nicks_count; /* # nicks on channel (0 if dcc/pv) */ + int checking_away; /* = 1 if checking away with WHO cmd */ + t_irc_nick *nicks; /* nicks on the channel */ + t_irc_nick *last_nick; /* last nick on the channel */ + t_gui_buffer *buffer; /* GUI buffer allocated for channel */ + t_irc_channel *prev_channel; /* link to previous channel */ + t_irc_channel *next_channel; /* link to next channel */ }; /* server types */ @@ -123,55 +123,55 @@ typedef struct t_irc_server t_irc_server; struct t_irc_server { /* user choices */ - char *name; /* name of server (only for display) */ - int autoconnect; /* = 1 if auto connect at startup */ - int autoreconnect; /* = 1 if auto reco when disconnected */ - int autoreconnect_delay; /* delay before trying again reconnect */ - int command_line; /* server was given on command line */ - char *address; /* address of server (IP or name) */ - int port; /* port for server (6667 by default) */ - int ipv6; /* use IPv6 protocol */ - int ssl; /* SSL protocol */ - char *password; /* password for server */ - char *nick1; /* first nickname for the server */ - char *nick2; /* alternate nickname */ - char *nick3; /* 2nd alternate nickname */ - char *username; /* user name */ - char *realname; /* real name */ - char *command; /* command to run once connected */ - int command_delay; /* delay after execution of command */ - char *autojoin; /* channels to automatically join */ - int autorejoin; /* auto rejoin channels when kicked */ - char *notify_levels; /* channels notify levels */ - char *charset_decode_iso; /* channels charsets for decoding ISO */ - char *charset_decode_utf; /* channels charsets for decoding UTF */ - char *charset_encode; /* channels charsets for encoding msgs */ + char *name; /* name of server (only for display) */ + int autoconnect; /* = 1 if auto connect at startup */ + int autoreconnect; /* = 1 if auto reco when disconnected */ + int autoreconnect_delay; /* delay before trying again reconnect */ + int command_line; /* server was given on command line */ + char *address; /* address of server (IP or name) */ + int port; /* port for server (6667 by default) */ + int ipv6; /* use IPv6 protocol */ + int ssl; /* SSL protocol */ + char *password; /* password for server */ + char *nick1; /* first nickname for the server */ + char *nick2; /* alternate nickname */ + char *nick3; /* 2nd alternate nickname */ + char *username; /* user name */ + char *realname; /* real name */ + char *command; /* command to run once connected */ + int command_delay; /* delay after execution of command */ + char *autojoin; /* channels to automatically join */ + int autorejoin; /* auto rejoin channels when kicked */ + char *notify_levels; /* channels notify levels */ + char *charset_decode_iso; /* channels charsets for decoding ISO */ + char *charset_decode_utf; /* channels charsets for decoding UTF */ + char *charset_encode; /* channels charsets for encoding msgs */ /* internal vars */ - pid_t child_pid; /* pid of child process (connecting) */ - int child_read; /* to read into child pipe */ - int child_write; /* to write into child pipe */ - int sock; /* socket for server (IPv4 or IPv6) */ - int is_connected; /* 1 if WeeChat is connected to server */ - int ssl_connected; /* = 1 if connected with SSL */ + pid_t child_pid; /* pid of child process (connecting) */ + int child_read; /* to read into child pipe */ + int child_write; /* to write into child pipe */ + int sock; /* socket for server (IPv4 or IPv6) */ + int is_connected; /* 1 if WeeChat is connected to server */ + int ssl_connected; /* = 1 if connected with SSL */ #ifdef HAVE_GNUTLS - gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */ + gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */ #endif - char *unterminated_message; /* beginning of a message in input buf */ - char *nick; /* current nickname */ - time_t reconnect_start; /* this time + delay = reconnect time */ - int reconnect_join; /* 1 if channels opened to rejoin */ - int is_away; /* 1 is user is marker as away */ - time_t away_time; /* time() when user marking as away */ - int lag; /* lag (in milliseconds) */ - struct timeval lag_check_time; /* last time lag was checked (ping sent)*/ - time_t lag_next_check; /* time for next check */ - t_gui_buffer *buffer; /* GUI buffer allocated for server */ - t_gui_buffer *saved_buffer; /* channel before jumping to next server*/ - t_irc_channel *channels; /* opened channels on server */ - t_irc_channel *last_channel; /* last opened channal on server */ - t_irc_server *prev_server; /* link to previous server */ - t_irc_server *next_server; /* link to next server */ + char *unterminated_message; /* beginning of a message in input buf */ + char *nick; /* current nickname */ + time_t reconnect_start; /* this time + delay = reconnect time */ + int reconnect_join; /* 1 if channels opened to rejoin */ + int is_away; /* 1 is user is marker as away */ + time_t away_time; /* time() when user marking as away */ + int lag; /* lag (in milliseconds) */ + struct timeval lag_check_time; /* last time lag was checked (ping sent) */ + time_t lag_next_check; /* time for next check */ + t_gui_buffer *buffer; /* GUI buffer allocated for server */ + t_gui_buffer *saved_buffer; /* channel before jumping to next server */ + t_irc_channel *channels; /* opened channels on server */ + t_irc_channel *last_channel; /* last opened channal on server */ + t_irc_server *prev_server; /* link to previous server */ + t_irc_server *next_server; /* link to next server */ }; /* irc commands */ @@ -180,18 +180,20 @@ typedef struct t_irc_command t_irc_command; struct t_irc_command { - char *command_name; /* command name (internal or IRC cmd) */ - char *command_description; /* command description */ - char *arguments; /* command parameters */ - char *arguments_description; /* parameters description */ - int min_arg, max_arg; /* min & max number of parameters */ - int need_connection; /* = 1 if cmd needs server connection */ + char *command_name; /* IRC command name */ + char *command_description; /* command description (for /help) */ + char *arguments; /* command arguments (for /help) */ + char *arguments_description; /* arguments description (for /help) */ + char *completion_template; /* template for completion */ + /* NULL=no completion, ""=default (nick) */ + int min_arg, max_arg; /* min & max number of arguments */ + int need_connection; /* = 1 if cmd needs server connection */ int (*cmd_function_args)(t_irc_server *, int, char **); - /* function called when user enters cmd */ + /* function called when user enters cmd */ int (*cmd_function_1arg)(t_irc_server *, char *); - /* function called when user enters cmd */ + /* function called when user enters cmd */ int (*recv_function)(t_irc_server *, char *, char *, char *); - /* function called when cmd is received */ + /* function called when cmd is received */ }; /* irc messages */ @@ -200,24 +202,24 @@ typedef struct t_irc_message t_irc_message; struct t_irc_message { - t_irc_server *server; /* server pointer for received msg */ - char *data; /* message content */ - t_irc_message *next_message; /* link to next message */ + t_irc_server *server; /* server pointer for received msg */ + char *data; /* message content */ + t_irc_message *next_message; /* link to next message */ }; /* DCC types */ -#define DCC_CHAT_RECV 0 /* receiving DCC chat */ -#define DCC_CHAT_SEND 1 /* sending DCC chat */ -#define DCC_FILE_RECV 2 /* incoming DCC file */ -#define DCC_FILE_SEND 3 /* sending DCC file */ +#define DCC_CHAT_RECV 0 /* receiving DCC chat */ +#define DCC_CHAT_SEND 1 /* sending DCC chat */ +#define DCC_FILE_RECV 2 /* incoming DCC file */ +#define DCC_FILE_SEND 3 /* sending DCC file */ -#define DCC_WAITING 0 /* waiting for host answer */ -#define DCC_CONNECTING 1 /* connecting to host */ -#define DCC_ACTIVE 2 /* sending/receiving data */ -#define DCC_DONE 3 /* transfer done */ -#define DCC_FAILED 4 /* DCC failed */ -#define DCC_ABORTED 5 /* DCC aborted by user */ +#define DCC_WAITING 0 /* waiting for host answer */ +#define DCC_CONNECTING 1 /* connecting to host */ +#define DCC_ACTIVE 2 /* sending/receiving data */ +#define DCC_DONE 3 /* transfer done */ +#define DCC_FAILED 4 /* DCC failed */ +#define DCC_ABORTED 5 /* DCC aborted by user */ #define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) #define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) @@ -231,38 +233,38 @@ typedef struct t_irc_dcc t_irc_dcc; struct t_irc_dcc { - t_irc_server *server; /* irc server */ - t_irc_channel *channel; /* irc channel (for DCC chat only) */ - int type; /* DCC type (send or receive) */ - int status; /* DCC status (waiting, sending, ..) */ - time_t start_time; /* the time when DCC started */ - time_t start_transfer; /* the time when DCC transfer started */ - unsigned long addr; /* IP address */ - int port; /* port */ - char *nick; /* remote nick */ - int sock; /* socket for connection */ - char *unterminated_message; /* beginning of a message in input buf */ - int file; /* local file (for reading or writing) */ - char *filename; /* filename (given by sender) */ - char *local_filename; /* local filename (with path) */ - int filename_suffix; /* suffix (.1 for ex) if renaming file */ - unsigned long size; /* file size */ - unsigned long pos; /* number of bytes received/sent */ - unsigned long ack; /* number of bytes received OK */ - unsigned long start_resume; /* start of resume (in bytes) */ - time_t last_check_time; /* last time we looked at bytes sent/rcv*/ - unsigned long last_check_pos; /* bytes sent/recv at last check */ - time_t last_activity; /* time of last byte received/sent */ - unsigned long bytes_per_sec; /* bytes per second */ - unsigned long eta; /* estimated time of arrival */ - t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */ - t_irc_dcc *next_dcc; /* link to next dcc file/chat */ + t_irc_server *server; /* irc server */ + t_irc_channel *channel; /* irc channel (for DCC chat only) */ + int type; /* DCC type (send or receive) */ + int status; /* DCC status (waiting, sending, ..) */ + time_t start_time; /* the time when DCC started */ + time_t start_transfer; /* the time when DCC transfer started */ + unsigned long addr; /* IP address */ + int port; /* port */ + char *nick; /* remote nick */ + int sock; /* socket for connection */ + char *unterminated_message; /* beginning of a message in input buf */ + int file; /* local file (for reading or writing) */ + char *filename; /* filename (given by sender) */ + char *local_filename; /* local filename (with path) */ + int filename_suffix; /* suffix (.1 for ex) if renaming file */ + unsigned long size; /* file size */ + unsigned long pos; /* number of bytes received/sent */ + unsigned long ack; /* number of bytes received OK */ + unsigned long start_resume; /* start of resume (in bytes) */ + time_t last_check_time; /* last time we looked at bytes sent/recv */ + unsigned long last_check_pos; /* bytes sent/recv at last check */ + time_t last_activity; /* time of last byte received/sent */ + unsigned long bytes_per_sec; /* bytes per second */ + unsigned long eta; /* estimated time of arrival */ + t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */ + t_irc_dcc *next_dcc; /* link to next dcc file/chat */ }; /* ignore types */ -/* pre-defined ignore types, all other types are made with IRC commands */ -/* for example: part join quit notice invite ... */ +/* pre-defined ignore types, all other types are made with IRC commands */ +/* for example: part join quit notice invite ... */ #define IGNORE_ACTION "action" #define IGNORE_CTCP "ctcp" @@ -273,12 +275,12 @@ typedef struct t_irc_ignore t_irc_ignore; struct t_irc_ignore { - char *mask; /* nickname or mask */ - char *type; /* type of ignore */ - char *channel_name; /* name of channel, "*" == all */ - char *server_name; /* name of server, "*" == all */ - t_irc_ignore *prev_ignore; /* pointer to previous ignore */ - t_irc_ignore *next_ignore; /* pointer to next ignore */ + char *mask; /* nickname or mask */ + char *type; /* type of ignore */ + char *channel_name; /* name of channel, "*" == all */ + char *server_name; /* name of server, "*" == all */ + t_irc_ignore *prev_ignore; /* pointer to previous ignore */ + t_irc_ignore *next_ignore; /* pointer to next ignore */ }; /* variables */ diff --git a/src/plugins/plugins-interface.c b/src/plugins/plugins-interface.c index 615ef89d6..13aaf06a4 100644 --- a/src/plugins/plugins-interface.c +++ b/src/plugins/plugins-interface.c @@ -237,12 +237,14 @@ t_plugin_handler * weechat_plugin_cmd_handler_add (t_weechat_plugin *plugin, char *command, char *description, char *arguments, char *arguments_description, + char *completion_template, t_plugin_handler_func *handler_func, char *handler_args, void *handler_pointer) { if (plugin && command && handler_func) return plugin_cmd_handler_add (plugin, command, description, arguments, arguments_description, + completion_template, handler_func, handler_args, handler_pointer); diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 3b1d62c45..e8ce91cee 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -225,10 +225,11 @@ plugin_msg_handler_add (t_weechat_plugin *plugin, char *irc_command, * 3. command description (for /help) * 4. command arguments (for /help) * 5. command args description (for /help) - * 6. the handler function - * 7. handler args: a string given to + * 6. completion template + * 7. the handler function + * 8. handler args: a string given to * handler when called (used by scripts) - * 8. handler pointer: a pointer given to + * 9. handler pointer: a pointer given to * handler when called (used by scripts) */ @@ -236,6 +237,7 @@ t_plugin_handler * plugin_cmd_handler_add (t_weechat_plugin *plugin, char *command, char *description, char *arguments, char *arguments_description, + char *completion_template, t_plugin_handler_func *handler_func, char *handler_args, void *handler_pointer) { @@ -260,6 +262,7 @@ plugin_cmd_handler_add (t_weechat_plugin *plugin, char *command, new_handler->description = (description) ? strdup (description) : NULL; new_handler->arguments = (arguments) ? strdup (arguments) : NULL; new_handler->arguments_description = (arguments_description) ? strdup (arguments_description) : NULL; + new_handler->completion_template = (completion_template) ? strdup (completion_template) : NULL; new_handler->handler = handler_func; new_handler->handler_args = (handler_args) ? strdup (handler_args) : NULL; new_handler->handler_pointer = handler_pointer; @@ -706,35 +709,61 @@ int plugin_auto_load_file (t_weechat_plugin *plugin, char *filename) void plugin_auto_load () { - char *ptr_home, *dir_name; + char *ptr_home, *dir_name, *list_plugins, *pos, *pos2; - /* auto-load plugins in WeeChat home dir */ - if (cfg_plugins_path && cfg_plugins_path[0]) + if (cfg_plugins_autoload && cfg_plugins_autoload[0]) { - if (cfg_plugins_path[0] == '~') + if (ascii_strcasecmp (cfg_plugins_autoload, "*") == 0) { - ptr_home = getenv ("HOME"); - dir_name = (char *)malloc (strlen (cfg_plugins_path) + strlen (ptr_home) + 2); + /* auto-load plugins in WeeChat home dir */ + if (cfg_plugins_path && cfg_plugins_path[0]) + { + if (cfg_plugins_path[0] == '~') + { + ptr_home = getenv ("HOME"); + dir_name = (char *)malloc (strlen (cfg_plugins_path) + strlen (ptr_home) + 2); + if (dir_name) + { + strcpy (dir_name, ptr_home); + strcat (dir_name, cfg_plugins_path + 1); + plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file); + free (dir_name); + } + } + else + plugin_exec_on_files (NULL, cfg_plugins_path, &plugin_auto_load_file); + } + + /* auto-load plugins in WeeChat global lib dir */ + dir_name = (char *)malloc (strlen (WEECHAT_LIBDIR) + 16); if (dir_name) { - strcpy (dir_name, ptr_home); - strcat (dir_name, cfg_plugins_path + 1); + snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16, + "%s/plugins", WEECHAT_LIBDIR); plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file); free (dir_name); } } else - plugin_exec_on_files (NULL, cfg_plugins_path, &plugin_auto_load_file); - } - - /* auto-load plugins in WeeChat global lib dir */ - dir_name = (char *)malloc (strlen (WEECHAT_LIBDIR) + 16); - if (dir_name) - { - snprintf (dir_name, strlen (WEECHAT_LIBDIR) + 16, - "%s/plugins", WEECHAT_LIBDIR); - plugin_exec_on_files (NULL, dir_name, &plugin_auto_load_file); - free (dir_name); + { + list_plugins = strdup (cfg_plugins_autoload); + if (list_plugins) + { + pos = list_plugins; + while (pos && pos[0]) + { + pos2 = strchr (pos, ','); + if (pos2) + pos2[0] = '\0'; + plugin_load (pos); + if (pos2) + pos = pos2 + 1; + else + pos = NULL; + } + free (list_plugins); + } + } } } @@ -835,37 +864,12 @@ plugin_unload_all () void plugin_init (int auto_load) { - char *list_plugins, *pos, *pos2; - /* read plugins options on disk */ plugin_config_read (); /* auto-load plugins if asked */ - if (auto_load && cfg_plugins_autoload && cfg_plugins_autoload[0]) - { - if (ascii_strcasecmp (cfg_plugins_autoload, "*") == 0) - plugin_auto_load (); - else - { - list_plugins = strdup (cfg_plugins_autoload); - if (list_plugins) - { - pos = list_plugins; - while (pos && pos[0]) - { - pos2 = strchr (pos, ','); - if (pos2) - pos2[0] = '\0'; - plugin_load (pos); - if (pos2) - pos = pos2 + 1; - else - pos = NULL; - } - free (list_plugins); - } - } - } + if (auto_load) + plugin_auto_load (); } /* diff --git a/src/plugins/plugins.h b/src/plugins/plugins.h index 3c05e0f3b..85b03a8d9 100644 --- a/src/plugins/plugins.h +++ b/src/plugins/plugins.h @@ -41,6 +41,7 @@ extern t_plugin_handler *plugin_msg_handler_add (t_weechat_plugin *, char *, char *, void *); extern t_plugin_handler *plugin_cmd_handler_add (t_weechat_plugin *, char *, char *, char *, char *, + char *, t_plugin_handler_func *, char *, void *); extern int plugin_msg_handler_exec (char *, char *, char *); diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index ab4513972..877de0ef1 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -426,6 +426,7 @@ static XS (XS_weechat_add_message_handler) static XS (XS_weechat_add_command_handler) { char *command, *function, *description, *arguments, *arguments_description; + char *completion_template; unsigned int integer; dXSARGS; @@ -453,12 +454,14 @@ static XS (XS_weechat_add_command_handler) description = (items >= 3) ? SvPV (ST (2), integer) : NULL; arguments = (items >= 4) ? SvPV (ST (3), integer) : NULL; arguments_description = (items >= 5) ? SvPV (ST (4), integer) : NULL; + completion_template = (items >= 6) ? SvPV (ST (5), integer) : NULL; if (perl_plugin->cmd_handler_add (perl_plugin, command, description, arguments, arguments_description, + completion_template, weechat_perl_handler, function, (void *)perl_current_script)) @@ -1197,6 +1200,7 @@ weechat_plugin_init (t_weechat_plugin *plugin) "[load filename] | [autoload] | [reload] | [unload]", "filename: Perl script (file) to load\n\n" "Without argument, /perl command lists all loaded Perl scripts.", + "load|autoload|reload|unload", weechat_perl_cmd, NULL, NULL); plugin->mkdir_home (plugin, "perl"); diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 00728bba5..bbe74ef8e 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -333,6 +333,7 @@ static PyObject * weechat_python_add_command_handler (PyObject *self, PyObject *args) { char *command, *function, *description, *arguments, *arguments_description; + char *completion_template; /* make gcc happy */ (void) self; @@ -350,9 +351,11 @@ weechat_python_add_command_handler (PyObject *self, PyObject *args) description = NULL; arguments = NULL; arguments_description = NULL; + completion_template = NULL; - if (!PyArg_ParseTuple (args, "ss|sss", &command, &function, - &description, &arguments, &arguments_description)) + if (!PyArg_ParseTuple (args, "ss|ssss", &command, &function, + &description, &arguments, &arguments_description, + completion_template)) { python_plugin->printf_server (python_plugin, "Python error: wrong parameters for " @@ -365,6 +368,7 @@ weechat_python_add_command_handler (PyObject *self, PyObject *args) description, arguments, arguments_description, + completion_template, weechat_python_handler, function, (void *)python_current_script)) @@ -1151,6 +1155,7 @@ weechat_plugin_init (t_weechat_plugin *plugin) "[load filename] | [autoload] | [reload] | [unload]", "filename: Python script (file) to load\n\n" "Without argument, /python command lists all loaded Python scripts.", + "load|autoload|reload|unload", weechat_python_cmd, NULL, NULL); plugin->mkdir_home (plugin, "python"); diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index 389100264..294a57244 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -448,7 +448,9 @@ static VALUE weechat_ruby_add_command_handler (int argc, VALUE *argv, VALUE class) { VALUE command, function, description, arguments, arguments_description; + VALUE completion_template; char *c_command, *c_function, *c_description, *c_arguments, *c_arguments_description; + char *c_completion_template; /* make gcc happy */ (void) class; @@ -466,14 +468,16 @@ weechat_ruby_add_command_handler (int argc, VALUE *argv, VALUE class) description = Qnil; arguments = Qnil; arguments_description = Qnil; + completion_template = Qnil; c_command = NULL; c_function = NULL; c_description = NULL; c_arguments = NULL; c_arguments_description = NULL; + c_completion_template = NULL; - rb_scan_args (argc, argv, "23", &command, &function, &description, - &arguments, &arguments_description); + rb_scan_args (argc, argv, "24", &command, &function, &description, + &arguments, &arguments_description, &completion_template); if (NIL_P (command) || NIL_P (function)) { @@ -500,16 +504,24 @@ weechat_ruby_add_command_handler (int argc, VALUE *argv, VALUE class) c_arguments = STR2CSTR (arguments); } - if (!NIL_P (arguments_description)) { + if (!NIL_P (arguments_description)) + { Check_Type (arguments_description, T_STRING); c_arguments_description = STR2CSTR (arguments_description); } + if (!NIL_P (completion_template)) + { + Check_Type (completion_template, T_STRING); + c_completion_template = STR2CSTR (completion_template); + } + if (ruby_plugin->cmd_handler_add (ruby_plugin, c_command, c_description, c_arguments, c_arguments_description, + c_completion_template, weechat_ruby_handler, c_function, (void *)ruby_current_script)) @@ -1322,6 +1334,7 @@ weechat_plugin_init (t_weechat_plugin *plugin) "[load filename] | [autoload] | [reload] | [unload]", "filename: Ruby script (file) to load\n\n" "Without argument, /ruby command lists all loaded Ruby scripts.", + "load|autoload|reload|unload", weechat_ruby_cmd, NULL, NULL); plugin->mkdir_home (plugin, "ruby"); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index acce6b4fa..101c3df3f 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -86,6 +86,7 @@ struct t_plugin_handler char *description; /* (for /help) short cmd description */ char *arguments; /* (for /help) command arguments */ char *arguments_description; /* (for /help) args long description */ + char *completion_template; /* template for completion */ /* data common to all handlers */ t_plugin_handler_func *handler; /* pointer to handler */ @@ -141,6 +142,7 @@ struct t_weechat_plugin char *, void *); t_plugin_handler *(*cmd_handler_add) (t_weechat_plugin *, char *, char *, char *, char *, + char *, t_plugin_handler_func *, char *, void *); void (*handler_remove) (t_weechat_plugin *, t_plugin_handler *); @@ -178,6 +180,7 @@ extern t_plugin_handler *weechat_plugin_msg_handler_add (t_weechat_plugin *, cha char *, void *); extern t_plugin_handler *weechat_plugin_cmd_handler_add (t_weechat_plugin *, char *, char *, char *, char *, + char *, t_plugin_handler_func *, char *, void *); extern void weechat_plugin_handler_remove (t_weechat_plugin *, t_plugin_handler *); |