diff options
Diffstat (limited to 'src/plugins/weechat-plugin.h')
-rw-r--r-- | src/plugins/weechat-plugin.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 2eb8a49a3..5c8837b6c 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -46,7 +46,7 @@ struct timeval; */ /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20110820-01" +#define WEECHAT_PLUGIN_API_VERSION "20110826-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -145,6 +145,34 @@ struct timeval; #define WEECHAT_HOOK_SIGNAL_INT "int" #define WEECHAT_HOOK_SIGNAL_POINTER "pointer" +/* macro to format string with variable args, using dynamic buffer size */ +#define weechat_va_format(__format) \ + va_list argptr; \ + int vaa_size, vaa_num; \ + char *vbuffer, *vaa_buffer2; \ + vaa_size = 1024; \ + vbuffer = malloc (vaa_size); \ + if (vbuffer) \ + { \ + while (1) \ + { \ + va_start (argptr, __format); \ + vaa_num = vsnprintf (vbuffer, vaa_size, __format, argptr); \ + va_end (argptr); \ + if ((vaa_num >= 0) && (vaa_num < vaa_size)) \ + break; \ + vaa_size = (vaa_num >= 0) ? vaa_num + 1 : vaa_size * 2; \ + vaa_buffer2 = realloc (vbuffer, vaa_size); \ + if (!vaa_buffer2) \ + { \ + free (vbuffer); \ + vbuffer = NULL; \ + break; \ + } \ + vbuffer = vaa_buffer2; \ + } \ + } + struct t_weechat_plugin { /* plugin variables */ |