summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugin.c2
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c73
-rw-r--r--src/plugins/scripts/perl/weechat-perl-api.c69
-rw-r--r--src/plugins/scripts/python/weechat-python-api.c69
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby-api.c75
-rw-r--r--src/plugins/scripts/tcl/weechat-tcl-api.c75
-rw-r--r--src/plugins/weechat-plugin.h10
7 files changed, 372 insertions, 1 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index 3fbda4721..8ae513188 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -511,7 +511,9 @@ plugin_load (const char *filename)
new_plugin->list_new = &weelist_new;
new_plugin->list_add = &weelist_add;
new_plugin->list_search = &weelist_search;
+ new_plugin->list_search_pos = &weelist_search_pos;
new_plugin->list_casesearch = &weelist_casesearch;
+ new_plugin->list_casesearch_pos = &weelist_casesearch_pos;
new_plugin->list_get = &weelist_get;
new_plugin->list_set = &weelist_set;
new_plugin->list_next = &weelist_next;
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 226eb86ba..991116d50 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -817,6 +817,41 @@ weechat_lua_api_list_search (lua_State *L)
}
/*
+ * weechat_lua_api_list_search_pos: search position of a string in list
+ */
+
+static int
+weechat_lua_api_list_search_pos (lua_State *L)
+{
+ const char *weelist, *data;
+ int n, pos;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script || !lua_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_search_pos");
+ LUA_RETURN_INT(-1);
+ }
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_search_pos");
+ LUA_RETURN_INT(-1);
+ }
+
+ weelist = lua_tostring (lua_current_interpreter, -2);
+ data = lua_tostring (lua_current_interpreter, -1);
+
+ pos = weechat_list_search_pos (script_str2ptr (weelist), data);
+
+ LUA_RETURN_INT(pos);
+}
+
+/*
* weechat_lua_api_list_casesearch: search a string in list (ignore case)
*/
@@ -854,6 +889,42 @@ weechat_lua_api_list_casesearch (lua_State *L)
}
/*
+ * weechat_lua_api_list_casesearch_pos: search position of a string in list
+ * (ignore case)
+ */
+
+static int
+weechat_lua_api_list_casesearch_pos (lua_State *L)
+{
+ const char *weelist, *data;
+ int n, pos;
+
+ /* make C compiler happy */
+ (void) L;
+
+ if (!lua_current_script || !lua_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ LUA_RETURN_INT(-1);
+ }
+
+ n = lua_gettop (lua_current_interpreter);
+
+ if (n < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ LUA_RETURN_INT(-1);
+ }
+
+ weelist = lua_tostring (lua_current_interpreter, -2);
+ data = lua_tostring (lua_current_interpreter, -1);
+
+ pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
+
+ LUA_RETURN_INT(pos);
+}
+
+/*
* weechat_lua_api_list_get: get item by position
*/
@@ -7612,7 +7683,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "list_new", &weechat_lua_api_list_new },
{ "list_add", &weechat_lua_api_list_add },
{ "list_search", &weechat_lua_api_list_search },
+ { "list_search_pos", &weechat_lua_api_list_search_pos },
{ "list_casesearch", &weechat_lua_api_list_casesearch },
+ { "list_casesearch_pos", &weechat_lua_api_list_casesearch_pos },
{ "list_get", &weechat_lua_api_list_get },
{ "list_set", &weechat_lua_api_list_set },
{ "list_next", &weechat_lua_api_list_next },
diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c
index 273661e9c..22060c541 100644
--- a/src/plugins/scripts/perl/weechat-perl-api.c
+++ b/src/plugins/scripts/perl/weechat-perl-api.c
@@ -729,6 +729,39 @@ XS (XS_weechat_api_list_search)
}
/*
+ * weechat::list_search_pos: search position of a string in list
+ */
+
+XS (XS_weechat_api_list_search_pos)
+{
+ char *weelist, *data;
+ int pos;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script || !perl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_search_pos");
+ PERL_RETURN_INT(-1);
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_search_pos");
+ PERL_RETURN_INT(-1);
+ }
+
+ weelist = SvPV (ST (0), PL_na);
+ data = SvPV (ST (1), PL_na);
+
+ pos = weechat_list_search_pos (script_str2ptr (weelist), data);
+
+ PERL_RETURN_INT(pos);
+}
+
+/*
* weechat::list_casesearch: search a string in list (ignore case)
*/
@@ -762,6 +795,40 @@ XS (XS_weechat_api_list_casesearch)
}
/*
+ * weechat::list_casesearch_pos: search position of a string in list
+ * (ignore case)
+ */
+
+XS (XS_weechat_api_list_casesearch_pos)
+{
+ char *weelist, *data;
+ int pos;
+ dXSARGS;
+
+ /* make C compiler happy */
+ (void) cv;
+
+ if (!perl_current_script || !perl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ PERL_RETURN_INT(-1);
+ }
+
+ if (items < 2)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ PERL_RETURN_INT(-1);
+ }
+
+ weelist = SvPV (ST (0), PL_na);
+ data = SvPV (ST (1), PL_na);
+
+ pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
+
+ PERL_RETURN_INT(pos);
+}
+
+/*
* weechat::list_get: get item by position
*/
@@ -6553,7 +6620,9 @@ weechat_perl_api_init (pTHX)
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");
+ newXS ("weechat::list_search_pos", XS_weechat_api_list_search_pos, "weechat");
newXS ("weechat::list_casesearch", XS_weechat_api_list_casesearch, "weechat");
+ newXS ("weechat::list_casesearch_pos", XS_weechat_api_list_casesearch_pos, "weechat");
newXS ("weechat::list_get", XS_weechat_api_list_get, "weechat");
newXS ("weechat::list_set", XS_weechat_api_list_set, "weechat");
newXS ("weechat::list_next", XS_weechat_api_list_next, "weechat");
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c
index 6429ad383..3aed89013 100644
--- a/src/plugins/scripts/python/weechat-python-api.c
+++ b/src/plugins/scripts/python/weechat-python-api.c
@@ -769,6 +769,39 @@ weechat_python_api_list_search (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_list_search_pos: search position of a string in list
+ */
+
+static PyObject *
+weechat_python_api_list_search_pos (PyObject *self, PyObject *args)
+{
+ char *weelist, *data;
+ int pos;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script || !python_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_search_pos");
+ PYTHON_RETURN_INT(-1);
+ }
+
+ weelist = NULL;
+ data = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &weelist, &data))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_search_pos");
+ PYTHON_RETURN_INT(-1);
+ }
+
+ pos = weechat_list_search_pos (script_str2ptr (weelist), data);
+
+ PYTHON_RETURN_INT(pos);
+}
+
+/*
* weechat_python_api_list_casesearch: search a string in list (ignore case)
*/
@@ -803,6 +836,40 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_api_list_casesearch_pos: search position of a string in list
+ * (ignore case)
+ */
+
+static PyObject *
+weechat_python_api_list_casesearch_pos (PyObject *self, PyObject *args)
+{
+ char *weelist, *data;
+ int pos;
+
+ /* make C compiler happy */
+ (void) self;
+
+ if (!python_current_script || !python_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ PYTHON_RETURN_INT(-1);
+ }
+
+ weelist = NULL;
+ data = NULL;
+
+ if (!PyArg_ParseTuple (args, "ss", &weelist, &data))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ PYTHON_RETURN_INT(-1);
+ }
+
+ pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
+
+ PYTHON_RETURN_INT(pos);
+}
+
+/*
* weechat_python_api_list_get: get item by position
*/
@@ -6886,7 +6953,9 @@ PyMethodDef weechat_python_funcs[] =
{ "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, "" },
+ { "list_search_pos", &weechat_python_api_list_search_pos, METH_VARARGS, "" },
{ "list_casesearch", &weechat_python_api_list_casesearch, METH_VARARGS, "" },
+ { "list_casesearch_pos", &weechat_python_api_list_casesearch_pos, METH_VARARGS, "" },
{ "list_get", &weechat_python_api_list_get, METH_VARARGS, "" },
{ "list_set", &weechat_python_api_list_set, METH_VARARGS, "" },
{ "list_next", &weechat_python_api_list_next, METH_VARARGS, "" },
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c
index 33516526a..93d211dd2 100644
--- a/src/plugins/scripts/ruby/weechat-ruby-api.c
+++ b/src/plugins/scripts/ruby/weechat-ruby-api.c
@@ -831,6 +831,42 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data)
}
/*
+ * weechat_ruby_api_list_search_pos: search position of a string in list
+ */
+
+static VALUE
+weechat_ruby_api_list_search_pos (VALUE class, VALUE weelist, VALUE data)
+{
+ char *c_weelist, *c_data;
+ int pos;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script || !ruby_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_search_pos");
+ RUBY_RETURN_INT(-1);
+ }
+
+ if (NIL_P (weelist) || NIL_P (data))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_search_pos");
+ RUBY_RETURN_INT(-1);
+ }
+
+ Check_Type (weelist, T_STRING);
+ Check_Type (data, T_STRING);
+
+ c_weelist = StringValuePtr (weelist);
+ c_data = StringValuePtr (data);
+
+ pos = weechat_list_search_pos (script_str2ptr(c_weelist), c_data);
+
+ RUBY_RETURN_INT(pos);
+}
+
+/*
* weechat_ruby_api_list_casesearch: search a string in list (ignore case)
*/
@@ -867,6 +903,43 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data)
}
/*
+ * weechat_ruby_api_list_casesearch_pos: search position of a string in list
+ * (ignore case)
+ */
+
+static VALUE
+weechat_ruby_api_list_casesearch_pos (VALUE class, VALUE weelist, VALUE data)
+{
+ char *c_weelist, *c_data;
+ int pos;
+
+ /* make C compiler happy */
+ (void) class;
+
+ if (!ruby_current_script || !ruby_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ RUBY_RETURN_INT(-1);
+ }
+
+ if (NIL_P (weelist) || NIL_P (data))
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ RUBY_RETURN_INT(-1);
+ }
+
+ Check_Type (weelist, T_STRING);
+ Check_Type (data, T_STRING);
+
+ c_weelist = StringValuePtr (weelist);
+ c_data = StringValuePtr (data);
+
+ pos = weechat_list_casesearch_pos (script_str2ptr(c_weelist), c_data);
+
+ RUBY_RETURN_INT(pos);
+}
+
+/*
* weechat_ruby_api_list_get: get item by position
*/
@@ -7546,7 +7619,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
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, 4);
rb_define_module_function (ruby_mWeechat, "list_search", &weechat_ruby_api_list_search, 2);
+ rb_define_module_function (ruby_mWeechat, "list_search_pos", &weechat_ruby_api_list_search_pos, 2);
rb_define_module_function (ruby_mWeechat, "list_casesearch", &weechat_ruby_api_list_casesearch, 2);
+ rb_define_module_function (ruby_mWeechat, "list_casesearch_pos", &weechat_ruby_api_list_casesearch_pos, 2);
rb_define_module_function (ruby_mWeechat, "list_get", &weechat_ruby_api_list_get, 2);
rb_define_module_function (ruby_mWeechat, "list_set", &weechat_ruby_api_list_set, 2);
rb_define_module_function (ruby_mWeechat, "list_next", &weechat_ruby_api_list_next, 1);
diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c
index 581b5499b..9d1946240 100644
--- a/src/plugins/scripts/tcl/weechat-tcl-api.c
+++ b/src/plugins/scripts/tcl/weechat-tcl-api.c
@@ -932,6 +932,41 @@ weechat_tcl_api_list_search (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_list_search_pos: search position of a string in list
+ */
+
+static int
+weechat_tcl_api_list_search_pos (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj* objp;
+ char *weelist, *data;
+ int i, pos;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script || !tcl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_search_pos");
+ TCL_RETURN_INT(-1);
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_search_pos");
+ TCL_RETURN_INT(-1);
+ }
+
+ weelist = Tcl_GetStringFromObj (objv[1], &i);
+ data = Tcl_GetStringFromObj (objv[2], &i);
+
+ pos = weechat_list_search_pos (script_str2ptr (weelist), data);
+
+ TCL_RETURN_INT(pos);
+}
+
+/*
* weechat_tcl_api_list_casesearch: search a string in list (ignore case)
*/
@@ -968,6 +1003,42 @@ weechat_tcl_api_list_casesearch (ClientData clientData, Tcl_Interp *interp,
}
/*
+ * weechat_tcl_api_list_casesearch_pos: search position of a string in list
+ * (ignore case)
+ */
+
+static int
+weechat_tcl_api_list_casesearch_pos (ClientData clientData, Tcl_Interp *interp,
+ int objc, Tcl_Obj *CONST objv[])
+{
+ Tcl_Obj* objp;
+ char *weelist, *data;
+ int i, pos;
+
+ /* make C compiler happy */
+ (void) clientData;
+
+ if (!tcl_current_script || !tcl_current_script->name)
+ {
+ WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ TCL_RETURN_INT(-1);
+ }
+
+ if (objc < 3)
+ {
+ WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_casesearch_pos");
+ TCL_RETURN_INT(-1);
+ }
+
+ weelist = Tcl_GetStringFromObj (objv[1], &i);
+ data = Tcl_GetStringFromObj (objv[2], &i);
+
+ pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data);
+
+ TCL_RETURN_INT(pos);
+}
+
+/*
* weechat_tcl_api_list_get: get item by position
*/
@@ -7405,8 +7476,12 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
weechat_tcl_api_list_add, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::list_search",
weechat_tcl_api_list_search, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::list_search_pos",
+ weechat_tcl_api_list_search_pos, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::list_casesearch",
weechat_tcl_api_list_casesearch, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
+ Tcl_CreateObjCommand (interp, "weechat::list_casesearch_pos",
+ weechat_tcl_api_list_casesearch_pos, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::list_get",
weechat_tcl_api_list_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateObjCommand (interp, "weechat::list_set",
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 4f846694a..13c418ce3 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 "20101125-01"
+#define WEECHAT_PLUGIN_API_VERSION "20101220-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -237,8 +237,12 @@ struct t_weechat_plugin
void *user_data);
struct t_weelist_item *(*list_search) (struct t_weelist *weelist,
const char *data);
+ int (*list_search_pos) (struct t_weelist *weelist,
+ const char *data);
struct t_weelist_item *(*list_casesearch) (struct t_weelist *weelist,
const char *data);
+ int (*list_casesearch_pos) (struct t_weelist *weelist,
+ const char *data);
struct t_weelist_item *(*list_get) (struct t_weelist *weelist,
int position);
void (*list_set) (struct t_weelist_item *item, const char *value);
@@ -899,8 +903,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->list_add(__list, __string, __where, __user_data)
#define weechat_list_search(__list, __string) \
weechat_plugin->list_search(__list, __string)
+#define weechat_list_search_pos(__list, __string) \
+ weechat_plugin->list_search_pos(__list, __string)
#define weechat_list_casesearch(__list, __string) \
weechat_plugin->list_casesearch(__list, __string)
+#define weechat_list_casesearch_pos(__list, __string) \
+ weechat_plugin->list_casesearch_pos(__list, __string)
#define weechat_list_get(__list, __index) \
weechat_plugin->list_get(__list, __index)
#define weechat_list_set(__item, __value) \