mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 12:56:37 +02:00
Add new features to logger plugin (command /logger, log level, level by buffer, mask by buffer, ..), fix some bugs
New features: - new command /logger - log level, to log only some messages, according to importance (task #8592) - level by buffer: custom level for some buffers (or group of buffers) - log filename mask by buffer (or group of buffers) - marker line is added after display of backlog - add "delete" callback for config file sections - add "mkdir_parents" function to plugin API - remove old log options in IRC plugin Bug fix: - marker line is set only when user switches buffer (not when a plugin force switch, like IRC plugin does when opening server or channel buffer) - backlog fixed (sometimes lines were not properly displayed)
This commit is contained in:
@@ -442,6 +442,46 @@ weechat_lua_api_mkdir (lua_State *L)
|
||||
LUA_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_mkdir_parents: create a directory and make parent
|
||||
* directories as needed
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_mkdir_parents (lua_State *L)
|
||||
{
|
||||
const char *directory;
|
||||
int mode, n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
directory = NULL;
|
||||
mode = 0;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
directory = lua_tostring (lua_current_interpreter, -2);
|
||||
mode = lua_tonumber (lua_current_interpreter, -1);
|
||||
|
||||
if (weechat_mkdir_parents (directory, mode))
|
||||
LUA_RETURN_OK;
|
||||
|
||||
LUA_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_list_new: create a new list
|
||||
*/
|
||||
@@ -1157,6 +1197,54 @@ weechat_lua_api_config_section_create_option_cb (void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_section_delete_option_cb: callback to delete an option
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_lua_api_config_section_delete_option_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *lua_argv[4];
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = script_ptr2str (config_file);
|
||||
lua_argv[1] = script_ptr2str (section);
|
||||
lua_argv[2] = script_ptr2str (option);
|
||||
lua_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
lua_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (lua_argv[0])
|
||||
free (lua_argv[0]);
|
||||
if (lua_argv[1])
|
||||
free (lua_argv[1]);
|
||||
if (lua_argv[2])
|
||||
free (lua_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_config_new_section: create a new section in configuration file
|
||||
*/
|
||||
@@ -1166,6 +1254,7 @@ weechat_lua_api_config_new_section (lua_State *L)
|
||||
{
|
||||
const char *config_file, *name, *function_read, *function_write;
|
||||
const char *function_write_default, *function_create_option;
|
||||
const char *function_delete_option;
|
||||
char *result;
|
||||
int n, user_can_add_options, user_can_delete_options;
|
||||
|
||||
@@ -1186,23 +1275,25 @@ weechat_lua_api_config_new_section (lua_State *L)
|
||||
function_write = NULL;
|
||||
function_write_default = NULL;
|
||||
function_create_option = NULL;
|
||||
function_delete_option = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 8)
|
||||
if (n < 9)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
config_file = lua_tostring (lua_current_interpreter, -8);
|
||||
name = lua_tostring (lua_current_interpreter, -7);
|
||||
user_can_add_options = lua_tonumber (lua_current_interpreter, -6);
|
||||
user_can_delete_options = lua_tonumber (lua_current_interpreter, -5);
|
||||
function_read = lua_tostring (lua_current_interpreter, -4);
|
||||
function_write = lua_tostring (lua_current_interpreter, -3);
|
||||
function_write_default = lua_tostring (lua_current_interpreter, -2);
|
||||
function_create_option = lua_tostring (lua_current_interpreter, -1);
|
||||
config_file = lua_tostring (lua_current_interpreter, -9);
|
||||
name = lua_tostring (lua_current_interpreter, -8);
|
||||
user_can_add_options = lua_tonumber (lua_current_interpreter, -7);
|
||||
user_can_delete_options = lua_tonumber (lua_current_interpreter, -6);
|
||||
function_read = lua_tostring (lua_current_interpreter, -5);
|
||||
function_write = lua_tostring (lua_current_interpreter, -4);
|
||||
function_write_default = lua_tostring (lua_current_interpreter, -3);
|
||||
function_create_option = lua_tostring (lua_current_interpreter, -2);
|
||||
function_delete_option = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_config_new_section (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
@@ -1217,7 +1308,9 @@ weechat_lua_api_config_new_section (lua_State *L)
|
||||
&weechat_lua_api_config_section_write_default_cb,
|
||||
function_write_default,
|
||||
&weechat_lua_api_config_section_create_option_cb,
|
||||
function_create_option));
|
||||
function_create_option,
|
||||
&weechat_lua_api_config_section_delete_option_cb,
|
||||
function_delete_option));
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -2722,7 +2815,8 @@ weechat_lua_api_hook_connect (lua_State *L)
|
||||
|
||||
int
|
||||
weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count, char **tags,
|
||||
time_t date,
|
||||
int tags_count, const char **tags,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
@@ -5603,6 +5697,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "ngettext", &weechat_lua_api_ngettext },
|
||||
{ "mkdir_home", &weechat_lua_api_mkdir_home },
|
||||
{ "mkdir", &weechat_lua_api_mkdir },
|
||||
{ "mkdir_parents", &weechat_lua_api_mkdir_parents },
|
||||
{ "list_new", &weechat_lua_api_list_new },
|
||||
{ "list_add", &weechat_lua_api_list_add },
|
||||
{ "list_search", &weechat_lua_api_list_search },
|
||||
|
||||
@@ -366,6 +366,37 @@ static XS (XS_weechat_api_mkdir)
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::mkdir_parents: create a directory and make parent directories as
|
||||
* needed
|
||||
*/
|
||||
|
||||
static XS (XS_weechat_api_mkdir_parents)
|
||||
{
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (weechat_mkdir_parents (SvPV (ST (0), PL_na), /* directory */
|
||||
SvIV (ST (1)))) /* mode */
|
||||
PERL_RETURN_OK;
|
||||
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::list_new: create a new list
|
||||
*/
|
||||
@@ -976,6 +1007,54 @@ weechat_perl_api_config_section_create_option_cb (void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_api_config_section_delete_option_cb: callback to delete an option
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_perl_api_config_section_delete_option_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *perl_argv[4];
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
{
|
||||
perl_argv[0] = script_ptr2str (config_file);
|
||||
perl_argv[1] = script_ptr2str (section);
|
||||
perl_argv[2] = script_ptr2str (option);
|
||||
perl_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
perl_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (perl_argv[0])
|
||||
free (perl_argv[0]);
|
||||
if (perl_argv[1])
|
||||
free (perl_argv[1]);
|
||||
if (perl_argv[2])
|
||||
free (perl_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::config_new_section: create a new section in configuration file
|
||||
*/
|
||||
@@ -984,6 +1063,7 @@ static XS (XS_weechat_api_config_new_section)
|
||||
{
|
||||
char *result, *cfg_file, *name, *function_read, *function_write;
|
||||
char *function_write_default, *function_create_option;
|
||||
char *function_delete_option;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -995,7 +1075,7 @@ static XS (XS_weechat_api_config_new_section)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 8)
|
||||
if (items < 9)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
|
||||
PERL_RETURN_EMPTY;
|
||||
@@ -1007,6 +1087,7 @@ static XS (XS_weechat_api_config_new_section)
|
||||
function_write = SvPV (ST (5), PL_na);
|
||||
function_write_default = SvPV (ST (6), PL_na);
|
||||
function_create_option = SvPV (ST (7), PL_na);
|
||||
function_delete_option = SvPV (ST (8), PL_na);
|
||||
result = script_ptr2str (script_api_config_new_section (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
script_str2ptr (cfg_file),
|
||||
@@ -1020,7 +1101,9 @@ static XS (XS_weechat_api_config_new_section)
|
||||
&weechat_perl_api_config_section_write_default_cb,
|
||||
function_write_default,
|
||||
&weechat_perl_api_config_section_create_option_cb,
|
||||
function_create_option));
|
||||
function_create_option,
|
||||
&weechat_perl_api_config_section_delete_option_cb,
|
||||
function_delete_option));
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -2256,7 +2339,8 @@ static XS (XS_weechat_api_hook_connect)
|
||||
|
||||
int
|
||||
weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count, char **tags,
|
||||
time_t date,
|
||||
int tags_count, const char **tags,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
@@ -4359,6 +4443,7 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::ngettext", XS_weechat_api_ngettext, "weechat");
|
||||
newXS ("weechat::mkdir_home", XS_weechat_api_mkdir_home, "weechat");
|
||||
newXS ("weechat::mkdir", XS_weechat_api_mkdir, "weechat");
|
||||
newXS ("weechat::mkdir_parents", XS_weechat_api_mkdir_parents, "weechat");
|
||||
newXS ("weechat::list_new", XS_weechat_api_list_new, "weechat");
|
||||
newXS ("weechat::list_add", XS_weechat_api_list_add, "weechat");
|
||||
newXS ("weechat::list_search", XS_weechat_api_list_search, "weechat");
|
||||
|
||||
@@ -379,6 +379,41 @@ weechat_python_api_mkdir (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_mkdir_parents: create a directory and make parent
|
||||
* directories as needed
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_mkdir_parents (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *directory;
|
||||
int mode;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
directory = NULL;
|
||||
mode = 0;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "si", &directory, &mode))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (weechat_mkdir_parents (directory, mode))
|
||||
PYTHON_RETURN_OK;
|
||||
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_list_new: create a new list
|
||||
*/
|
||||
@@ -1023,6 +1058,54 @@ weechat_python_api_config_section_create_option_cb (void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_section_delete_option_cb: callback to delete an option
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_python_api_config_section_delete_option_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *python_argv[4];
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
{
|
||||
python_argv[0] = script_ptr2str (config_file);
|
||||
python_argv[1] = script_ptr2str (section);
|
||||
python_argv[2] = script_ptr2str (option);
|
||||
python_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
python_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (python_argv[0])
|
||||
free (python_argv[0]);
|
||||
if (python_argv[1])
|
||||
free (python_argv[1]);
|
||||
if (python_argv[2])
|
||||
free (python_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_config_new_section: create a new section in configuration file
|
||||
*/
|
||||
@@ -1032,6 +1115,7 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *config_file, *name, *function_read, *function_write;
|
||||
char *function_write_default, *function_create_option;
|
||||
char *function_delete_option;
|
||||
char *result;
|
||||
int user_can_add_options, user_can_delete_options;
|
||||
PyObject *object;
|
||||
@@ -1053,11 +1137,13 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
|
||||
function_write = NULL;
|
||||
function_write_default = NULL;
|
||||
function_create_option = NULL;
|
||||
function_delete_option = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ssiissss", &config_file, &name,
|
||||
if (!PyArg_ParseTuple (args, "ssiisssss", &config_file, &name,
|
||||
&user_can_add_options, &user_can_delete_options,
|
||||
&function_read, &function_write,
|
||||
&function_write_default, &function_create_option))
|
||||
&function_write_default, &function_create_option,
|
||||
&function_delete_option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
@@ -1076,7 +1162,9 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
|
||||
&weechat_python_api_config_section_write_default_cb,
|
||||
function_write_default,
|
||||
&weechat_python_api_config_section_create_option_cb,
|
||||
function_create_option));
|
||||
function_create_option,
|
||||
&weechat_python_api_config_section_delete_option_cb,
|
||||
function_delete_option));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -2404,7 +2492,8 @@ weechat_python_api_hook_connect (PyObject *self, PyObject *args)
|
||||
|
||||
int
|
||||
weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count, char **tags,
|
||||
time_t date,
|
||||
int tags_count, const char **tags,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
@@ -4630,6 +4719,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "ngettext", &weechat_python_api_ngettext, METH_VARARGS, "" },
|
||||
{ "mkdir_home", &weechat_python_api_mkdir_home, METH_VARARGS, "" },
|
||||
{ "mkdir", &weechat_python_api_mkdir, METH_VARARGS, "" },
|
||||
{ "mkdir_parents", &weechat_python_api_mkdir_parents, METH_VARARGS, "" },
|
||||
{ "list_new", &weechat_python_api_list_new, METH_VARARGS, "" },
|
||||
{ "list_add", &weechat_python_api_list_add, METH_VARARGS, "" },
|
||||
{ "list_search", &weechat_python_api_list_search, METH_VARARGS, "" },
|
||||
|
||||
@@ -441,6 +441,47 @@ weechat_ruby_api_mkdir (VALUE class, VALUE directory, VALUE mode)
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_mkdir_parents: create a directory and make parent
|
||||
* directories as needed
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_mkdir_parents (VALUE class, VALUE directory, VALUE mode)
|
||||
{
|
||||
char *c_directory;
|
||||
int c_mode;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("mkdir_parents");
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
c_directory = NULL;
|
||||
c_mode = 0;
|
||||
|
||||
if (NIL_P (directory) || NIL_P (mode))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("mkdir_parents");
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
Check_Type (directory, T_STRING);
|
||||
Check_Type (mode, T_FIXNUM);
|
||||
|
||||
c_directory = STR2CSTR (directory);
|
||||
c_mode = FIX2INT (mode);
|
||||
|
||||
if (weechat_mkdir_parents (c_directory, c_mode))
|
||||
RUBY_RETURN_OK;
|
||||
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_list_new: create a new list
|
||||
*/
|
||||
@@ -1146,6 +1187,54 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_section_delete_option_cb: callback to delete an option
|
||||
*/
|
||||
|
||||
int
|
||||
weechat_ruby_api_config_section_delete_option_cb (void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
char *ruby_argv[4];
|
||||
int *rc, ret;
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ruby_argv[0] = script_ptr2str (config_file);
|
||||
ruby_argv[1] = script_ptr2str (section);
|
||||
ruby_argv[2] = script_ptr2str (option);
|
||||
ruby_argv[3] = NULL;
|
||||
|
||||
rc = (int *) weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_INT,
|
||||
script_callback->function,
|
||||
ruby_argv);
|
||||
|
||||
if (!rc)
|
||||
ret = WEECHAT_RC_ERROR;
|
||||
else
|
||||
{
|
||||
ret = *rc;
|
||||
free (rc);
|
||||
}
|
||||
if (ruby_argv[0])
|
||||
free (ruby_argv[0]);
|
||||
if (ruby_argv[1])
|
||||
free (ruby_argv[1]);
|
||||
if (ruby_argv[2])
|
||||
free (ruby_argv[2]);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_config_new_section: create a new section in configuration file
|
||||
*/
|
||||
@@ -1157,10 +1246,12 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
|
||||
VALUE function_read,
|
||||
VALUE function_write,
|
||||
VALUE function_write_default,
|
||||
VALUE function_create_option)
|
||||
VALUE function_create_option,
|
||||
VALUE function_delete_option)
|
||||
{
|
||||
char *c_config_file, *c_name, *c_function_read, *c_function_write;
|
||||
char *c_function_write_default, *c_function_create_option;
|
||||
char *c_function_delete_option;
|
||||
char *result;
|
||||
int c_user_can_add_options, c_user_can_delete_options;
|
||||
VALUE return_value;
|
||||
@@ -1182,11 +1273,12 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
|
||||
c_function_write = NULL;
|
||||
c_function_write_default = NULL;
|
||||
c_function_create_option = NULL;
|
||||
c_function_delete_option = NULL;
|
||||
|
||||
if (NIL_P (config_file) || NIL_P (name) || NIL_P (user_can_add_options)
|
||||
|| NIL_P (user_can_delete_options) || NIL_P (function_read)
|
||||
|| NIL_P (function_write) || NIL_P (function_write_default)
|
||||
|| NIL_P (function_create_option))
|
||||
|| NIL_P (function_create_option) || NIL_P (function_delete_option))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
|
||||
RUBY_RETURN_EMPTY;
|
||||
@@ -1200,6 +1292,7 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
|
||||
Check_Type (function_write, T_STRING);
|
||||
Check_Type (function_write_default, T_STRING);
|
||||
Check_Type (function_create_option, T_STRING);
|
||||
Check_Type (function_delete_option, T_STRING);
|
||||
|
||||
c_config_file = STR2CSTR (config_file);
|
||||
c_name = STR2CSTR (name);
|
||||
@@ -1209,6 +1302,7 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
|
||||
c_function_write = STR2CSTR (function_write);
|
||||
c_function_write_default = STR2CSTR (function_write_default);
|
||||
c_function_create_option = STR2CSTR (function_create_option);
|
||||
c_function_delete_option = STR2CSTR (function_delete_option);
|
||||
|
||||
result = script_ptr2str (script_api_config_new_section (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
@@ -1223,7 +1317,9 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
|
||||
&weechat_ruby_api_config_section_write_default_cb,
|
||||
c_function_write_default,
|
||||
&weechat_ruby_api_config_section_create_option_cb,
|
||||
c_function_create_option));
|
||||
c_function_create_option,
|
||||
&weechat_ruby_api_config_section_delete_option_cb,
|
||||
c_function_delete_option));
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -2777,7 +2873,8 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE address, VALUE port,
|
||||
|
||||
int
|
||||
weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count, char **tags,
|
||||
time_t date,
|
||||
int tags_count, const char **tags,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
@@ -5344,6 +5441,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "ngettext", &weechat_ruby_api_ngettext, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir_home", &weechat_ruby_api_mkdir_home, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir", &weechat_ruby_api_mkdir, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir_parents", &weechat_ruby_api_mkdir_parents, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "list_new", &weechat_ruby_api_list_new, 0);
|
||||
rb_define_module_function (ruby_mWeechat, "list_add", &weechat_ruby_api_list_add, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "list_search", &weechat_ruby_api_list_search, 2);
|
||||
@@ -5358,7 +5456,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "list_remove_all", &weechat_ruby_api_list_remove_all, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "list_free", &weechat_ruby_api_list_free, 1);
|
||||
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, 8);
|
||||
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_search_option", &weechat_ruby_api_config_search_option, 3);
|
||||
|
||||
@@ -118,21 +118,29 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_config_section *section,
|
||||
const char *option_name,
|
||||
const char *value),
|
||||
const char *function_create_option)
|
||||
const char *function_create_option,
|
||||
int (*callback_delete_option)(void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option),
|
||||
const char *function_delete_option)
|
||||
{
|
||||
struct t_script_callback *new_script_callback1, *new_script_callback2;
|
||||
struct t_script_callback *new_script_callback3, *new_script_callback4;
|
||||
struct t_script_callback *new_script_callback5;
|
||||
struct t_config_section *new_section;
|
||||
void *callback1, *callback2, *callback3, *callback4;
|
||||
|
||||
void *callback1, *callback2, *callback3, *callback4, *callback5;
|
||||
|
||||
new_script_callback1 = NULL;
|
||||
new_script_callback2 = NULL;
|
||||
new_script_callback3 = NULL;
|
||||
new_script_callback4 = NULL;
|
||||
new_script_callback5 = NULL;
|
||||
callback1 = NULL;
|
||||
callback2 = NULL;
|
||||
callback3 = NULL;
|
||||
callback4 = NULL;
|
||||
callback5 = NULL;
|
||||
|
||||
if (function_read && function_read[0])
|
||||
{
|
||||
@@ -141,7 +149,7 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
|
||||
return NULL;
|
||||
callback1 = callback_read;
|
||||
}
|
||||
|
||||
|
||||
if (function_write && function_write[0])
|
||||
{
|
||||
new_script_callback2 = script_callback_alloc ();
|
||||
@@ -202,6 +210,36 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
|
||||
callback4 = callback_create_option;
|
||||
}
|
||||
|
||||
if (function_delete_option && function_delete_option[0])
|
||||
{
|
||||
new_script_callback5 = script_callback_alloc ();
|
||||
if (!new_script_callback5)
|
||||
{
|
||||
if (new_script_callback1)
|
||||
{
|
||||
script_callback_free_data (new_script_callback1);
|
||||
free (new_script_callback1);
|
||||
}
|
||||
if (new_script_callback2)
|
||||
{
|
||||
script_callback_free_data (new_script_callback2);
|
||||
free (new_script_callback2);
|
||||
}
|
||||
if (new_script_callback3)
|
||||
{
|
||||
script_callback_free_data (new_script_callback3);
|
||||
free (new_script_callback3);
|
||||
}
|
||||
if (new_script_callback4)
|
||||
{
|
||||
script_callback_free_data (new_script_callback4);
|
||||
free (new_script_callback4);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
callback5 = callback_delete_option;
|
||||
}
|
||||
|
||||
new_section = weechat_config_new_section (config_file,
|
||||
name,
|
||||
user_can_add_options,
|
||||
@@ -213,7 +251,9 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
|
||||
callback3,
|
||||
new_script_callback3,
|
||||
callback4,
|
||||
new_script_callback4);
|
||||
new_script_callback4,
|
||||
callback5,
|
||||
new_script_callback5);
|
||||
if (!new_section)
|
||||
{
|
||||
if (new_script_callback1)
|
||||
@@ -236,6 +276,11 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
|
||||
script_callback_free_data (new_script_callback4);
|
||||
free (new_script_callback4);
|
||||
}
|
||||
if (new_script_callback5)
|
||||
{
|
||||
script_callback_free_data (new_script_callback5);
|
||||
free (new_script_callback5);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -275,6 +320,15 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
|
||||
script_callback_add (script, new_script_callback4);
|
||||
}
|
||||
|
||||
if (new_script_callback5)
|
||||
{
|
||||
new_script_callback5->script = script;
|
||||
new_script_callback5->function = strdup (function_delete_option);
|
||||
new_script_callback5->config_file = config_file;
|
||||
new_script_callback5->config_section = new_section;
|
||||
script_callback_add (script, new_script_callback5);
|
||||
}
|
||||
|
||||
return new_section;
|
||||
}
|
||||
|
||||
@@ -734,7 +788,7 @@ script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
int (*callback)(void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
int tags_count, char **tags,
|
||||
int tags_count, const char **tags,
|
||||
const char *prefix,
|
||||
const char *message),
|
||||
const char *function)
|
||||
|
||||
@@ -51,7 +51,12 @@ extern struct t_config_section *script_api_config_new_section (struct t_weechat_
|
||||
struct t_config_section *section,
|
||||
const char *option_name,
|
||||
const char *value),
|
||||
const char *function_create_option);
|
||||
const char *function_create_option,
|
||||
int (*callback_delete_option)(void *data,
|
||||
struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option),
|
||||
const char *function_delete_option);
|
||||
extern struct t_config_option *script_api_config_new_option (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_config_file *config_file,
|
||||
@@ -136,7 +141,7 @@ extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_pl
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
int tags_count,
|
||||
char **tags,
|
||||
const char **tags,
|
||||
const char *prefix,
|
||||
const char *message),
|
||||
const char *function);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user