summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/perl/weechat-perl-api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/scripts/perl/weechat-perl-api.c')
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c52
1 files changed, 43 insertions, 9 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 0f393b04a..faca5fcec 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -1948,6 +1948,7 @@ static XS (XS_weechat_api_config_get_plugin)
static XS (XS_weechat_api_config_set_plugin)
{
char *option, *value;
+ int rc;
dXSARGS;
/* make C compiler happy */
@@ -1956,24 +1957,56 @@ static XS (XS_weechat_api_config_set_plugin)
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_set_plugin");
- PERL_RETURN_ERROR;
+ PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_set_plugin");
- PERL_RETURN_ERROR;
+ PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
}
-
+
option = SvPV (ST (0), PL_na);
value = SvPV (ST (1), PL_na);
- if (script_api_config_set_plugin (weechat_perl_plugin,
- perl_current_script,
- option,
- value))
- PERL_RETURN_OK;
+ rc = script_api_config_set_plugin (weechat_perl_plugin,
+ perl_current_script,
+ option,
+ value);
- PERL_RETURN_ERROR;
+ PERL_RETURN_INT(rc);
+}
+
+/*
+ * weechat::config_unset_plugin: unset a plugin option
+ */
+
+static XS (XS_weechat_api_config_unset_plugin)
+{
+ char *option;
+ int rc;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_unset_plugin");
+ PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
+ }
+
+ if (items < 1)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_unset_plugin");
+ PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
+ }
+
+ option = SvPV (ST (0), PL_na);
+ rc = script_api_config_unset_plugin (weechat_perl_plugin,
+ perl_current_script,
+ option);
+
+ PERL_RETURN_INT(rc);
}
/*
@@ -4766,6 +4799,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_get", XS_weechat_api_config_get, "weechat");
newXS ("weechat::config_get_plugin", XS_weechat_api_config_get_plugin, "weechat");
newXS ("weechat::config_set_plugin", XS_weechat_api_config_set_plugin, "weechat");
+ newXS ("weechat::config_unset_plugin", XS_weechat_api_config_unset_plugin, "weechat");
newXS ("weechat::prefix", XS_weechat_api_prefix, "weechat");
newXS ("weechat::color", XS_weechat_api_color, "weechat");
newXS ("weechat::print", XS_weechat_api_print, "weechat");