1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 04:16:38 +02:00

Use of const for some functions returning "char *"

This commit is contained in:
Sebastien Helleu
2008-11-15 22:35:12 +01:00
parent e1d639d7eb
commit 8724fc18af
60 changed files with 895 additions and 290 deletions
+141 -33
View File
@@ -140,8 +140,7 @@ weechat_lua_api_register (lua_State *L)
static int
weechat_lua_api_plugin_get_name (lua_State *L)
{
const char *plugin;
char *result;
const char *plugin, *result;
int n;
/* make C compiler happy */
@@ -293,8 +292,7 @@ weechat_lua_api_iconv_from_internal (lua_State *L)
static int
weechat_lua_api_gettext (lua_State *L)
{
const char *string;
char *result;
const char *string, *result;
int n;
/* make C compiler happy */
@@ -330,8 +328,7 @@ weechat_lua_api_gettext (lua_State *L)
static int
weechat_lua_api_ngettext (lua_State *L)
{
const char *single, *plural;
char *result;
const char *single, *plural, *result;
int n, count;
/* make C compiler happy */
@@ -788,8 +785,7 @@ weechat_lua_api_list_prev (lua_State *L)
static int
weechat_lua_api_list_string (lua_State *L)
{
const char *item;
char *result;
const char *item, *result;
int n;
/* make C compiler happy */
@@ -1848,8 +1844,7 @@ weechat_lua_api_config_integer (lua_State *L)
static int
weechat_lua_api_config_string (lua_State *L)
{
const char *option;
char *result;
const char *option, *result;
int n;
/* make C compiler happy */
@@ -1885,8 +1880,7 @@ weechat_lua_api_config_string (lua_State *L)
static int
weechat_lua_api_config_color (lua_State *L)
{
const char *option;
char *result;
const char *option, *result;
int n;
/* make C compiler happy */
@@ -2148,8 +2142,7 @@ weechat_lua_api_config_get (lua_State *L)
static int
weechat_lua_api_config_get_plugin (lua_State *L)
{
const char *option;
char *result;
const char *option, *result;
int n;
/* make C compiler happy */
@@ -2229,8 +2222,7 @@ weechat_lua_api_config_set_plugin (lua_State *L)
static int
weechat_lua_api_prefix (lua_State *L)
{
const char *prefix;
char *result;
const char *prefix, *result;
int n;
/* make C compiler happy */
@@ -2266,8 +2258,7 @@ weechat_lua_api_prefix (lua_State *L)
static int
weechat_lua_api_color (lua_State *L)
{
const char *color;
char *result;
const char *color, *result;
int n;
/* make C compiler happy */
@@ -3382,7 +3373,7 @@ weechat_lua_api_hook_modifier_exec (lua_State *L)
* weechat_lua_api_hook_info_cb: callback for info hooked
*/
char *
const char *
weechat_lua_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
@@ -3395,10 +3386,10 @@ weechat_lua_api_hook_info_cb (void *data, const char *info_name,
lua_argv[1] = (char *)arguments;
lua_argv[2] = NULL;
return (char *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
return (const char *)weechat_lua_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
lua_argv);
}
/*
@@ -3882,8 +3873,7 @@ weechat_lua_api_buffer_get_integer (lua_State *L)
static int
weechat_lua_api_buffer_get_string (lua_State *L)
{
const char *buffer, *property;
char *result;
const char *buffer, *property, *result;
int n;
/* make C compiler happy */
@@ -3949,8 +3939,8 @@ weechat_lua_api_buffer_get_pointer (lua_State *L)
buffer = lua_tostring (lua_current_interpreter, -2);
property = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_buffer_get_string (script_str2ptr (buffer),
property));
result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer),
property));
LUA_RETURN_STRING_FREE(result);
}
@@ -3994,6 +3984,124 @@ weechat_lua_api_buffer_set (lua_State *L)
LUA_RETURN_OK;
}
/*
* weechat_lua_api_window_get_integer: get a window property as integer
*/
static int
weechat_lua_api_window_get_integer (lua_State *L)
{
const char *window, *property;
int n, value;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer");
LUA_RETURN_INT(-1);
}
window = NULL;
property = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer");
LUA_RETURN_INT(-1);
}
window = lua_tostring (lua_current_interpreter, -2);
property = lua_tostring (lua_current_interpreter, -1);
value = weechat_window_get_integer (script_str2ptr (window),
property);
LUA_RETURN_INT(value);
}
/*
* weechat_lua_api_window_get_string: get a window property as string
*/
static int
weechat_lua_api_window_get_string (lua_State *L)
{
const char *window, *property, *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string");
LUA_RETURN_EMPTY;
}
window = NULL;
property = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string");
LUA_RETURN_EMPTY;
}
window = lua_tostring (lua_current_interpreter, -2);
property = lua_tostring (lua_current_interpreter, -1);
result = weechat_window_get_string (script_str2ptr (window),
property);
LUA_RETURN_STRING(result);
}
/*
* weechat_lua_api_window_get_pointer: get a window property as pointer
*/
static int
weechat_lua_api_window_get_pointer (lua_State *L)
{
const char *window, *property;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer");
LUA_RETURN_EMPTY;
}
window = NULL;
property = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer");
LUA_RETURN_EMPTY;
}
window = lua_tostring (lua_current_interpreter, -2);
property = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (window),
property));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_nicklist_add_group: add a group in nicklist
*/
@@ -4773,8 +4881,7 @@ weechat_lua_api_command (lua_State *L)
static int
weechat_lua_api_info_get (lua_State *L)
{
const char *info_name, *arguments;
char *result;
const char *info_name, *arguments, *result;
int n;
/* make C compiler happy */
@@ -5125,8 +5232,7 @@ weechat_lua_api_infolist_prev (lua_State *L)
static int
weechat_lua_api_infolist_fields (lua_State *L)
{
const char *infolist;
char *result;
const char *infolist, *result;
int n;
/* make C compiler happy */
@@ -5201,8 +5307,7 @@ weechat_lua_api_infolist_integer (lua_State *L)
static int
weechat_lua_api_infolist_string (lua_State *L)
{
const char *infolist, *variable;
char *result;
const char *infolist, *variable, *result;
int n;
/* make C compiler happy */
@@ -5788,6 +5893,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "buffer_get_string", &weechat_lua_api_buffer_get_string },
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
{ "buffer_set", &weechat_lua_api_buffer_set },
{ "window_get_integer", &weechat_lua_api_window_get_integer },
{ "window_get_string", &weechat_lua_api_window_get_string },
{ "window_get_pointer", &weechat_lua_api_window_get_pointer },
{ "nicklist_add_group", &weechat_lua_api_nicklist_add_group },
{ "nicklist_search_group", &weechat_lua_api_nicklist_search_group },
{ "nicklist_add_nick", &weechat_lua_api_nicklist_add_nick },
+119 -18
View File
@@ -130,7 +130,7 @@ static XS (XS_weechat_api_register)
static XS (XS_weechat_api_plugin_get_name)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -251,7 +251,7 @@ static XS (XS_weechat_api_iconv_from_internal)
static XS (XS_weechat_api_gettext)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -280,7 +280,8 @@ static XS (XS_weechat_api_gettext)
static XS (XS_weechat_api_ngettext)
{
char *result, *single, *plural;
char *single, *plural;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -644,7 +645,7 @@ static XS (XS_weechat_api_list_prev)
static XS (XS_weechat_api_list_string)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -1554,7 +1555,7 @@ static XS (XS_weechat_api_config_integer)
static XS (XS_weechat_api_config_string)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -1583,7 +1584,7 @@ static XS (XS_weechat_api_config_string)
static XS (XS_weechat_api_config_color)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -1791,7 +1792,7 @@ static XS (XS_weechat_api_config_get)
static XS (XS_weechat_api_config_get_plugin)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -1857,7 +1858,7 @@ static XS (XS_weechat_api_config_set_plugin)
static XS (XS_weechat_api_prefix)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -1886,7 +1887,7 @@ static XS (XS_weechat_api_prefix)
static XS (XS_weechat_api_color)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -2838,7 +2839,7 @@ static XS (XS_weechat_api_hook_modifier_exec)
* weechat_perl_api_hook_info_cb: callback for info hooked
*/
char *
const char *
weechat_perl_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
@@ -2851,10 +2852,10 @@ weechat_perl_api_hook_info_cb (void *data, const char *info_name,
perl_argv[1] = (char *)arguments;
perl_argv[2] = NULL;
return (char *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
return (const char *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
}
/*
@@ -3272,7 +3273,8 @@ static XS (XS_weechat_api_buffer_get_integer)
static XS (XS_weechat_api_buffer_get_string)
{
char *result, *buffer, *property;
char *buffer, *property;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -3361,6 +3363,102 @@ static XS (XS_weechat_api_buffer_set)
PERL_RETURN_OK;
}
/*
* weechat::window_get_integer: get a window property as integer
*/
static XS (XS_weechat_api_window_get_integer)
{
char *window, *property;
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer");
PERL_RETURN_INT(-1);
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer");
PERL_RETURN_INT(-1);
}
window = SvPV (ST (0), PL_na);
property = SvPV (ST (1), PL_na);
value = weechat_window_get_integer (script_str2ptr (window), property);
PERL_RETURN_INT(value);
}
/*
* weechat::window_get_string: get a window property as string
*/
static XS (XS_weechat_api_window_get_string)
{
char *window, *property;
const char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string");
PERL_RETURN_EMPTY;
}
window = SvPV (ST (0), PL_na);
property = SvPV (ST (1), PL_na);
result = weechat_window_get_string (script_str2ptr (window), property);
PERL_RETURN_STRING(result);
}
/*
* weechat::window_get_pointer: get a window property as pointer
*/
static XS (XS_weechat_api_window_get_pointer)
{
char *result, *window, *property;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer");
PERL_RETURN_EMPTY;
}
window = SvPV (ST (0), PL_na);
property = SvPV (ST (1), PL_na);
result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (window),
property));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::nicklist_add_group: add a group in nicklist
*/
@@ -3981,7 +4079,7 @@ static XS (XS_weechat_api_command)
static XS (XS_weechat_api_info_get)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -4265,7 +4363,7 @@ static XS (XS_weechat_api_infolist_prev)
static XS (XS_weechat_api_infolist_fields)
{
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -4327,7 +4425,7 @@ static XS (XS_weechat_api_infolist_integer)
static XS (XS_weechat_api_infolist_string)
{
char *infolist, *variable;
char *result;
const char *result;
dXSARGS;
/* make C compiler happy */
@@ -4534,6 +4632,9 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::buffer_get_string", XS_weechat_api_buffer_get_string, "weechat");
newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat");
newXS ("weechat::buffer_set", XS_weechat_api_buffer_set, "weechat");
newXS ("weechat::window_get_integer", XS_weechat_api_window_get_integer, "weechat");
newXS ("weechat::window_get_string", XS_weechat_api_window_get_string, "weechat");
newXS ("weechat::window_get_pointer", XS_weechat_api_window_get_pointer, "weechat");
newXS ("weechat::nicklist_add_group", XS_weechat_api_nicklist_add_group, "weechat");
newXS ("weechat::nicklist_search_group", XS_weechat_api_nicklist_search_group, "weechat");
newXS ("weechat::nicklist_add_nick", XS_weechat_api_nicklist_add_nick, "weechat");
+136 -20
View File
@@ -123,7 +123,8 @@ weechat_python_api_register (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_plugin_get_name (PyObject *self, PyObject *args)
{
char *plugin, *result;
char *plugin;
const char *result;
/* make C compiler happy */
(void) self;
@@ -253,7 +254,8 @@ weechat_python_api_iconv_from_internal (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_gettext (PyObject *self, PyObject *args)
{
char *string, *result;
char *string;
const char *result;
/* make C compiler happy */
(void) self;
@@ -284,7 +286,8 @@ weechat_python_api_gettext (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_ngettext (PyObject *self, PyObject *args)
{
char *single, *plural, *result;
char *single, *plural;
const char *result;
int count;
/* make C compiler happy */
@@ -681,7 +684,8 @@ weechat_python_api_list_prev (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_list_string (PyObject *self, PyObject *args)
{
char *item, *result;
char *item;
const char *result;
/* make C compiler happy */
(void) self;
@@ -1641,7 +1645,8 @@ weechat_python_api_config_integer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_config_string (PyObject *self, PyObject *args)
{
char *option, *result;
char *option;
const char *result;
/* make C compiler happy */
(void) self;
@@ -1672,7 +1677,8 @@ weechat_python_api_config_string (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_config_color (PyObject *self, PyObject *args)
{
char *option, *result;
char *option;
const char *result;
/* make C compiler happy */
(void) self;
@@ -1900,7 +1906,8 @@ weechat_python_api_config_get (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_config_get_plugin (PyObject *self, PyObject *args)
{
char *option, *result;
char *option;
const char *result;
/* make C compiler happy */
(void) self;
@@ -1969,7 +1976,8 @@ weechat_python_api_config_set_plugin (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_prefix (PyObject *self, PyObject *args)
{
char *prefix, *result;
char *prefix;
const char *result;
/* make C compiler happy */
(void) self;
@@ -2000,7 +2008,8 @@ weechat_python_api_prefix (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_color (PyObject *self, PyObject *args)
{
char *color, *result;
char *color;
const char *result;
/* make C compiler happy */
(void) self;
@@ -3009,7 +3018,7 @@ weechat_python_api_hook_modifier_exec (PyObject *self, PyObject *args)
* weechat_python_api_hook_info_cb: callback for info hooked
*/
char *
const char *
weechat_python_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
@@ -3022,10 +3031,10 @@ weechat_python_api_hook_info_cb (void *data, const char *info_name,
python_argv[1] = (char *)arguments;
python_argv[2] = NULL;
return (char *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
return (const char *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
}
/*
@@ -3466,7 +3475,8 @@ weechat_python_api_buffer_get_integer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_buffer_get_string (PyObject *self, PyObject *args)
{
char *buffer, *property, *result;
char *buffer, *property;
const char *result;
/* make C compiler happy */
(void) self;
@@ -3560,6 +3570,106 @@ weechat_python_api_buffer_set (PyObject *self, PyObject *args)
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_window_get_integer get a window property as integer
*/
static PyObject *
weechat_python_api_window_get_integer (PyObject *self, PyObject *args)
{
char *window, *property;
int value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer");
PYTHON_RETURN_INT(-1);
}
window = NULL;
property = NULL;
if (!PyArg_ParseTuple (args, "ss", &window, &property))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer");
PYTHON_RETURN_INT(-1);
}
value = weechat_window_get_integer (script_str2ptr (window), property);
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_window_get_string: get a window property as string
*/
static PyObject *
weechat_python_api_window_get_string (PyObject *self, PyObject *args)
{
char *window, *property;
const char *result;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string");
PYTHON_RETURN_ERROR;
}
window = NULL;
property = NULL;
if (!PyArg_ParseTuple (args, "ss", &window, &property))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string");
PYTHON_RETURN_EMPTY;
}
result = weechat_window_get_string (script_str2ptr (window), property);
PYTHON_RETURN_STRING(result);
}
/*
* weechat_python_api_window_get_pointer: get a window property as pointer
*/
static PyObject *
weechat_python_api_window_get_pointer (PyObject *self, PyObject *args)
{
char *window, *property, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer");
PYTHON_RETURN_ERROR;
}
window = NULL;
property = NULL;
if (!PyArg_ParseTuple (args, "ss", &window, &property))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (window),
property));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_nicklist_add_group: add a group in nicklist
*/
@@ -4229,7 +4339,8 @@ weechat_python_api_command (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_info_get (PyObject *self, PyObject *args)
{
char *info_name, *arguments, *result;
char *info_name, *arguments;
const char *result;
/* make C compiler happy */
(void) self;
@@ -4535,7 +4646,8 @@ weechat_python_api_infolist_prev (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_fields (PyObject *self, PyObject *args)
{
char *infolist, *result;
char *infolist;
const char *result;
/* make C compiler happy */
(void) self;
@@ -4600,7 +4712,8 @@ weechat_python_api_infolist_integer (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_infolist_string (PyObject *self, PyObject *args)
{
char *infolist, *variable, *result;
char *infolist, *variable;
const char *result;
/* make C compiler happy */
(void) self;
@@ -4654,8 +4767,8 @@ weechat_python_api_infolist_pointer (PyObject *self, PyObject *args)
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_infolist_string (script_str2ptr (infolist),
variable));
result = script_ptr2str (weechat_infolist_pointer (script_str2ptr (infolist),
variable));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -4810,6 +4923,9 @@ PyMethodDef weechat_python_funcs[] =
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
{ "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" },
{ "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" },
{ "window_get_pointer", &weechat_python_api_window_get_pointer, METH_VARARGS, "" },
{ "nicklist_add_group", &weechat_python_api_nicklist_add_group, METH_VARARGS, "" },
{ "nicklist_search_group", &weechat_python_api_nicklist_search_group, METH_VARARGS, "" },
{ "nicklist_add_nick", &weechat_python_api_nicklist_add_nick, METH_VARARGS, "" },
+6 -5
View File
@@ -263,7 +263,8 @@ weechat_python_load (const char *filename)
PyThreadState *python_current_interpreter;
PyObject *weechat_module, *weechat_outputs, *weechat_dict;
PyObject *python_path, *path;
char *w_home, *p_home;
const char *weechat_home;
char *p_home;
int len;
if ((fp = fopen (filename, "r")) == NULL)
@@ -315,14 +316,14 @@ weechat_python_load (const char *filename)
/* adding $weechat_dir/python in $PYTHONPATH */
python_path = PySys_GetObject ("path");
w_home = weechat_info_get ("weechat_dir", "");
if (w_home)
weechat_home = weechat_info_get ("weechat_dir", "");
if (weechat_home)
{
len = strlen (w_home) + 1 + strlen(PYTHON_PLUGIN_NAME) + 1;
len = strlen (weechat_home) + 1 + strlen(PYTHON_PLUGIN_NAME) + 1;
p_home = malloc (len);
if (p_home)
{
snprintf (p_home, len, "%s/python", w_home);
snprintf (p_home, len, "%s/python", weechat_home);
path = PyString_FromString (p_home);
if (path != NULL)
{
+150 -23
View File
@@ -141,7 +141,8 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author,
static VALUE
weechat_ruby_api_plugin_get_name (VALUE class, VALUE plugin)
{
char *c_plugin, *result;
char *c_plugin;
const char *result;
/* make C compiler happy */
(void) class;
@@ -290,7 +291,8 @@ weechat_ruby_api_iconv_from_internal (VALUE class, VALUE charset, VALUE string)
static VALUE
weechat_ruby_api_gettext (VALUE class, VALUE string)
{
char *c_string, *result;
char *c_string;
const char *result;
/* make C compiler happy */
(void) class;
@@ -326,7 +328,8 @@ static VALUE
weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural,
VALUE count)
{
char *c_single, *c_plural, *result;
char *c_single, *c_plural;
const char *result;
int c_count;
/* make C compiler happy */
@@ -782,7 +785,8 @@ weechat_ruby_api_list_prev (VALUE class, VALUE item)
static VALUE
weechat_ruby_api_list_string (VALUE class, VALUE item)
{
char *c_item, *result;
char *c_item;
const char *result;
/* make C compiler happy */
(void) class;
@@ -1889,7 +1893,8 @@ weechat_ruby_api_config_integer (VALUE class, VALUE option)
static VALUE
weechat_ruby_api_config_string (VALUE class, VALUE option)
{
char *c_option, *result;
char *c_option;
const char *result;
/* make C compiler happy */
(void) class;
@@ -1924,7 +1929,8 @@ weechat_ruby_api_config_string (VALUE class, VALUE option)
static VALUE
weechat_ruby_api_config_color (VALUE class, VALUE option)
{
char *c_option, *result;
char *c_option;
const char *result;
/* make C compiler happy */
(void) class;
@@ -2183,7 +2189,8 @@ weechat_ruby_api_config_get (VALUE class, VALUE option)
static VALUE
weechat_ruby_api_config_get_plugin (VALUE class, VALUE option)
{
char *c_option, *result;
char *c_option;
const char *result;
/* make C compiler happy */
(void) class;
@@ -2257,7 +2264,8 @@ weechat_ruby_api_config_set_plugin (VALUE class, VALUE option, VALUE value)
static VALUE
weechat_ruby_api_prefix (VALUE class, VALUE prefix)
{
char *c_prefix, *result;
char *c_prefix;
const char *result;
/* make C compiler happy */
(void) class;
@@ -2292,7 +2300,8 @@ weechat_ruby_api_prefix (VALUE class, VALUE prefix)
static VALUE
weechat_ruby_api_color (VALUE class, VALUE color)
{
char *c_color, *result;
char *c_color;
const char *result;
/* make C compiler happy */
(void) class;
@@ -3457,7 +3466,7 @@ weechat_ruby_api_hook_modifier_exec (VALUE class, VALUE modifier,
* weechat_ruby_api_hook_info_cb: callback for info hooked
*/
char *
const char *
weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
@@ -3470,10 +3479,10 @@ weechat_ruby_api_hook_info_cb (void *data, const char *info_name,
ruby_argv[1] = (char *)arguments;
ruby_argv[2] = NULL;
return (char *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
return (const char *)weechat_ruby_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
ruby_argv);
}
/*
@@ -3964,7 +3973,8 @@ weechat_ruby_api_buffer_get_integer (VALUE class, VALUE buffer, VALUE property)
static VALUE
weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property)
{
char *c_buffer, *c_property, *result;
char *c_buffer, *c_property;
const char *result;
/* make C compiler happy */
(void) class;
@@ -4024,8 +4034,8 @@ weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property)
c_buffer = STR2CSTR (buffer);
c_property = STR2CSTR (property);
result = script_ptr2str (weechat_buffer_get_string (script_str2ptr (c_buffer),
c_property));
result = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (c_buffer),
c_property));
RUBY_RETURN_STRING_FREE(result);
}
@@ -4070,6 +4080,117 @@ weechat_ruby_api_buffer_set (VALUE class, VALUE buffer, VALUE property,
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_window_get_integer: get a window property as integer
*/
static VALUE
weechat_ruby_api_window_get_integer (VALUE class, VALUE window, VALUE property)
{
char *c_window, *c_property;
int value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer");
RUBY_RETURN_INT(-1);
}
if (NIL_P (window) || NIL_P (property))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer");
RUBY_RETURN_INT(-1);
}
Check_Type (window, T_STRING);
Check_Type (property, T_STRING);
c_window = STR2CSTR (window);
c_property = STR2CSTR (property);
value = weechat_window_get_integer (script_str2ptr (c_window),
c_property);
RUBY_RETURN_INT(value);
}
/*
* weechat_ruby_api_window_get_string: get a window property as string
*/
static VALUE
weechat_ruby_api_window_get_string (VALUE class, VALUE window, VALUE property)
{
char *c_window, *c_property;
const char *result;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string");
RUBY_RETURN_EMPTY;
}
if (NIL_P (window) || NIL_P (property))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string");
RUBY_RETURN_EMPTY;
}
Check_Type (window, T_STRING);
Check_Type (property, T_STRING);
c_window = STR2CSTR (window);
c_property = STR2CSTR (property);
result = weechat_window_get_string (script_str2ptr (c_window),
c_property);
RUBY_RETURN_STRING(result);
}
/*
* weechat_ruby_api_window_get_pointer: get a window property as pointer
*/
static VALUE
weechat_ruby_api_window_get_pointer (VALUE class, VALUE window, VALUE property)
{
char *c_window, *c_property, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer");
RUBY_RETURN_EMPTY;
}
if (NIL_P (window) || NIL_P (property))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer");
RUBY_RETURN_EMPTY;
}
Check_Type (window, T_STRING);
Check_Type (property, T_STRING);
c_window = STR2CSTR (window);
c_property = STR2CSTR (property);
result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (c_window),
c_property));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_nicklist_add_group: add a group in nicklist
*/
@@ -4865,7 +4986,8 @@ weechat_ruby_api_command (VALUE class, VALUE buffer, VALUE command)
static VALUE
weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments)
{
char *c_info_name, *c_arguments, *result;
char *c_info_name, *c_arguments;
const char *result;
/* make C compiler happy */
(void) class;
@@ -5037,9 +5159,9 @@ weechat_ruby_api_infolist_new_var_pointer (VALUE class, VALUE infolist,
c_name = STR2CSTR (name);
c_value = STR2CSTR (value);
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (c_infolist),
c_name,
script_str2ptr (c_value)));
result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (c_infolist),
c_name,
script_str2ptr (c_value)));
RUBY_RETURN_STRING_FREE(result);
}
@@ -5202,7 +5324,8 @@ weechat_ruby_api_infolist_prev (VALUE class, VALUE infolist)
static VALUE
weechat_ruby_api_infolist_fields (VALUE class, VALUE infolist)
{
char *c_infolist, *result;
char *c_infolist;
const char *result;
/* make C compiler happy */
(void) class;
@@ -5271,7 +5394,8 @@ weechat_ruby_api_infolist_integer (VALUE class, VALUE infolist, VALUE variable)
static VALUE
weechat_ruby_api_infolist_string (VALUE class, VALUE infolist, VALUE variable)
{
char *c_infolist, *c_variable, *result;
char *c_infolist, *c_variable;
const char *result;
/* make C compiler happy */
(void) class;
@@ -5531,6 +5655,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2);
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3);
rb_define_module_function (ruby_mWeechat, "window_get_integer", &weechat_ruby_api_window_get_integer, 2);
rb_define_module_function (ruby_mWeechat, "window_get_string", &weechat_ruby_api_window_get_string, 2);
rb_define_module_function (ruby_mWeechat, "window_get_pointer", &weechat_ruby_api_window_get_pointer, 2);
rb_define_module_function (ruby_mWeechat, "nicklist_add_group", &weechat_ruby_api_nicklist_add_group, 5);
rb_define_module_function (ruby_mWeechat, "nicklist_search_group", &weechat_ruby_api_nicklist_search_group, 3);
rb_define_module_function (ruby_mWeechat, "nicklist_add_nick", &weechat_ruby_api_nicklist_add_nick, 7);
+6 -5
View File
@@ -980,9 +980,9 @@ script_api_hook_info (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *info_name,
const char *description,
char *(*callback)(void *data,
const char *info_name,
const char *arguments),
const char *(*callback)(void *data,
const char *info_name,
const char *arguments),
const char *function)
{
struct t_script_callback *new_script_callback;
@@ -1316,12 +1316,13 @@ script_api_command (struct t_weechat_plugin *weechat_plugin,
* format in file is: plugin.script.option = value
*/
char *
const char *
script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option)
{
char *option_fullname, *return_value;
char *option_fullname;
const char *return_value;
option_fullname = malloc ((strlen (script->name) +
strlen (option) + 2));
+6 -6
View File
@@ -180,9 +180,9 @@ extern struct t_hook *script_api_hook_info (struct t_weechat_plugin *weechat_plu
struct t_plugin_script *script,
const char *info_name,
const char *description,
char *(*callback)(void *data,
const char *info_name,
const char *arguments),
const char *(*callback)(void *data,
const char *info_name,
const char *arguments),
const char *function);
extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
@@ -227,9 +227,9 @@ extern void script_api_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
const char *command);
extern char *script_api_config_get_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option);
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_set_plugin (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *option, const char *value);
+5 -3
View File
@@ -44,7 +44,7 @@ int script_option_check_license = 0;
void
script_config_read (struct t_weechat_plugin *weechat_plugin)
{
char *string;
const char *string;
string = weechat_config_get_plugin (SCRIPT_OPTION_CHECK_LICENSE);
if (!string)
@@ -210,7 +210,8 @@ void
script_auto_load (struct t_weechat_plugin *weechat_plugin,
void (*callback)(void *data, const char *filename))
{
char *dir_home, *dir_name;
const char *dir_home;
char *dir_name;
int dir_length;
/* build directory, adding WeeChat home */
@@ -258,7 +259,8 @@ char *
script_search_full_name (struct t_weechat_plugin *weechat_plugin,
const char *filename)
{
char *final_name, *dir_home, *dir_system;
char *final_name;
const char *dir_home, *dir_system;
int length;
struct stat st;
+143 -25
View File
@@ -229,9 +229,10 @@ weechat_tcl_api_plugin_get_name (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
char *result, *plugin;
char *plugin;
const char *result;
int i;
/* make C compiler happy */
(void) clientData;
@@ -365,9 +366,9 @@ weechat_tcl_api_gettext (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
(void) clientData;
@@ -397,7 +398,8 @@ weechat_tcl_api_ngettext (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
char *result, *single, *plural;
char *single, *plural;
const char *result;
int i, count;
/* make C compiler happy */
@@ -828,9 +830,9 @@ weechat_tcl_api_list_string (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
(void) clientData;
@@ -1823,7 +1825,7 @@ weechat_tcl_api_config_string (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -1855,7 +1857,7 @@ weechat_tcl_api_config_color (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -2084,7 +2086,7 @@ weechat_tcl_api_config_get_plugin (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -2156,7 +2158,7 @@ weechat_tcl_api_prefix (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -2188,7 +2190,7 @@ weechat_tcl_api_color (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -3248,7 +3250,7 @@ weechat_tcl_api_hook_modifier_exec (ClientData clientData, Tcl_Interp *interp,
* weechat_tcl_api_hook_info_cb: callback for info hooked
*/
char *
const char *
weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
const char *arguments)
{
@@ -3261,10 +3263,10 @@ weechat_tcl_api_hook_info_cb (void *data, const char *info_name,
tcl_argv[1] = (char *)arguments;
tcl_argv[2] = NULL;
return (char *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
tcl_argv);
return (const char *)weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
tcl_argv);
}
/*
@@ -3722,7 +3724,8 @@ weechat_tcl_api_buffer_get_string (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result, *buffer, *property;
char *buffer, *property;
const char *result;
int i;
/* make C compiler happy */
@@ -3757,7 +3760,7 @@ weechat_tcl_api_buffer_get_pointer (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result, *buffer, *property;
char *buffer, *property, *result;
int i;
/* make C compiler happy */
@@ -3820,6 +3823,114 @@ weechat_tcl_api_buffer_set (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_OK;
}
/*
* weechat_tcl_api_window_get_integer: get a window property as integer
*/
static int
weechat_tcl_api_window_get_integer (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *window, *property;
int result;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_integer");
TCL_RETURN_INT(-1);
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_integer");
TCL_RETURN_INT(-1);
}
window = Tcl_GetStringFromObj (objv[1], &i);
property = Tcl_GetStringFromObj (objv[2], &i);
result = weechat_window_get_integer (script_str2ptr (window), property);
TCL_RETURN_INT(result);
}
/*
* weechat_tcl_api_window_get_string: get a window property as string
*/
static int
weechat_tcl_api_window_get_string (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *window, *property;
const char *result;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_string");
TCL_RETURN_EMPTY;
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_string");
TCL_RETURN_EMPTY;
}
window = Tcl_GetStringFromObj (objv[1], &i);
property = Tcl_GetStringFromObj (objv[2], &i);
result = weechat_window_get_string (script_str2ptr (window), property);
TCL_RETURN_STRING(result);
}
/*
* weechat_tcl_api_window_get_pointer: get a window property as pointer
*/
static int
weechat_tcl_api_window_get_pointer (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *window, *property, *result;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("window_get_pointer");
TCL_RETURN_EMPTY;
}
if (objc < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("window_get_pointer");
TCL_RETURN_EMPTY;
}
window = Tcl_GetStringFromObj (objv[1], &i);
property = Tcl_GetStringFromObj (objv[2], &i);
result = script_ptr2str (weechat_window_get_pointer (script_str2ptr (window),
property));
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_nicklist_add_group: add a group in nicklist
*/
@@ -4507,7 +4618,7 @@ weechat_tcl_api_info_get (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -4661,9 +4772,9 @@ weechat_tcl_api_infolist_new_var_pointer (ClientData clientData, Tcl_Interp *int
TCL_RETURN_INT(0);
}
result = script_ptr2str (weechat_infolist_new_var_string (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)), /* infolist */
Tcl_GetStringFromObj (objv[2], &i), /* name */
script_str2ptr (Tcl_GetStringFromObj (objv[3], &i)))); /* value */
result = script_ptr2str (weechat_infolist_new_var_pointer (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)), /* infolist */
Tcl_GetStringFromObj (objv[2], &i), /* name */
script_str2ptr (Tcl_GetStringFromObj (objv[3], &i)))); /* value */
TCL_RETURN_STRING_FREE(result);
}
@@ -4818,7 +4929,7 @@ weechat_tcl_api_infolist_fields (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result;
const char *result;
int i;
/* make C compiler happy */
@@ -4886,7 +4997,8 @@ weechat_tcl_api_infolist_string (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *infolist, *variable, *result;
char *infolist, *variable;
const char *result;
int i;
/* make C compiler happy */
@@ -5271,6 +5383,12 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
weechat_tcl_api_buffer_get_pointer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::buffer_set",
weechat_tcl_api_buffer_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::window_get_integer",
weechat_tcl_api_window_get_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::window_get_string",
weechat_tcl_api_window_get_string, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::window_get_pointer",
weechat_tcl_api_window_get_pointer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::nicklist_add_group",
weechat_tcl_api_nicklist_add_group, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::nicklist_search_group",