api: add new function hdata_search
This commit is contained in:
parent
fcd71d14bc
commit
509a58b1d5
@ -1,7 +1,7 @@
|
||||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.4.1-dev, 2013-04-20
|
||||
v0.4.1-dev, 2013-04-21
|
||||
|
||||
|
||||
This document lists all changes for each version.
|
||||
@ -33,6 +33,7 @@ Version 0.4.1 (under dev!)
|
||||
weechat.history.max_buffer_lines_minutes is set (bug #38197)
|
||||
* core: use default hash/comparison callback for keys of type
|
||||
integer/pointer/time in hashtable
|
||||
* api: add new function hdata_search
|
||||
* api: add property "completion_freeze" for function buffer_set: do not stop
|
||||
completion when command line is updated
|
||||
* api: fix connection to servers with hook_connect on OS X (bug #38496)
|
||||
|
@ -447,8 +447,8 @@ Liste der Skript API Funktionen:
|
||||
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
|
||||
hdata_get_var_array_size, hdata_get_var_array_size_string,
|
||||
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
|
||||
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
|
||||
hdata_time, hdata_hashtable, hdata_get_string
|
||||
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
|
||||
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
|
||||
| Upgrade |
|
||||
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
|
||||
|========================================
|
||||
|
@ -13813,6 +13813,67 @@ if buffer:
|
||||
buffer = weechat.hdata_move(hdata, buffer, -1)
|
||||
----------------------------------------
|
||||
|
||||
weechat_hdata_search
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
_New in version 0.4.1._
|
||||
|
||||
Search element in a list: the expression 'search' is evaluated for each element
|
||||
in list, until element is found (or end of list).
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
----------------------------------------
|
||||
|
||||
Arguments:
|
||||
|
||||
* 'hdata': hdata pointer
|
||||
* 'pointer': pointer to a WeeChat/plugin object
|
||||
* 'search': expression to evaluate, default pointer in expression is the name of
|
||||
hdata (and this pointer changes for each element in list); for help on
|
||||
expression, see command `/eval` in 'WeeChat User's guide'
|
||||
* 'move': number of jump(s) to execute after unsuccessful search (negative or
|
||||
positive integer, different from 0)
|
||||
|
||||
Return value:
|
||||
|
||||
* pointer to element found, NULL if not found
|
||||
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get (hdata, "irc_servers");
|
||||
|
||||
/* search irc server with name "freenode" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == freenode", 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
----------------------------------------
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----------------------------------------
|
||||
# prototype
|
||||
pointer = weechat.hdata_search(hdata, pointer, search, count)
|
||||
|
||||
# example
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# search irc server with name "freenode"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == freenode", 1)
|
||||
if server:
|
||||
# ...
|
||||
----------------------------------------
|
||||
|
||||
weechat_hdata_char
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -440,8 +440,8 @@ List of functions in script API:
|
||||
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
|
||||
hdata_get_var_array_size, hdata_get_var_array_size_string,
|
||||
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
|
||||
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
|
||||
hdata_time, hdata_hashtable, hdata_get_string
|
||||
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
|
||||
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
|
||||
| upgrade |
|
||||
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
|
||||
|========================================
|
||||
|
@ -14043,6 +14043,68 @@ if buffer:
|
||||
buffer = weechat.hdata_move(hdata, buffer, -1)
|
||||
----------------------------------------
|
||||
|
||||
weechat_hdata_search
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
_Nouveau dans la version 0.4.1._
|
||||
|
||||
Cherche un élément dans la liste: l'expression 'search' est évaluée pour chaque
|
||||
élément dans la liste, jusqu'à trouver l'élément (ou la fin de la liste).
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
----------------------------------------
|
||||
|
||||
Paramètres :
|
||||
|
||||
* 'hdata' : pointeur vers le hdata
|
||||
* 'pointer' : pointeur vers un objet WeeChat ou d'une extension
|
||||
* 'search' : expression à évaluer, le pointeur par défaut dans l'expression est
|
||||
le nom du hdata (et ce pointeur change pour chaque élément dans la liste);
|
||||
pour l'aide sur l'expression, voir la commande `/eval` dans le
|
||||
'Guide utilisateur WeeChat'
|
||||
* 'move' : nombre de saut(s) à exécuter après une recherche infructueuse (entier
|
||||
négatif ou positif, différent de 0)
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* pointeur vers l'élément trouvé, ou NULL si non trouvé
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get (hdata, "irc_servers");
|
||||
|
||||
/* cherche un serveur irc avec le nom "freenode" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == freenode", 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
----------------------------------------
|
||||
|
||||
Script (Python) :
|
||||
|
||||
[source,python]
|
||||
----------------------------------------
|
||||
# prototype
|
||||
pointer = weechat.hdata_search(hdata, pointer, search, count)
|
||||
|
||||
# exemple
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# cherche un serveur irc avec le nom "freenode"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == freenode", 1)
|
||||
if server:
|
||||
# ...
|
||||
----------------------------------------
|
||||
|
||||
weechat_hdata_char
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -450,8 +450,8 @@ Liste des fonctions de l'API script :
|
||||
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
|
||||
hdata_get_var_array_size, hdata_get_var_array_size_string,
|
||||
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
|
||||
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
|
||||
hdata_time, hdata_hashtable, hdata_get_string
|
||||
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
|
||||
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
|
||||
| mise à jour |
|
||||
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
|
||||
|========================================
|
||||
|
@ -14018,6 +14018,72 @@ if buffer:
|
||||
buffer = weechat.hdata_move(hdata, buffer, -1)
|
||||
----------------------------------------
|
||||
|
||||
weechat_hdata_search
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
_Novità nella versione 0.4.1._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Search element in a list: the expression 'search' is evaluated for each element
|
||||
in list, until element is found (or end of list).
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
----------------------------------------
|
||||
|
||||
Argomenti:
|
||||
|
||||
* 'hdata': puntatore hdata
|
||||
* 'pointer': puntatore ad un oggetto di WeeChat/plugin
|
||||
// TRANSLATION MISSING
|
||||
* 'search': expression to evaluate, default pointer in expression is the name of
|
||||
hdata (and this pointer changes for each element in list); for help on
|
||||
expression, see command `/eval` in 'WeeChat User's guide'
|
||||
// TRANSLATION MISSING
|
||||
* 'move': number of jump(s) to execute after unsuccessful search (negative or
|
||||
positive integer, different from 0)
|
||||
|
||||
Valore restituito:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* pointer to element found, NULL if not found
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get (hdata, "irc_servers");
|
||||
|
||||
/* search irc server with name "freenode" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == freenode", 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
----------------------------------------
|
||||
|
||||
Script (Python):
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[source,python]
|
||||
----------------------------------------
|
||||
# prototipo
|
||||
pointer = weechat.hdata_search(hdata, pointer, search, count)
|
||||
|
||||
# esempio
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# search irc server with name "freenode"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == freenode", 1)
|
||||
if server:
|
||||
# ...
|
||||
----------------------------------------
|
||||
|
||||
weechat_hdata_char
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -453,8 +453,8 @@ Elenco di funzioni nelle API per gli script:
|
||||
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
|
||||
hdata_get_var_array_size, hdata_get_var_array_size_string,
|
||||
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
|
||||
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
|
||||
hdata_time, hdata_hashtable, hdata_get_string
|
||||
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
|
||||
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
|
||||
| aggiornamento |
|
||||
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
|
||||
|========================================
|
||||
|
@ -431,8 +431,8 @@ API に含まれる関数の詳しい情報は
|
||||
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
|
||||
hdata_get_var_array_size, hdata_get_var_array_size_string,
|
||||
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
|
||||
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
|
||||
hdata_time, hdata_hashtable, hdata_get_string
|
||||
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
|
||||
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
|
||||
| アップグレード |
|
||||
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
|
||||
|========================================
|
||||
|
@ -443,8 +443,8 @@ Lista funkcji w API skryptów:
|
||||
hdata_get, hdata_get_var_offset, hdata_get_var_type_string,
|
||||
hdata_get_var_array_size, hdata_get_var_array_size_string,
|
||||
hdata_get_var_hdata, hdata_get_list, hdata_check_pointer, hdata_move,
|
||||
hdata_char, hdata_integer, hdata_long, hdata_string, hdata_pointer,
|
||||
hdata_time, hdata_hashtable, hdata_get_string
|
||||
hdata_search, hdata_char, hdata_integer, hdata_long, hdata_string,
|
||||
hdata_pointer, hdata_time, hdata_hashtable, hdata_update, hdata_get_string
|
||||
| uaktualnienie |
|
||||
upgrade_new, upgrade_write_object, upgrade_read, upgrade_close
|
||||
|========================================
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "wee-hdata.h"
|
||||
#include "wee-eval.h"
|
||||
#include "wee-hashtable.h"
|
||||
#include "wee-log.h"
|
||||
#include "wee-string.h"
|
||||
@ -36,6 +37,10 @@
|
||||
|
||||
struct t_hashtable *weechat_hdata = NULL;
|
||||
|
||||
/* hashtables used in hdata_search() for evaluating expression */
|
||||
struct t_hashtable *hdata_search_pointers = NULL;
|
||||
struct t_hashtable *hdata_search_extra_vars = NULL;
|
||||
|
||||
char *hdata_type_string[8] =
|
||||
{ "other", "char", "integer", "long", "string", "pointer", "time",
|
||||
"hashtable" };
|
||||
@ -90,6 +95,7 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name,
|
||||
new_hdata = malloc (sizeof (*new_hdata));
|
||||
if (new_hdata)
|
||||
{
|
||||
new_hdata->name = strdup (hdata_name);
|
||||
new_hdata->plugin = plugin;
|
||||
new_hdata->var_prev = (var_prev) ? strdup (var_prev) : NULL;
|
||||
new_hdata->var_next = (var_next) ? strdup (var_next) : NULL;
|
||||
@ -459,6 +465,69 @@ hdata_move (struct t_hdata *hdata, void *pointer, int count)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for an element in list using expression.
|
||||
*
|
||||
* Returns pointer to element found, NULL if not found.
|
||||
*/
|
||||
|
||||
void *
|
||||
hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move)
|
||||
{
|
||||
char *result;
|
||||
int rc;
|
||||
|
||||
if (!hdata || !pointer || !search || !search[0] || (move == 0))
|
||||
return NULL;
|
||||
|
||||
/* clear or create hashtable with pointer for search */
|
||||
if (hdata_search_pointers)
|
||||
{
|
||||
hashtable_remove_all (hdata_search_pointers);
|
||||
}
|
||||
else
|
||||
{
|
||||
hdata_search_pointers = hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* create hashtable with extra vars (empty hashtable)
|
||||
* (hashtable would be created in eval_expression(), but it's created here
|
||||
* so it will not be created for each call to eval_expression())
|
||||
*/
|
||||
if (!hdata_search_extra_vars)
|
||||
{
|
||||
hdata_search_extra_vars = hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
while (pointer)
|
||||
{
|
||||
/* set pointer in hashtable (used for evaluating expression) */
|
||||
hashtable_set (hdata_search_pointers, hdata->name, pointer);
|
||||
|
||||
/* evaluate expression */
|
||||
result = eval_expression (search, hdata_search_pointers,
|
||||
hdata_search_extra_vars);
|
||||
rc = eval_is_true (result);
|
||||
if (result)
|
||||
free (result);
|
||||
if (rc)
|
||||
return pointer;
|
||||
|
||||
pointer = hdata_move (hdata, pointer, move);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extracts index from name of a variable.
|
||||
*
|
||||
@ -1000,11 +1069,13 @@ hdata_print_log_map_cb (void *data, struct t_hashtable *hashtable,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) hashtable;
|
||||
(void) key;
|
||||
|
||||
ptr_hdata = (struct t_hdata *)value;
|
||||
|
||||
log_printf ("");
|
||||
log_printf ("[hdata (addr:0x%lx, name:'%s')]", ptr_hdata, (const char *)key);
|
||||
log_printf ("[hdata (addr:0x%lx)]", ptr_hdata);
|
||||
log_printf (" name . . . . . . . . . : '%s'", ptr_hdata->name);
|
||||
log_printf (" plugin . . . . . . . . : 0x%lx", ptr_hdata->plugin);
|
||||
log_printf (" var_prev . . . . . . . : '%s'", ptr_hdata->var_prev);
|
||||
log_printf (" var_next . . . . . . . : '%s'", ptr_hdata->var_next);
|
||||
@ -1055,4 +1126,16 @@ hdata_end ()
|
||||
{
|
||||
hdata_free_all ();
|
||||
hashtable_free (weechat_hdata);
|
||||
weechat_hdata = NULL;
|
||||
|
||||
if (hdata_search_pointers)
|
||||
{
|
||||
hashtable_free (hdata_search_pointers);
|
||||
hdata_search_pointers = NULL;
|
||||
}
|
||||
if (hdata_search_extra_vars)
|
||||
{
|
||||
hashtable_free (hdata_search_extra_vars);
|
||||
hdata_search_extra_vars = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ struct t_hdata_var
|
||||
|
||||
struct t_hdata
|
||||
{
|
||||
char *name; /* name of hdata */
|
||||
struct t_weechat_plugin *plugin; /* plugin which created this hdata */
|
||||
/* (NULL if created by WeeChat) */
|
||||
char *var_prev; /* name of var with pointer to */
|
||||
@ -98,6 +99,8 @@ extern void *hdata_get_list (struct t_hdata *hdata, const char *name);
|
||||
extern int hdata_check_pointer (struct t_hdata *hdata, void *list,
|
||||
void *pointer);
|
||||
extern void *hdata_move (struct t_hdata *hdata, void *pointer, int count);
|
||||
extern void *hdata_search (struct t_hdata *hdata, void *pointer,
|
||||
const char *search, int move);
|
||||
extern char hdata_char (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
extern int hdata_integer (struct t_hdata *hdata, void *pointer,
|
||||
|
@ -4263,6 +4263,25 @@ weechat_guile_api_hdata_move (SCM hdata, SCM pointer, SCM count)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_hdata_search (SCM hdata, SCM pointer, SCM search, SCM move)
|
||||
{
|
||||
char *result;
|
||||
SCM return_value;
|
||||
|
||||
API_FUNC(1, "hdata_search", API_RETURN_EMPTY);
|
||||
if (!scm_is_string (hdata) || !scm_is_string (pointer)
|
||||
|| !scm_is_string (search) || !scm_is_integer (move))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(API_SCM_TO_STRING(hdata)),
|
||||
API_STR2PTR(API_SCM_TO_STRING(pointer)),
|
||||
API_SCM_TO_STRING(search),
|
||||
scm_to_int (move)));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_hdata_char (SCM hdata, SCM pointer, SCM name)
|
||||
{
|
||||
@ -4732,6 +4751,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(hdata_get_list, 2);
|
||||
API_DEF_FUNC(hdata_check_pointer, 3);
|
||||
API_DEF_FUNC(hdata_move, 3);
|
||||
API_DEF_FUNC(hdata_search, 4);
|
||||
API_DEF_FUNC(hdata_char, 3);
|
||||
API_DEF_FUNC(hdata_integer, 3);
|
||||
API_DEF_FUNC(hdata_long, 3);
|
||||
|
@ -4711,6 +4711,30 @@ weechat_lua_api_hdata_move (lua_State *L)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_search (lua_State *L)
|
||||
{
|
||||
const char *hdata, *pointer, *search;
|
||||
char *result;
|
||||
int move;
|
||||
|
||||
API_FUNC(1, "hdata_search", API_RETURN_EMPTY);
|
||||
if (lua_gettop (lua_current_interpreter) < 4)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
hdata = lua_tostring (lua_current_interpreter, -4);
|
||||
pointer = lua_tostring (lua_current_interpreter, -3);
|
||||
search = lua_tostring (lua_current_interpreter, -2);
|
||||
move = lua_tonumber (lua_current_interpreter, -1);
|
||||
|
||||
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
search,
|
||||
move));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static int
|
||||
weechat_lua_api_hdata_char (lua_State *L)
|
||||
{
|
||||
@ -5208,6 +5232,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(hdata_get_list),
|
||||
API_DEF_FUNC(hdata_check_pointer),
|
||||
API_DEF_FUNC(hdata_move),
|
||||
API_DEF_FUNC(hdata_search),
|
||||
API_DEF_FUNC(hdata_char),
|
||||
API_DEF_FUNC(hdata_integer),
|
||||
API_DEF_FUNC(hdata_long),
|
||||
|
@ -4462,6 +4462,29 @@ XS (XS_weechat_api_hdata_move)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
XS (XS_weechat_api_hdata_search)
|
||||
{
|
||||
char *result, *hdata, *pointer, *search;
|
||||
int move;
|
||||
dXSARGS;
|
||||
|
||||
API_FUNC(1, "hdata_search", API_RETURN_EMPTY);
|
||||
if (items < 4)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
hdata = SvPV_nolen (ST (0));
|
||||
pointer = SvPV_nolen (ST (1));
|
||||
search = SvPV_nolen (ST (2));
|
||||
move = SvIV(ST (3));
|
||||
|
||||
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
search,
|
||||
move));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
XS (XS_weechat_api_hdata_char)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
@ -4965,6 +4988,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(hdata_get_list);
|
||||
API_DEF_FUNC(hdata_check_pointer);
|
||||
API_DEF_FUNC(hdata_move);
|
||||
API_DEF_FUNC(hdata_search);
|
||||
API_DEF_FUNC(hdata_char);
|
||||
API_DEF_FUNC(hdata_integer);
|
||||
API_DEF_FUNC(hdata_long);
|
||||
|
@ -760,6 +760,7 @@ plugin_load (const char *filename, int argc, char **argv)
|
||||
new_plugin->hdata_get_list = &hdata_get_list;
|
||||
new_plugin->hdata_check_pointer = &hdata_check_pointer;
|
||||
new_plugin->hdata_move = &hdata_move;
|
||||
new_plugin->hdata_search = &hdata_search;
|
||||
new_plugin->hdata_char = &hdata_char;
|
||||
new_plugin->hdata_integer = &hdata_integer;
|
||||
new_plugin->hdata_long = &hdata_long;
|
||||
|
@ -4631,6 +4631,29 @@ weechat_python_api_hdata_move (PyObject *self, PyObject *args)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_search (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *result, *hdata, *pointer, *search;
|
||||
int move;
|
||||
PyObject *return_value;
|
||||
|
||||
API_FUNC(1, "hdata_search", API_RETURN_EMPTY);
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
search = NULL;
|
||||
move = 0;
|
||||
if (!PyArg_ParseTuple (args, "sssi", &hdata, &pointer, &search, &move))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
search,
|
||||
move));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hdata_char (PyObject *self, PyObject *args)
|
||||
{
|
||||
@ -5117,6 +5140,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(hdata_get_list),
|
||||
API_DEF_FUNC(hdata_check_pointer),
|
||||
API_DEF_FUNC(hdata_move),
|
||||
API_DEF_FUNC(hdata_search),
|
||||
API_DEF_FUNC(hdata_char),
|
||||
API_DEF_FUNC(hdata_integer),
|
||||
API_DEF_FUNC(hdata_long),
|
||||
|
@ -5444,6 +5444,36 @@ weechat_ruby_api_hdata_move (VALUE class, VALUE hdata, VALUE pointer,
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_search (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE search, VALUE move)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_search, *result;
|
||||
int c_move;
|
||||
VALUE return_value;
|
||||
|
||||
API_FUNC(1, "hdata_search", API_RETURN_EMPTY);
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (search) || NIL_P (move))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (search, T_STRING);
|
||||
Check_Type (move, T_FIXNUM);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_search = StringValuePtr (search);
|
||||
c_move = FIX2INT (move);
|
||||
|
||||
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(c_hdata),
|
||||
API_STR2PTR(c_pointer),
|
||||
c_search,
|
||||
c_move));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_char (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
@ -6053,6 +6083,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(hdata_get_list, 2);
|
||||
API_DEF_FUNC(hdata_check_pointer, 3);
|
||||
API_DEF_FUNC(hdata_move, 3);
|
||||
API_DEF_FUNC(hdata_search, 4);
|
||||
API_DEF_FUNC(hdata_char, 3);
|
||||
API_DEF_FUNC(hdata_integer, 3);
|
||||
API_DEF_FUNC(hdata_long, 3);
|
||||
|
@ -5165,6 +5165,33 @@ weechat_tcl_api_hdata_move (ClientData clientData, Tcl_Interp *interp,
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_search (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *hdata, *pointer, *search, *result;
|
||||
int i, move;
|
||||
|
||||
API_FUNC(1, "hdata_search", API_RETURN_EMPTY);
|
||||
if (objc < 5)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
hdata = Tcl_GetStringFromObj (objv[1], &i);
|
||||
pointer = Tcl_GetStringFromObj (objv[2], &i);
|
||||
search = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[4], &move) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(weechat_hdata_search (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
search,
|
||||
move));
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hdata_char (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
@ -5802,6 +5829,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(hdata_get_list);
|
||||
API_DEF_FUNC(hdata_check_pointer);
|
||||
API_DEF_FUNC(hdata_move);
|
||||
API_DEF_FUNC(hdata_search);
|
||||
API_DEF_FUNC(hdata_char);
|
||||
API_DEF_FUNC(hdata_integer);
|
||||
API_DEF_FUNC(hdata_long);
|
||||
|
@ -52,7 +52,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 "20121208-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20130421-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@ -877,6 +877,8 @@ struct t_weechat_plugin
|
||||
int (*hdata_check_pointer) (struct t_hdata *hdata, void *list,
|
||||
void *pointer);
|
||||
void *(*hdata_move) (struct t_hdata *hdata, void *pointer, int count);
|
||||
void *(*hdata_search) (struct t_hdata *hdata, void *pointer,
|
||||
const char *search, int move);
|
||||
char (*hdata_char) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
int (*hdata_integer) (struct t_hdata *hdata, void *pointer,
|
||||
@ -1674,6 +1676,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
weechat_plugin->hdata_check_pointer(__hdata, __list, __pointer)
|
||||
#define weechat_hdata_move(__hdata, __pointer, __count) \
|
||||
weechat_plugin->hdata_move(__hdata, __pointer, __count)
|
||||
#define weechat_hdata_search(__hdata, __pointer, __search, __move) \
|
||||
weechat_plugin->hdata_search(__hdata, __pointer, __search, __move)
|
||||
#define weechat_hdata_char(__hdata, __pointer, __name) \
|
||||
weechat_plugin->hdata_char(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_integer(__hdata, __pointer, __name) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user