api: add hashtable with variables in plugin structure

v2.8-utf8proc
Sébastien Helleu 2017-12-23 15:33:31 +01:00
parent aa7a3cf07d
commit 87be29ed3d
9 changed files with 18 additions and 1 deletions

View File

@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
New features::
* core: add option weechat.completion.partial_completion_templates to force partial completion on specific templates
* api: add hashtable with variables in plugin structure
[[v2.0.1]]
== Version 2.0.1 (2017-12-20)

View File

@ -941,6 +941,7 @@ _charset_   (string) +
_priority_   (integer) +
_initialized_   (integer) +
_debug_   (integer) +
_variables_   (hashtable) +
_prev_plugin_   (pointer, hdata: "plugin") +
_next_plugin_   (pointer, hdata: "plugin") +

View File

@ -941,6 +941,7 @@ _charset_   (string) +
_priority_   (integer) +
_initialized_   (integer) +
_debug_   (integer) +
_variables_   (hashtable) +
_prev_plugin_   (pointer, hdata: "plugin") +
_next_plugin_   (pointer, hdata: "plugin") +

View File

@ -941,6 +941,7 @@ _charset_   (string) +
_priority_   (integer) +
_initialized_   (integer) +
_debug_   (integer) +
_variables_   (hashtable) +
_prev_plugin_   (pointer, hdata: "plugin") +
_next_plugin_   (pointer, hdata: "plugin") +

View File

@ -941,6 +941,7 @@ _charset_   (string) +
_priority_   (integer) +
_initialized_   (integer) +
_debug_   (integer) +
_variables_   (hashtable) +
_prev_plugin_   (pointer, hdata: "plugin") +
_next_plugin_   (pointer, hdata: "plugin") +

View File

@ -941,6 +941,7 @@ _charset_   (string) +
_priority_   (integer) +
_initialized_   (integer) +
_debug_   (integer) +
_variables_   (hashtable) +
_prev_plugin_   (pointer, hdata: "plugin") +
_next_plugin_   (pointer, hdata: "plugin") +

View File

@ -941,6 +941,7 @@ _charset_   (string) +
_priority_   (integer) +
_initialized_   (integer) +
_debug_   (integer) +
_variables_   (hashtable) +
_prev_plugin_   (pointer, hdata: "plugin") +
_next_plugin_   (pointer, hdata: "plugin") +

View File

@ -592,6 +592,10 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->initialized = 0;
ptr_option = config_weechat_debug_get (name);
new_plugin->debug = (ptr_option) ? CONFIG_INTEGER(ptr_option) : 0;
new_plugin->variables = hashtable_new (
32,
WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING,
NULL, NULL);
/* functions */
new_plugin->plugin_get_name = &plugin_get_name;
@ -1174,6 +1178,7 @@ plugin_remove (struct t_weechat_plugin *plugin)
free (plugin->license);
if (plugin->charset)
free (plugin->charset);
hashtable_free (plugin->variables);
free (plugin);
@ -1406,6 +1411,7 @@ plugin_hdata_plugin_cb (const void *pointer, void *data,
HDATA_VAR(struct t_weechat_plugin, priority, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, initialized, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, debug, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, variables, HASHTABLE, 0, NULL, NULL);
HDATA_VAR(struct t_weechat_plugin, prev_plugin, POINTER, 0, NULL, hdata_name);
HDATA_VAR(struct t_weechat_plugin, next_plugin, POINTER, 0, NULL, hdata_name);
HDATA_LIST(weechat_plugins, WEECHAT_HDATA_LIST_CHECK_POINTERS);
@ -1463,6 +1469,8 @@ plugin_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!infolist_new_var_integer (ptr_item, "debug", plugin->debug))
return 0;
if (!hashtable_add_to_infolist (plugin->variables, ptr_item, "var"))
return 0;
return 1;
}
@ -1492,6 +1500,7 @@ plugin_print_log ()
log_printf (" priority . . . . . . . : %d", ptr_plugin->priority);
log_printf (" initialized. . . . . . : %d", ptr_plugin->initialized);
log_printf (" debug. . . . . . . . . : %d", ptr_plugin->debug);
hashtable_print_log (ptr_plugin->variables, "variables");
log_printf (" prev_plugin. . . . . . : 0x%lx", ptr_plugin->prev_plugin);
log_printf (" next_plugin. . . . . . : 0x%lx", ptr_plugin->next_plugin);
}

View File

@ -67,7 +67,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20170704-01"
#define WEECHAT_PLUGIN_API_VERSION "20171223-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -255,6 +255,7 @@ struct t_weechat_plugin
int priority; /* plugin priority (default is 1000) */
int initialized; /* plugin initialized? (init called) */
int debug; /* debug level for plugin (0=off) */
struct t_hashtable *variables; /* plugin custom variables */
struct t_weechat_plugin *prev_plugin; /* link to previous plugin */
struct t_weechat_plugin *next_plugin; /* link to next plugin */