diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2016-03-21 18:11:21 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2016-03-21 18:11:21 +0100 |
commit | cf6aca1619c32422a43fa3d82e0674f6b7b49fe9 (patch) | |
tree | 65392ef12eab877f544fe306fe0abb98214ddebd /src/plugins/xfer | |
parent | 6d764b64c50adb19309a9de14bfeafac648ab47a (diff) | |
download | weechat-cf6aca1619c32422a43fa3d82e0674f6b7b49fe9.zip |
core: add pointer in some callbacks (closes #406)
This pointer is the first argument received by callbacks, and the
existing argument "data" is now automatically freed by WeeChat when the
object containing the callback is removed.
With this new pointer, the linked list of callbacks in scripts has been
removed. This will improve speed of scripts (using a lot of hooks),
reduce memory used by scripts and reduce time to unload scripts.
Following functions are affected in the C API:
* exec_on_files
* config_new
* config_new_section
* config_new_option
* hook_command
* hook_command_run
* hook_timer
* hook_fd
* hook_process
* hook_process_hashtable
* hook_connect
* hook_print
* hook_signal
* hook_hsignal
* hook_config
* hook_completion
* hook_modifier
* hook_info
* hook_info_hashtable
* hook_infolist
* hook_hdata
* hook_focus
* unhook_all_plugin
* buffer_new
* bar_item_new
* upgrade_new
* upgrade_read
Diffstat (limited to 'src/plugins/xfer')
-rw-r--r-- | src/plugins/xfer/xfer-buffer.c | 12 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-buffer.h | 6 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-chat.c | 20 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-chat.h | 2 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-command.c | 14 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-completion.c | 6 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-config.c | 136 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-info.c | 14 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-network.c | 35 | ||||
-rw-r--r-- | src/plugins/xfer/xfer-upgrade.c | 16 | ||||
-rw-r--r-- | src/plugins/xfer/xfer.c | 35 |
11 files changed, 196 insertions, 100 deletions
diff --git a/src/plugins/xfer/xfer-buffer.c b/src/plugins/xfer/xfer-buffer.c index c6840a44a..934797b46 100644 --- a/src/plugins/xfer/xfer-buffer.c +++ b/src/plugins/xfer/xfer-buffer.c @@ -259,12 +259,14 @@ xfer_buffer_refresh (const char *hotlist) */ int -xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer, +xfer_buffer_input_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *input_data) { struct t_xfer *xfer, *ptr_xfer, *next_xfer; /* make C compiler happy */ + (void) pointer; (void) data; xfer = xfer_search_by_number (xfer_buffer_selected_line); @@ -323,9 +325,11 @@ xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer, */ int -xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer) +xfer_buffer_close_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer) { /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; @@ -344,8 +348,8 @@ xfer_buffer_open () if (!xfer_buffer) { xfer_buffer = weechat_buffer_new (XFER_BUFFER_NAME, - &xfer_buffer_input_cb, NULL, - &xfer_buffer_close_cb, NULL); + &xfer_buffer_input_cb, NULL, NULL, + &xfer_buffer_close_cb, NULL, NULL); /* failed to create buffer ? then exit */ if (!xfer_buffer) diff --git a/src/plugins/xfer/xfer-buffer.h b/src/plugins/xfer/xfer-buffer.h index a855f0939..6d5ebb188 100644 --- a/src/plugins/xfer/xfer-buffer.h +++ b/src/plugins/xfer/xfer-buffer.h @@ -26,9 +26,11 @@ extern struct t_gui_buffer *xfer_buffer; extern int xfer_buffer_selected_line; extern void xfer_buffer_refresh (const char *hotlist); -extern int xfer_buffer_input_cb (void *data, struct t_gui_buffer *buffer, +extern int xfer_buffer_input_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *input_data); -extern int xfer_buffer_close_cb (void *data, struct t_gui_buffer *buffer); +extern int xfer_buffer_close_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer); extern void xfer_buffer_open (); #endif /* WEECHAT_XFER_BUFFER_H */ diff --git a/src/plugins/xfer/xfer-chat.c b/src/plugins/xfer/xfer-chat.c index 5ac687da0..ce620bdd9 100644 --- a/src/plugins/xfer/xfer-chat.c +++ b/src/plugins/xfer/xfer-chat.c @@ -104,7 +104,7 @@ xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...) */ int -xfer_chat_recv_cb (void *arg_xfer, int fd) +xfer_chat_recv_cb (const void *pointer, void *data, int fd) { struct t_xfer *xfer; static char buffer[4096 + 2]; @@ -115,9 +115,10 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) int num_read, length, ctcp_action; /* make C compiler happy */ + (void) data; (void) fd; - xfer = (struct t_xfer *)arg_xfer; + xfer = (struct t_xfer *)pointer; num_read = recv (xfer->sock, buffer, sizeof (buffer) - 2, 0); if (num_read > 0) @@ -259,13 +260,15 @@ xfer_chat_recv_cb (void *arg_xfer, int fd) */ int -xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer, +xfer_chat_buffer_input_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer, const char *input_data) { struct t_xfer *ptr_xfer; char *input_data_color, str_tags[256], *str_color; /* make C compiler happy */ + (void) pointer; (void) data; ptr_xfer = xfer_search_by_buffer (buffer); @@ -307,11 +310,13 @@ xfer_chat_buffer_input_cb (void *data, struct t_gui_buffer *buffer, */ int -xfer_chat_buffer_close_cb (void *data, struct t_gui_buffer *buffer) +xfer_chat_buffer_close_cb (const void *pointer, void *data, + struct t_gui_buffer *buffer) { struct t_xfer *ptr_xfer; /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; @@ -353,9 +358,10 @@ xfer_chat_open_buffer (struct t_xfer *xfer) xfer->buffer = weechat_buffer_search (XFER_PLUGIN_NAME, name); if (!xfer->buffer) { - xfer->buffer = weechat_buffer_new (name, - &xfer_chat_buffer_input_cb, NULL, - &xfer_chat_buffer_close_cb, NULL); + xfer->buffer = weechat_buffer_new ( + name, + &xfer_chat_buffer_input_cb, NULL, NULL, + &xfer_chat_buffer_close_cb, NULL, NULL); buffer_created = 1; /* failed to create buffer ? then return */ diff --git a/src/plugins/xfer/xfer-chat.h b/src/plugins/xfer/xfer-chat.h index f2ecca818..fa1018651 100644 --- a/src/plugins/xfer/xfer-chat.h +++ b/src/plugins/xfer/xfer-chat.h @@ -21,7 +21,7 @@ #define WEECHAT_XFER_CHAT_H 1 extern void xfer_chat_sendf (struct t_xfer *xfer, const char *format, ...); -extern int xfer_chat_recv_cb (void *arg_xfer, int fd); +extern int xfer_chat_recv_cb (const void *pointer, void *data, int fd); extern void xfer_chat_open_buffer (struct t_xfer *xfer); #endif /* WEECHAT_XFER_CHAT_H */ diff --git a/src/plugins/xfer/xfer-command.c b/src/plugins/xfer/xfer-command.c index 21790fa09..3c643e58c 100644 --- a/src/plugins/xfer/xfer-command.c +++ b/src/plugins/xfer/xfer-command.c @@ -35,12 +35,14 @@ */ int -xfer_command_me (void *data, struct t_gui_buffer *buffer, int argc, +xfer_command_me (const void *pointer, void *data, + struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { struct t_xfer *ptr_xfer; /* make C compiler happy */ + (void) pointer; (void) data; (void) argc; (void) argv; @@ -192,10 +194,12 @@ xfer_command_xfer_list (int full) */ int -xfer_command_xfer (void *data, struct t_gui_buffer *buffer, int argc, +xfer_command_xfer (const void *pointer, void *data, + struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; (void) argv_eol; @@ -251,7 +255,8 @@ xfer_command_init () N_("send a CTCP action to remote host"), N_("<message>"), N_("message: message to send"), - NULL, &xfer_command_me, NULL); + NULL, + &xfer_command_me, NULL, NULL); weechat_hook_command ( "xfer", N_("xfer control"), @@ -260,5 +265,6 @@ xfer_command_init () "listfull: list xfer (verbose)\n" "\n" "Without argument, this command opens buffer with xfer list."), - "list|listfull", &xfer_command_xfer, NULL); + "list|listfull", + &xfer_command_xfer, NULL, NULL); } diff --git a/src/plugins/xfer/xfer-completion.c b/src/plugins/xfer/xfer-completion.c index a65e34aeb..75004657e 100644 --- a/src/plugins/xfer/xfer-completion.c +++ b/src/plugins/xfer/xfer-completion.c @@ -33,13 +33,15 @@ */ int -xfer_completion_nick_cb (void *data, const char *completion_item, +xfer_completion_nick_cb (const void *pointer, void *data, + const char *completion_item, struct t_gui_buffer *buffer, struct t_gui_completion *completion) { struct t_xfer *ptr_xfer; /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -70,5 +72,5 @@ xfer_completion_init () { weechat_hook_completion ("nick", N_("nicks of DCC chat"), - &xfer_completion_nick_cb, NULL); + &xfer_completion_nick_cb, NULL, NULL); } diff --git a/src/plugins/xfer/xfer-config.c b/src/plugins/xfer/xfer-config.c index e6d374a30..b3971690c 100644 --- a/src/plugins/xfer/xfer-config.c +++ b/src/plugins/xfer/xfer-config.c @@ -71,9 +71,11 @@ struct t_config_option *xfer_config_file_use_nick_in_filename; */ void -xfer_config_refresh_cb (void *data, struct t_config_option *option) +xfer_config_refresh_cb (const void *pointer, void *data, + struct t_config_option *option) { /* make C compiler happy */ + (void) pointer; (void) data; (void) option; @@ -86,9 +88,11 @@ xfer_config_refresh_cb (void *data, struct t_config_option *option) */ int -xfer_config_reload (void *data, struct t_config_file *config_file) +xfer_config_reload (const void *pointer, void *data, + struct t_config_file *config_file) { /* make C compiler happy */ + (void) pointer; (void) data; return weechat_config_reload (config_file); @@ -108,15 +112,17 @@ xfer_config_init () struct t_config_section *ptr_section; xfer_config_file = weechat_config_new (XFER_CONFIG_NAME, - &xfer_config_reload, NULL); + &xfer_config_reload, NULL, NULL); if (!xfer_config_file) return 0; ptr_section = weechat_config_new_section (xfer_config_file, "look", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (xfer_config_file); @@ -128,26 +134,31 @@ xfer_config_init () "auto_open_buffer", "boolean", N_("auto open xfer buffer when a new xfer is added " "to list"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_look_progress_bar_size = weechat_config_new_option ( xfer_config_file, ptr_section, "progress_bar_size", "integer", N_("size of progress bar, in chars (if 0, progress bar is disabled)"), NULL, 0, XFER_CONFIG_PROGRESS_BAR_MAX_SIZE, "20", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_look_pv_tags = weechat_config_new_option ( xfer_config_file, ptr_section, "pv_tags", "string", N_("comma separated list of tags used in private messages, for example: " "\"notify_message\", \"notify_private\" or \"notify_highlight\""), - NULL, 0, 0, "notify_private", NULL, 0, NULL, NULL, - NULL, NULL, NULL, NULL); + NULL, 0, 0, "notify_private", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ptr_section = weechat_config_new_section (xfer_config_file, "color", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (xfer_config_file); @@ -159,61 +170,81 @@ xfer_config_init () "status_waiting", "color", N_("text color for \"waiting\" status"), NULL, 0, 0, "lightcyan", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_status[XFER_STATUS_CONNECTING] = weechat_config_new_option ( xfer_config_file, ptr_section, "status_connecting", "color", N_("text color for \"connecting\" status"), NULL, 0, 0, "yellow", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_status[XFER_STATUS_ACTIVE] = weechat_config_new_option ( xfer_config_file, ptr_section, "status_active", "color", N_("text color for \"active\" status"), NULL, 0, 0, "lightblue", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_status[XFER_STATUS_DONE] = weechat_config_new_option ( xfer_config_file, ptr_section, "status_done", "color", N_("text color for \"done\" status"), NULL, 0, 0, "lightgreen", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_status[XFER_STATUS_FAILED] = weechat_config_new_option ( xfer_config_file, ptr_section, "status_failed", "color", N_("text color for \"failed\" status"), NULL, 0, 0, "lightred", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_status[XFER_STATUS_ABORTED] = weechat_config_new_option ( xfer_config_file, ptr_section, "status_aborted", "color", N_("text color for \"aborted\" status"), NULL, 0, 0, "lightred", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_text = weechat_config_new_option ( xfer_config_file, ptr_section, "text", "color", N_("text color in xfer buffer"), NULL, 0, 0, "default", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_text_bg = weechat_config_new_option ( xfer_config_file, ptr_section, "text_bg", "color", N_("background color in xfer buffer"), NULL, 0, 0, "default", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); xfer_config_color_text_selected = weechat_config_new_option ( xfer_config_file, ptr_section, "text_selected", "color", N_("text color of selected line in xfer buffer"), NULL, 0, 0, "white", NULL, 0, - NULL, NULL, &xfer_config_refresh_cb, NULL, NULL, NULL); + NULL, NULL, NULL, + &xfer_config_refresh_cb, NULL, NULL, + NULL, NULL, NULL); ptr_section = weechat_config_new_section (xfer_config_file, "network", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (xfer_config_file); @@ -225,18 +256,20 @@ xfer_config_init () "blocksize", "integer", N_("block size for sending packets, in bytes"), NULL, XFER_BLOCKSIZE_MIN, XFER_BLOCKSIZE_MAX, "65536", NULL, 0, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_network_fast_send = weechat_config_new_option ( xfer_config_file, ptr_section, "fast_send", "boolean", N_("does not wait for ACK when sending file"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_network_own_ip = weechat_config_new_option ( xfer_config_file, ptr_section, "own_ip", "string", N_("IP or DNS address used for sending files/chats " "(if empty, local interface IP is used)"), - NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_network_port_range = weechat_config_new_option ( xfer_config_file, ptr_section, "port_range", "string", @@ -245,24 +278,29 @@ xfer_config_init () "range, ie. 5000-5015, empty value means any port, it's recommended " "to use ports greater than 1024, because only root can use ports " "below 1024)"), - NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_network_speed_limit = weechat_config_new_option ( xfer_config_file, ptr_section, "speed_limit", "integer", N_("speed limit for sending files, in kilo-bytes by second (0 means " "no limit)"), - NULL, 0, INT_MAX, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, INT_MAX, "0", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_network_timeout = weechat_config_new_option ( xfer_config_file, ptr_section, "timeout", "integer", N_("timeout for xfer request (in seconds)"), - NULL, 5, INT_MAX, "300", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 5, INT_MAX, "300", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); ptr_section = weechat_config_new_section (xfer_config_file, "file", 0, 0, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL); + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); if (!ptr_section) { weechat_config_free (xfer_config_file); @@ -273,12 +311,14 @@ xfer_config_init () xfer_config_file, ptr_section, "auto_accept_chats", "boolean", N_("automatically accept chat requests (use carefully!)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_auto_accept_files = weechat_config_new_option ( xfer_config_file, ptr_section, "auto_accept_files", "boolean", N_("automatically accept incoming files (use carefully!)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_auto_accept_nicks = weechat_config_new_option ( xfer_config_file, ptr_section, "auto_accept_nicks", "string", @@ -286,36 +326,42 @@ xfer_config_init () "chats are automatically accepted; format is \"server.nick\" (for a " "specific server) or \"nick\" (for all servers); example: " "\"freenode.FlashCode,andrew\""), - NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_auto_check_crc32 = weechat_config_new_option ( xfer_config_file, ptr_section, "auto_check_crc32", "boolean", N_("automatically check CRC32 file checksum if it is found in the " "filename (8 hexadecimal chars)"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "off", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_auto_rename = weechat_config_new_option ( xfer_config_file, ptr_section, "auto_rename", "boolean", N_("rename incoming files if already exists (add \".1\", \".2\", ...)"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_auto_resume = weechat_config_new_option ( xfer_config_file, ptr_section, "auto_resume", "boolean", N_("automatically resume file transfer if connection with remote host " "is lost"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_convert_spaces = weechat_config_new_option ( xfer_config_file, ptr_section, "convert_spaces", "boolean", N_("convert spaces to underscores when sending and receiving files"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_download_path = weechat_config_new_option ( xfer_config_file, ptr_section, "download_path", "string", N_("path for writing incoming files: \"%h\" at beginning of string is " "replaced by WeeChat home (\"~/.weechat\" by default) " "(note: content is evaluated, see /help eval)"), - NULL, 0, 0, "%h/xfer", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "%h/xfer", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_upload_path = weechat_config_new_option ( xfer_config_file, ptr_section, "upload_path", "string", @@ -323,12 +369,14 @@ xfer_config_init () "by user): \"%h\" at beginning of string is replaced by WeeChat " "home (\"~/.weechat\" by default) " "(note: content is evaluated, see /help eval)"), - NULL, 0, 0, "~", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "~", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); xfer_config_file_use_nick_in_filename = weechat_config_new_option ( xfer_config_file, ptr_section, "use_nick_in_filename", "boolean", N_("use remote nick as prefix in local filename when receiving a file"), - NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); return 1; } diff --git a/src/plugins/xfer/xfer-info.c b/src/plugins/xfer/xfer-info.c index d4a5b5c69..a3f55d84e 100644 --- a/src/plugins/xfer/xfer-info.c +++ b/src/plugins/xfer/xfer-info.c @@ -31,28 +31,30 @@ */ struct t_infolist * -xfer_info_infolist_xfer_cb (void *data, const char *infolist_name, - void *pointer, const char *arguments) +xfer_info_infolist_xfer_cb (const void *pointer, void *data, + const char *infolist_name, + void *obj_pointer, const char *arguments) { struct t_infolist *ptr_infolist; struct t_xfer *ptr_xfer; /* make C compiler happy */ + (void) pointer; (void) data; (void) infolist_name; (void) arguments; - if (pointer && !xfer_valid (pointer)) + if (obj_pointer && !xfer_valid (obj_pointer)) return NULL; ptr_infolist = weechat_infolist_new (); if (!ptr_infolist) return NULL; - if (pointer) + if (obj_pointer) { /* build list with only one xfer */ - if (!xfer_add_to_infolist (ptr_infolist, pointer)) + if (!xfer_add_to_infolist (ptr_infolist, obj_pointer)) { weechat_infolist_free (ptr_infolist); return NULL; @@ -88,5 +90,5 @@ xfer_info_init () "xfer", N_("list of xfer"), N_("xfer pointer (optional)"), NULL, - &xfer_info_infolist_xfer_cb, NULL); + &xfer_info_infolist_xfer_cb, NULL, NULL); } diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c index d536b4fb4..f52345dee 100644 --- a/src/plugins/xfer/xfer-network.c +++ b/src/plugins/xfer/xfer-network.c @@ -93,16 +93,17 @@ xfer_network_write_pipe (struct t_xfer *xfer, int status, int error) */ int -xfer_network_child_read_cb (void *arg_xfer, int fd) +xfer_network_child_read_cb (const void *pointer, void *data, int fd) { struct t_xfer *xfer; char bufpipe[1 + 1 + 32 + 1]; int num_read; /* make C compiler happy */ + (void) data; (void) fd; - xfer = (struct t_xfer *)arg_xfer; + xfer = (struct t_xfer *)pointer; num_read = read (xfer->child_read, bufpipe, sizeof (bufpipe)); if (num_read > 0) @@ -270,7 +271,7 @@ xfer_network_send_file_fork (struct t_xfer *xfer) xfer->hook_fd = weechat_hook_fd (xfer->child_read, 1, 0, 0, &xfer_network_child_read_cb, - xfer); + xfer, NULL); } /* @@ -328,7 +329,7 @@ xfer_network_recv_file_fork (struct t_xfer *xfer) xfer->hook_fd = weechat_hook_fd (xfer->child_read, 1, 0, 0, &xfer_network_child_read_cb, - xfer); + xfer, NULL); } /* @@ -364,7 +365,7 @@ xfer_network_child_kill (struct t_xfer *xfer) */ int -xfer_network_fd_cb (void *arg_xfer, int fd) +xfer_network_fd_cb (const void *pointer, void *data, int fd) { struct t_xfer *xfer; int sock, flags, error; @@ -373,11 +374,12 @@ xfer_network_fd_cb (void *arg_xfer, int fd) char str_address[NI_MAXHOST]; /* make C compiler happy */ + (void) data; (void) fd; length = sizeof (addr); memset (&addr, 0, length); - xfer = (struct t_xfer *)arg_xfer; + xfer = (struct t_xfer *)pointer; if (xfer->status == XFER_STATUS_CONNECTING) { @@ -484,7 +486,7 @@ xfer_network_fd_cb (void *arg_xfer, int fd) xfer->hook_fd = weechat_hook_fd (xfer->sock, 1, 0, 0, &xfer_chat_recv_cb, - xfer); + xfer, NULL); xfer_chat_open_buffer (xfer); } } @@ -498,14 +500,15 @@ xfer_network_fd_cb (void *arg_xfer, int fd) */ int -xfer_network_timer_cb (void *arg_xfer, int remaining_calls) +xfer_network_timer_cb (const void *pointer, void *data, int remaining_calls) { struct t_xfer *xfer; /* make C compiler happy */ + (void) data; (void) remaining_calls; - xfer = (struct t_xfer *)arg_xfer; + xfer = (struct t_xfer *)pointer; if ((xfer->status == XFER_STATUS_WAITING) || (xfer->status == XFER_STATUS_CONNECTING)) @@ -526,7 +529,8 @@ xfer_network_timer_cb (void *arg_xfer, int remaining_calls) */ int -xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc, +xfer_network_connect_chat_recv_cb (const void *pointer, void *data, + int status, int gnutls_rc, int sock, const char *error, const char *ip_address) { @@ -534,10 +538,11 @@ xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc, int flags; /* make C compiler happy */ + (void) data; (void) gnutls_rc; (void) ip_address; - xfer = (struct t_xfer*)data; + xfer = (struct t_xfer*)pointer; weechat_unhook (xfer->hook_connect); xfer->hook_connect = NULL; @@ -567,7 +572,7 @@ xfer_network_connect_chat_recv_cb (void *data, int status, int gnutls_rc, xfer->hook_fd = weechat_hook_fd (xfer->sock, 1, 0, 0, &xfer_chat_recv_cb, - xfer); + xfer, NULL); xfer_chat_open_buffer (xfer); xfer->status = XFER_STATUS_ACTIVE; @@ -691,7 +696,7 @@ xfer_network_connect (struct t_xfer *xfer) xfer->hook_fd = weechat_hook_fd (xfer->sock, 1, 0, 0, &xfer_network_fd_cb, - xfer); + xfer, NULL); /* add timeout */ if (weechat_config_integer (xfer_config_network_timeout) > 0) @@ -699,7 +704,7 @@ xfer_network_connect (struct t_xfer *xfer) xfer->hook_timer = weechat_hook_timer (weechat_config_integer (xfer_config_network_timeout) * 1000, 0, 1, &xfer_network_timer_cb, - xfer); + xfer, NULL); } } @@ -711,7 +716,7 @@ xfer_network_connect (struct t_xfer *xfer) xfer->port, 1, 0, NULL, NULL, 0, "NONE", NULL, &xfer_network_connect_chat_recv_cb, - xfer); + xfer, NULL); } /* for file receiving, connection is made in child process (blocking) */ diff --git a/src/plugins/xfer/xfer-upgrade.c b/src/plugins/xfer/xfer-upgrade.c index 65b3bbcab..8d0cb2809 100644 --- a/src/plugins/xfer/xfer-upgrade.c +++ b/src/plugins/xfer/xfer-upgrade.c @@ -58,7 +58,8 @@ xfer_upgrade_save () int rc; struct t_upgrade_file *upgrade_file; - upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 1); + upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, + NULL, NULL, NULL); if (!upgrade_file) return 0; @@ -106,17 +107,19 @@ xfer_upgrade_set_buffer_callbacks () */ int -xfer_upgrade_read_cb (void *data, +xfer_upgrade_read_cb (const void *pointer, void *data, struct t_upgrade_file *upgrade_file, int object_id, struct t_infolist *infolist) { - /* TODO: write xfer read cb */ + /* make C compiler happy */ + (void) pointer; (void) data; (void) upgrade_file; (void) object_id; (void) infolist; + /* TODO: write xfer read cb */ return WEECHAT_RC_OK; } @@ -136,10 +139,13 @@ xfer_upgrade_load () xfer_upgrade_set_buffer_callbacks (); - upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, 0); + upgrade_file = weechat_upgrade_new (XFER_UPGRADE_FILENAME, + &xfer_upgrade_read_cb, NULL, NULL); if (!upgrade_file) return 0; - rc = weechat_upgrade_read (upgrade_file, &xfer_upgrade_read_cb, NULL); + + rc = weechat_upgrade_read (upgrade_file); + weechat_upgrade_close (upgrade_file); return rc; diff --git a/src/plugins/xfer/xfer.c b/src/plugins/xfer/xfer.c index 5af0fc7cf..fb7d5ff52 100644 --- a/src/plugins/xfer/xfer.c +++ b/src/plugins/xfer/xfer.c @@ -116,10 +116,12 @@ xfer_valid (struct t_xfer *xfer) */ int -xfer_signal_upgrade_cb (void *data, const char *signal, const char *type_data, +xfer_signal_upgrade_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -997,7 +999,8 @@ xfer_resolve_addr (const char *str_address, const char *str_port, */ int -xfer_add_cb (void *data, const char *signal, const char *type_data, +xfer_add_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_infolist *infolist; @@ -1014,6 +1017,7 @@ xfer_add_cb (void *data, const char *signal, const char *type_data, struct t_xfer *ptr_xfer; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -1367,7 +1371,8 @@ error: */ int -xfer_start_resume_cb (void *data, const char *signal, const char *type_data, +xfer_start_resume_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_infolist *infolist; @@ -1377,6 +1382,7 @@ xfer_start_resume_cb (void *data, const char *signal, const char *type_data, unsigned long long start_resume; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -1451,7 +1457,8 @@ error: */ int -xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, +xfer_accept_resume_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { struct t_infolist *infolist; @@ -1461,6 +1468,7 @@ xfer_accept_resume_cb (void *data, const char *signal, const char *type_data, unsigned long long start_resume; /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -1737,10 +1745,12 @@ xfer_print_log () */ int -xfer_debug_dump_cb (void *data, const char *signal, const char *type_data, +xfer_debug_dump_cb (const void *pointer, void *data, + const char *signal, const char *type_data, void *signal_data) { /* make C compiler happy */ + (void) pointer; (void) data; (void) signal; (void) type_data; @@ -1783,11 +1793,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) xfer_command_init (); /* hook some signals */ - weechat_hook_signal ("upgrade", &xfer_signal_upgrade_cb, NULL); - weechat_hook_signal ("xfer_add", &xfer_add_cb, NULL); - weechat_hook_signal ("xfer_start_resume", &xfer_start_resume_cb, NULL); - weechat_hook_signal ("xfer_accept_resume", &xfer_accept_resume_cb, NULL); - weechat_hook_signal ("debug_dump", &xfer_debug_dump_cb, NULL); + weechat_hook_signal ("upgrade", + &xfer_signal_upgrade_cb, NULL, NULL); + weechat_hook_signal ("xfer_add", + &xfer_add_cb, NULL, NULL); + weechat_hook_signal ("xfer_start_resume", + &xfer_start_resume_cb, NULL, NULL); + weechat_hook_signal ("xfer_accept_resume", + &xfer_accept_resume_cb, NULL, NULL); + weechat_hook_signal ("debug_dump", + &xfer_debug_dump_cb, NULL, NULL); /* hook completions */ xfer_completion_init (); |