diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-01 13:31:20 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2009-02-01 13:31:20 +0100 |
commit | 5205be4b875c7fbc5d82818367e51ad49b667f72 (patch) | |
tree | ca4d107431f558e46a36a4b382ac89bf30585893 /src/plugins/scripts/tcl/weechat-tcl-api.c | |
parent | 33e733cb0adad382fde58764a2de29031c2df767 (diff) | |
download | weechat-5205be4b875c7fbc5d82818367e51ad49b667f72.zip |
Add function config_unset_plugin in API, fix return code of config_set_plugin
Diffstat (limited to 'src/plugins/scripts/tcl/weechat-tcl-api.c')
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index f4216a70a..711be2e16 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -2260,7 +2260,7 @@ weechat_tcl_api_config_set_plugin (ClientData clientData, Tcl_Interp *interp, { Tcl_Obj *objp; char *option, *value; - int i; + int i, rc; /* make C compiler happy */ (void) clientData; @@ -2268,24 +2268,60 @@ weechat_tcl_api_config_set_plugin (ClientData clientData, Tcl_Interp *interp, if (!tcl_current_script) { WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin"); - TCL_RETURN_ERROR; + TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } if (objc < 3) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin"); - TCL_RETURN_ERROR; + TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR); } - + option = Tcl_GetStringFromObj (objv[1], &i); value = Tcl_GetStringFromObj (objv[2], &i); - if (script_api_config_set_plugin (weechat_tcl_plugin, - tcl_current_script, - option, - value)) - TCL_RETURN_OK; - TCL_RETURN_ERROR; + rc = script_api_config_set_plugin (weechat_tcl_plugin, + tcl_current_script, + option, + value); + + TCL_RETURN_INT(rc); +} + +/* + * weechat_tcl_api_config_set_plugin: unset plugin option + */ + +static int +weechat_tcl_api_config_unset_plugin (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + char *option; + int i, rc; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin"); + TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); + } + + if (objc < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin"); + TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR); + } + + option = Tcl_GetStringFromObj (objv[1], &i); + + rc = script_api_config_unset_plugin (weechat_tcl_plugin, + tcl_current_script, + option); + + TCL_RETURN_INT(rc); } /* @@ -5499,6 +5535,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) { weechat_tcl_api_config_get_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp,"weechat::config_set_plugin", weechat_tcl_api_config_set_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp,"weechat::config_unset_plugin", + weechat_tcl_api_config_unset_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp,"weechat::prefix", weechat_tcl_api_prefix, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp,"weechat::color", |