api: use pointer for infolist "hook" to return only one hook

This commit is contained in:
Sebastien Helleu 2013-07-28 12:40:08 +02:00
parent 1a7037d9cb
commit 0e4eb69d33
21 changed files with 461 additions and 388 deletions

View File

@ -46,6 +46,7 @@ Version 0.4.2 (under dev!)
"layout_window"
* core: fix line alignment when option weechat.look.buffer_time_format is set
to empty string
* api: use pointer for infolist "hook" to return only one hook
* api: add new function strlen_screen
* aspell: rename option aspell.look.color to aspell.color.misspelled, add option
aspell.color.suggestions

View File

@ -48,7 +48,7 @@
| weechat | history | Verlaufspeicher der Befehle | Buffer Pointer (falls nicht gesetzt, wird der globale Verlauf zurückgegeben) (optional) | -
| weechat | hook | Auflistung der Hooks | - | type,arguments (type ist ein command/timer/.., arguments dient dazu nur einige hooks abzufragen (darf mit einem "*" als Platzhalter beginnen oder enden), beide Optionen sind optional)
| weechat | hook | Auflistung der Hooks | hook pointer (optional) | type,arguments (type ist ein command/timer/.., arguments dient dazu nur einige hooks abzufragen (darf mit einem "*" als Platzhalter beginnen oder enden), beide Optionen sind optional)
| weechat | hotlist | Liste der Buffer in Hotlist | - | -

View File

@ -48,7 +48,7 @@
| weechat | history | history of commands | buffer pointer (if not set, return global history) (optional) | -
| weechat | hook | list of hooks | - | type,arguments (type is command/timer/.., arguments to get only some hooks (can start or end with "*" as wildcard), both are optional)
| weechat | hook | list of hooks | hook pointer (optional) | type,arguments (type is command/timer/.., arguments to get only some hooks (can start or end with "*" as wildcard), both are optional)
| weechat | hotlist | list of buffers in hotlist | - | -

View File

@ -48,7 +48,7 @@
| weechat | history | historique des commandes | pointeur vers le tampon (si non défini, retourne l'historique global) (optionnel) | -
| weechat | hook | liste des hooks | - | type,paramètres (le type est command/timer/.., paramètres pour avoir seulement quelques hooks (peut démarrer ou se terminer par "*" comme joker), les deux sont optionnels)
| weechat | hook | liste des hooks | pointeur vers le hook (optionnel) | type,paramètres (le type est command/timer/.., paramètres pour avoir seulement quelques hooks (peut démarrer ou se terminer par "*" comme joker), les deux sont optionnels)
| weechat | hotlist | liste des tampons dans la hotlist | - | -

View File

@ -48,7 +48,7 @@
| weechat | history | cronologia dei comandi | puntatore al buffer (se non impostato, restituisce la cronologia globale) (opzionale) | -
| weechat | hook | elenco di hook | - | tipo,argomenti (il tipo è comando/timer/.., gli argomenti sono necessari solo per ottenere alcuni hook, (possono iniziare o terminare con "*" come carattere jolly, entrambi sono opzionali)
| weechat | hook | elenco di hook | hook pointer (optional) | tipo,argomenti (il tipo è comando/timer/.., gli argomenti sono necessari solo per ottenere alcuni hook, (possono iniziare o terminare con "*" come carattere jolly, entrambi sono opzionali)
| weechat | hotlist | elenco dei buffer nella hotlist | - | -

View File

@ -48,7 +48,7 @@
| weechat | history | コマンドの履歴 | バッファポインタ (ワイルドカードとして "*" で始めるか終われる) (オプション) | -
| weechat | hook | フックリスト | - | type,arguments (type はコマンド/タイマー/..、arguments はいくつかのフックで必要 (ワイルドカードとして "*" で始めるか終われる)、両方ともオプション)
| weechat | hook | フックリスト | hook pointer (optional) | type,arguments (type はコマンド/タイマー/..、arguments はいくつかのフックで必要 (ワイルドカードとして "*" で始めるか終われる)、両方ともオプション)
| weechat | hotlist | ホットリストに含まれるバッファ | - | -

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7606,6 +7606,10 @@ msgstr ""
msgid "list of hooks"
msgstr "seznam napojení"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "ukazatel přezdívky (volitelné)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@ -8332,6 +8332,10 @@ msgstr ""
msgid "list of hooks"
msgstr "Auflistung der Hooks"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "Nick Pointer (optional)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7875,6 +7875,10 @@ msgstr ""
msgid "list of hooks"
msgstr "lista de enganches"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "puntero del apodo (opcional)"
# translate command,timer?
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"PO-Revision-Date: 2013-07-27 23:19+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-28 12:33+0200\n"
"Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@ -8109,6 +8109,9 @@ msgstr ""
msgid "list of hooks"
msgstr "liste des hooks"
msgid "hook pointer (optional)"
msgstr "pointeur vers le hook (optionnel)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7079,6 +7079,10 @@ msgstr ""
msgid "list of hooks"
msgstr "Aliaszok listája:\n"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "Beállítások mentése a lemezre\n"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7944,6 +7944,10 @@ msgstr ""
msgid "list of hooks"
msgstr "elenco di hook"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "puntatore al nick (opzionale)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/WeeChat>\n"
@ -7814,6 +7814,10 @@ msgstr ""
msgid "list of hooks"
msgstr "フックリスト"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "ニックネームポインタ (オプション)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7960,6 +7960,10 @@ msgstr ""
msgid "list of hooks"
msgstr "lista powiązań"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "wskaźnik nicka (opcjonalne)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:51+0200\n"
"Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7278,6 +7278,10 @@ msgstr ""
msgid "list of hooks"
msgstr ""
#, fuzzy
msgid "hook pointer (optional)"
msgstr "ponteiro do apelido (opcional)"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:52+0200\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -7107,6 +7107,10 @@ msgstr ""
msgid "list of hooks"
msgstr "Список сокращений:\n"
#, fuzzy
msgid "hook pointer (optional)"
msgstr "Сохраняю конфигурацию\n"
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.2-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-07-18 19:52+0200\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6285,6 +6285,9 @@ msgstr ""
msgid "list of hooks"
msgstr ""
msgid "hook pointer (optional)"
msgstr ""
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat 0.4.1-dev\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2013-07-27 23:18+0200\n"
"POT-Creation-Date: 2013-07-28 12:32+0200\n"
"PO-Revision-Date: 2013-02-14 18:20+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -6251,6 +6251,9 @@ msgstr ""
msgid "list of hooks"
msgstr ""
msgid "hook pointer (optional)"
msgstr ""
msgid ""
"type,arguments (type is command/timer/.., arguments to get only some hooks "
"(can start or end with \"*\" as wildcard), both are optional)"

View File

@ -3463,6 +3463,389 @@ unhook_all ()
}
}
/*
* Adds a hook in an infolist.
*
* Returns:
* 1: OK
* 0: error
*/
int
hook_add_to_infolist_pointer (struct t_infolist *infolist, struct t_hook *hook)
{
struct t_infolist_item *ptr_item;
char value[64];
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_pointer (ptr_item, "pointer", hook))
return 0;
if (!infolist_new_var_pointer (ptr_item, "plugin", hook->plugin))
return 0;
if (!infolist_new_var_string (ptr_item, "plugin_name",
(hook->plugin) ?
hook->plugin->name : NULL))
return 0;
if (!infolist_new_var_string (ptr_item, "subplugin", hook->subplugin))
return 0;
if (!infolist_new_var_string (ptr_item, "type", hook_type_string[hook->type]))
return 0;
if (!infolist_new_var_integer (ptr_item, "deleted", hook->deleted))
return 0;
if (!infolist_new_var_integer (ptr_item, "running", hook->running))
return 0;
if (!infolist_new_var_integer (ptr_item, "priority", hook->priority))
return 0;
switch (hook->type)
{
case HOOK_TYPE_COMMAND:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND(hook, command)))
return 0;
if (!infolist_new_var_string (ptr_item, "description",
HOOK_COMMAND(hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_COMMAND(hook, description)
&& HOOK_COMMAND(hook, description)[0]) ?
_(HOOK_COMMAND(hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args",
HOOK_COMMAND(hook, args)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_nls",
(HOOK_COMMAND(hook, args)
&& HOOK_COMMAND(hook, args)[0]) ?
_(HOOK_COMMAND(hook, args)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description",
HOOK_COMMAND(hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_COMMAND(hook, args_description)
&& HOOK_COMMAND(hook, args_description)[0]) ?
_(HOOK_COMMAND(hook, args_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "completion", HOOK_COMMAND(hook, completion)))
return 0;
}
break;
case HOOK_TYPE_COMMAND_RUN:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND_RUN(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND_RUN(hook, command)))
return 0;
}
break;
case HOOK_TYPE_TIMER:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_TIMER(hook, callback)))
return 0;
snprintf (value, sizeof (value), "%ld", HOOK_TIMER(hook, interval));
if (!infolist_new_var_string (ptr_item, "interval", value))
return 0;
if (!infolist_new_var_integer (ptr_item, "align_second", HOOK_TIMER(hook, align_second)))
return 0;
if (!infolist_new_var_integer (ptr_item, "remaining_calls", HOOK_TIMER(hook, remaining_calls)))
return 0;
if (!infolist_new_var_buffer (ptr_item, "last_exec",
&(HOOK_TIMER(hook, last_exec)),
sizeof (HOOK_TIMER(hook, last_exec))))
return 0;
if (!infolist_new_var_buffer (ptr_item, "next_exec",
&(HOOK_TIMER(hook, next_exec)),
sizeof (HOOK_TIMER(hook, next_exec))))
return 0;
}
break;
case HOOK_TYPE_FD:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FD(hook, callback)))
return 0;
if (!infolist_new_var_integer (ptr_item, "fd", HOOK_FD(hook, fd)))
return 0;
if (!infolist_new_var_integer (ptr_item, "flags", HOOK_FD(hook, flags)))
return 0;
if (!infolist_new_var_integer (ptr_item, "error", HOOK_FD(hook, error)))
return 0;
}
break;
case HOOK_TYPE_PROCESS:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PROCESS(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "command", HOOK_PROCESS(hook, command)))
return 0;
if (!infolist_new_var_string (ptr_item, "options", hashtable_get_string (HOOK_PROCESS(hook, options), "keys_values")))
return 0;
if (!infolist_new_var_integer (ptr_item, "timeout", HOOK_PROCESS(hook, timeout)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_read_stdout", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDOUT])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_write_stdout", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDOUT])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_read_stderr", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDERR])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_write_stderr", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDERR])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_PROCESS(hook, child_pid)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stdout", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDOUT])))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stderr", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDERR])))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_timer", HOOK_PROCESS(hook, hook_timer)))
return 0;
}
break;
case HOOK_TYPE_CONNECT:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONNECT(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "address", HOOK_CONNECT(hook, address)))
return 0;
if (!infolist_new_var_integer (ptr_item, "port", HOOK_CONNECT(hook, port)))
return 0;
if (!infolist_new_var_integer (ptr_item, "sock", HOOK_CONNECT(hook, sock)))
return 0;
if (!infolist_new_var_integer (ptr_item, "ipv6", HOOK_CONNECT(hook, ipv6)))
return 0;
if (!infolist_new_var_integer (ptr_item, "retry", HOOK_CONNECT(hook, retry)))
return 0;
#ifdef HAVE_GNUTLS
if (!infolist_new_var_pointer (ptr_item, "gnutls_sess", HOOK_CONNECT(hook, gnutls_sess)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "gnutls_cb", HOOK_CONNECT(hook, gnutls_cb)))
return 0;
if (!infolist_new_var_integer (ptr_item, "gnutls_dhkey_size", HOOK_CONNECT(hook, gnutls_dhkey_size)))
return 0;
#endif
if (!infolist_new_var_string (ptr_item, "local_hostname", HOOK_CONNECT(hook, local_hostname)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_read", HOOK_CONNECT(hook, child_read)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_write", HOOK_CONNECT(hook, child_write)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_recv", HOOK_CONNECT(hook, child_recv)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_send", HOOK_CONNECT(hook, child_send)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_CONNECT(hook, child_pid)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_child_timer", HOOK_CONNECT(hook, hook_child_timer)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_fd", HOOK_CONNECT(hook, hook_fd)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_fd", HOOK_CONNECT(hook, handshake_hook_fd)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_timer", HOOK_CONNECT(hook, handshake_hook_timer)))
return 0;
if (!infolist_new_var_integer (ptr_item, "handshake_fd_flags", HOOK_CONNECT(hook, handshake_fd_flags)))
return 0;
if (!infolist_new_var_string (ptr_item, "handshake_ip_address", HOOK_CONNECT(hook, handshake_ip_address)))
return 0;
}
break;
case HOOK_TYPE_PRINT:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PRINT(hook, callback)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "buffer", HOOK_PRINT(hook, buffer)))
return 0;
if (!infolist_new_var_integer (ptr_item, "tags_count", HOOK_PRINT(hook, tags_count)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "tags_array", HOOK_PRINT(hook, tags_array)))
return 0;
if (!infolist_new_var_string (ptr_item, "message", HOOK_PRINT(hook, message)))
return 0;
if (!infolist_new_var_integer (ptr_item, "strip_colors", HOOK_PRINT(hook, strip_colors)))
return 0;
}
break;
case HOOK_TYPE_SIGNAL:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_SIGNAL(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "signal", HOOK_SIGNAL(hook, signal)))
return 0;
}
break;
case HOOK_TYPE_HSIGNAL:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HSIGNAL(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "signal", HOOK_HSIGNAL(hook, signal)))
return 0;
}
break;
case HOOK_TYPE_CONFIG:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONFIG(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "option", HOOK_CONFIG(hook, option)))
return 0;
}
break;
case HOOK_TYPE_COMPLETION:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMPLETION(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "completion_item", HOOK_COMPLETION(hook, completion_item)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_COMPLETION(hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_COMPLETION(hook, description)
&& HOOK_COMPLETION(hook, description)[0]) ?
_(HOOK_COMPLETION(hook, description)) : ""))
return 0;
}
break;
case HOOK_TYPE_MODIFIER:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_MODIFIER(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "modifier", HOOK_MODIFIER(hook, modifier)))
return 0;
}
break;
case HOOK_TYPE_INFO:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO(hook, info_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO(hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFO(hook, description)
&& HOOK_INFO(hook, description)[0]) ?
_(HOOK_INFO(hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO(hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFO(hook, args_description)
&& HOOK_INFO(hook, args_description)[0]) ?
_(HOOK_INFO(hook, args_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_INFO_HASHTABLE:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO_HASHTABLE(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO_HASHTABLE(hook, info_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO_HASHTABLE(hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFO_HASHTABLE(hook, description)
&& HOOK_INFO_HASHTABLE(hook, description)[0]) ?
_(HOOK_INFO_HASHTABLE(hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO_HASHTABLE(hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFO_HASHTABLE(hook, args_description)
&& HOOK_INFO_HASHTABLE(hook, args_description)[0]) ?
_(HOOK_INFO_HASHTABLE(hook, args_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "output_description", HOOK_INFO_HASHTABLE(hook, output_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "output_description_nls",
(HOOK_INFO_HASHTABLE(hook, output_description)
&& HOOK_INFO_HASHTABLE(hook, output_description)[0]) ?
_(HOOK_INFO_HASHTABLE(hook, output_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_INFOLIST:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFOLIST(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "infolist_name", HOOK_INFOLIST(hook, infolist_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFOLIST(hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFOLIST(hook, description)
&& HOOK_INFOLIST(hook, description)[0]) ?
_(HOOK_INFOLIST(hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "pointer_description", HOOK_INFOLIST(hook, pointer_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "pointer_description_nls",
(HOOK_INFOLIST(hook, pointer_description)
&& HOOK_INFOLIST(hook, pointer_description)[0]) ?
_(HOOK_INFOLIST(hook, pointer_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFOLIST(hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFOLIST(hook, args_description)
&& HOOK_INFOLIST(hook, args_description)[0]) ?
_(HOOK_INFOLIST(hook, args_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_HDATA:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HDATA(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "hdata_name", HOOK_HDATA(hook, hdata_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_HDATA(hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_HDATA(hook, description)
&& HOOK_HDATA(hook, description)[0]) ?
_(HOOK_HDATA(hook, description)) : ""))
return 0;
}
break;
case HOOK_TYPE_FOCUS:
if (!hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FOCUS(hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "area", HOOK_FOCUS(hook, area)))
return 0;
}
break;
case HOOK_NUM_TYPES:
/*
* this constant is used to count types only,
* it is never used as type
*/
break;
}
return 1;
}
/*
* Adds hooks of a type in an infolist.
*
@ -3476,8 +3859,6 @@ hook_add_to_infolist_type (struct t_infolist *infolist, int type,
const char *arguments)
{
struct t_hook *ptr_hook;
struct t_infolist_item *ptr_item;
char value[64];
int match;
for (ptr_hook = weechat_hooks[type]; ptr_hook;
@ -3499,371 +3880,7 @@ hook_add_to_infolist_type (struct t_infolist *infolist, int type,
if (!match)
continue;
ptr_item = infolist_new_item (infolist);
if (!ptr_item)
return 0;
if (!infolist_new_var_pointer (ptr_item, "pointer", ptr_hook))
return 0;
if (!infolist_new_var_pointer (ptr_item, "plugin", ptr_hook->plugin))
return 0;
if (!infolist_new_var_string (ptr_item, "plugin_name",
(ptr_hook->plugin) ?
ptr_hook->plugin->name : NULL))
return 0;
if (!infolist_new_var_string (ptr_item, "subplugin", ptr_hook->subplugin))
return 0;
if (!infolist_new_var_string (ptr_item, "type", hook_type_string[ptr_hook->type]))
return 0;
if (!infolist_new_var_integer (ptr_item, "deleted", ptr_hook->deleted))
return 0;
if (!infolist_new_var_integer (ptr_item, "running", ptr_hook->running))
return 0;
if (!infolist_new_var_integer (ptr_item, "priority", ptr_hook->priority))
return 0;
switch (ptr_hook->type)
{
case HOOK_TYPE_COMMAND:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND(ptr_hook, command)))
return 0;
if (!infolist_new_var_string (ptr_item, "description",
HOOK_COMMAND(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_COMMAND(ptr_hook, description)
&& HOOK_COMMAND(ptr_hook, description)[0]) ?
_(HOOK_COMMAND(ptr_hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args",
HOOK_COMMAND(ptr_hook, args)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_nls",
(HOOK_COMMAND(ptr_hook, args)
&& HOOK_COMMAND(ptr_hook, args)[0]) ?
_(HOOK_COMMAND(ptr_hook, args)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description",
HOOK_COMMAND(ptr_hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_COMMAND(ptr_hook, args_description)
&& HOOK_COMMAND(ptr_hook, args_description)[0]) ?
_(HOOK_COMMAND(ptr_hook, args_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "completion", HOOK_COMMAND(ptr_hook, completion)))
return 0;
}
break;
case HOOK_TYPE_COMMAND_RUN:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND_RUN(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND_RUN(ptr_hook, command)))
return 0;
}
break;
case HOOK_TYPE_TIMER:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_TIMER(ptr_hook, callback)))
return 0;
snprintf (value, sizeof (value), "%ld", HOOK_TIMER(ptr_hook, interval));
if (!infolist_new_var_string (ptr_item, "interval", value))
return 0;
if (!infolist_new_var_integer (ptr_item, "align_second", HOOK_TIMER(ptr_hook, align_second)))
return 0;
if (!infolist_new_var_integer (ptr_item, "remaining_calls", HOOK_TIMER(ptr_hook, remaining_calls)))
return 0;
if (!infolist_new_var_buffer (ptr_item, "last_exec",
&(HOOK_TIMER(ptr_hook, last_exec)),
sizeof (HOOK_TIMER(ptr_hook, last_exec))))
return 0;
if (!infolist_new_var_buffer (ptr_item, "next_exec",
&(HOOK_TIMER(ptr_hook, next_exec)),
sizeof (HOOK_TIMER(ptr_hook, next_exec))))
return 0;
}
break;
case HOOK_TYPE_FD:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FD(ptr_hook, callback)))
return 0;
if (!infolist_new_var_integer (ptr_item, "fd", HOOK_FD(ptr_hook, fd)))
return 0;
if (!infolist_new_var_integer (ptr_item, "flags", HOOK_FD(ptr_hook, flags)))
return 0;
if (!infolist_new_var_integer (ptr_item, "error", HOOK_FD(ptr_hook, error)))
return 0;
}
break;
case HOOK_TYPE_PROCESS:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PROCESS(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "command", HOOK_PROCESS(ptr_hook, command)))
return 0;
if (!infolist_new_var_string (ptr_item, "options", hashtable_get_string (HOOK_PROCESS(ptr_hook, options), "keys_values")))
return 0;
if (!infolist_new_var_integer (ptr_item, "timeout", HOOK_PROCESS(ptr_hook, timeout)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_read_stdout", HOOK_PROCESS(ptr_hook, child_read[HOOK_PROCESS_STDOUT])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_write_stdout", HOOK_PROCESS(ptr_hook, child_write[HOOK_PROCESS_STDOUT])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_read_stderr", HOOK_PROCESS(ptr_hook, child_read[HOOK_PROCESS_STDERR])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_write_stderr", HOOK_PROCESS(ptr_hook, child_write[HOOK_PROCESS_STDERR])))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_PROCESS(ptr_hook, child_pid)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stdout", HOOK_PROCESS(ptr_hook, hook_fd[HOOK_PROCESS_STDOUT])))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stderr", HOOK_PROCESS(ptr_hook, hook_fd[HOOK_PROCESS_STDERR])))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_timer", HOOK_PROCESS(ptr_hook, hook_timer)))
return 0;
}
break;
case HOOK_TYPE_CONNECT:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONNECT(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "address", HOOK_CONNECT(ptr_hook, address)))
return 0;
if (!infolist_new_var_integer (ptr_item, "port", HOOK_CONNECT(ptr_hook, port)))
return 0;
if (!infolist_new_var_integer (ptr_item, "sock", HOOK_CONNECT(ptr_hook, sock)))
return 0;
if (!infolist_new_var_integer (ptr_item, "ipv6", HOOK_CONNECT(ptr_hook, ipv6)))
return 0;
if (!infolist_new_var_integer (ptr_item, "retry", HOOK_CONNECT(ptr_hook, retry)))
return 0;
#ifdef HAVE_GNUTLS
if (!infolist_new_var_pointer (ptr_item, "gnutls_sess", HOOK_CONNECT(ptr_hook, gnutls_sess)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "gnutls_cb", HOOK_CONNECT(ptr_hook, gnutls_cb)))
return 0;
if (!infolist_new_var_integer (ptr_item, "gnutls_dhkey_size", HOOK_CONNECT(ptr_hook, gnutls_dhkey_size)))
return 0;
#endif
if (!infolist_new_var_string (ptr_item, "local_hostname", HOOK_CONNECT(ptr_hook, local_hostname)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_read", HOOK_CONNECT(ptr_hook, child_read)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_write", HOOK_CONNECT(ptr_hook, child_write)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_recv", HOOK_CONNECT(ptr_hook, child_recv)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_send", HOOK_CONNECT(ptr_hook, child_send)))
return 0;
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_CONNECT(ptr_hook, child_pid)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_child_timer", HOOK_CONNECT(ptr_hook, hook_child_timer)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "hook_fd", HOOK_CONNECT(ptr_hook, hook_fd)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_fd", HOOK_CONNECT(ptr_hook, handshake_hook_fd)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_timer", HOOK_CONNECT(ptr_hook, handshake_hook_timer)))
return 0;
if (!infolist_new_var_integer (ptr_item, "handshake_fd_flags", HOOK_CONNECT(ptr_hook, handshake_fd_flags)))
return 0;
if (!infolist_new_var_string (ptr_item, "handshake_ip_address", HOOK_CONNECT(ptr_hook, handshake_ip_address)))
return 0;
}
break;
case HOOK_TYPE_PRINT:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PRINT(ptr_hook, callback)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "buffer", HOOK_PRINT(ptr_hook, buffer)))
return 0;
if (!infolist_new_var_integer (ptr_item, "tags_count", HOOK_PRINT(ptr_hook, tags_count)))
return 0;
if (!infolist_new_var_pointer (ptr_item, "tags_array", HOOK_PRINT(ptr_hook, tags_array)))
return 0;
if (!infolist_new_var_string (ptr_item, "message", HOOK_PRINT(ptr_hook, message)))
return 0;
if (!infolist_new_var_integer (ptr_item, "strip_colors", HOOK_PRINT(ptr_hook, strip_colors)))
return 0;
}
break;
case HOOK_TYPE_SIGNAL:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_SIGNAL(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "signal", HOOK_SIGNAL(ptr_hook, signal)))
return 0;
}
break;
case HOOK_TYPE_HSIGNAL:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HSIGNAL(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "signal", HOOK_HSIGNAL(ptr_hook, signal)))
return 0;
}
break;
case HOOK_TYPE_CONFIG:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONFIG(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "option", HOOK_CONFIG(ptr_hook, option)))
return 0;
}
break;
case HOOK_TYPE_COMPLETION:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMPLETION(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "completion_item", HOOK_COMPLETION(ptr_hook, completion_item)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_COMPLETION(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_COMPLETION(ptr_hook, description)
&& HOOK_COMPLETION(ptr_hook, description)[0]) ?
_(HOOK_COMPLETION(ptr_hook, description)) : ""))
return 0;
}
break;
case HOOK_TYPE_MODIFIER:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_MODIFIER(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "modifier", HOOK_MODIFIER(ptr_hook, modifier)))
return 0;
}
break;
case HOOK_TYPE_INFO:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO(ptr_hook, info_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFO(ptr_hook, description)
&& HOOK_INFO(ptr_hook, description)[0]) ?
_(HOOK_INFO(ptr_hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO(ptr_hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFO(ptr_hook, args_description)
&& HOOK_INFO(ptr_hook, args_description)[0]) ?
_(HOOK_INFO(ptr_hook, args_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_INFO_HASHTABLE:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO_HASHTABLE(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO_HASHTABLE(ptr_hook, info_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO_HASHTABLE(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFO_HASHTABLE(ptr_hook, description)
&& HOOK_INFO_HASHTABLE(ptr_hook, description)[0]) ?
_(HOOK_INFO_HASHTABLE(ptr_hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO_HASHTABLE(ptr_hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFO_HASHTABLE(ptr_hook, args_description)
&& HOOK_INFO_HASHTABLE(ptr_hook, args_description)[0]) ?
_(HOOK_INFO_HASHTABLE(ptr_hook, args_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "output_description", HOOK_INFO_HASHTABLE(ptr_hook, output_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "output_description_nls",
(HOOK_INFO_HASHTABLE(ptr_hook, output_description)
&& HOOK_INFO_HASHTABLE(ptr_hook, output_description)[0]) ?
_(HOOK_INFO_HASHTABLE(ptr_hook, output_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_INFOLIST:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFOLIST(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "infolist_name", HOOK_INFOLIST(ptr_hook, infolist_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFOLIST(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_INFOLIST(ptr_hook, description)
&& HOOK_INFOLIST(ptr_hook, description)[0]) ?
_(HOOK_INFOLIST(ptr_hook, description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "pointer_description", HOOK_INFOLIST(ptr_hook, pointer_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "pointer_description_nls",
(HOOK_INFOLIST(ptr_hook, pointer_description)
&& HOOK_INFOLIST(ptr_hook, pointer_description)[0]) ?
_(HOOK_INFOLIST(ptr_hook, pointer_description)) : ""))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFOLIST(ptr_hook, args_description)))
return 0;
if (!infolist_new_var_string (ptr_item, "args_description_nls",
(HOOK_INFOLIST(ptr_hook, args_description)
&& HOOK_INFOLIST(ptr_hook, args_description)[0]) ?
_(HOOK_INFOLIST(ptr_hook, args_description)) : ""))
return 0;
}
break;
case HOOK_TYPE_HDATA:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HDATA(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "hdata_name", HOOK_HDATA(ptr_hook, hdata_name)))
return 0;
if (!infolist_new_var_string (ptr_item, "description", HOOK_HDATA(ptr_hook, description)))
return 0;
if (!infolist_new_var_string (ptr_item, "description_nls",
(HOOK_HDATA(ptr_hook, description)
&& HOOK_HDATA(ptr_hook, description)[0]) ?
_(HOOK_HDATA(ptr_hook, description)) : ""))
return 0;
}
break;
case HOOK_TYPE_FOCUS:
if (!ptr_hook->deleted)
{
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FOCUS(ptr_hook, callback)))
return 0;
if (!infolist_new_var_string (ptr_item, "area", HOOK_FOCUS(ptr_hook, area)))
return 0;
}
break;
case HOOK_NUM_TYPES:
/*
* this constant is used to count types only,
* it is never used as type
*/
break;
}
hook_add_to_infolist_pointer (infolist, ptr_hook);
}
return 1;
@ -3880,7 +3897,8 @@ hook_add_to_infolist_type (struct t_infolist *infolist, int type,
*/
int
hook_add_to_infolist (struct t_infolist *infolist, const char *arguments)
hook_add_to_infolist (struct t_infolist *infolist, struct t_hook *pointer,
const char *arguments)
{
const char *pos_arguments;
char *type;
@ -3889,6 +3907,9 @@ hook_add_to_infolist (struct t_infolist *infolist, const char *arguments)
if (!infolist)
return 0;
if (pointer)
return hook_add_to_infolist_pointer (infolist, pointer);
type = NULL;
pos_arguments = NULL;

View File

@ -431,6 +431,7 @@ extern struct t_hook *last_weechat_hook[];
/* hook functions */
extern void hook_init ();
extern int hook_valid (struct t_hook *hook);
extern struct t_hook *hook_command (struct t_weechat_plugin *plugin,
const char *command,
const char *description,
@ -592,6 +593,7 @@ extern void unhook (struct t_hook *hook);
extern void unhook_all_plugin (struct t_weechat_plugin *plugin);
extern void unhook_all ();
extern int hook_add_to_infolist (struct t_infolist *infolist,
struct t_hook *hook,
const char *arguments);
extern void hook_print_log ();

View File

@ -665,10 +665,14 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
}
else if (string_strcasecmp (infolist_name, "hook") == 0)
{
/* invalid hook pointer ? */
if (pointer && !hook_valid (pointer))
return NULL;
ptr_infolist = infolist_new ();
if (ptr_infolist)
{
if (!hook_add_to_infolist (ptr_infolist, arguments))
if (!hook_add_to_infolist (ptr_infolist, pointer, arguments))
{
infolist_free (ptr_infolist);
return NULL;
@ -1154,7 +1158,7 @@ plugin_api_init ()
NULL,
&plugin_api_infolist_get_internal, NULL);
hook_infolist (NULL, "hook", N_("list of hooks"),
NULL,
N_("hook pointer (optional)"),
N_("type,arguments (type is command/timer/.., arguments to "
"get only some hooks (can start or end with \"*\" as "
"wildcard), both are optional)"),