mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 09:13:14 +02:00
api: add parameters pointers, extra_vars and options in function hdata_search
This commit is contained in:
@@ -17135,7 +17135,7 @@ if buffer:
|
||||
|
||||
==== hdata_search
|
||||
|
||||
_WeeChat ≥ 0.4.1._
|
||||
_WeeChat ≥ 0.4.1, updated in 3.4._
|
||||
|
||||
Search element in a list: the expression _search_ is evaluated for each element
|
||||
in list, until element is found (or end of list).
|
||||
@@ -17144,7 +17144,9 @@ Prototype:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search,
|
||||
struct t_hashtable *pointers, struct t_hashtable *extra_vars,
|
||||
struct t_hashtable *options, int move);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
@@ -17155,9 +17157,20 @@ Arguments:
|
||||
hdata (and this pointer changes for each element in list); for help on
|
||||
expression, see the
|
||||
link:weechat_user.en.html#command_weechat_eval[WeeChat user's guide / Command /eval]
|
||||
* _pointers_: hashtable for call to function
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _extra_vars_: hashtable for call to function
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _options_: hashtable for call to function
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _move_: number of jump(s) to execute after unsuccessful search (negative or
|
||||
positive integer, different from 0)
|
||||
|
||||
[IMPORTANT]
|
||||
You must ensure the _search_ expression is safe and does not include any
|
||||
user data. Such unsafe data must be given in the hashtable _extra_vars_ and
|
||||
referenced by `${xxx}` in the _search_ expression (see the example below).
|
||||
|
||||
Return value:
|
||||
|
||||
* pointer to element found, NULL if not found
|
||||
@@ -17168,13 +17181,21 @@ C example:
|
||||
----
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get_list (hdata, "irc_servers");
|
||||
struct t_hashtable *extra_vars = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* search irc server with name "libera" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == libera", 1);
|
||||
weechat_hashtable_set (extra_vars, "name", "libera");
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == ${name}",
|
||||
NULL, extra_vars, NULL, 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
weechat_hashtable_free (extra_vars);
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
@@ -17182,14 +17203,17 @@ Script (Python):
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def hdata_search(hdata: str, pointer: str, search: str, count: int) -> str: ...
|
||||
def hdata_search(hdata: str, pointer: str, search: str,
|
||||
pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
|
||||
count: int) -> str: ...
|
||||
|
||||
# example
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# search irc server with name "libera"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == libera", 1)
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == ${name}",
|
||||
{}, {"name": "libera"}, {}, 1)
|
||||
if server:
|
||||
# ...
|
||||
----
|
||||
|
||||
@@ -17488,7 +17488,7 @@ if buffer:
|
||||
|
||||
==== hdata_search
|
||||
|
||||
_WeeChat ≥ 0.4.1._
|
||||
_WeeChat ≥ 0.4.1, mis à jour dans la 3.4._
|
||||
|
||||
Chercher 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).
|
||||
@@ -17497,7 +17497,9 @@ Prototype :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search,
|
||||
struct t_hashtable *pointers, struct t_hashtable *extra_vars,
|
||||
struct t_hashtable *options, int move);
|
||||
----
|
||||
|
||||
Paramètres :
|
||||
@@ -17508,9 +17510,22 @@ Paramètres :
|
||||
le nom du hdata (et ce pointeur change pour chaque élément dans la liste);
|
||||
pour l'aide sur l'expression, voir le
|
||||
link:weechat_user.fr.html#command_weechat_eval[Guide utilisateur WeeChat / Commande /eval]
|
||||
* _pointers_ : table de hachage pour l'appel à la fonction
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _extra_vars_ : table de hachage pour l'appel à la fonction
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _options_ : table de hachage pour l'appel à la fonction
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _move_ : nombre de saut(s) à exécuter après une recherche infructueuse (entier
|
||||
négatif ou positif, différent de 0)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[IMPORTANT]
|
||||
Vous devez vous assurer que l'expression _search_ est sûre et ne contient
|
||||
aucune donnée utilisateur. De telles données non sûres doivent être données
|
||||
dans la table de hachage _extra_vars_ et être référencées par `${xxx}` dans
|
||||
l'expression _search_ (voir l'exemple ci-dessous).
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* pointeur vers l'élément trouvé, ou NULL si non trouvé
|
||||
@@ -17521,13 +17536,21 @@ Exemple en C :
|
||||
----
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get_list (hdata, "irc_servers");
|
||||
struct t_hashtable *extra_vars = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* cherche un serveur irc avec le nom "libera" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == libera", 1);
|
||||
weechat_hashtable_set (extra_vars, "name", "libera");
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == ${name}",
|
||||
NULL, extra_vars, NULL, 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
weechat_hashtable_free (extra_vars);
|
||||
----
|
||||
|
||||
Script (Python) :
|
||||
@@ -17535,14 +17558,17 @@ Script (Python) :
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def hdata_search(hdata: str, pointer: str, search: str, count: int) -> str: ...
|
||||
def hdata_search(hdata: str, pointer: str, search: str,
|
||||
pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
|
||||
count: int) -> str: ...
|
||||
|
||||
# exemple
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# cherche un serveur irc avec le nom "libera"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == libera", 1)
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == ${name}",
|
||||
{}, {"name": "libera"}, {}, 1)
|
||||
if server:
|
||||
# ...
|
||||
----
|
||||
|
||||
@@ -17822,7 +17822,8 @@ if buffer:
|
||||
|
||||
==== hdata_search
|
||||
|
||||
_WeeChat ≥ 0.4.1._
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 0.4.1, updated in 3.4._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Search element in a list: the expression _search_ is evaluated for each element
|
||||
@@ -17832,7 +17833,9 @@ Prototipo:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search,
|
||||
struct t_hashtable *pointers, struct t_hashtable *extra_vars,
|
||||
struct t_hashtable *options, int move);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
@@ -17845,9 +17848,24 @@ Argomenti:
|
||||
expression, see the
|
||||
link:weechat_user.it.html#command_weechat_eval[WeeChat user's guide / Command /eval]
|
||||
// TRANSLATION MISSING
|
||||
* _pointers_: hashtable for call to function
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
// TRANSLATION MISSING
|
||||
* _extra_vars_: hashtable for call to function
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
// TRANSLATION MISSING
|
||||
* _options_: hashtable for call to function
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
// TRANSLATION MISSING
|
||||
* _move_: number of jump(s) to execute after unsuccessful search (negative or
|
||||
positive integer, different from 0)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[IMPORTANT]
|
||||
You must ensure the _search_ expression is safe and does not include any
|
||||
user data. Such unsafe data must be given in the hashtable _extra_vars_ and
|
||||
referenced by `${xxx}` in the _search_ expression (see the example below).
|
||||
|
||||
Valore restituito:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
@@ -17859,13 +17877,21 @@ Esempio in C:
|
||||
----
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get_list (hdata, "irc_servers");
|
||||
struct t_hashtable *extra_vars = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* search irc server with name "libera" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == libera", 1);
|
||||
weechat_hashtable_set (extra_vars, "name", "libera");
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == ${name}",
|
||||
NULL, extra_vars, NULL, 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
weechat_hashtable_free (extra_vars);
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
@@ -17874,14 +17900,17 @@ Script (Python):
|
||||
[source,python]
|
||||
----
|
||||
# prototipo
|
||||
def hdata_search(hdata: str, pointer: str, search: str, count: int) -> str: ...
|
||||
def hdata_search(hdata: str, pointer: str, search: str,
|
||||
pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
|
||||
count: int) -> str: ...
|
||||
|
||||
# esempio
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# search irc server with name "libera"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == libera", 1)
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == ${name}",
|
||||
{}, {"name": "libera"}, {}, 1)
|
||||
if server:
|
||||
# ...
|
||||
----
|
||||
|
||||
@@ -17199,7 +17199,7 @@ if buffer:
|
||||
|
||||
==== hdata_search
|
||||
|
||||
_WeeChat バージョン 0.4.1 以上で利用可。_
|
||||
_WeeChat バージョン 0.4.1 以上で利用可、バージョン 3.4 で更新。_
|
||||
|
||||
リストから要素を検索: リスト内の各要素に対して _search_
|
||||
の内容を評価し、マッチする要素が見つかるかリストの最後に到達するまでこれを続ける。
|
||||
@@ -17208,7 +17208,9 @@ _WeeChat バージョン 0.4.1 以上で利用可。_
|
||||
|
||||
[source,C]
|
||||
----
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search,
|
||||
struct t_hashtable *pointers, struct t_hashtable *extra_vars,
|
||||
struct t_hashtable *options, int move);
|
||||
----
|
||||
|
||||
引数:
|
||||
@@ -17218,9 +17220,21 @@ void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *se
|
||||
* _search_: 評価する式、式中のデフォルトポインタは hdata の名前
|
||||
(デフォルトポインタはリストに含まれる各要素で置換されます); 式に関する詳細は
|
||||
link:weechat_user.ja.html#command_weechat_eval[WeeChat ユーザーズガイド / WeeChat コマンド / eval] を参照してください
|
||||
* _pointers_: 関数に渡されるハッシュテーブル
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _extra_vars_: 関数に渡されるハッシュテーブル
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _options_: 関数に渡されるハッシュテーブル
|
||||
<<_string_eval_expression,string_eval_expression>>
|
||||
* _move_: 検索に失敗した後に移動を実行する回数
|
||||
(負および正の整数、ゼロは禁止)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[IMPORTANT]
|
||||
You must ensure the _search_ expression is safe and does not include any
|
||||
user data. Such unsafe data must be given in the hashtable _extra_vars_ and
|
||||
referenced by `${xxx}` in the _search_ expression (see the example below).
|
||||
|
||||
戻り値:
|
||||
|
||||
* 見つかった要素へのポインタ、見つからなかった場合は NULL
|
||||
@@ -17231,13 +17245,21 @@ C 言語での使用例:
|
||||
----
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get_list (hdata, "irc_servers");
|
||||
struct t_hashtable *extra_vars = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* search irc server with name "libera" */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == libera", 1);
|
||||
weechat_hashtable_set (extra_vars, "name", "libera");
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == ${name}",
|
||||
NULL, extra_vars, NULL, 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
weechat_hashtable_free (extra_vars);
|
||||
----
|
||||
|
||||
スクリプト (Python) での使用例:
|
||||
@@ -17245,14 +17267,17 @@ if (server)
|
||||
[source,python]
|
||||
----
|
||||
# プロトタイプ
|
||||
def hdata_search(hdata: str, pointer: str, search: str, count: int) -> str: ...
|
||||
def hdata_search(hdata: str, pointer: str, search: str,
|
||||
pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
|
||||
count: int) -> str: ...
|
||||
|
||||
# 例
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# search irc server with name "libera"
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == libera", 1)
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == ${name}",
|
||||
{}, {"name": "libera"}, {}, 1)
|
||||
if server:
|
||||
# ...
|
||||
----
|
||||
|
||||
@@ -16575,7 +16575,7 @@ if buffer:
|
||||
|
||||
==== hdata_search
|
||||
|
||||
_WeeChat ≥ 0.4.1._
|
||||
_WeeChat ≥ 0.4.1, ажурирано у верзији 3.4._
|
||||
|
||||
Тражи елемент у листи: израз _search_ се тражи за сваки елемент у листи, све док се елемент не пронађе (или наиђе на крај листе).
|
||||
|
||||
@@ -16583,7 +16583,9 @@ _WeeChat ≥ 0.4.1._
|
||||
|
||||
[source, C]
|
||||
----
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search, int move);
|
||||
void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *search,
|
||||
struct t_hashtable *pointers, struct t_hashtable *extra_vars,
|
||||
struct t_hashtable *options, int move);
|
||||
----
|
||||
|
||||
Аргументи:
|
||||
@@ -16591,8 +16593,17 @@ void *weechat_hdata_search (struct t_hdata *hdata, void *pointer, const char *se
|
||||
* _hdata_: показивач на hdata
|
||||
* _pointer_: показивач на објекат програма WeeChat/додатка
|
||||
* _search_: израз који се израчунава, подразумевани показивач у изразу је име hdata (и овај показивач се мења за сваки елемент у листи); за помоћ у вези израза, погледајте link:weechat_user.sr.html#command_weechat_eval[WeeChat корисничко упутство / Команда /eval]
|
||||
* _pointers_: хеш табела за позив функције <<_string_eval_expression,string_eval_expression>>
|
||||
* _extra_vars_: хеш табела за позив функције <<_string_eval_expression,string_eval_expression>>
|
||||
* _options_: хеш табела за позив функције <<_string_eval_expression,string_eval_expression>>
|
||||
* _move_: број скок(а/ова) који треба да се изврши након неуспешне претраге (негативни или позитивни цео број, различит од 0)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[IMPORTANT]
|
||||
You must ensure the _search_ expression is safe and does not include any
|
||||
user data. Such unsafe data must be given in the hashtable _extra_vars_ and
|
||||
referenced by `${xxx}` in the _search_ expression (see the example below).
|
||||
|
||||
Повратна вредност:
|
||||
|
||||
* показивач на пронађени елемент, NULL у случају да се не пронађе
|
||||
@@ -16603,13 +16614,21 @@ C пример:
|
||||
----
|
||||
struct t_hdata *hdata = weechat_hdata_get ("irc_server");
|
||||
void *servers = weechat_hdata_get_list (hdata, "irc_servers");
|
||||
struct t_hashtable *extra_vars = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* тражи irc сервер под именом „libera” */
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == libera", 1);
|
||||
weechat_hashtable_set (extra_vars, "name", "libera");
|
||||
void *server = weechat_hdata_search (hdata, servers, "${irc_server.name} == ${name}",
|
||||
NULL, extra_vars, NULL, 1);
|
||||
if (server)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
weechat_hashtable_free (extra_vars);
|
||||
----
|
||||
|
||||
Скрипта (Python):
|
||||
@@ -16617,14 +16636,17 @@ if (server)
|
||||
[source, python]
|
||||
----
|
||||
# прототип
|
||||
def hdata_search(hdata: str, pointer: str, search: str, count: int) -> str: ...
|
||||
def hdata_search(hdata: str, pointer: str, search: str,
|
||||
pointers: Dict[str, str], extra_vars: Dict[str, str], options: Dict[str, str],
|
||||
count: int) -> str: ...
|
||||
|
||||
# пример
|
||||
hdata = weechat.hdata_get("irc_server")
|
||||
servers = weechat.hdata_get_list(hdata, "irc_servers")
|
||||
|
||||
# тражи irc сервер под именом „libera”
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == libera", 1)
|
||||
server = weechat.hdata_search(hdata, servers, "${irc_server.name} == ${name}",
|
||||
{}, {"name": "libera"}, {}, 1)
|
||||
if server:
|
||||
# ...
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user