api: add function "infolist_search_var"
parent
79f2f46dec
commit
a763797d36
|
@ -70,8 +70,9 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
|||
weechat.look.buffer_search_{case_sensitive|force_default|regex|where}
|
||||
* doc: add Japanese plugin API reference and developer's guide
|
||||
* doc: add Polish man page and user's guide
|
||||
* api: add function "infolist_search_var"
|
||||
* api: add stdin options in functions hook_process_hashtable and hook_set
|
||||
to send data on stdin of child process, add function hook_set in script API
|
||||
to send data on stdin of child process, add function "hook_set" in script API
|
||||
(task #10847, task #13031)
|
||||
* api: add hdata "buffer_visited"
|
||||
* api: add support of infos with format `${info:name,arguments}` in function
|
||||
|
|
|
@ -12718,6 +12718,53 @@ weechat.infolist_reset_item_cursor(infolist)
|
|||
weechat.infolist_reset_item_cursor(infolist)
|
||||
----
|
||||
|
||||
==== weechat_infolist_search_var
|
||||
|
||||
_WeeChat ≥ 0.4.3._
|
||||
|
||||
Search a variable in the current infolist item.
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_infolist_var *weechat_infolist_search_var (struct t_infolist *infolist,
|
||||
const char *name);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
|
||||
* 'infolist': infolist pointer
|
||||
* 'name': variable name
|
||||
|
||||
Return value:
|
||||
|
||||
* pointer to variable found, NULL if the variable was not found
|
||||
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
if (weechat_infolist_search_var (infolist, "name"))
|
||||
{
|
||||
/* variable "name" exists */
|
||||
/* ... */
|
||||
}
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
var = weechat.infolist_search_var(infolist, name)
|
||||
|
||||
# example
|
||||
if weechat.infolist_search_var(infolist, "name"):
|
||||
# variable "name" exists
|
||||
# ...
|
||||
----
|
||||
|
||||
==== weechat_infolist_fields
|
||||
|
||||
Return list of fields for current infolist item.
|
||||
|
|
|
@ -12941,6 +12941,53 @@ weechat.infolist_reset_item_cursor(infolist)
|
|||
weechat.infolist_reset_item_cursor(infolist)
|
||||
----
|
||||
|
||||
==== weechat_infolist_search_var
|
||||
|
||||
_WeeChat ≥ 0.4.3._
|
||||
|
||||
Chercher une variable dans l'objet courant de l'infolist.
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_infolist_var *weechat_infolist_search_var (struct t_infolist *infolist,
|
||||
const char *name);
|
||||
----
|
||||
|
||||
Paramètres :
|
||||
|
||||
* 'infolist' : pointeur vers l'infolist
|
||||
* 'name' : nom de la variable
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* ponteur vers la variable trouvée, NULL si la variable n'est pas trouvée
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
if (weechat_infolist_search_var (infolist, "name"))
|
||||
{
|
||||
/* la variable "name" existe */
|
||||
/* ... */
|
||||
}
|
||||
----
|
||||
|
||||
Script (Python) :
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
var = weechat.infolist_search_var(infolist, name)
|
||||
|
||||
# exemple
|
||||
if weechat.infolist_search_var(infolist, "name"):
|
||||
# la variable "name" existe
|
||||
# ...
|
||||
----
|
||||
|
||||
==== weechat_infolist_fields
|
||||
|
||||
Retourner la liste des champs pour l'objet courant de l'infolist.
|
||||
|
|
|
@ -13025,6 +13025,57 @@ weechat.infolist_reset_item_cursor(infolist)
|
|||
weechat.infolist_reset_item_cursor(infolist)
|
||||
----
|
||||
|
||||
==== weechat_infolist_search_var
|
||||
|
||||
_WeeChat ≥ 0.4.3._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Search a variable in the current infolist item.
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_infolist_var *weechat_infolist_search_var (struct t_infolist *infolist,
|
||||
const char *name);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
|
||||
* 'infolist': puntatore alla lista info
|
||||
* 'name': nome della variabile
|
||||
|
||||
Valore restituito:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* pointer to variable found, NULL if the variable was not found
|
||||
|
||||
Esempio in C:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[source,C]
|
||||
----
|
||||
if (weechat_infolist_search_var (infolist, "name"))
|
||||
{
|
||||
/* variable "name" exists */
|
||||
/* ... */
|
||||
}
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[source,python]
|
||||
----
|
||||
# prototipo
|
||||
var = weechat.infolist_search_var(infolist, name)
|
||||
|
||||
# esempio
|
||||
if weechat.infolist_search_var(infolist, "name"):
|
||||
# variable "name" exists
|
||||
# ...
|
||||
----
|
||||
|
||||
==== weechat_infolist_fields
|
||||
|
||||
Restituisce una lista di campi per l'elemento della
|
||||
|
|
|
@ -12715,6 +12715,57 @@ weechat.infolist_reset_item_cursor(infolist)
|
|||
weechat.infolist_reset_item_cursor(infolist)
|
||||
----
|
||||
|
||||
==== weechat_infolist_search_var
|
||||
|
||||
_WeeChat バージョン 0.4.3 以上で利用可。_
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Search a variable in the current infolist item.
|
||||
|
||||
プロトタイプ:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_infolist_var *weechat_infolist_search_var (struct t_infolist *infolist,
|
||||
const char *name);
|
||||
----
|
||||
|
||||
引数:
|
||||
|
||||
* 'infolist': インフォリストへのポインタ
|
||||
* 'name': 変数名
|
||||
|
||||
戻り値:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* pointer to variable found, NULL if the variable was not found
|
||||
|
||||
C 言語での使用例:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[source,C]
|
||||
----
|
||||
if (weechat_infolist_search_var (infolist, "name"))
|
||||
{
|
||||
/* variable "name" exists */
|
||||
/* ... */
|
||||
}
|
||||
----
|
||||
|
||||
スクリプト (Python) での使用例:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
var = weechat.infolist_search_var(infolist, name)
|
||||
|
||||
# example
|
||||
if weechat.infolist_search_var(infolist, "name"):
|
||||
# variable "name" exists
|
||||
# ...
|
||||
----
|
||||
|
||||
==== weechat_infolist_fields
|
||||
|
||||
現在のインフォリストの要素に対するフィールドのリストを返す。
|
||||
|
|
|
@ -67,6 +67,33 @@ infolist_new (struct t_weechat_plugin *plugin)
|
|||
return new_infolist;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if an infolist pointer is valid.
|
||||
*
|
||||
* Returns:
|
||||
* 1: infolist exists
|
||||
* 0: infolist is not found
|
||||
*/
|
||||
|
||||
int
|
||||
infolist_valid (struct t_infolist *infolist)
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
|
||||
if (!infolist)
|
||||
return 0;
|
||||
|
||||
for (ptr_infolist = weechat_infolists; ptr_infolist;
|
||||
ptr_infolist = ptr_infolist->next_infolist)
|
||||
{
|
||||
if (ptr_infolist == infolist)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* list not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a new item in an infolist.
|
||||
*
|
||||
|
@ -274,33 +301,6 @@ infolist_new_var_time (struct t_infolist_item *item,
|
|||
return new_var;
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks if an infolist pointer is valid.
|
||||
*
|
||||
* Returns:
|
||||
* 1: infolist exists
|
||||
* 0: infolist is not found
|
||||
*/
|
||||
|
||||
int
|
||||
infolist_valid (struct t_infolist *infolist)
|
||||
{
|
||||
struct t_infolist *ptr_infolist;
|
||||
|
||||
if (!infolist)
|
||||
return 0;
|
||||
|
||||
for (ptr_infolist = weechat_infolists; ptr_infolist;
|
||||
ptr_infolist = ptr_infolist->next_infolist)
|
||||
{
|
||||
if (ptr_infolist == infolist)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* list not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets next item for an infolist.
|
||||
*
|
||||
|
@ -347,6 +347,29 @@ infolist_reset_item_cursor (struct t_infolist *infolist)
|
|||
infolist->ptr_item = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for a variable in current infolist item.
|
||||
*/
|
||||
|
||||
struct t_infolist_var *
|
||||
infolist_search_var (struct t_infolist *infolist, const char *name)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !name || !name[0])
|
||||
return NULL;
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
if (string_strcasecmp (ptr_var->name, name) == 0)
|
||||
return ptr_var;
|
||||
}
|
||||
|
||||
/* variable not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets list of fields for current infolist item.
|
||||
*/
|
||||
|
@ -551,29 +574,6 @@ infolist_time (struct t_infolist *infolist, const char *var)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Searches for a variable in current infolist item.
|
||||
*/
|
||||
|
||||
struct t_infolist_var *
|
||||
infolist_search_var (struct t_infolist *infolist, const char *var)
|
||||
{
|
||||
struct t_infolist_var *ptr_var;
|
||||
|
||||
if (!infolist || !infolist->ptr_item || !var || !var[0])
|
||||
return NULL;
|
||||
|
||||
for (ptr_var = infolist->ptr_item->vars; ptr_var;
|
||||
ptr_var = ptr_var->next_var)
|
||||
{
|
||||
if (string_strcasecmp (ptr_var->name, var) == 0)
|
||||
return ptr_var;
|
||||
}
|
||||
|
||||
/* variable not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees a variable in item.
|
||||
*/
|
||||
|
|
|
@ -69,6 +69,7 @@ extern struct t_infolist *last_weechat_infolist;
|
|||
/* list functions */
|
||||
|
||||
extern struct t_infolist *infolist_new ();
|
||||
extern int infolist_valid (struct t_infolist *infolist);
|
||||
extern struct t_infolist_item *infolist_new_item (struct t_infolist *infolist);
|
||||
extern struct t_infolist_var *infolist_new_var_integer (struct t_infolist_item *item,
|
||||
const char *name,
|
||||
|
@ -86,7 +87,8 @@ extern struct t_infolist_var *infolist_new_var_buffer (struct t_infolist_item *i
|
|||
extern struct t_infolist_var *infolist_new_var_time (struct t_infolist_item *item,
|
||||
const char *name,
|
||||
time_t time);
|
||||
extern int infolist_valid (struct t_infolist *infolist);
|
||||
extern struct t_infolist_var *infolist_search_var (struct t_infolist *infolist,
|
||||
const char *name);
|
||||
extern struct t_infolist_item *infolist_next (struct t_infolist *infolist);
|
||||
extern struct t_infolist_item *infolist_prev (struct t_infolist *infolist);
|
||||
extern void infolist_reset_item_cursor (struct t_infolist *infolist);
|
||||
|
@ -101,8 +103,6 @@ extern void *infolist_buffer (struct t_infolist *infolist,
|
|||
const char *var, int *size);
|
||||
extern time_t infolist_time (struct t_infolist *infolist,
|
||||
const char *var);
|
||||
extern struct t_infolist_var *infolist_search_var (struct t_infolist *infolist,
|
||||
const char *var);
|
||||
extern void infolist_free (struct t_infolist *infolist);
|
||||
extern void infolist_free_all_plugin (struct t_weechat_plugin *plugin);
|
||||
extern void infolist_print_log ();
|
||||
|
|
|
@ -734,6 +734,7 @@ plugin_load (const char *filename, int argc, char **argv)
|
|||
new_plugin->infolist_new_var_pointer = &infolist_new_var_pointer;
|
||||
new_plugin->infolist_new_var_buffer = &infolist_new_var_buffer;
|
||||
new_plugin->infolist_new_var_time = &infolist_new_var_time;
|
||||
new_plugin->infolist_search_var = &infolist_search_var;
|
||||
new_plugin->infolist_get = &hook_infolist_get;
|
||||
new_plugin->infolist_next = &plugin_api_infolist_next;
|
||||
new_plugin->infolist_prev = &plugin_api_infolist_prev;
|
||||
|
|
|
@ -57,7 +57,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 "20140109-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20140122-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
|
@ -839,6 +839,8 @@ struct t_weechat_plugin
|
|||
struct t_infolist_var *(*infolist_new_var_time) (struct t_infolist_item *item,
|
||||
const char *name,
|
||||
time_t time);
|
||||
struct t_infolist_var *(*infolist_search_var) (struct t_infolist *infolist,
|
||||
const char *name);
|
||||
struct t_infolist *(*infolist_get) (struct t_weechat_plugin *plugin,
|
||||
const char *infolist_name,
|
||||
void *pointer,
|
||||
|
@ -1618,6 +1620,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
|||
__size)
|
||||
#define weechat_infolist_new_var_time(__item, __name, __time) \
|
||||
weechat_plugin->infolist_new_var_time(__item, __name, __time)
|
||||
#define weechat_infolist_search_var(__list, __name) \
|
||||
weechat_plugin->infolist_search_var(__list, __name)
|
||||
#define weechat_infolist_get(__infolist_name, __pointer, __arguments) \
|
||||
weechat_plugin->infolist_get(weechat_plugin, __infolist_name, \
|
||||
__pointer, __arguments)
|
||||
|
|
Loading…
Reference in New Issue