diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-04-03 11:39:23 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-04-03 11:39:23 +0200 |
commit | 936d5559f40ff7a977cd78da3251b17c9b7d3d27 (patch) | |
tree | b1c80bd09ce69a2a2d754bb0908a900e6ac0650b /src | |
parent | 6bf64e979dfdeac8556d55cd8f1b4ea8f839c967 (diff) | |
download | weechat-936d5559f40ff7a977cd78da3251b17c9b7d3d27.zip |
api: add option "buffer_flush" in function hook_process_hashtable
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-hook.c | 24 | ||||
-rw-r--r-- | src/core/wee-hook.h | 1 |
2 files changed, 24 insertions, 1 deletions
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 */ |