diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 37 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 34 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 37 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 38 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 38 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 5 |
7 files changed, 188 insertions, 2 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 771872023..771488656 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -619,6 +619,7 @@ plugin_load (const char *filename) new_plugin->buffer_set = &gui_buffer_set; new_plugin->buffer_set_pointer = &gui_buffer_set_pointer; new_plugin->buffer_string_replace_local_var = &gui_buffer_string_replace_local_var; + new_plugin->buffer_match_list = &gui_buffer_match_list; new_plugin->window_get_integer = &gui_window_get_integer; new_plugin->window_get_string = &gui_window_get_string; diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index ba88f24db..f0b64af5d 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -5244,6 +5244,42 @@ weechat_lua_api_buffer_string_replace_local_var (lua_State *L) } /* + * weechat_lua_api_buffer_match_list: return 1 if buffer matches list of buffers + */ + +static int +weechat_lua_api_buffer_match_list (lua_State *L) +{ + const char *buffer, *string; + int n, value; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script || !lua_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_match_list"); + LUA_RETURN_INT(0); + } + + n = lua_gettop (lua_current_interpreter); + + if (n < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_match_list"); + LUA_RETURN_INT(0); + } + + buffer = lua_tostring (lua_current_interpreter, -2); + string = lua_tostring (lua_current_interpreter, -1); + + value = weechat_buffer_match_list (script_str2ptr (buffer), + string); + + LUA_RETURN_INT(value); +} + +/* * weechat_lua_api_current_window: get current window */ @@ -7769,6 +7805,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer }, { "buffer_set", &weechat_lua_api_buffer_set }, { "buffer_string_replace_local_var", &weechat_lua_api_buffer_string_replace_local_var }, + { "buffer_match_list", &weechat_lua_api_buffer_match_list }, { "current_window", &weechat_lua_api_current_window }, { "window_get_integer", &weechat_lua_api_window_get_integer }, { "window_get_string", &weechat_lua_api_window_get_string }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index c652aabab..6ea96f1bc 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -4766,6 +4766,39 @@ XS (XS_weechat_api_buffer_string_replace_local_var) } /* + * weechat::buffer_match_list: return 1 if buffer matches list of buffers + */ + +XS (XS_weechat_api_buffer_match_list) +{ + char *buffer, *string; + int value; + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script || !perl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_match_list"); + PERL_RETURN_INT(0); + } + + if (items < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_match_list"); + PERL_RETURN_INT(0); + } + + buffer = SvPV (ST (0), PL_na); + string = SvPV (ST (1), PL_na); + + value = weechat_buffer_match_list (script_str2ptr (buffer), string); + + PERL_RETURN_INT(value); +} + +/* * weechat::current_window: get current window */ @@ -6707,6 +6740,7 @@ weechat_perl_api_init (pTHX) newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat"); newXS ("weechat::buffer_set", XS_weechat_api_buffer_set, "weechat"); newXS ("weechat::buffer_string_replace_local_var", XS_weechat_api_buffer_string_replace_local_var, "weechat"); + newXS ("weechat::buffer_match_list", XS_weechat_api_buffer_match_list, "weechat"); newXS ("weechat::current_window", XS_weechat_api_current_window, "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"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index e306d00fc..58dd89af1 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -4853,7 +4853,7 @@ weechat_python_api_buffer_unmerge (PyObject *self, PyObject *args) } /* - * weechat_python_api_buffer_get_integer get a buffer property as integer + * weechat_python_api_buffer_get_integer: get a buffer property as integer */ static PyObject * @@ -5022,6 +5022,40 @@ weechat_python_api_buffer_string_replace_local_var (PyObject *self, PyObject *ar } /* + * weechat_python_api_buffer_match_list: return 1 if buffer matches list of + * buffers + */ + +static PyObject * +weechat_python_api_buffer_match_list (PyObject *self, PyObject *args) +{ + char *buffer, *string; + int value; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script || !python_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_match_list"); + PYTHON_RETURN_INT(0); + } + + buffer = NULL; + string = NULL; + + if (!PyArg_ParseTuple (args, "ss", &buffer, &string)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_match_list"); + PYTHON_RETURN_INT(0); + } + + value = weechat_buffer_match_list (script_str2ptr (buffer), string); + + PYTHON_RETURN_INT(value); +} + +/* * weechat_python_api_current_window: get current window */ @@ -7040,6 +7074,7 @@ PyMethodDef weechat_python_funcs[] = { "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" }, { "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" }, { "buffer_string_replace_local_var", &weechat_python_api_buffer_string_replace_local_var, METH_VARARGS, "" }, + { "buffer_match_list", &weechat_python_api_buffer_match_list, METH_VARARGS, "" }, { "current_window", &weechat_python_api_current_window, METH_VARARGS, "" }, { "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" }, { "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index cc97b5785..af75cad78 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -5437,6 +5437,43 @@ weechat_ruby_api_buffer_string_replace_local_var (VALUE class, VALUE buffer, VAL } /* + * weechat_ruby_api_buffer_match_list: return 1 if buffer matches list of buffers + */ + +static VALUE +weechat_ruby_api_buffer_match_list (VALUE class, VALUE buffer, VALUE string) +{ + char *c_buffer, *c_string; + int value; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script || !ruby_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_match_list"); + RUBY_RETURN_INT(0); + } + + if (NIL_P (buffer) || NIL_P (string)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_match_list"); + RUBY_RETURN_INT(0); + } + + Check_Type (buffer, T_STRING); + Check_Type (string, T_STRING); + + c_buffer = StringValuePtr (buffer); + c_string = StringValuePtr (string); + + value = weechat_buffer_match_list (script_str2ptr (c_buffer), + c_string); + + RUBY_RETURN_INT(value); +} + +/* * weechat_ruby_api_current_window: get current window */ @@ -7706,6 +7743,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) 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, "buffer_string_replace_local_var", &weechat_ruby_api_buffer_string_replace_local_var, 2); + rb_define_module_function (ruby_mWeechat, "buffer_match_list", &weechat_ruby_api_buffer_match_list, 2); rb_define_module_function (ruby_mWeechat, "current_window", &weechat_ruby_api_current_window, 0); 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); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index f5db112d3..9f870efb9 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -5328,6 +5328,42 @@ weechat_tcl_api_buffer_string_replace_local_var (ClientData clientData, Tcl_Inte } /* + * weechat_tcl_api_buffer_match_list: return 1 if buffers matches list of buffers + */ + +static int +weechat_tcl_api_buffer_match_list (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + char *buffer, *string; + int result; + int i; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script || !tcl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_match_list"); + TCL_RETURN_INT(0); + } + + if (objc < 3) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_match_list"); + TCL_RETURN_INT(0); + } + + buffer = Tcl_GetStringFromObj (objv[1], &i); + string = Tcl_GetStringFromObj (objv[2], &i); + + result = weechat_buffer_match_list (script_str2ptr (buffer), string); + + TCL_RETURN_INT(result); +} + +/* * weechat_tcl_api_current_window: get current window */ @@ -7650,6 +7686,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) weechat_tcl_api_buffer_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_string_replace_local_var", weechat_tcl_api_buffer_string_replace_local_var, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::buffer_match_list", + weechat_tcl_api_buffer_match_list, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::current_window", weechat_tcl_api_current_window, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::window_get_integer", diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index c5a8433d1..92b6c40b2 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -45,7 +45,7 @@ struct timeval; */ /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20110302-01" +#define WEECHAT_PLUGIN_API_VERSION "20110311-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -597,6 +597,7 @@ struct t_weechat_plugin const char *property, void *pointer); char *(*buffer_string_replace_local_var) (struct t_gui_buffer *buffer, const char *string); + int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string); /* windows */ int (*window_get_integer) (struct t_gui_window *window, @@ -1255,6 +1256,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->buffer_set_pointer(__buffer, __property, __pointer) #define weechat_buffer_string_replace_local_var(__buffer, __string) \ weechat_plugin->buffer_string_replace_local_var(__buffer, __string) +#define weechat_buffer_match_list(__buffer, __string) \ + weechat_plugin->buffer_match_list(__buffer, __string) /* windows */ #define weechat_window_get_integer(__window, __property) \ |