mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Add null values for options, new syntax for /set, reintroduce temporary IRC server feature, improve IRC server options, new functions in API
This commit is contained in:
@@ -1461,7 +1461,7 @@ weechat_lua_api_config_new_option (lua_State *L)
|
||||
const char *string_values, *default_value, *value;
|
||||
const char *function_check_value, *function_change, *function_delete;
|
||||
char *result;
|
||||
int n, min, max;
|
||||
int n, min, max, null_value_allowed;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
@@ -1482,28 +1482,30 @@ weechat_lua_api_config_new_option (lua_State *L)
|
||||
max = 0;
|
||||
default_value = NULL;
|
||||
value = NULL;
|
||||
null_value_allowed = 0;
|
||||
function_check_value = NULL;
|
||||
function_change = NULL;
|
||||
function_delete = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 13)
|
||||
if (n < 14)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
config_file = lua_tostring (lua_current_interpreter, -13);
|
||||
section = lua_tostring (lua_current_interpreter, -12);
|
||||
name = lua_tostring (lua_current_interpreter, -11);
|
||||
type = lua_tostring (lua_current_interpreter, -10);
|
||||
description = lua_tostring (lua_current_interpreter, -9);
|
||||
string_values = lua_tostring (lua_current_interpreter, -8);
|
||||
min = lua_tonumber (lua_current_interpreter, -7);
|
||||
max = lua_tonumber (lua_current_interpreter, -6);
|
||||
default_value = lua_tostring (lua_current_interpreter, -5);
|
||||
value = lua_tostring (lua_current_interpreter, -4);
|
||||
config_file = lua_tostring (lua_current_interpreter, -14);
|
||||
section = lua_tostring (lua_current_interpreter, -13);
|
||||
name = lua_tostring (lua_current_interpreter, -12);
|
||||
type = lua_tostring (lua_current_interpreter, -11);
|
||||
description = lua_tostring (lua_current_interpreter, -10);
|
||||
string_values = lua_tostring (lua_current_interpreter, -9);
|
||||
min = lua_tonumber (lua_current_interpreter, -8);
|
||||
max = lua_tonumber (lua_current_interpreter, -7);
|
||||
default_value = lua_tostring (lua_current_interpreter, -6);
|
||||
value = lua_tostring (lua_current_interpreter, -5);
|
||||
null_value_allowed = lua_tonumber (lua_current_interpreter, -4);
|
||||
function_check_value = lua_tostring (lua_current_interpreter, -3);
|
||||
function_change = lua_tostring (lua_current_interpreter, -2);
|
||||
function_delete = lua_tostring (lua_current_interpreter, -1);
|
||||
@@ -1520,6 +1522,7 @@ weechat_lua_api_config_new_option (lua_State *L)
|
||||
max,
|
||||
default_value,
|
||||
value,
|
||||
null_value_allowed,
|
||||
&weechat_lua_api_config_option_check_value_cb,
|
||||
function_check_value,
|
||||
&weechat_lua_api_config_option_change_cb,
|
||||
@@ -1664,7 +1667,7 @@ weechat_lua_api_config_option_set (lua_State *L)
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
|
||||
LUA_RETURN_INT(0);
|
||||
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
@@ -1676,7 +1679,7 @@ weechat_lua_api_config_option_set (lua_State *L)
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
|
||||
LUA_RETURN_INT(0);
|
||||
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -3);
|
||||
@@ -1690,6 +1693,46 @@ weechat_lua_api_config_option_set (lua_State *L)
|
||||
LUA_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_option_set_null: set null (undefined) value for
|
||||
* option
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_config_option_set_null (lua_State *L)
|
||||
{
|
||||
const char *option;
|
||||
int n, run_callback, rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
|
||||
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
run_callback = 0;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
|
||||
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -2);
|
||||
run_callback = lua_tonumber (lua_current_interpreter, -1);
|
||||
|
||||
rc = weechat_config_option_set_null (script_str2ptr (option),
|
||||
run_callback);
|
||||
|
||||
LUA_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_option_unset: unset an option
|
||||
*/
|
||||
@@ -1706,7 +1749,7 @@ weechat_lua_api_config_option_unset (lua_State *L)
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
LUA_RETURN_INT(0);
|
||||
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
@@ -1716,7 +1759,7 @@ weechat_lua_api_config_option_unset (lua_State *L)
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
LUA_RETURN_INT(0);
|
||||
LUA_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -1);
|
||||
@@ -1741,7 +1784,7 @@ weechat_lua_api_config_option_rename (lua_State *L)
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");;
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
@@ -1765,6 +1808,79 @@ weechat_lua_api_config_option_rename (lua_State *L)
|
||||
LUA_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_option_is_null: return 1 if value of option is null
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_config_option_is_null (lua_State *L)
|
||||
{
|
||||
const char *option;
|
||||
int n, value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
|
||||
LUA_RETURN_INT(1);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
|
||||
LUA_RETURN_INT(1);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
value = weechat_config_option_is_null (script_str2ptr (option));
|
||||
|
||||
LUA_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_option_default_is_null: return 1 if default value of
|
||||
* option is null
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_config_option_default_is_null (lua_State *L)
|
||||
{
|
||||
const char *option;
|
||||
int n, value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
|
||||
LUA_RETURN_INT(1);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
|
||||
LUA_RETURN_INT(1);
|
||||
}
|
||||
|
||||
option = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
value = weechat_config_option_default_is_null (script_str2ptr (option));
|
||||
|
||||
LUA_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_boolean: return boolean value of option
|
||||
*/
|
||||
@@ -1909,6 +2025,45 @@ weechat_lua_api_config_color (lua_State *L)
|
||||
LUA_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_write_option: write an option in configuration file
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_config_write_option (lua_State *L)
|
||||
{
|
||||
const char *config_file, *option;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
config_file = NULL;
|
||||
option = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
config_file = lua_tostring (lua_current_interpreter, -2);
|
||||
option = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
weechat_config_write_option (script_str2ptr (config_file),
|
||||
script_str2ptr (option));
|
||||
|
||||
LUA_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_write_line: write a line in configuration file
|
||||
*/
|
||||
@@ -5880,12 +6035,16 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "config_string_to_boolean", &weechat_lua_api_config_string_to_boolean },
|
||||
{ "config_option_reset", &weechat_lua_api_config_option_reset },
|
||||
{ "config_option_set", &weechat_lua_api_config_option_set },
|
||||
{ "config_option_set_null", &weechat_lua_api_config_option_set_null },
|
||||
{ "config_option_unset", &weechat_lua_api_config_option_unset },
|
||||
{ "config_option_rename", &weechat_lua_api_config_option_rename },
|
||||
{ "config_option_is_null", &weechat_lua_api_config_option_is_null },
|
||||
{ "config_option_default_is_null", &weechat_lua_api_config_option_default_is_null },
|
||||
{ "config_boolean", &weechat_lua_api_config_boolean },
|
||||
{ "config_integer", &weechat_lua_api_config_integer },
|
||||
{ "config_string", &weechat_lua_api_config_string },
|
||||
{ "config_color", &weechat_lua_api_config_color },
|
||||
{ "config_write_option", &weechat_lua_api_config_write_option },
|
||||
{ "config_write_line", &weechat_lua_api_config_write_line },
|
||||
{ "config_write", &weechat_lua_api_config_write },
|
||||
{ "config_read", &weechat_lua_api_config_read },
|
||||
|
||||
@@ -1260,7 +1260,7 @@ static XS (XS_weechat_api_config_new_option)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 13)
|
||||
if (items < 14)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
|
||||
PERL_RETURN_EMPTY;
|
||||
@@ -1274,9 +1274,9 @@ static XS (XS_weechat_api_config_new_option)
|
||||
string_values = SvPV (ST (5), PL_na);
|
||||
default_value = SvPV (ST (8), PL_na);
|
||||
value = SvPV (ST (9), PL_na);
|
||||
function_check_value = SvPV (ST (10), PL_na);
|
||||
function_change = SvPV (ST (11), PL_na);
|
||||
function_delete = SvPV (ST (12), PL_na);
|
||||
function_check_value = SvPV (ST (11), PL_na);
|
||||
function_change = SvPV (ST (12), PL_na);
|
||||
function_delete = SvPV (ST (13), PL_na);
|
||||
result = script_ptr2str (script_api_config_new_option (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
script_str2ptr (config_file),
|
||||
@@ -1289,6 +1289,7 @@ static XS (XS_weechat_api_config_new_option)
|
||||
SvIV (ST (7)), /* max */
|
||||
default_value,
|
||||
value,
|
||||
SvIV (ST (10)), /* null_value_allowed */
|
||||
&weechat_perl_api_config_option_check_value_cb,
|
||||
function_check_value,
|
||||
&weechat_perl_api_config_option_change_cb,
|
||||
@@ -1410,13 +1411,13 @@ static XS (XS_weechat_api_config_option_set)
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
|
||||
PERL_RETURN_INT(0);
|
||||
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
|
||||
PERL_RETURN_INT(0);
|
||||
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = SvPV (ST (0), PL_na);
|
||||
@@ -1428,6 +1429,38 @@ static XS (XS_weechat_api_config_option_set)
|
||||
PERL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_option_set_null: set null (undefined) value for option
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_api_config_option_set_null)
|
||||
{
|
||||
int rc;
|
||||
char *option;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
|
||||
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
|
||||
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = SvPV (ST (0), PL_na);
|
||||
rc = weechat_config_option_set_null (script_str2ptr (option),
|
||||
SvIV (ST (1))); /* run_callback */
|
||||
|
||||
PERL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_option_unset: unset an option
|
||||
*/
|
||||
@@ -1444,13 +1477,13 @@ static XS (XS_weechat_api_config_option_unset)
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
PERL_RETURN_INT(0);
|
||||
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
PERL_RETURN_INT(0);
|
||||
PERL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
option = SvPV (ST (0), PL_na);
|
||||
@@ -1491,6 +1524,65 @@ static XS (XS_weechat_api_config_option_rename)
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_option_is_null: return 1 if value of option is null
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_api_config_option_is_null)
|
||||
{
|
||||
int value;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
|
||||
PERL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
|
||||
PERL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
value = weechat_config_option_is_null (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
|
||||
|
||||
PERL_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_option_default_is_null: return 1 if default value of option
|
||||
* is null
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_api_config_option_default_is_null)
|
||||
{
|
||||
int value;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
|
||||
PERL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
|
||||
PERL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
value = weechat_config_option_default_is_null (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
|
||||
|
||||
PERL_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_boolean: return boolean value of option
|
||||
*/
|
||||
@@ -1607,6 +1699,38 @@ static XS (XS_weechat_api_config_color)
|
||||
PERL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_write_option: write an option in configuration file
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_api_config_write_option)
|
||||
{
|
||||
char *config_file, *option;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
config_file = SvPV (ST (0), PL_na);
|
||||
option = SvPV (ST (1), PL_na);
|
||||
weechat_config_write_option (script_str2ptr (config_file),
|
||||
script_str2ptr (option));
|
||||
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_write_line: write a line in configuration file
|
||||
*/
|
||||
@@ -4624,12 +4748,16 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::config_string_to_boolean", XS_weechat_api_config_string_to_boolean, "weechat");
|
||||
newXS ("weechat::config_option_reset", XS_weechat_api_config_option_reset, "weechat");
|
||||
newXS ("weechat::config_option_set", XS_weechat_api_config_option_set, "weechat");
|
||||
newXS ("weechat::config_option_set_null", XS_weechat_api_config_option_set_null, "weechat");
|
||||
newXS ("weechat::config_option_unset", XS_weechat_api_config_option_unset, "weechat");
|
||||
newXS ("weechat::config_option_rename", XS_weechat_api_config_option_rename, "weechat");
|
||||
newXS ("weechat::config_option_is_null", XS_weechat_api_config_option_is_null, "weechat");
|
||||
newXS ("weechat::config_option_default_is_null", XS_weechat_api_config_option_default_is_null, "weechat");
|
||||
newXS ("weechat::config_boolean", XS_weechat_api_config_boolean, "weechat");
|
||||
newXS ("weechat::config_integer", XS_weechat_api_config_integer, "weechat");
|
||||
newXS ("weechat::config_string", XS_weechat_api_config_string, "weechat");
|
||||
newXS ("weechat::config_color", XS_weechat_api_config_color, "weechat");
|
||||
newXS ("weechat::config_write_option", XS_weechat_api_config_write_option, "weechat");
|
||||
newXS ("weechat::config_write_line", XS_weechat_api_config_write_line, "weechat");
|
||||
newXS ("weechat::config_write", XS_weechat_api_config_write, "weechat");
|
||||
newXS ("weechat::config_read", XS_weechat_api_config_read, "weechat");
|
||||
|
||||
@@ -1316,7 +1316,7 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
|
||||
char *config_file, *section, *name, *type, *description, *string_values;
|
||||
char *default_value, *value, *result;
|
||||
char *function_check_value, *function_change, *function_delete;
|
||||
int min, max;
|
||||
int min, max, null_value_allowed;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1340,10 +1340,11 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
|
||||
function_change = NULL;
|
||||
function_delete = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ssssssiisssss", &config_file, §ion, &name,
|
||||
if (!PyArg_ParseTuple (args, "ssssssiississs", &config_file, §ion, &name,
|
||||
&type, &description, &string_values, &min, &max,
|
||||
&default_value, &value, &function_check_value,
|
||||
&function_change, &function_delete))
|
||||
&default_value, &value, &null_value_allowed,
|
||||
&function_check_value, &function_change,
|
||||
&function_delete))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -1361,6 +1362,7 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
|
||||
max,
|
||||
default_value,
|
||||
value,
|
||||
null_value_allowed,
|
||||
&weechat_python_api_config_option_check_value_cb,
|
||||
function_check_value,
|
||||
&weechat_python_api_config_option_change_cb,
|
||||
@@ -1489,7 +1491,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
|
||||
PYTHON_RETURN_INT(0);
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
@@ -1499,7 +1501,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple (args, "ssi", &option, &new_value, &run_callback))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
|
||||
PYTHON_RETURN_INT(0);
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
rc = weechat_config_option_set (script_str2ptr (option),
|
||||
@@ -1509,6 +1511,41 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_option_set_null: set null (undefined) value for
|
||||
* option
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_config_option_set_null (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *option;
|
||||
int run_callback, rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
run_callback = 0;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "si", &option, &run_callback))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
rc = weechat_config_option_set_null (script_str2ptr (option),
|
||||
run_callback);
|
||||
|
||||
PYTHON_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_option_unset: unset an option
|
||||
*/
|
||||
@@ -1525,7 +1562,7 @@ weechat_python_api_config_option_unset (PyObject *self, PyObject *args)
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
PYTHON_RETURN_INT(0);
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
@@ -1533,7 +1570,7 @@ weechat_python_api_config_option_unset (PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple (args, "s", &option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
PYTHON_RETURN_INT(0);
|
||||
PYTHON_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
rc = weechat_config_option_unset (script_str2ptr (option));
|
||||
@@ -1574,6 +1611,71 @@ weechat_python_api_config_option_rename (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_option_is_null: return 1 if value of option is null
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_config_option_is_null (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *option;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
|
||||
PYTHON_RETURN_INT(1);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
|
||||
PYTHON_RETURN_INT(1);
|
||||
}
|
||||
|
||||
value = weechat_config_option_is_null (script_str2ptr (option));
|
||||
|
||||
PYTHON_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_option_default_is_null: return 1 if default value
|
||||
* of option is null
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_config_option_default_is_null (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *option;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
|
||||
PYTHON_RETURN_INT(1);
|
||||
}
|
||||
|
||||
option = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
|
||||
PYTHON_RETURN_INT(1);
|
||||
}
|
||||
|
||||
value = weechat_config_option_default_is_null (script_str2ptr (option));
|
||||
|
||||
PYTHON_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_boolean: return boolean value of option
|
||||
*/
|
||||
@@ -1702,6 +1804,39 @@ weechat_python_api_config_color (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_write_option: write an option in configuration file
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_config_write_option (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *config_file, *option;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
config_file = NULL;
|
||||
option = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &config_file, &option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
weechat_config_write_option (script_str2ptr (config_file),
|
||||
script_str2ptr (option));
|
||||
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_write_line: write a line in configuration file
|
||||
*/
|
||||
@@ -4911,12 +5046,16 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "config_string_to_boolean", &weechat_python_api_config_string_to_boolean, METH_VARARGS, "" },
|
||||
{ "config_option_reset", &weechat_python_api_config_option_reset, METH_VARARGS, "" },
|
||||
{ "config_option_set", &weechat_python_api_config_option_set, METH_VARARGS, "" },
|
||||
{ "config_option_set_null", &weechat_python_api_config_option_set_null, METH_VARARGS, "" },
|
||||
{ "config_option_unset", &weechat_python_api_config_option_unset, METH_VARARGS, "" },
|
||||
{ "config_option_rename", &weechat_python_api_config_option_rename, METH_VARARGS, "" },
|
||||
{ "config_option_is_null", &weechat_python_api_config_option_is_null, METH_VARARGS, "" },
|
||||
{ "config_option_default_is_null", &weechat_python_api_config_option_default_is_null, METH_VARARGS, "" },
|
||||
{ "config_boolean", &weechat_python_api_config_boolean, METH_VARARGS, "" },
|
||||
{ "config_integer", &weechat_python_api_config_integer, METH_VARARGS, "" },
|
||||
{ "config_string", &weechat_python_api_config_string, METH_VARARGS, "" },
|
||||
{ "config_color", &weechat_python_api_config_color, METH_VARARGS, "" },
|
||||
{ "config_write_option", &weechat_python_api_config_write_option, METH_VARARGS, "" },
|
||||
{ "config_write_line", &weechat_python_api_config_write_line, METH_VARARGS, "" },
|
||||
{ "config_write", &weechat_python_api_config_write, METH_VARARGS, "" },
|
||||
{ "config_read", &weechat_python_api_config_read, METH_VARARGS, "" },
|
||||
|
||||
@@ -1477,7 +1477,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
|
||||
VALUE section, VALUE name, VALUE type,
|
||||
VALUE description, VALUE string_values,
|
||||
VALUE min, VALUE max, VALUE default_value,
|
||||
VALUE value,
|
||||
VALUE value, VALUE null_value_allowed,
|
||||
VALUE function_check_value,
|
||||
VALUE function_change,
|
||||
VALUE function_delete)
|
||||
@@ -1485,7 +1485,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
|
||||
char *c_config_file, *c_section, *c_name, *c_type, *c_description;
|
||||
char *c_string_values, *c_default_value, *c_value, *result;
|
||||
char *c_function_check_value, *c_function_change, *c_function_delete;
|
||||
int c_min, c_max;
|
||||
int c_min, c_max, c_null_value_allowed;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1507,13 +1507,14 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
|
||||
c_max = 0;
|
||||
c_default_value = NULL;
|
||||
c_value = NULL;
|
||||
c_null_value_allowed = 0;
|
||||
c_function_check_value = NULL;
|
||||
c_function_change = NULL;
|
||||
c_function_delete = NULL;
|
||||
|
||||
if (NIL_P (config_file) || NIL_P (section) || NIL_P (name) || NIL_P (type)
|
||||
|| NIL_P (description) || NIL_P (string_values)
|
||||
|| NIL_P (default_value) || NIL_P (value)
|
||||
|| NIL_P (default_value) || NIL_P (value) || NIL_P (null_value_allowed)
|
||||
|| NIL_P (function_check_value) || NIL_P (function_change)
|
||||
|| NIL_P (function_delete))
|
||||
{
|
||||
@@ -1531,6 +1532,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
|
||||
Check_Type (max, T_FIXNUM);
|
||||
Check_Type (default_value, T_STRING);
|
||||
Check_Type (value, T_STRING);
|
||||
Check_Type (null_value_allowed, T_FIXNUM);
|
||||
Check_Type (function_check_value, T_STRING);
|
||||
Check_Type (function_change, T_STRING);
|
||||
Check_Type (function_delete, T_STRING);
|
||||
@@ -1545,6 +1547,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
|
||||
c_max = FIX2INT (max);
|
||||
c_default_value = STR2CSTR (default_value);
|
||||
c_value = STR2CSTR (value);
|
||||
c_null_value_allowed = FIX2INT (null_value_allowed);
|
||||
c_function_check_value = STR2CSTR (function_check_value);
|
||||
c_function_change = STR2CSTR (function_change);
|
||||
c_function_delete = STR2CSTR (function_delete);
|
||||
@@ -1561,6 +1564,7 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
|
||||
c_max,
|
||||
c_default_value,
|
||||
c_value,
|
||||
c_null_value_allowed,
|
||||
&weechat_ruby_api_config_option_check_value_cb,
|
||||
c_function_check_value,
|
||||
&weechat_ruby_api_config_option_change_cb,
|
||||
@@ -1710,7 +1714,7 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
|
||||
RUBY_RETURN_INT(0);
|
||||
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
c_option = NULL;
|
||||
@@ -1720,7 +1724,7 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
|
||||
if (NIL_P (option) || NIL_P (new_value) || NIL_P (run_callback))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
|
||||
RUBY_RETURN_INT(0);
|
||||
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
@@ -1738,6 +1742,48 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
|
||||
RUBY_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_option_set_null: set null (undefined) value for
|
||||
* option
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_config_option_set_null (VALUE class, VALUE option,
|
||||
VALUE run_callback)
|
||||
{
|
||||
char *c_option;
|
||||
int c_run_callback, rc;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
|
||||
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
c_option = NULL;
|
||||
c_run_callback = 0;
|
||||
|
||||
if (NIL_P (option) || NIL_P (run_callback))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
|
||||
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
Check_Type (run_callback, T_FIXNUM);
|
||||
|
||||
c_option = STR2CSTR (option);
|
||||
c_run_callback = FIX2INT (run_callback);
|
||||
|
||||
rc = weechat_config_option_set_null (script_str2ptr (c_option),
|
||||
c_run_callback);
|
||||
|
||||
RUBY_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_option_unset: unset an option
|
||||
*/
|
||||
@@ -1754,7 +1800,7 @@ weechat_ruby_api_config_option_unset (VALUE class, VALUE option)
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
RUBY_RETURN_INT(0);
|
||||
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
c_option = NULL;
|
||||
@@ -1762,7 +1808,7 @@ weechat_ruby_api_config_option_unset (VALUE class, VALUE option)
|
||||
if (NIL_P (option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
RUBY_RETURN_INT(0);
|
||||
RUBY_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
@@ -1814,6 +1860,78 @@ weechat_ruby_api_config_option_rename (VALUE class, VALUE option,
|
||||
RUBY_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_option_is_null: return 1 if value of option is null
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_config_option_is_null (VALUE class, VALUE option)
|
||||
{
|
||||
char *c_option;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
|
||||
RUBY_RETURN_INT(1);
|
||||
}
|
||||
|
||||
c_option = NULL;
|
||||
|
||||
if (NIL_P (option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
|
||||
RUBY_RETURN_INT(1);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
|
||||
c_option = STR2CSTR (option);
|
||||
|
||||
value = weechat_config_option_is_null (script_str2ptr (c_option));
|
||||
|
||||
RUBY_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_option_default_is_null: return 1 if value of option is null
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_config_option_default_is_null (VALUE class, VALUE option)
|
||||
{
|
||||
char *c_option;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
|
||||
RUBY_RETURN_INT(1);
|
||||
}
|
||||
|
||||
c_option = NULL;
|
||||
|
||||
if (NIL_P (option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
|
||||
RUBY_RETURN_INT(1);
|
||||
}
|
||||
|
||||
Check_Type (option, T_STRING);
|
||||
|
||||
c_option = STR2CSTR (option);
|
||||
|
||||
value = weechat_config_option_default_is_null (script_str2ptr (c_option));
|
||||
|
||||
RUBY_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_boolean: return boolean value of option
|
||||
*/
|
||||
@@ -1958,6 +2076,46 @@ weechat_ruby_api_config_color (VALUE class, VALUE option)
|
||||
RUBY_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_write_option: write an option in configuration file
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_config_write_option (VALUE class, VALUE config_file,
|
||||
VALUE option)
|
||||
{
|
||||
char *c_config_file, *c_option;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
c_config_file = NULL;
|
||||
c_option = NULL;
|
||||
|
||||
if (NIL_P (config_file) || NIL_P (option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
Check_Type (config_file, T_STRING);
|
||||
Check_Type (option, T_STRING);
|
||||
|
||||
c_config_file = STR2CSTR (config_file);
|
||||
c_option = STR2CSTR (option);
|
||||
|
||||
weechat_config_write_option (script_str2ptr (c_config_file),
|
||||
script_str2ptr (c_option));
|
||||
|
||||
RUBY_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_write_line: write a line in configuration file
|
||||
*/
|
||||
@@ -5636,17 +5794,21 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "config_new", &weechat_ruby_api_config_new, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 9);
|
||||
rb_define_module_function (ruby_mWeechat, "config_search_section", &weechat_ruby_api_config_search_section, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 13);
|
||||
rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 14);
|
||||
rb_define_module_function (ruby_mWeechat, "config_search_option", &weechat_ruby_api_config_search_option, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "config_string_to_boolean", &weechat_ruby_api_config_string_to_boolean, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_reset", &weechat_ruby_api_config_option_reset, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_set", &weechat_ruby_api_config_option_set, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_set_null", &weechat_ruby_api_config_option_set_null, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_unset", &weechat_ruby_api_config_option_unset, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_rename", &weechat_ruby_api_config_option_rename, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_is_null", &weechat_ruby_api_config_option_is_null, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_option_default_is_null", &weechat_ruby_api_config_option_default_is_null, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_boolean", &weechat_ruby_api_config_boolean, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_integer", &weechat_ruby_api_config_integer, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_string", &weechat_ruby_api_config_string, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_color", &weechat_ruby_api_config_color, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "config_write_option", &weechat_ruby_api_config_write_option, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "config_write_line", &weechat_ruby_api_config_write_line, 3);
|
||||
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);
|
||||
|
||||
@@ -347,6 +347,7 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
|
||||
int min, int max,
|
||||
const char *default_value,
|
||||
const char *value,
|
||||
int null_value_allowed,
|
||||
void (*callback_check_value)(void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value),
|
||||
@@ -416,6 +417,7 @@ script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
|
||||
new_option = weechat_config_new_option (config_file, section, name, type,
|
||||
description, string_values, min,
|
||||
max, default_value, value,
|
||||
null_value_allowed,
|
||||
callback1, new_script_callback1,
|
||||
callback2, new_script_callback2,
|
||||
callback3, new_script_callback3);
|
||||
|
||||
@@ -68,6 +68,7 @@ extern struct t_config_option *script_api_config_new_option (struct t_weechat_pl
|
||||
int min, int max,
|
||||
const char *default_value,
|
||||
const char *value,
|
||||
int null_value_allowed,
|
||||
void (*callback_check_value)(void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value),
|
||||
|
||||
@@ -1458,10 +1458,6 @@ weechat_tcl_api_config_option_delete_cb (void *data,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_new_option: create a new option in section
|
||||
*/
|
||||
@@ -1474,7 +1470,7 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
|
||||
char *result, *config_file, *section, *name, *type;
|
||||
char *description, *string_values, *default_value, *value;
|
||||
char *function_check_value, *function_change, *function_delete;
|
||||
int i,min,max;
|
||||
int i, min, max, null_value_allowed;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
@@ -1485,14 +1481,15 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 14)
|
||||
if (objc < 15)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if ((Tcl_GetIntFromObj (interp, objv[7], &min) != TCL_OK)
|
||||
|| (Tcl_GetIntFromObj (interp, objv[8], &max) != TCL_OK))
|
||||
|| (Tcl_GetIntFromObj (interp, objv[8], &max) != TCL_OK)
|
||||
|| (Tcl_GetIntFromObj (interp, objv[11], &null_value_allowed) != TCL_OK))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_option");
|
||||
TCL_RETURN_EMPTY;
|
||||
@@ -1506,9 +1503,9 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
|
||||
string_values = Tcl_GetStringFromObj (objv[6], &i);
|
||||
default_value = Tcl_GetStringFromObj (objv[9], &i);
|
||||
value = Tcl_GetStringFromObj (objv[10], &i);
|
||||
function_check_value = Tcl_GetStringFromObj (objv[11], &i);
|
||||
function_change = Tcl_GetStringFromObj (objv[12], &i);
|
||||
function_delete = Tcl_GetStringFromObj (objv[13], &i);
|
||||
function_check_value = Tcl_GetStringFromObj (objv[12], &i);
|
||||
function_change = Tcl_GetStringFromObj (objv[13], &i);
|
||||
function_delete = Tcl_GetStringFromObj (objv[14], &i);
|
||||
|
||||
result = script_ptr2str (script_api_config_new_option (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
@@ -1522,6 +1519,7 @@ weechat_tcl_api_config_new_option (ClientData clientData, Tcl_Interp *interp,
|
||||
max,
|
||||
default_value,
|
||||
value,
|
||||
null_value_allowed,
|
||||
&weechat_tcl_api_config_option_check_value_cb,
|
||||
function_check_value,
|
||||
&weechat_tcl_api_config_option_change_cb,
|
||||
@@ -1653,7 +1651,7 @@ weechat_tcl_api_config_option_set (ClientData clientData, Tcl_Interp *interp,
|
||||
Tcl_Obj* objp;
|
||||
int rc;
|
||||
char *option, *new_value;
|
||||
int i,run_cb;
|
||||
int i, run_callback;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
@@ -1661,26 +1659,67 @@ weechat_tcl_api_config_option_set (ClientData clientData, Tcl_Interp *interp,
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set");
|
||||
TCL_RETURN_INT(0);
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
|
||||
TCL_RETURN_INT(0);
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[3], &run_cb) != TCL_OK)
|
||||
if (Tcl_GetIntFromObj (interp, objv[3], &run_callback) != TCL_OK)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set");
|
||||
TCL_RETURN_INT(0);
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = Tcl_GetStringFromObj (objv[1], &i);
|
||||
new_value = Tcl_GetStringFromObj (objv[2], &i);
|
||||
rc = weechat_config_option_set (script_str2ptr (option),
|
||||
new_value,
|
||||
run_cb); /* run_callback */
|
||||
run_callback);
|
||||
|
||||
TCL_RETURN_INT(rc);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_option_set_null: set null (undefined)value for option
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_config_option_set_null (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
int rc;
|
||||
char *option;
|
||||
int i, run_callback;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_set_null");
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &run_callback) != TCL_OK)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_set_null");
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_SET_ERROR);
|
||||
}
|
||||
|
||||
option = Tcl_GetStringFromObj (objv[1], &i);
|
||||
rc = weechat_config_option_set_null (script_str2ptr (option),
|
||||
run_callback);
|
||||
|
||||
TCL_RETURN_INT(rc);
|
||||
}
|
||||
@@ -1704,13 +1743,13 @@ weechat_tcl_api_config_option_unset (ClientData clientData, Tcl_Interp *interp,
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_unset");
|
||||
TCL_RETURN_INT(0);
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_unset");
|
||||
TCL_RETURN_INT(0);
|
||||
TCL_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR);
|
||||
}
|
||||
|
||||
option = Tcl_GetStringFromObj (objv[1], &i);
|
||||
@@ -1748,12 +1787,77 @@ weechat_tcl_api_config_option_rename (ClientData clientData, Tcl_Interp *interp,
|
||||
|
||||
option = Tcl_GetStringFromObj (objv[1], &i);
|
||||
new_name = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
weechat_config_option_rename (script_str2ptr (option),
|
||||
new_name);
|
||||
|
||||
TCL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_option_is_null: return 1 if value of option is null
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_config_option_is_null (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
int result, i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_is_null");
|
||||
TCL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_is_null");
|
||||
TCL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
result = weechat_config_option_is_null (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* option */
|
||||
|
||||
TCL_RETURN_INT(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_option_default_is_null: return 1 if default value of
|
||||
* option is null
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_config_option_default_is_null (ClientData clientData,
|
||||
Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
int result, i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_default_is_null");
|
||||
TCL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_default_is_null");
|
||||
TCL_RETURN_INT(1);
|
||||
}
|
||||
|
||||
result = weechat_config_option_default_is_null (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i))); /* option */
|
||||
|
||||
TCL_RETURN_INT(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_boolean: return boolean value of option
|
||||
*/
|
||||
@@ -1880,6 +1984,41 @@ weechat_tcl_api_config_color (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_write_option: write an option in configuration file
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_config_write_option (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *config_file, *option;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_write_option");
|
||||
TCL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_write_option");
|
||||
TCL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
config_file = Tcl_GetStringFromObj (objv[1], &i);
|
||||
option = Tcl_GetStringFromObj (objv[2], &i);
|
||||
weechat_config_write_option (script_str2ptr (config_file),
|
||||
script_str2ptr (option));
|
||||
|
||||
TCL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_config_write_line: write a line in configuration file
|
||||
*/
|
||||
@@ -5324,10 +5463,16 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
|
||||
weechat_tcl_api_config_option_reset, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_option_set",
|
||||
weechat_tcl_api_config_option_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_option_set_null",
|
||||
weechat_tcl_api_config_option_set_null, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_option_unset",
|
||||
weechat_tcl_api_config_option_unset, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_option_rename",
|
||||
weechat_tcl_api_config_option_rename, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_option_is_null",
|
||||
weechat_tcl_api_config_option_is_null, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_option_default_is_null",
|
||||
weechat_tcl_api_config_option_default_is_null, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_boolean",
|
||||
weechat_tcl_api_config_boolean, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_integer",
|
||||
@@ -5336,6 +5481,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
|
||||
weechat_tcl_api_config_string, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_color",
|
||||
weechat_tcl_api_config_color, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_write_option",
|
||||
weechat_tcl_api_config_write_option, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_write_line",
|
||||
weechat_tcl_api_config_write_line, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp,"weechat::config_write",
|
||||
|
||||
Reference in New Issue
Block a user