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

Add hook type "command_run", add new function "string_remove_color" in plugin API (task #9089)

This commit is contained in:
Sebastien Helleu
2009-02-08 19:52:16 +01:00
parent a253398165
commit 29bc0276bc
25 changed files with 1153 additions and 205 deletions
+129
View File
@@ -361,6 +361,43 @@ weechat_lua_api_ngettext (lua_State *L)
LUA_RETURN_STRING(result);
}
/*
* weechat_lua_api_string_remove_color: remove WeeChat color codes from string
*/
static int
weechat_lua_api_string_remove_color (lua_State *L)
{
const char *string;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color");
LUA_RETURN_EMPTY;
}
string = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
LUA_RETURN_EMPTY;
}
string = lua_tostring (lua_current_interpreter, -1);
result = weechat_string_remove_color (string);
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2739,6 +2776,85 @@ weechat_lua_api_hook_command (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_command_run_cb: callback for command_run hooked
*/
int
weechat_lua_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *lua_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
lua_argv[0] = script_ptr2str (buffer);
lua_argv[1] = (char *)command;
lua_argv[2] = 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]);
return ret;
}
/*
* weechat_lua_api_hook_command_run: hook a command_run
*/
static int
weechat_lua_api_hook_command_run (lua_State *L)
{
const char *command, *function;
char *result;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run");
LUA_RETURN_EMPTY;
}
command = NULL;
function = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run");
LUA_RETURN_EMPTY;
}
command = lua_tostring (lua_current_interpreter, -2);
function = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (script_api_hook_command_run (weechat_lua_plugin,
lua_current_script,
command,
&weechat_lua_api_hook_command_run_cb,
function));
LUA_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hook_timer_cb: callback for timer hooked
*/
@@ -5689,6 +5805,16 @@ weechat_lua_api_constant_weechat_rc_ok (lua_State *L)
return 1;
}
static int
weechat_lua_api_constant_weechat_rc_ok_eat (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK_EAT);
return 1;
}
static int
weechat_lua_api_constant_weechat_rc_error (lua_State *L)
{
@@ -6041,6 +6167,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "iconv_from_internal", &weechat_lua_api_iconv_from_internal },
{ "gettext", &weechat_lua_api_gettext },
{ "ngettext", &weechat_lua_api_ngettext },
{ "string_remove_color", &weechat_lua_api_string_remove_color },
{ "mkdir_home", &weechat_lua_api_mkdir_home },
{ "mkdir", &weechat_lua_api_mkdir },
{ "mkdir_parents", &weechat_lua_api_mkdir_parents },
@@ -6091,6 +6218,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "print_y", &weechat_lua_api_print_y },
{ "log_print", &weechat_lua_api_log_print },
{ "hook_command", &weechat_lua_api_hook_command },
{ "hook_command_run", &weechat_lua_api_hook_command_run },
{ "hook_timer", &weechat_lua_api_hook_timer },
{ "hook_fd", &weechat_lua_api_hook_fd },
{ "hook_connect", &weechat_lua_api_hook_connect },
@@ -6155,6 +6283,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
/* define constants as function which returns values */
{ "WEECHAT_RC_OK", &weechat_lua_api_constant_weechat_rc_ok },
{ "WEECHAT_RC_OK_EAT", &weechat_lua_api_constant_weechat_rc_ok_eat },
{ "WEECHAT_RC_ERROR", &weechat_lua_api_constant_weechat_rc_error },
{ "WEECHAT_CONFIG_READ_OK", &weechat_lua_api_constant_weechat_config_read_ok },
+104
View File
@@ -307,6 +307,36 @@ static XS (XS_weechat_api_ngettext)
PERL_RETURN_STRING(result);
}
/*
* weechat::string_remove_color: remove WeeChat color codes from string
*/
static XS (XS_weechat_api_string_remove_color)
{
char *result, *string;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
PERL_RETURN_EMPTY;
}
string = SvPV (ST (0), PL_na);
result = weechat_string_remove_color (string);
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::mkdir_home: create a directory in WeeChat home
*/
@@ -2281,6 +2311,77 @@ static XS (XS_weechat_api_hook_command)
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_hook_command_run_cb: callback for command_run hooked
*/
int
weechat_perl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *perl_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
perl_argv[0] = script_ptr2str (buffer);
perl_argv[1] = (char *)command;
perl_argv[2] = 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]);
return ret;
}
/*
* weechat::hook_command_run: hook a command_run
*/
static XS (XS_weechat_api_hook_command_run)
{
char *result, *command, *function;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run");
PERL_RETURN_EMPTY;
}
command = SvPV (ST (0), PL_na);
function = SvPV (ST (1), PL_na);
result = script_ptr2str (script_api_hook_command_run (weechat_perl_plugin,
perl_current_script,
command,
&weechat_perl_api_hook_command_run_cb,
function));
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_hook_timer_cb: callback for timer hooked
*/
@@ -4750,6 +4851,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::iconv_from_internal", XS_weechat_api_iconv_from_internal, "weechat");
newXS ("weechat::gettext", XS_weechat_api_gettext, "weechat");
newXS ("weechat::ngettext", XS_weechat_api_ngettext, "weechat");
newXS ("weechat::string_remove_color", XS_weechat_api_string_remove_color, "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");
@@ -4800,6 +4902,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::print_y", XS_weechat_api_print_y, "weechat");
newXS ("weechat::log_print", XS_weechat_api_log_print, "weechat");
newXS ("weechat::hook_command", XS_weechat_api_hook_command, "weechat");
newXS ("weechat::hook_command_run", XS_weechat_api_hook_command_run, "weechat");
newXS ("weechat::hook_timer", XS_weechat_api_hook_timer, "weechat");
newXS ("weechat::hook_fd", XS_weechat_api_hook_fd, "weechat");
newXS ("weechat::hook_connect", XS_weechat_api_hook_connect, "weechat");
@@ -4864,6 +4967,7 @@ weechat_perl_api_init (pTHX)
/* interface constants */
stash = gv_stashpv ("weechat", TRUE);
newCONSTSUB (stash, "weechat::WEECHAT_RC_OK", newSViv (WEECHAT_RC_OK));
newCONSTSUB (stash, "weechat::WEECHAT_RC_OK_EAT", newSViv (WEECHAT_RC_OK_EAT));
newCONSTSUB (stash, "weechat::WEECHAT_RC_ERROR", newSViv (WEECHAT_RC_ERROR));
newCONSTSUB (stash, "weechat::WEECHAT_CONFIG_READ_OK", newSViv (WEECHAT_CONFIG_READ_OK));
@@ -314,6 +314,38 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING(result);
}
/*
* weechat_python_api_string_remove_color: remove WeeChat color codes from string
*/
static PyObject *
weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
{
char *string, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color");
PYTHON_RETURN_EMPTY;
}
string = NULL;
if (!PyArg_ParseTuple (args, "s", &string))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
PYTHON_RETURN_EMPTY;
}
result = weechat_string_remove_color (string);
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2429,6 +2461,79 @@ weechat_python_api_hook_command (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_command_run_cb: callback for command_run hooked
*/
int
weechat_python_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *python_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
python_argv[0] = script_ptr2str (buffer);
python_argv[1] = (char *)command;
python_argv[2] = 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]);
return ret;
}
/*
* weechat_python_api_hook_command_run: hook a command_run
*/
static PyObject *
weechat_python_api_hook_command_run (PyObject *self, PyObject *args)
{
char *command, *function, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run");
PYTHON_RETURN_EMPTY;
}
command = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "ss", &command, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (script_api_hook_command_run (weechat_python_plugin,
python_current_script,
command,
&weechat_python_api_hook_command_run_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hook_timer_cb: callback for timer hooked
*/
@@ -5049,6 +5154,7 @@ PyMethodDef weechat_python_funcs[] =
{ "iconv_from_internal", &weechat_python_api_iconv_from_internal, METH_VARARGS, "" },
{ "gettext", &weechat_python_api_gettext, METH_VARARGS, "" },
{ "ngettext", &weechat_python_api_ngettext, METH_VARARGS, "" },
{ "string_remove_color", &weechat_python_api_string_remove_color, 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, "" },
@@ -5099,6 +5205,7 @@ PyMethodDef weechat_python_funcs[] =
{ "prnt_y", &weechat_python_api_prnt_y, METH_VARARGS, "" },
{ "log_print", &weechat_python_api_log_print, METH_VARARGS, "" },
{ "hook_command", &weechat_python_api_hook_command, METH_VARARGS, "" },
{ "hook_command_run", &weechat_python_api_hook_command_run, METH_VARARGS, "" },
{ "hook_timer", &weechat_python_api_hook_timer, METH_VARARGS, "" },
{ "hook_fd", &weechat_python_api_hook_fd, METH_VARARGS, "" },
{ "hook_connect", &weechat_python_api_hook_connect, METH_VARARGS, "" },
@@ -356,6 +356,7 @@ weechat_python_load (const char *filename)
/* define some constants */
weechat_dict = PyModule_GetDict(weechat_module);
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK", PyInt_FromLong((long) WEECHAT_RC_OK));
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_EAT", PyInt_FromLong((long) WEECHAT_RC_OK_EAT));
PyDict_SetItemString(weechat_dict, "WEECHAT_RC_ERROR", PyInt_FromLong((long) WEECHAT_RC_ERROR));
PyDict_SetItemString(weechat_dict, "WEECHAT_CONFIG_READ_OK", PyInt_FromLong((long) WEECHAT_CONFIG_READ_OK));
+118
View File
@@ -364,6 +364,42 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural,
RUBY_RETURN_STRING(result);
}
/*
* weechat_ruby_api_string_remove_color: remove WeeChat color codes from string
*/
static VALUE
weechat_ruby_api_string_remove_color (VALUE class, VALUE string)
{
char *c_string, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color");
RUBY_RETURN_EMPTY;
}
c_string = NULL;
if (NIL_P (string))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
RUBY_RETURN_EMPTY;
}
Check_Type (string, T_STRING);
c_string = STR2CSTR (string);
result = weechat_string_remove_color (c_string);
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2795,6 +2831,85 @@ weechat_ruby_api_hook_command (VALUE class, VALUE command, VALUE description,
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_command_run_cb: callback for command_run hooked
*/
int
weechat_ruby_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *ruby_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
ruby_argv[0] = script_ptr2str (buffer);
ruby_argv[1] = (char *)command;
ruby_argv[2] = 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]);
return ret;
}
/*
* weechat_ruby_api_hook_command_run: hook a command_run
*/
static VALUE
weechat_ruby_api_hook_command_run (VALUE class, VALUE command, VALUE function)
{
char *c_command, *c_function, *result;
VALUE return_value;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run");
RUBY_RETURN_EMPTY;
}
c_command = NULL;
c_function = NULL;
if (NIL_P (command) || NIL_P (function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run");
RUBY_RETURN_EMPTY;
}
Check_Type (command, T_STRING);
Check_Type (function, T_STRING);
c_command = STR2CSTR (command);
c_function = STR2CSTR (function);
result = script_ptr2str (script_api_hook_command_run (weechat_ruby_plugin,
ruby_current_script,
c_command,
&weechat_ruby_api_hook_command_run_cb,
c_function));
RUBY_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hook_timer_cb: callback for timer hooked
*/
@@ -5757,6 +5872,7 @@ void
weechat_ruby_api_init (VALUE ruby_mWeechat)
{
rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK", INT2NUM(WEECHAT_RC_OK));
rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK_EAT", INT2NUM(WEECHAT_RC_OK_EAT));
rb_define_const(ruby_mWeechat, "WEECHAT_RC_ERROR", INT2NUM(WEECHAT_RC_ERROR));
rb_define_const(ruby_mWeechat, "WEECHAT_CONFIG_READ_OK", INT2NUM(WEECHAT_CONFIG_READ_OK));
@@ -5804,6 +5920,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "iconv_from_internal", &weechat_ruby_api_iconv_from_internal, 2);
rb_define_module_function (ruby_mWeechat, "gettext", &weechat_ruby_api_gettext, 1);
rb_define_module_function (ruby_mWeechat, "ngettext", &weechat_ruby_api_ngettext, 3);
rb_define_module_function (ruby_mWeechat, "string_remove_color", &weechat_ruby_api_string_remove_color, 1);
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);
@@ -5854,6 +5971,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "print_y", &weechat_ruby_api_print_y, 3);
rb_define_module_function (ruby_mWeechat, "log_print", &weechat_ruby_api_log_print, 1);
rb_define_module_function (ruby_mWeechat, "hook_command", &weechat_ruby_api_hook_command, 6);
rb_define_module_function (ruby_mWeechat, "hook_command_run", &weechat_ruby_api_hook_command_run, 2);
rb_define_module_function (ruby_mWeechat, "hook_timer", &weechat_ruby_api_hook_timer, 4);
rb_define_module_function (ruby_mWeechat, "hook_fd", &weechat_ruby_api_hook_fd, 5);
rb_define_module_function (ruby_mWeechat, "hook_connect", &weechat_ruby_api_hook_connect, 7);
+39
View File
@@ -663,6 +663,45 @@ script_api_hook_command (struct t_weechat_plugin *weechat_plugin,
return new_hook;
}
/*
* script_api_hook_command_run: hook a command_run
* return new hook, NULL if error
*/
struct t_hook *
script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *command,
int (*callback)(void *data,
struct t_gui_buffer *buffer,
const char *command),
const char *function)
{
struct t_script_callback *new_script_callback;
struct t_hook *new_hook;
new_script_callback = script_callback_alloc ();
if (!new_script_callback)
return NULL;
new_hook = weechat_hook_command_run (command,
callback, new_script_callback);
if (!new_hook)
{
script_callback_free_data (new_script_callback);
free (new_script_callback);
return NULL;
}
new_script_callback->script = script;
new_script_callback->function = strdup (function);
new_script_callback->hook = new_hook;
script_callback_add (script, new_script_callback);
return new_hook;
}
/*
* script_api_hook_timer: hook a timer
* return new hook, NULL if error
+7
View File
@@ -108,6 +108,13 @@ extern struct t_hook *script_api_hook_command (struct t_weechat_plugin *weechat_
int argc, char **argv,
char **argv_eol),
const char *function);
extern struct t_hook *script_api_hook_command_run (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *command,
int (*callback)(void *data,
struct t_gui_buffer *buffer,
const char *command),
const char *function);
extern struct t_hook *script_api_hook_timer (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
int interval, int align_second,
+113
View File
@@ -431,6 +431,39 @@ weechat_tcl_api_ngettext (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING(result);
}
/*
* weechat_tcl_api_string_remove_color: remove WeeChat color codes from string
*/
static int
weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
char *result, *string;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("string_remove_color");
TCL_RETURN_EMPTY;
}
if (objc < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
TCL_RETURN_EMPTY;
}
string = Tcl_GetStringFromObj (objv[1], &i);
result = weechat_string_remove_color (string);
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_mkdir_home: create a directory in WeeChat home
*/
@@ -2635,6 +2668,80 @@ weechat_tcl_api_hook_command (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_hook_command_run_cb: callback for command_run hooked
*/
int
weechat_tcl_api_hook_command_run_cb (void *data, struct t_gui_buffer *buffer,
const char *command)
{
struct t_script_callback *script_callback;
char *tcl_argv[3];
int *rc, ret;
script_callback = (struct t_script_callback *)data;
tcl_argv[0] = script_ptr2str (buffer);
tcl_argv[1] = (char *)command;
tcl_argv[2] = NULL;
rc = (int *) weechat_tcl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_INT,
script_callback->function,
tcl_argv);
if (!rc)
ret = WEECHAT_RC_ERROR;
else
{
ret = *rc;
free (rc);
}
if (tcl_argv[0])
free (tcl_argv[0]);
return ret;
}
/*
* weechat_tcl_api_hook_command_run: hook a command_run
*/
static int
weechat_tcl_api_hook_command_run (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj *objp;
char *result, *command, *function;
int i;
/* make C compiler happy */
(void) clientData;
if (!tcl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("hook_command_run");
TCL_RETURN_EMPTY;
}
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_command_run");
TCL_RETURN_EMPTY;
}
command = Tcl_GetStringFromObj (objv[1], &i);
function = Tcl_GetStringFromObj (objv[2], &i);
result = script_ptr2str (script_api_hook_command_run (weechat_tcl_plugin,
tcl_current_script,
command,
&weechat_tcl_api_hook_command_run_cb,
function));
TCL_RETURN_STRING_FREE(result);
}
/*
* weechat_tcl_api_hook_timer_cb: callback for timer hooked
*/
@@ -5353,6 +5460,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
Tcl_IncrRefCount (objp);
Tcl_SetVar (interp, "weechat::WEECHAT_RC_OK", Tcl_GetStringFromObj (objp, &i),0);
Tcl_SetIntObj (objp,WEECHAT_RC_OK_EAT);
Tcl_SetVar (interp, "weechat::WEECHAT_RC_OK_EAT", Tcl_GetStringFromObj (objp, &i),0);
Tcl_SetIntObj (objp,WEECHAT_RC_ERROR);
Tcl_SetVar (interp, "weechat::WEECHAT_RC_ERROR", Tcl_GetStringFromObj (objp, &i),0);
@@ -5444,6 +5553,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
weechat_tcl_api_gettext, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::ngettext",
weechat_tcl_api_ngettext, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::string_remove_color",
weechat_tcl_api_string_remove_color, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::mkdir_home",
weechat_tcl_api_mkdir_home, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::mkdir",
@@ -5544,6 +5655,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
weechat_tcl_api_log_print, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::hook_command",
weechat_tcl_api_hook_command, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::hook_command_run",
weechat_tcl_api_hook_command_run, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::hook_timer",
weechat_tcl_api_hook_timer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp,"weechat::hook_fd",