From 00578a70e19c2b14f5cba876f11d75005b4ddd56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 12 Oct 2024 17:55:46 +0200 Subject: [PATCH] api: return the buffer input callback return code in functions command and command_options --- CHANGELOG.md | 1 + src/core/core-input.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51c04a9c0..6e84a96e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Changed +- api: return the buffer input callback return code in functions command and command_options - relay/api: allow array with multiple requests in websocket frame received from client - core, plugins: simplify help on parameters that can be repeated in commands diff --git a/src/core/core-input.c b/src/core/core-input.c index 728ad430a..580c1a772 100644 --- a/src/core/core-input.c +++ b/src/core/core-input.c @@ -44,17 +44,20 @@ char **input_commands_allowed = NULL; /* * Sends data to buffer input callback. + * + * Returns the return code of buffer callback, or WEECHAT_RC_ERROR if the + * buffer has no input callback. */ -void +int input_exec_data (struct t_gui_buffer *buffer, const char *data) { if (buffer->input_callback) { - (void)(buffer->input_callback) (buffer->input_callback_pointer, - buffer->input_callback_data, - buffer, - data); + return (buffer->input_callback) (buffer->input_callback_pointer, + buffer->input_callback_data, + buffer, + data); } else { @@ -62,6 +65,7 @@ input_exec_data (struct t_gui_buffer *buffer, const char *data) _("%sYou cannot write text in this " "buffer"), gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + return WEECHAT_RC_ERROR; } } @@ -175,7 +179,7 @@ input_exec_command (struct t_gui_buffer *buffer, */ if (buffer->input_get_unknown_commands) { - input_exec_data (buffer, string); + rc = input_exec_data (buffer, string); } else { @@ -318,12 +322,14 @@ input_data (struct t_gui_buffer *buffer, const char *data, memcpy (buf, ptr_data_for_buffer, char_size); snprintf (buf + char_size, length - char_size, "%s", ptr_data_for_buffer); - input_exec_data (buffer, buf); + rc = input_exec_data (buffer, buf); free (buf); } } else - input_exec_data (buffer, ptr_data_for_buffer); + { + rc = input_exec_data (buffer, ptr_data_for_buffer); + } } else { @@ -334,7 +340,7 @@ input_data (struct t_gui_buffer *buffer, const char *data, * if data is sent from user and buffer catches any user data: * send it to callback */ - input_exec_data (buffer, ptr_data); + rc = input_exec_data (buffer, ptr_data); } else {