diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-21 21:31:46 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-21 21:31:46 +0100 |
commit | a708f9f81397e5d9e8a066cc74b2103f4cfc2178 (patch) | |
tree | 42327f4ee7a2b7a445add14441f61f2cbdbf5b58 | |
parent | afdee2d9194bced6af912daefb91895890a1fefd (diff) | |
download | weechat-a708f9f81397e5d9e8a066cc74b2103f4cfc2178.zip |
Add missing config functions in script plugin API to free sections and options
-rw-r--r-- | src/core/wee-config-file.c | 20 | ||||
-rw-r--r-- | src/core/wee-config-file.h | 4 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 118 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 94 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 103 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 115 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.c | 86 | ||||
-rw-r--r-- | src/plugins/scripts/script-api.h | 9 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 106 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 7 |
10 files changed, 648 insertions, 14 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 14a982628..b2bd41c31 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -171,6 +171,7 @@ config_file_new_section (struct t_config_file *config_file, const char *name, new_section = malloc (sizeof (*new_section)); if (new_section) { + new_section->config_file = config_file; new_section->name = strdup (name); new_section->user_can_add_options = user_can_add_options; new_section->user_can_delete_options = user_can_delete_options; @@ -2245,21 +2246,23 @@ config_file_section_free_options (struct t_config_section *section) */ void -config_file_section_free (struct t_config_file *config_file, - struct t_config_section *section) +config_file_section_free (struct t_config_section *section) { + struct t_config_file *ptr_config; struct t_config_section *new_sections; - if (!config_file || !section) + if (!section) return; + ptr_config = section->config_file; + /* remove section */ - if (config_file->last_section == section) - config_file->last_section = section->prev_section; + if (ptr_config->last_section == section) + ptr_config->last_section = section->prev_section; if (section->prev_section) { (section->prev_section)->next_section = section->next_section; - new_sections = config_file->sections; + new_sections = ptr_config->sections; } else new_sections = section->next_section; @@ -2274,7 +2277,7 @@ config_file_section_free (struct t_config_file *config_file, free (section); - config_file->sections = new_sections; + ptr_config->sections = new_sections; } /* @@ -2306,7 +2309,7 @@ config_file_free (struct t_config_file *config_file) /* free data */ while (config_file->sections) { - config_file_section_free (config_file, config_file->sections); + config_file_section_free (config_file->sections); } if (config_file->name) free (config_file->name); @@ -2689,6 +2692,7 @@ config_file_print_log () { log_printf (""); log_printf (" [section (addr:0x%lx)]", ptr_section); + log_printf (" config_file. . . . . . . . : 0x%lx", ptr_section->config_file); log_printf (" name . . . . . . . . . . . : '%s'", ptr_section->name); log_printf (" callback_read. . . . . . . : 0x%lx", ptr_section->callback_read); log_printf (" callback_read_data . . . . : 0x%lx", ptr_section->callback_read_data); diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index eb35e0c60..3aa3c7be2 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -59,6 +59,7 @@ struct t_config_file struct t_config_section { + struct t_config_file *config_file; /* configuration file */ char *name; /* section name */ int user_can_add_options; /* user can add with /set ? */ int user_can_delete_options; /* user can del with /unset ? */ @@ -242,8 +243,7 @@ extern int config_file_read (struct t_config_file *config_file); extern int config_file_reload (struct t_config_file *config_file); extern void config_file_option_free (struct t_config_option *option); extern void config_file_section_free_options (struct t_config_section *section); -extern void config_file_section_free (struct t_config_file *config_file, - struct t_config_section *section); +extern void config_file_section_free (struct t_config_section *section); extern void config_file_free (struct t_config_file *config_file); extern void config_file_free_all (); extern void config_file_free_all_plugin (struct t_weechat_plugin *plugin); diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index b9d9ea66b..f39284df0 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -2274,6 +2274,121 @@ weechat_lua_api_config_reload (lua_State *L) } /* + * weechat_lua_api_config_option_free: free an option in configuration file + */ + +static int +weechat_lua_api_config_option_free (lua_State *L) +{ + const char *option; + int n; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + LUA_RETURN_ERROR; + } + + option = NULL; + + n = lua_gettop (lua_current_interpreter); + + if (n < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + LUA_RETURN_ERROR; + } + + option = lua_tostring (lua_current_interpreter, -1); + + script_api_config_option_free (weechat_lua_plugin, + lua_current_script, + script_str2ptr (option)); + + LUA_RETURN_OK; +} + +/* + * weechat_lua_api_config_section_free_options: free all options of a section + * in configuration file + */ + +static int +weechat_lua_api_config_section_free_options (lua_State *L) +{ + const char *section; + int n; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + LUA_RETURN_ERROR; + } + + section = NULL; + + n = lua_gettop (lua_current_interpreter); + + if (n < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + LUA_RETURN_ERROR; + } + + section = lua_tostring (lua_current_interpreter, -1); + + script_api_config_section_free_options (weechat_lua_plugin, + lua_current_script, + script_str2ptr (section)); + + LUA_RETURN_OK; +} + +/* + * weechat_lua_api_config_section_free: free section in configuration file + */ + +static int +weechat_lua_api_config_section_free (lua_State *L) +{ + const char *section; + int n; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + LUA_RETURN_ERROR; + } + + section = NULL; + + n = lua_gettop (lua_current_interpreter); + + if (n < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + LUA_RETURN_ERROR; + } + + section = lua_tostring (lua_current_interpreter, -1); + + script_api_config_section_free (weechat_lua_plugin, + lua_current_script, + script_str2ptr (section)); + + LUA_RETURN_OK; +} + +/* * weechat_lua_api_config_free: free configuration file */ @@ -6300,6 +6415,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "config_write", &weechat_lua_api_config_write }, { "config_read", &weechat_lua_api_config_read }, { "config_reload", &weechat_lua_api_config_reload }, + { "config_option_free", &weechat_lua_api_config_option_free }, + { "config_section_free_options", &weechat_lua_api_config_section_free_options }, + { "config_section_free", &weechat_lua_api_config_section_free }, { "config_free", &weechat_lua_api_config_free }, { "config_get", &weechat_lua_api_config_get }, { "config_get_plugin", &weechat_lua_api_config_get_plugin }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 4856d679f..6e314afe1 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -1904,6 +1904,97 @@ static XS (XS_weechat_api_config_reload) } /* + * weechat::config_option_free: free an option in configuration file + */ + +static XS (XS_weechat_api_config_option_free) +{ + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + PERL_RETURN_ERROR; + } + + if (items < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + PERL_RETURN_ERROR; + } + + script_api_config_option_free (weechat_perl_plugin, + perl_current_script, + script_str2ptr (SvPV (ST (0), PL_na))); /* option */ + + PERL_RETURN_OK; +} + +/* + * weechat::config_section_free_options: free options of a section in + * configuration file + */ + +static XS (XS_weechat_api_config_section_free_options) +{ + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + PERL_RETURN_ERROR; + } + + if (items < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + PERL_RETURN_ERROR; + } + + script_api_config_section_free_options (weechat_perl_plugin, + perl_current_script, + script_str2ptr (SvPV (ST (0), PL_na))); /* section */ + + PERL_RETURN_OK; +} + +/* + * weechat::config_section_free: free section in configuration file + */ + +static XS (XS_weechat_api_config_section_free) +{ + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + PERL_RETURN_ERROR; + } + + if (items < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + PERL_RETURN_ERROR; + } + + script_api_config_section_free (weechat_perl_plugin, + perl_current_script, + script_str2ptr (SvPV (ST (0), PL_na))); /* section */ + + PERL_RETURN_OK; +} + +/* * weechat::config_free: free configuration file */ @@ -4984,6 +5075,9 @@ weechat_perl_api_init (pTHX) newXS ("weechat::config_write", XS_weechat_api_config_write, "weechat"); newXS ("weechat::config_read", XS_weechat_api_config_read, "weechat"); newXS ("weechat::config_reload", XS_weechat_api_config_reload, "weechat"); + newXS ("weechat::config_option_free", XS_weechat_api_config_option_free, "weechat"); + newXS ("weechat::config_section_free_options", XS_weechat_api_config_section_free_options, "weechat"); + newXS ("weechat::config_section_free", XS_weechat_api_config_section_free, "weechat"); newXS ("weechat::config_free", XS_weechat_api_config_free, "weechat"); newXS ("weechat::config_get", XS_weechat_api_config_get, "weechat"); newXS ("weechat::config_get_plugin", XS_weechat_api_config_get_plugin, "weechat"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 94214a865..841e5428e 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -2023,6 +2023,106 @@ weechat_python_api_config_reload (PyObject *self, PyObject *args) } /* + * weechat_python_api_config_option_free: free an option in configuration file + */ + +static PyObject * +weechat_python_api_config_option_free (PyObject *self, PyObject *args) +{ + char *option; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + PYTHON_RETURN_ERROR; + } + + option = NULL; + + if (!PyArg_ParseTuple (args, "s", &option)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + PYTHON_RETURN_ERROR; + } + + script_api_config_option_free (weechat_python_plugin, + python_current_script, + script_str2ptr (option)); + + PYTHON_RETURN_OK; +} + +/* + * weechat_python_api_config_section_free_options: free all options of a section + * in configuration file + */ + +static PyObject * +weechat_python_api_config_section_free_options (PyObject *self, PyObject *args) +{ + char *section; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + PYTHON_RETURN_ERROR; + } + + section = NULL; + + if (!PyArg_ParseTuple (args, "s", §ion)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + PYTHON_RETURN_ERROR; + } + + script_api_config_section_free_options (weechat_python_plugin, + python_current_script, + script_str2ptr (section)); + + PYTHON_RETURN_OK; +} + +/* + * weechat_python_api_config_section_free: free section in configuration file + */ + +static PyObject * +weechat_python_api_config_section_free (PyObject *self, PyObject *args) +{ + char *section; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + PYTHON_RETURN_ERROR; + } + + section = NULL; + + if (!PyArg_ParseTuple (args, "s", §ion)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + PYTHON_RETURN_ERROR; + } + + script_api_config_section_free (weechat_python_plugin, + python_current_script, + script_str2ptr (section)); + + PYTHON_RETURN_OK; +} + +/* * weechat_python_api_config_free: free configuration file */ @@ -5286,6 +5386,9 @@ PyMethodDef weechat_python_funcs[] = { "config_write", &weechat_python_api_config_write, METH_VARARGS, "" }, { "config_read", &weechat_python_api_config_read, METH_VARARGS, "" }, { "config_reload", &weechat_python_api_config_reload, METH_VARARGS, "" }, + { "config_option_free", &weechat_python_api_config_option_free, METH_VARARGS, "" }, + { "config_section_free_options", &weechat_python_api_config_section_free_options, METH_VARARGS, "" }, + { "config_section_free", &weechat_python_api_config_section_free, METH_VARARGS, "" }, { "config_free", &weechat_python_api_config_free, METH_VARARGS, "" }, { "config_get", &weechat_python_api_config_get, METH_VARARGS, "" }, { "config_get_plugin", &weechat_python_api_config_get_plugin, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 794972cf5..b26d222ab 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -2327,6 +2327,118 @@ weechat_ruby_api_config_reload (VALUE class, VALUE config_file) } /* + * weechat_ruby_api_config_option_free: free an option in configuration file + */ + +static VALUE +weechat_ruby_api_config_option_free (VALUE class, VALUE option) +{ + char *c_option; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + RUBY_RETURN_ERROR; + } + + c_option = NULL; + + if (NIL_P (option)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + RUBY_RETURN_ERROR; + } + + Check_Type (option, T_STRING); + + c_option = STR2CSTR (option); + + script_api_config_option_free (weechat_ruby_plugin, + ruby_current_script, + script_str2ptr (c_option)); + + RUBY_RETURN_OK; +} + +/* + * weechat_ruby_api_config_section_free_options: free all options of a section + * in configuration file + */ + +static VALUE +weechat_ruby_api_config_section_free_options (VALUE class, VALUE section) +{ + char *c_section; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + RUBY_RETURN_ERROR; + } + + c_section = NULL; + + if (NIL_P (section)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + RUBY_RETURN_ERROR; + } + + Check_Type (section, T_STRING); + + c_section = STR2CSTR (section); + + script_api_config_section_free_options (weechat_ruby_plugin, + ruby_current_script, + script_str2ptr (c_section)); + + RUBY_RETURN_OK; +} + +/* + * weechat_ruby_api_config_section_free: free section in configuration file + */ + +static VALUE +weechat_ruby_api_config_section_free (VALUE class, VALUE section) +{ + char *c_section; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + RUBY_RETURN_ERROR; + } + + c_section = NULL; + + if (NIL_P (section)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + RUBY_RETURN_ERROR; + } + + Check_Type (section, T_STRING); + + c_section = STR2CSTR (section); + + script_api_config_section_free (weechat_ruby_plugin, + ruby_current_script, + script_str2ptr (c_section)); + + RUBY_RETURN_OK; +} + +/* * weechat_ruby_api_config_free: free configuration file */ @@ -6053,6 +6165,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "config_write", &weechat_ruby_api_config_write, 1); rb_define_module_function (ruby_mWeechat, "config_read", &weechat_ruby_api_config_read, 1); rb_define_module_function (ruby_mWeechat, "config_reload", &weechat_ruby_api_config_reload, 1); + rb_define_module_function (ruby_mWeechat, "config_option_free", &weechat_ruby_api_config_option_free, 1); + rb_define_module_function (ruby_mWeechat, "config_section_free_options", &weechat_ruby_api_config_section_free_options, 1); + rb_define_module_function (ruby_mWeechat, "config_section_free", &weechat_ruby_api_config_section_free, 1); rb_define_module_function (ruby_mWeechat, "config_free", &weechat_ruby_api_config_free, 1); rb_define_module_function (ruby_mWeechat, "config_get", &weechat_ruby_api_config_get, 1); rb_define_module_function (ruby_mWeechat, "config_get_plugin", &weechat_ruby_api_config_get_plugin, 1); diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index a3c1882b4..994db733b 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -476,6 +476,92 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin, } /* + * script_api_config_option_free: free an option in configuration file + */ + +void +script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_option *option) +{ + struct t_script_callback *ptr_script_callback, *next_callback; + + if (!weechat_plugin || !script || !option) + return; + + weechat_config_option_free (option); + + ptr_script_callback = script->callbacks; + while (ptr_script_callback) + { + next_callback = ptr_script_callback->next_callback; + + if (ptr_script_callback->config_option == option) + script_callback_remove (script, ptr_script_callback); + + ptr_script_callback = next_callback; + } +} + +/* + * script_api_config_section_free_options: free all options of a section in + * configuration file + */ + +void +script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section) +{ + struct t_script_callback *ptr_script_callback, *next_callback; + + if (!weechat_plugin || !script || !section) + return; + + weechat_config_section_free_options (section); + + ptr_script_callback = script->callbacks; + while (ptr_script_callback) + { + next_callback = ptr_script_callback->next_callback; + + if ((ptr_script_callback->config_section == section) + && ptr_script_callback->config_option) + script_callback_remove (script, ptr_script_callback); + + ptr_script_callback = next_callback; + } +} + +/* + * script_api_config_section_free: free a section in configuration file + */ + +void +script_api_config_section_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section) +{ + struct t_script_callback *ptr_script_callback, *next_callback; + + if (!weechat_plugin || !script || !section) + return; + + weechat_config_section_free (section); + + ptr_script_callback = script->callbacks; + while (ptr_script_callback) + { + next_callback = ptr_script_callback->next_callback; + + if (ptr_script_callback->config_section == section) + script_callback_remove (script, ptr_script_callback); + + ptr_script_callback = next_callback; + } +} + +/* * script_api_config_free: free configuration file */ diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index b91296d4d..6375e4ded 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -80,6 +80,15 @@ extern struct t_config_option *script_api_config_new_option (struct t_weechat_pl void (*callback_delete)(void *data, struct t_config_option *option), const char *function_delete); +extern void script_api_config_option_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_option *option); +extern void script_api_config_section_free_options (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section); +extern void script_api_config_section_free (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + struct t_config_section *section); extern void script_api_config_free (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_config_file *config_file); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index cd6b15790..b93f8ae2e 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -2206,6 +2206,106 @@ weechat_tcl_api_config_reload (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_config_option_free: free an option in configuration file + */ + +static int +weechat_tcl_api_config_option_free (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + int i; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_free"); + TCL_RETURN_ERROR; + } + + if (objc < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_free"); + TCL_RETURN_ERROR; + } + + script_api_config_option_free (weechat_tcl_plugin, + tcl_current_script, + script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* option */ + + TCL_RETURN_OK; +} + +/* + * weechat_tcl_api_config_section_free_options: free all options of a section + * in configuration file + */ + +static int +weechat_tcl_api_config_section_free_options (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + int i; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free_options"); + TCL_RETURN_ERROR; + } + + if (objc < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free_options"); + TCL_RETURN_ERROR; + } + + script_api_config_section_free_options (weechat_tcl_plugin, + tcl_current_script, + script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* section */ + + TCL_RETURN_OK; +} + +/* + * weechat_tcl_api_config_section_free: free section in configuration file + */ + +static int +weechat_tcl_api_config_section_free (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + int i; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_section_free"); + TCL_RETURN_ERROR; + } + + if (objc < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_section_free"); + TCL_RETURN_ERROR; + } + + script_api_config_section_free (weechat_tcl_plugin, + tcl_current_script, + script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* section */ + + TCL_RETURN_OK; +} + +/* * weechat_tcl_api_config_free: free configuration file */ @@ -5724,6 +5824,12 @@ void weechat_tcl_api_init (Tcl_Interp *interp) { weechat_tcl_api_config_read, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp,"weechat::config_reload", weechat_tcl_api_config_reload, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp,"weechat::config_option_free", + weechat_tcl_api_config_option_free, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp,"weechat::config_section_free_options", + weechat_tcl_api_config_section_free_options, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp,"weechat::config_section_free", + weechat_tcl_api_config_section_free, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp,"weechat::config_free", weechat_tcl_api_config_free, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp,"weechat::config_get", diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 8f537577c..d5d4ac4e9 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -315,8 +315,7 @@ struct t_weechat_plugin int (*config_reload) (struct t_config_file *config_file); void (*config_option_free) (struct t_config_option *option); void (*config_section_free_options) (struct t_config_section *section); - void (*config_section_free) (struct t_config_file *config_file, - struct t_config_section *section); + void (*config_section_free) (struct t_config_section *section); void (*config_free) (struct t_config_file *config_file); struct t_config_option *(*config_get) (const char *option_name); const char *(*config_get_plugin) (struct t_weechat_plugin *plugin, @@ -867,8 +866,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->config_option_free(__option) #define weechat_config_section_free_options(__section) \ weechat_plugin->config_section_free_options(__section) -#define weechat_config_section_free(__config, __section) \ - weechat_plugin->config_section_free(__config, __section) +#define weechat_config_section_free(__section) \ + weechat_plugin->config_section_free(__section) #define weechat_config_free(__config) \ weechat_plugin->config_free(__config) #define weechat_config_get(__option) \ |