mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Add function "config_is_set_plugin" in plugin/script API
This commit is contained in:
@@ -2691,6 +2691,44 @@ weechat_lua_api_config_get_plugin (lua_State *L)
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_is_set_plugin: check if a plugin option is set
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_config_is_set_plugin (lua_State *L)
|
||||
{
|
||||
const char *option;
|
||||
int n, rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
rc = script_api_config_is_set_plugin (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
option);
|
||||
|
||||
LUA_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_set_plugin: set value of a plugin option
|
||||
*/
|
||||
@@ -7047,6 +7085,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "config_free", &weechat_lua_api_config_free },
|
||||
{ "config_get", &weechat_lua_api_config_get },
|
||||
{ "config_get_plugin", &weechat_lua_api_config_get_plugin },
|
||||
{ "config_is_set_plugin", &weechat_lua_api_config_is_set_plugin },
|
||||
{ "config_set_plugin", &weechat_lua_api_config_set_plugin },
|
||||
{ "config_unset_plugin", &weechat_lua_api_config_unset_plugin },
|
||||
{ "prefix", &weechat_lua_api_prefix },
|
||||
|
||||
@@ -2257,6 +2257,40 @@ static XS (XS_weechat_api_config_get_plugin)
|
||||
PERL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_is_set_plugin: check if a plugin option is set
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_api_config_is_set_plugin)
|
||||
{
|
||||
char *option;
|
||||
int rc;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = SvPV (ST (0), PL_na);
|
||||
|
||||
rc = script_api_config_is_set_plugin (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
option);
|
||||
|
||||
PERL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_set_plugin: set value of a plugin option
|
||||
*/
|
||||
@@ -5646,6 +5680,7 @@ weechat_perl_api_init (pTHX)
|
||||
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");
|
||||
newXS ("weechat::config_is_set_plugin", XS_weechat_api_config_is_set_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");
|
||||
|
||||
@@ -2386,6 +2386,40 @@ weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_is_set_plugin: check if a plugin option is set
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_config_is_set_plugin (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *option;
|
||||
int rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
rc = script_api_config_is_set_plugin (weechat_python_plugin,
|
||||
python_current_script,
|
||||
option);
|
||||
|
||||
PYTHON_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_set_plugin: set value of a plugin option
|
||||
*/
|
||||
@@ -5924,6 +5958,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "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, "" },
|
||||
{ "config_is_set_plugin", &weechat_python_api_config_is_set_plugin, METH_VARARGS, "" },
|
||||
{ "config_set_plugin", &weechat_python_api_config_set_plugin, METH_VARARGS, "" },
|
||||
{ "config_unset_plugin", &weechat_python_api_config_unset_plugin, METH_VARARGS, "" },
|
||||
{ "prefix", &weechat_python_api_prefix, METH_VARARGS, "" },
|
||||
|
||||
@@ -2760,6 +2760,42 @@ weechat_ruby_api_config_get_plugin (VALUE class, VALUE option)
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_is_set_plugin: check if a plugin option is set
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_config_is_set_plugin (VALUE class, VALUE option)
|
||||
{
|
||||
char *c_option;
|
||||
int rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (NIL_P (option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
|
||||
c_option = STR2CSTR (option);
|
||||
|
||||
rc = script_api_config_is_set_plugin (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_option);
|
||||
|
||||
RUBY_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_set_plugin: set value of a plugin option
|
||||
*/
|
||||
@@ -6837,6 +6873,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
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);
|
||||
rb_define_module_function (ruby_mWeechat, "config_is_set_plugin", &weechat_ruby_api_config_is_set_plugin, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_set_plugin", &weechat_ruby_api_config_set_plugin, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_unset_plugin", &weechat_ruby_api_config_unset_plugin, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "prefix", &weechat_ruby_api_prefix, 1);
|
||||
|
||||
@@ -1535,6 +1535,33 @@ script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
return return_value;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_config_is_set_plugin: check if a script option is set
|
||||
*/
|
||||
|
||||
int
|
||||
script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *option)
|
||||
{
|
||||
char *option_fullname;
|
||||
int return_code;
|
||||
|
||||
option_fullname = malloc ((strlen (script->name) +
|
||||
strlen (option) + 2));
|
||||
if (!option_fullname)
|
||||
return 0;
|
||||
|
||||
strcpy (option_fullname, script->name);
|
||||
strcat (option_fullname, ".");
|
||||
strcat (option_fullname, option);
|
||||
|
||||
return_code = weechat_config_is_set_plugin (option_fullname);
|
||||
free (option_fullname);
|
||||
|
||||
return return_code;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_config_set_plugin: set value of a script config option
|
||||
* format in file is "plugin.script.option"
|
||||
|
||||
@@ -286,6 +286,9 @@ extern void script_api_command (struct t_weechat_plugin *weechat_plugin,
|
||||
extern const char *script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *option);
|
||||
extern int script_api_config_is_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *option);
|
||||
extern int script_api_config_set_plugin (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *option, const char *value);
|
||||
|
||||
@@ -2583,6 +2583,42 @@ weechat_tcl_api_config_get_plugin (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_is_set_plugin: check if a plugin option is set
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_config_is_set_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_INIT(TCL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "config_is_set_plugin");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
option = Tcl_GetStringFromObj (objv[1], &i);
|
||||
|
||||
rc = script_api_config_is_set_plugin (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
option);
|
||||
|
||||
TCL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_set_plugin: set value of a plugin option
|
||||
*/
|
||||
@@ -6434,6 +6470,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
weechat_tcl_api_config_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::config_get_plugin",
|
||||
weechat_tcl_api_config_get_plugin, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::config_is_set_plugin",
|
||||
weechat_tcl_api_config_is_set_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",
|
||||
|
||||
Reference in New Issue
Block a user