diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2016-03-23 13:51:15 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2016-03-23 13:51:15 +0100 |
commit | 293f758a3aaac724eb5008d67fabf8ac124edb48 (patch) | |
tree | d38c7241bfdcb9b9e7db5b6b5e165ce7db1381c2 /doc/en | |
parent | b9d427fc1f2f89d24dd0af679b7e331670cc42cc (diff) | |
download | weechat-293f758a3aaac724eb5008d67fabf8ac124edb48.zip |
doc: add callback pointer in doc of hook functions (plugin API reference)
Diffstat (limited to 'doc/en')
-rw-r--r-- | doc/en/weechat_plugin_api.en.asciidoc | 187 |
1 files changed, 128 insertions, 59 deletions
diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc index d36b71a8e..cbac91cb2 100644 --- a/doc/en/weechat_plugin_api.en.asciidoc +++ b/doc/en/weechat_plugin_api.en.asciidoc @@ -205,7 +205,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, "message: message to display two times\n" "command: command to execute two times", NULL, - &command_double_cb, NULL); + &command_double_cb, NULL, NULL); return WEECHAT_RC_OK; } @@ -7005,7 +7005,7 @@ C example: [source,C] ---- /* hook modifier with priority = 2000 */ -weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL); +weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL, NULL); ---- Following hook types allow priority: command, command_run, signal, hsignal, @@ -7024,7 +7024,8 @@ struct t_hook *weechat_hook_command (const char *command, const char *args, const char *args_description, const char *completion, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, struct t_gui_buffer *buffer, int argc, char **argv, @@ -7044,7 +7045,10 @@ Arguments: argument, separated by "|". Many templates are possible for same command, separated by "||". * 'callback': function called when command is used, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'struct t_gui_buffer *buffer': buffer where command is executed ** 'int argc': number of arguments given for command ** 'char **argv': arguments given for command @@ -7103,7 +7107,7 @@ struct t_hook *my_command_hook = /* callback */ &my_command_cb, /* callback_data */ - NULL); + NULL, NULL); ---- For example, if command called is `/command abc def ghi`, then 'argv' and @@ -7156,7 +7160,8 @@ Prototype: [source,C] ---- struct t_hook *weechat_hook_command_run (const char *command, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, struct t_gui_buffer *buffer, const char *command), void *callback_data); @@ -7167,7 +7172,10 @@ Arguments: * 'command': command to hook (wildcard "*" is allowed) (priority allowed, see note about <<hook_priority,priority>>) * 'callback': function called when command is run, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'struct t_gui_buffer *buffer': buffer where command is executed ** 'const char *command': the command executed, with its arguments ** return value: @@ -7198,7 +7206,7 @@ my_command_run_cb (void *data, struct t_gui_buffer *buffer, struct t_hook *my_command_run_hook = weechat_hook_command_run ("/input complete*", - &my_command_run_cb, NULL); + &my_command_run_cb, NULL, NULL); ---- Script (Python): @@ -7227,7 +7235,8 @@ Prototype: struct t_hook *weechat_hook_timer (long interval, int align_second, int max_calls, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, int remaining_calls), void *callback_data); ---- @@ -7240,7 +7249,10 @@ Arguments: called each minute when second is 0 * 'max_calls': number of calls to timer (if 0, then timer has no end) * 'callback': function called when time is reached, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'int remaining_calls': remaining calls (-1 if timer has no end) ** return value: *** 'WEECHAT_RC_OK' @@ -7264,7 +7276,7 @@ my_timer_cb (void *data, int remaining_calls) /* timer called each 20 seconds */ struct t_hook *my_timer_hook = - weechat_hook_timer (20 * 1000, 0, 0, &my_timer_cb, NULL); + weechat_hook_timer (20 * 1000, 0, 0, &my_timer_cb, NULL, NULL); ---- Script (Python): @@ -7297,7 +7309,8 @@ struct t_hook *weechat_hook_fd (int fd, int flag_read, int flag_write, int flag_exception, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, int fd), void *callback_data); ---- @@ -7311,7 +7324,10 @@ Arguments: (_WeeChat ≥ 1.3_: this argument is ignored and not used any more) * 'callback': function called a selected event occurs for file (or socket), arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'int fd': file descriptor ** return value: *** 'WEECHAT_RC_OK' @@ -7336,7 +7352,7 @@ my_fd_cb (void *data, int fd) int sock = socket (AF_INET, SOCK_STREAM, 0); /* set socket options */ /* ... */ -struct t_hook *my_fd_hook = weechat_hook_fd (sock, 1, 0, 0, &my_fd_cb, NULL); +struct t_hook *my_fd_hook = weechat_hook_fd (sock, 1, 0, 0, &my_fd_cb, NULL, NULL); ---- Script (Python): @@ -7374,7 +7390,8 @@ Prototype: ---- struct t_hook *weechat_hook_process (const char *command, int timeout, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, const char *command, int return_code, const char *out, @@ -7391,7 +7408,10 @@ Arguments: process is killed (0 means no timeout) * 'callback': function called when data from child is available, or when child has ended, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *command': command executed by child ** 'int return_code': return code: *** '>= 0': child return code for a command, and for URL possible values are: @@ -7468,7 +7488,7 @@ my_process_cb (void *data, const char *command, int return_code, } struct t_hook *my_process_hook = weechat_hook_process ("ls", 5000, - &my_process_cb, NULL); + &my_process_cb, NULL, NULL); ---- Script (Python): @@ -7508,7 +7528,8 @@ Prototype: struct t_hook *weechat_hook_process_hashtable (const char *command, struct t_hashtable *options, int timeout, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, const char *command, int return_code, const char *out, @@ -7618,7 +7639,7 @@ if (options) struct t_hook *my_process_hook = weechat_hook_process_hashtable ("url:https://weechat.org/", options, 20000, - &my_process_cb, NULL); + &my_process_cb, NULL, NULL); weechat_hashtable_free (options); } @@ -7637,7 +7658,7 @@ if (options_cmd1) struct t_hook *my_process_hook = weechat_hook_process_hashtable ("my-notify-command", options_cmd1, 20000, - &my_process_cb, NULL); + &my_process_cb, NULL, NULL); weechat_hashtable_free (options_cmd1); } @@ -7654,7 +7675,7 @@ if (options_cmd2) struct t_hook *my_process_hook = weechat_hook_process_hashtable ("sh", options_cmd2, 20000, - &my_process_cb, NULL); + &my_process_cb, NULL, NULL); weechat_hashtable_free (options_cmd2); } ---- @@ -7717,7 +7738,8 @@ struct t_hook *weechat_hook_connect (const char *proxy, int gnutls_dhkey_size, const char *gnutls_priorities, const char *local_hostname, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, int status, int gnutls_rc, int sock, @@ -7750,7 +7772,10 @@ Arguments: * 'local_hostname': local hostname to use for connection (optional) * 'callback': function called when connection is OK or failed, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'int status': connection status: *** 'WEECHAT_HOOK_CONNECT_OK': connection OK *** 'WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND': address not found @@ -7828,7 +7853,7 @@ struct t_hook *my_connect_hook = weechat_hook_connect (NULL, 1, 0, NULL, NULL, 0, /* GnuTLS */ NULL, - &my_connect_cb, NULL); + &my_connect_cb, NULL, NULL); ---- Script (Python): @@ -7883,7 +7908,8 @@ struct t_hook *weechat_hook_print (struct t_gui_buffer *buffer, const char *tags, const char *message, int strip_colors, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, struct t_gui_buffer *buffer, time_t date, int tags_count, @@ -7910,7 +7936,10 @@ Arguments: calling callback * 'callback': function called when a message is printed, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'struct t_gui_buffer *buffer': buffer pointer ** 'time_t date': date ** 'int tags_count': number of tags for line @@ -7950,7 +7979,7 @@ my_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, /* catch all messages, on all buffers, without color */ struct t_hook *my_print_hook = - weechat_hook_print (NULL, NULL, NULL, 1, &my_print_cb, NULL); + weechat_hook_print (NULL, NULL, NULL, 1, &my_print_cb, NULL, NULL); ---- Script (Python): @@ -7979,7 +8008,8 @@ Prototype: [source,C] ---- struct t_hook *weechat_hook_signal (const char *signal, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, const char *signal, const char *type_data, void *signal_data), @@ -7993,7 +8023,10 @@ Arguments: (see table below) * 'callback': function called when signal is received, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *signal': signal received ** 'const char *type_data': type of data sent with signal: *** 'WEECHAT_HOOK_SIGNAL_STRING': string @@ -8665,7 +8698,7 @@ my_signal_cb (void *data, const char *signal, const char *type_data, /* catch signal "quit" */ struct t_hook *my_signal_hook = weechat_hook_signal ("quit", - &my_signal_cb, NULL); + &my_signal_cb, NULL, NULL); ---- Script (Python): @@ -8893,7 +8926,8 @@ Prototype: [source,C] ---- struct t_hook *weechat_hook_hsignal (const char *signal, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, const char *signal, struct t_hashtable *hashtable), void *callback_data); @@ -8906,7 +8940,10 @@ Arguments: (see table below) * 'callback': function called when signal is received, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *signal': signal received ** 'struct t_hashtable *hashtable': hashtable ** return value: @@ -8990,7 +9027,7 @@ my_hsignal_cb (void *data, const char *signal, struct t_hashtable *hashtable) } struct t_hook *my_hsignal_hook = weechat_hook_hsignal ("test", - &my_hsignal_cb, NULL); + &my_hsignal_cb, NULL, NULL); ---- Script (Python): @@ -9131,7 +9168,7 @@ test_whois_cb (void *data, const char *signal, struct t_hashtable *hashtable) return WEECHAT_RC_OK; } -weechat_hook_hsignal ("irc_redirection_test_whois", &test_whois_cb, NULL); +weechat_hook_hsignal ("irc_redirection_test_whois", &test_whois_cb, NULL, NULL); struct t_hashtable *hashtable = weechat_hashtable_new (8, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING, @@ -9248,7 +9285,8 @@ Prototype: [source,C] ---- struct t_hook *weechat_hook_config (const char *option, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, const char *option, const char *value), void *callback_data); @@ -9261,7 +9299,10 @@ Arguments: (priority allowed, see note about <<hook_priority,priority>>) * 'callback': function called when configuration option is changed, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *option': name of option ** 'const char *value': new value for option ** return value: @@ -9286,7 +9327,7 @@ my_config_cb (void *data, const char *option, const char *value) /* catch changes to option "weechat.look.item_time_format" */ struct t_hook *my_config_hook = weechat_hook_config ("weechat.look.item_time_format", - &my_config_cb, NULL); + &my_config_cb, NULL, NULL); ---- Script (Python): @@ -9315,7 +9356,8 @@ Prototype: ---- struct t_hook *weechat_hook_completion (const char *completion_item, const char *description, - int (*callback)(void *data, + int (*callback)(const void *pointer, + void *data, const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion), @@ -9330,7 +9372,10 @@ Arguments: * 'description': description of completion * 'callback': function called when completion item is used (user is completing something using this item), arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *completion_item': name of completion item ** 'struct t_gui_buffer *buffer': buffer where completion is made ** 'struct t_gui_completion *completion': structure used to add words for @@ -9377,7 +9422,7 @@ my_completion_cb (void *data, const char *completion_item, struct t_hook *my_completion_hook = weechat_hook_completion ("plugin_item", "my custom completion!", - &my_completion_cb, NULL); + &my_completion_cb, NULL, NULL); ---- Script (Python): @@ -9499,7 +9544,8 @@ Prototype: [source,C] ---- struct t_hook *weechat_hook_modifier (const char *modifier, - char *(*callback)(void *data, + char *(*callback)(const void *pointer, + void *data, const char *modifier, const char *modifier_data, const char *string), @@ -9512,7 +9558,10 @@ Arguments: (priority allowed, see note about <<hook_priority,priority>>) (see table below) * 'callback': function called when modifier is used, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *modifier': name of modifier ** 'const char *modifier_data': data for modifier ** 'const char *string': string to modify @@ -9666,7 +9715,7 @@ my_modifier_cb (void *data, const char *modifier, } struct t_hook *my_modifier_hook = weechat_hook_modifier ("weechat_print", - &my_modifier_cb, NULL); + &my_modifier_cb, NULL, NULL); ---- Script (Python): @@ -9736,7 +9785,8 @@ Prototype: struct t_hook *weechat_hook_info (const char *info_name, const char *description, const char *args_description, - const char *(*callback)(void *data, + const char *(*callback)(const void *pointer, + void *data, const char *info_name, const char *arguments), void *callback_data); @@ -9749,7 +9799,10 @@ Arguments: * 'description': description * 'args_description': description of arguments (optional, can be NULL) * 'callback': function called when info is asked, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *info_name': name of info ** 'const char *arguments': additional arguments, depending on info ** return value: value of info asked @@ -9774,7 +9827,7 @@ my_info_cb (void *data, const char *info_name, const char *arguments) struct t_hook *my_info_hook = weechat_hook_info ("my_info", "Some info", "Info about arguments", - &my_info_cb, NULL); + &my_info_cb, NULL, NULL); ---- Script (Python): @@ -9806,7 +9859,8 @@ struct t_hook *weechat_hook_info_hashtable (const char *info_name, const char *description, const char *args_description, const char *output_description, - struct t_hashtable *(*callback)(void *data, + struct t_hashtable *(*callback)(const void *pointer, + void *data, const char *info_name, struct t_hashtable *hashtable), void *callback_data); @@ -9821,7 +9875,10 @@ Arguments: * 'output_description': description of hashtable returned by callback (optional, can be NULL) * 'callback': function called when info is asked, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *info_name': name of info ** 'struct t_hashtable *hashtable': hashtable, depending on info ** return value: hashtable asked @@ -9847,7 +9904,7 @@ struct t_hook *my_info_hook = weechat_hook_info_hashtable ("my_info_hashtable", "Some info", "Info about input hashtable", "Info about output hashtable", - &my_info_hashtable_cb, NULL); + &my_info_hashtable_cb, NULL, NULL); ---- Script (Python): @@ -9880,7 +9937,8 @@ struct t_hook *weechat_hook_infolist (const char *infolist_name, const char *description, const char *pointer_description, const char *args_description, - struct t_infolist *(*callback)(void *data, + struct t_infolist *(*callback)(const void *pointer, + void *data, const char *infolist_name, void *pointer, const char *arguments), @@ -9896,7 +9954,10 @@ Arguments: * 'args_description': description of arguments (optional, can be NULL) * 'callback': function called when infolist is asked, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *infolist_name': name of infolist ** 'void *pointer': pointer to an object that infolist must return (to get only one item in infolist) @@ -9929,7 +9990,7 @@ struct t_hook *my_infolist = weechat_hook_infolist ("my_infolist", "Infolist with some data", "Info about pointer", "Info about arguments", - &my_infolist_cb, NULL); + &my_infolist_cb, NULL, NULL); ---- Script (Python): @@ -9961,7 +10022,8 @@ Prototype: ---- struct t_hook *weechat_hook_hdata (const char *hdata_name, const char *description, - struct t_hdata *(*callback)(void *data, + struct t_hdata *(*callback)(const void *pointer, + void *data, const char *hdata_name), void *callback_data); ---- @@ -9973,7 +10035,10 @@ Arguments: * 'description': description * 'callback': function called when hdata is asked, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'const char *hdata_name': name of hdata ** return value: hdata asked * 'callback_data': pointer given to callback when it is called by WeeChat @@ -10000,7 +10065,7 @@ my_hdata_cb (void *data, const char *hdata_name) /* add hdata "my_hdata" */ struct t_hook *my_hdata = weechat_hook_hdata ("my_hdata", "Hdata for my structure", - &my_hdata_cb, NULL); + &my_hdata_cb, NULL, NULL); ---- [NOTE] @@ -10016,7 +10081,8 @@ Prototype: [source,C] ---- struct t_hook *weechat_hook_focus (const char *area, - struct t_hashtable *(*callback)(void *data, + struct t_hashtable *(*callback)(const void *pointer, + void *data, struct t_hashtable *info), void *callback_data); ---- @@ -10027,7 +10093,10 @@ Arguments: (priority allowed, see note about <<hook_priority,priority>>) * 'callback': function called when focus is made, arguments and return value: -** 'void *data': pointer +** 'const void *pointer': pointer +** 'void *data': pointer; if not NULL, it must have been allocated with malloc + (or similar function) and it will be automatically freed when the hook is + deleted ** 'struct t_hashtable *info': hashtable with info on focus and strings returned by other calls to focus callbacks (with higher priority) (see table below) ** return value: either "info" pointer (hashtable completed), or pointer to a @@ -10185,7 +10254,7 @@ my_focus_nicklist_cb (void *data, struct t_hashtable *info) /* add focus on nicklist */ struct t_hook *my_focus = weechat_hook_focus ("buffer_nicklist", - &my_focus_nicklist_cb, NULL); + &my_focus_nicklist_cb, NULL, NULL); ---- Script (Python): @@ -10259,7 +10328,7 @@ C example: struct t_hook *my_command_hook = weechat_hook_command ("abcd", "description", "args", "description args", - "", &my_command_cb, NULL); + "", &my_command_cb, NULL, NULL); weechat_hook_set (my_command_hook, "subplugin", "test"); ---- |