diff options
Diffstat (limited to 'src/plugins/scripts')
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl.c | 39 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python.c | 39 |
2 files changed, 78 insertions, 0 deletions
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c index 543c39ba5..a39437958 100644 --- a/src/plugins/scripts/perl/weechat-perl.c +++ b/src/plugins/scripts/perl/weechat-perl.c @@ -452,6 +452,44 @@ static XS (XS_weechat_get_dcc_info) } /* + * weechat::get_config: get value of a config option + */ + +static XS (XS_weechat_get_config) +{ + char *option, *value; + unsigned int integer; + dXSARGS; + + /* make gcc happy */ + (void) cv; + + if (items != 1) + { + perl_plugin->printf_server (perl_plugin, + "Perl error: wrong parameters for " + "\"get_config\" function"); + XSRETURN_NO; + } + + option = SvPV (ST (0), integer); + if (option) + { + value = perl_plugin->get_config (perl_plugin, option); + + if (value) + { + XST_mPV (0, value); + free (value); + } + else + XST_mPV (0, ""); + } + + XSRETURN (1); +} + +/* * weechat_perl_xs_init: initialize subroutines */ @@ -468,6 +506,7 @@ weechat_perl_xs_init (pTHX) newXS ("weechat::add_command_handler", XS_weechat_add_command_handler, "weechat"); newXS ("weechat::get_info", XS_weechat_get_info, "weechat"); newXS ("weechat::get_dcc_info", XS_weechat_get_dcc_info, "weechat"); + newXS ("weechat::get_config", XS_weechat_get_config, "weechat"); } /* diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 5a900ee31..45bc2bcd6 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -456,6 +456,44 @@ weechat_python_get_dcc_info (PyObject *self, PyObject *args) return list; } + +/* + * weechat.get_config: get value of a config option + */ + +static PyObject * +weechat_python_get_config (PyObject *self, PyObject *args) +{ + char *option, *value; + PyObject *object; + + /* make gcc happy */ + (void) self; + + if (!PyArg_ParseTuple (args, "s", &option)) + { + python_plugin->printf_server (python_plugin, + "Python error: wrong parameters for " + "\"get_config\" function"); + return NULL; + } + + if (option) + { + value = python_plugin->get_config (python_plugin, option); + + if (value) + { + object = Py_BuildValue ("s", value); + free (value); + return object; + } + else + return Py_BuildValue ("s", ""); + } + + return Py_BuildValue ("i", 1); +} /* * Python subroutines @@ -471,6 +509,7 @@ PyMethodDef weechat_funcs[] = { { "add_command_handler", weechat_python_add_command_handler, METH_VARARGS, "" }, { "get_info", weechat_python_get_info, METH_VARARGS, "" }, { "get_dcc_info", weechat_python_get_dcc_info, METH_VARARGS, "" }, + { "get_config", weechat_python_get_config, METH_VARARGS, "" }, { NULL, NULL, 0, NULL } }; |