summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-04-03 11:39:23 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-04-03 11:39:23 +0200
commit936d5559f40ff7a977cd78da3251b17c9b7d3d27 (patch)
treeb1c80bd09ce69a2a2d754bb0908a900e6ac0650b
parent6bf64e979dfdeac8556d55cd8f1b4ea8f839c967 (diff)
downloadweechat-936d5559f40ff7a977cd78da3251b17c9b7d3d27.zip
api: add option "buffer_flush" in function hook_process_hashtable
-rw-r--r--ChangeLog.asciidoc1
-rw-r--r--doc/en/weechat_plugin_api.en.txt6
-rw-r--r--doc/fr/weechat_plugin_api.fr.txt7
-rw-r--r--doc/it/weechat_plugin_api.it.txt7
-rw-r--r--doc/ja/weechat_plugin_api.ja.txt7
-rw-r--r--src/core/wee-hook.c24
-rw-r--r--src/core/wee-hook.h1
7 files changed, 52 insertions, 1 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc
index 9321dba04..d08911de4 100644
--- a/ChangeLog.asciidoc
+++ b/ChangeLog.asciidoc
@@ -70,6 +70,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* core: add signals "key_combo_{default|search|cursor}"
* core: display a warning in case of inconsistency between the options
weechat.look.save_{config|layout}_on_exit
+* api: add option "buffer_flush" in function hook_process_hashtable
* api: allow negative value for y in function printf_y
* api: add support of case insensitive search and search by buffer full name
in function buffer_search (bug #34318)
diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt
index a05c2acf2..02706bdb0 100644
--- a/doc/en/weechat_plugin_api.en.txt
+++ b/doc/en/weechat_plugin_api.en.txt
@@ -7214,6 +7214,12 @@ available:
Create a pipe for writing data on standard input (stdin) of child process
(see function <<_weechat_hook_set,weechat_hook_set>>)
+| buffer_flush +
+ _(WeeChat ≥ 0.4.4)_ |
+ number of bytes |
+ Minimum number of bytes to flush stdout/stderr (to send output to callback),
+ between 1 and 65536 (default); 1 = send any output immediately to the callback
+
| detached +
_(WeeChat ≥ 0.4.4)_ |
(not used) |
diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt
index a5823f2ac..4078f3d26 100644
--- a/doc/fr/weechat_plugin_api.fr.txt
+++ b/doc/fr/weechat_plugin_api.fr.txt
@@ -7339,6 +7339,13 @@ sont disponibles :
Créer un tuyau pour écrire sur l'entrée standard (stdin) du processus fils
(voir la fonction <<_weechat_hook_set,weechat_hook_set>>)
+| buffer_flush +
+ _(WeeChat ≥ 0.4.4)_ |
+ nombre d'octets |
+ Nombre minimum d'octets pour vider stdout/stderr (pour envoyer la sortie au
+ "callback"), entre 1 et 65536 (par défaut); 1 = envoyer toute sortie
+ immédiatement au "callback"
+
| detached +
_(WeeChat ≥ 0.4.4)_ |
(non utilisée) |
diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt
index 50957ff8e..f794030d4 100644
--- a/doc/it/weechat_plugin_api.it.txt
+++ b/doc/it/weechat_plugin_api.it.txt
@@ -7334,6 +7334,13 @@ available:
(see function <<_weechat_hook_set,weechat_hook_set>>)
// TRANSLATION MISSING
+| buffer_flush +
+ _(WeeChat ≥ 0.4.4)_ |
+ number of bytes |
+ Minimum number of bytes to flush stdout/stderr (to send output to callback),
+ between 1 and 65536 (default); 1 = send any output immediately to the callback
+
+// TRANSLATION MISSING
| detached +
_(WeeChat ≥ 0.4.4)_ |
(not used) |
diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt
index 9ae2d0363..a14bf8a0c 100644
--- a/doc/ja/weechat_plugin_api.ja.txt
+++ b/doc/ja/weechat_plugin_api.ja.txt
@@ -7208,6 +7208,13 @@ struct t_hook *weechat_hook_process_hashtable (const char *command,
データを書き込むためのパイプを子プロセスの標準入力 (stdin)
に作成します (関数 <<_weechat_hook_set,weechat_hook_set>> を参照)
+// TRANSLATION MISSING
+| buffer_flush +
+ _(WeeChat バージョン 0.4.4 以上で利用可)_ |
+ number of bytes |
+ Minimum number of bytes to flush stdout/stderr (to send output to callback),
+ between 1 and 65536 (default); 1 = send any output immediately to the callback
+
| detached +
_(WeeChat バージョン 0.4.4 以上で利用可)_ |
(非使用) |
diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c
index 0334464f3..5a12ec8f2 100644
--- a/src/core/wee-hook.c
+++ b/src/core/wee-hook.c
@@ -1351,7 +1351,9 @@ hook_process_hashtable (struct t_weechat_plugin *plugin,
{
struct t_hook *new_hook;
struct t_hook_process *new_hook_process;
- char *stdout_buffer, *stderr_buffer;
+ char *stdout_buffer, *stderr_buffer, *error;
+ const char *ptr_value;
+ long number;
stdout_buffer = NULL;
stderr_buffer = NULL;
@@ -1404,6 +1406,20 @@ hook_process_hashtable (struct t_weechat_plugin *plugin,
new_hook_process->buffer_size[HOOK_PROCESS_STDIN] = 0;
new_hook_process->buffer_size[HOOK_PROCESS_STDOUT] = 0;
new_hook_process->buffer_size[HOOK_PROCESS_STDERR] = 0;
+ new_hook_process->buffer_flush = HOOK_PROCESS_BUFFER_SIZE;
+ if (options)
+ {
+ ptr_value = hashtable_get (options, "buffer_flush");
+ if (ptr_value && ptr_value[0])
+ {
+ number = strtol (ptr_value, &error, 10);
+ if (error && !error[0]
+ && (number >= 1) && (number <= HOOK_PROCESS_BUFFER_SIZE))
+ {
+ new_hook_process->buffer_flush = (int)number;
+ }
+ }
+ }
hook_add_to_list (new_hook);
@@ -1668,6 +1684,12 @@ hook_process_child_read (struct t_hook *hook_process, int fd,
{
hook_process_add_to_buffer (hook_process, index_buffer,
buffer, num_read);
+ if (HOOK_PROCESS(hook_process, buffer_size[index_buffer]) >=
+ HOOK_PROCESS(hook_process, buffer_flush))
+ {
+ hook_process_send_buffers (hook_process,
+ WEECHAT_HOOK_PROCESS_RUNNING);
+ }
}
else if (num_read == 0)
{
diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h
index da14dc22d..e033b6639 100644
--- a/src/core/wee-hook.h
+++ b/src/core/wee-hook.h
@@ -222,6 +222,7 @@ struct t_hook_process
struct t_hook *hook_timer; /* timer to check if child has died */
char *buffer[3]; /* buffers for child stdin/out/err */
int buffer_size[3]; /* size of child stdin/out/err */
+ int buffer_flush; /* bytes to flush output buffers */
};
/* hook connect */