diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2017-05-30 20:26:19 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2017-05-30 20:29:17 +0200 |
commit | 7621939a7a40a0e535b5b2ef67c2cb60e12208e3 (patch) | |
tree | e6a62315f4dd7addb5fd93d912242da0d2360a8a /src/plugins | |
parent | f6a8c28d2dcf4d4ed6f87e7e94574b331455b40a (diff) | |
download | weechat-7621939a7a40a0e535b5b2ef67c2cb60e12208e3.zip |
api: add function hdata_compare
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 22 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 23 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 25 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 26 | ||||
-rw-r--r-- | src/plugins/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 25 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 35 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 28 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 9 |
9 files changed, 193 insertions, 1 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 425d60a43..2842b39ae 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -4632,6 +4632,27 @@ weechat_guile_api_hdata_hashtable (SCM hdata, SCM pointer, SCM name) } SCM +weechat_guile_api_hdata_compare (SCM hdata, SCM pointer1, SCM pointer2, + SCM name, SCM case_sensitive) +{ + int rc; + + API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); + if (!scm_is_string (hdata) || !scm_is_string (pointer1) + || !scm_is_string (pointer2) || !scm_is_string (name) + || !scm_is_integer (case_sensitive)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + rc = weechat_hdata_compare (API_STR2PTR(API_SCM_TO_STRING(hdata)), + API_STR2PTR(API_SCM_TO_STRING(pointer1)), + API_STR2PTR(API_SCM_TO_STRING(pointer2)), + API_SCM_TO_STRING(name), + scm_to_int (case_sensitive)); + + API_RETURN_INT(rc); +} + +SCM weechat_guile_api_hdata_update (SCM hdata, SCM pointer, SCM hashtable) { struct t_hashtable *c_hashtable; @@ -4991,6 +5012,7 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(hdata_pointer, 3); API_DEF_FUNC(hdata_time, 3); API_DEF_FUNC(hdata_hashtable, 3); + API_DEF_FUNC(hdata_compare, 5); API_DEF_FUNC(hdata_update, 3); API_DEF_FUNC(hdata_get_string, 2); API_DEF_FUNC(upgrade_new, 3); diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index dcf62e1b4..ee3cfdbbf 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -4572,6 +4572,28 @@ API_FUNC(hdata_hashtable) return result_obj; } +API_FUNC(hdata_compare) +{ + int case_sensitive, rc; + + API_INIT_FUNC(1, "hdata_compare", "ssssi", API_RETURN_INT(0)); + + v8::String::Utf8Value hdata(args[0]); + v8::String::Utf8Value pointer1(args[1]); + v8::String::Utf8Value pointer2(args[2]); + v8::String::Utf8Value name(args[3]); + case_sensitive = args[4]->IntegerValue(); + + rc = weechat_hdata_compare ( + (struct t_hdata *)API_STR2PTR(*hdata), + API_STR2PTR(*pointer1), + API_STR2PTR(*pointer2), + *name, + case_sensitive); + + API_RETURN_INT(rc); +} + API_FUNC(hdata_update) { struct t_hashtable *hashtable; @@ -4966,6 +4988,7 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(hdata_pointer); API_DEF_FUNC(hdata_time); API_DEF_FUNC(hdata_hashtable); + API_DEF_FUNC(hdata_compare); API_DEF_FUNC(hdata_update); API_DEF_FUNC(hdata_get_string); API_DEF_FUNC(upgrade_new); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 372f01905..c09f09676 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -4933,6 +4933,30 @@ API_FUNC(hdata_hashtable) return 1; } +API_FUNC(hdata_compare) +{ + const char *hdata, *pointer1, *pointer2, *name; + int case_sensitive, rc; + + API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); + if (lua_gettop (L) < 5) + API_WRONG_ARGS(API_RETURN_INT(0)); + + hdata = lua_tostring (L, -5); + pointer1 = lua_tostring (L, -4); + pointer2 = lua_tostring (L, -3); + name = lua_tostring (L, -2); + case_sensitive = lua_tonumber (L, -1); + + rc = weechat_hdata_compare (API_STR2PTR(hdata), + API_STR2PTR(pointer1), + API_STR2PTR(pointer2), + name, + case_sensitive); + + API_RETURN_INT(rc); +} + API_FUNC(hdata_update) { const char *hdata, *pointer; @@ -5289,6 +5313,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(hdata_pointer), API_DEF_FUNC(hdata_time), API_DEF_FUNC(hdata_hashtable), + API_DEF_FUNC(hdata_compare), API_DEF_FUNC(hdata_update), API_DEF_FUNC(hdata_get_string), API_DEF_FUNC(upgrade_new), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index eae85f275..8e7b19569 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -4861,6 +4861,31 @@ API_FUNC(hdata_hashtable) API_RETURN_OBJ(result_hash); } +API_FUNC(hdata_compare) +{ + char *hdata, *pointer1, *pointer2, *name; + int case_sensitive, rc; + dXSARGS; + + API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); + if (items < 5) + API_WRONG_ARGS(API_RETURN_INT(0)); + + hdata = SvPV_nolen (ST (0)); + pointer1 = SvPV_nolen (ST (1)); + pointer2 = SvPV_nolen (ST (2)); + name = SvPV_nolen (ST (3)); + case_sensitive = SvIV(ST (4)); + + rc = weechat_hdata_compare (API_STR2PTR(hdata), + API_STR2PTR(pointer1), + API_STR2PTR(pointer2), + name, + case_sensitive); + + API_RETURN_INT(rc); +} + API_FUNC(hdata_update) { char *hdata, *pointer; @@ -5229,6 +5254,7 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(hdata_pointer); API_DEF_FUNC(hdata_time); API_DEF_FUNC(hdata_hashtable); + API_DEF_FUNC(hdata_compare); API_DEF_FUNC(hdata_update); API_DEF_FUNC(hdata_get_string); API_DEF_FUNC(upgrade_new); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index bb2c25e7d..7065dfcca 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -891,6 +891,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->hdata_pointer = &hdata_pointer; new_plugin->hdata_time = &hdata_time; new_plugin->hdata_hashtable = &hdata_hashtable; + new_plugin->hdata_compare = &hdata_compare; new_plugin->hdata_set = &hdata_set; new_plugin->hdata_update = &hdata_update; new_plugin->hdata_get_string = &hdata_get_string; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 4d02445cb..93e932a31 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -4851,6 +4851,30 @@ API_FUNC(hdata_hashtable) return result_dict; } +API_FUNC(hdata_compare) +{ + char *hdata, *pointer1, *pointer2, *name; + int case_sensitive, rc; + + API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); + hdata = NULL; + pointer1 = NULL; + pointer2 = NULL; + name = NULL; + case_sensitive = 0; + if (!PyArg_ParseTuple (args, "ssssi", &hdata, &pointer1, &pointer2, &name, + &case_sensitive)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + rc = weechat_hdata_compare (API_STR2PTR(hdata), + API_STR2PTR(pointer1), + API_STR2PTR(pointer2), + name, + case_sensitive); + + API_RETURN_INT(rc); +} + API_FUNC(hdata_update) { char *hdata, *pointer; @@ -5205,6 +5229,7 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(hdata_pointer), API_DEF_FUNC(hdata_time), API_DEF_FUNC(hdata_hashtable), + API_DEF_FUNC(hdata_compare), API_DEF_FUNC(hdata_update), API_DEF_FUNC(hdata_get_string), API_DEF_FUNC(upgrade_new), diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index e78a5cf5c..639ec9eca 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -5917,6 +5917,40 @@ weechat_ruby_api_hdata_hashtable (VALUE class, VALUE hdata, VALUE pointer, } static VALUE +weechat_ruby_api_hdata_compare (VALUE class, VALUE hdata, + VALUE pointer1, VALUE pointer2, VALUE name, + VALUE case_sensitive) +{ + char *c_hdata, *c_pointer1, *c_pointer2, *c_name; + int c_case_sensitive, rc; + + API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); + if (NIL_P (hdata) || NIL_P (pointer1) || NIL_P (pointer2) || NIL_P (name) + || NIL_P (case_sensitive)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + Check_Type (hdata, T_STRING); + Check_Type (pointer1, T_STRING); + Check_Type (pointer2, T_STRING); + Check_Type (name, T_STRING); + Check_Type (case_sensitive, T_FIXNUM); + + c_hdata = StringValuePtr (hdata); + c_pointer1 = StringValuePtr (pointer1); + c_pointer2 = StringValuePtr (pointer2); + c_name = StringValuePtr (name); + c_case_sensitive = FIX2INT (case_sensitive); + + rc = weechat_hdata_compare (API_STR2PTR(c_hdata), + API_STR2PTR(c_pointer1), + API_STR2PTR(c_pointer2), + c_name, + c_case_sensitive); + + API_RETURN_INT(rc); +} + +static VALUE weechat_ruby_api_hdata_update (VALUE class, VALUE hdata, VALUE pointer, VALUE hashtable) { @@ -6351,6 +6385,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(hdata_pointer, 3); API_DEF_FUNC(hdata_time, 3); API_DEF_FUNC(hdata_hashtable, 3); + API_DEF_FUNC(hdata_compare, 5); API_DEF_FUNC(hdata_update, 3); API_DEF_FUNC(hdata_get_string, 2); API_DEF_FUNC(upgrade_new, 3); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index a53f1f970..a7de9b353 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -5221,6 +5221,33 @@ API_FUNC(hdata_hashtable) API_RETURN_OBJ(result_dict); } +API_FUNC(hdata_compare) +{ + Tcl_Obj *objp; + char *hdata, *pointer1, *pointer2, *name; + int case_sensitive, rc, i; + + API_INIT_FUNC(1, "hdata_compare", API_RETURN_INT(0)); + if (objc < 6) + API_WRONG_ARGS(API_RETURN_INT(0)); + + hdata = Tcl_GetStringFromObj (objv[1], &i); + pointer1 = Tcl_GetStringFromObj (objv[2], &i); + pointer2 = Tcl_GetStringFromObj (objv[3], &i); + name = Tcl_GetStringFromObj (objv[4], &i); + + if (Tcl_GetIntFromObj (interp, objv[5], &case_sensitive) != TCL_OK) + API_WRONG_ARGS(API_RETURN_INT(0)); + + rc = weechat_hdata_compare (API_STR2PTR(hdata), + API_STR2PTR(pointer1), + API_STR2PTR(pointer2), + name, + case_sensitive); + + API_RETURN_INT(rc); +} + API_FUNC(hdata_update) { Tcl_Obj *objp; @@ -5692,6 +5719,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(hdata_pointer); API_DEF_FUNC(hdata_time); API_DEF_FUNC(hdata_hashtable); + API_DEF_FUNC(hdata_compare); API_DEF_FUNC(hdata_update); API_DEF_FUNC(hdata_get_string); API_DEF_FUNC(upgrade_new); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 9d3fe101c..6d0019e2e 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -59,7 +59,7 @@ struct timeval; * please change the date with current one; for a second change at same * date, increment the 01, otherwise please keep 01. */ -#define WEECHAT_PLUGIN_API_VERSION "20170530-01" +#define WEECHAT_PLUGIN_API_VERSION "20170530-02" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -1065,6 +1065,9 @@ struct t_weechat_plugin const char *name); struct t_hashtable *(*hdata_hashtable) (struct t_hdata *hdata, void *pointer, const char *name); + int (*hdata_compare) (struct t_hdata *hdata, + void *pointer1, void *pointer2, const char *name, + int case_sensitive); int (*hdata_set) (struct t_hdata *hdata, void *pointer, const char *name, const char *value); int (*hdata_update) (struct t_hdata *hdata, void *pointer, @@ -1988,6 +1991,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); (weechat_plugin->hdata_time)(__hdata, __pointer, __name) #define weechat_hdata_hashtable(__hdata, __pointer, __name) \ (weechat_plugin->hdata_hashtable)(__hdata, __pointer, __name) +#define weechat_hdata_compare(__hdata, __pointer1, __pointer2, __name, \ + __case_sensitive) \ + (weechat_plugin->hdata_compare)(__hdata, __pointer1, __pointer2, \ + __name, __case_sensitive) #define weechat_hdata_set(__hdata, __pointer, __name, __value) \ (weechat_plugin->hdata_set)(__hdata, __pointer, __name, __value) #define weechat_hdata_update(__hdata, __pointer, __hashtable) \ |