mirror of
https://github.com/weechat/weechat.git
synced 2026-07-02 15:53:12 +02:00
api: add function "hdata_longlong" (issue #2081)
This commit is contained in:
@@ -24,6 +24,7 @@ New features::
|
||||
* api: add modifier "color_decode" to decode WeeChat colors with a replacement string
|
||||
* api: use whole replacement string instead of first char in function string_remove_color
|
||||
* api: add functions config_option_get_{string|pointer} and config_{boolean|integer|string|color|enum}_inherited in scripting API
|
||||
* api: add function "hdata_longlong" (issue #2081)
|
||||
* api: add info "plugin_loaded"
|
||||
* api: add support of specifier `%!` for timestamp in function util_strftimeval
|
||||
* api: add support of base64url in encode/decode functions
|
||||
|
||||
@@ -18095,7 +18095,7 @@ This function is not available in scripting API.
|
||||
|
||||
==== hdata_new_var
|
||||
|
||||
_WeeChat ≥ 0.3.6, updated in 0.3.7, 0.3.9, 0.4.3, 3.4._
|
||||
_WeeChat ≥ 0.3.6, updated in 0.3.7, 0.3.9, 0.4.3, 3.4, 4.3.0._
|
||||
|
||||
Create a new variable in hdata.
|
||||
|
||||
@@ -18116,6 +18116,7 @@ Arguments:
|
||||
** _WEECHAT_HDATA_CHAR_
|
||||
** _WEECHAT_HDATA_INTEGER_
|
||||
** _WEECHAT_HDATA_LONG_
|
||||
** _WEECHAT_HDATA_LONGLONG_ (_WeeChat ≥ 4.3.0_)
|
||||
** _WEECHAT_HDATA_STRING_
|
||||
** _WEECHAT_HDATA_SHARED_STRING_ (_WeeChat ≥ 0.4.3_)
|
||||
** _WEECHAT_HDATA_POINTER_
|
||||
@@ -18396,6 +18397,9 @@ switch (type)
|
||||
case WEECHAT_HDATA_LONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
/* ... */
|
||||
break;
|
||||
@@ -18997,7 +19001,7 @@ weechat.prnt("", "number = %d" % weechat.hdata_integer(hdata, buffer, "number"))
|
||||
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
Return value of long variable in structure using hdata.
|
||||
Return value of "long" variable in structure using hdata.
|
||||
|
||||
Prototype:
|
||||
|
||||
@@ -19035,6 +19039,48 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int: ...
|
||||
weechat.prnt("", "longvar = %d" % weechat.hdata_long(hdata, pointer, "longvar"))
|
||||
----
|
||||
|
||||
==== hdata_longlong
|
||||
|
||||
_WeeChat ≥ 4.3.0._
|
||||
|
||||
Return value of "long long" variable in structure using hdata.
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
long long weechat_hdata_longlong (struct t_hdata *hdata, void *pointer, const char *name);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
|
||||
* _hdata_: hdata pointer
|
||||
* _pointer_: pointer to WeeChat/plugin object
|
||||
* _name_: variable name (must be type "long long"); for arrays, the name can be
|
||||
"N|name" where N is the index in array (starting at 0), for example: "2|name"
|
||||
|
||||
Return value:
|
||||
|
||||
* long long value of variable
|
||||
|
||||
C example:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
weechat_printf (NULL, "longlongvar = %lld", weechat_hdata_longlong (hdata, pointer, "longlongvar"));
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def hdata_longlong(hdata: str, pointer: str, name: str) -> int: ...
|
||||
|
||||
# example
|
||||
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
|
||||
----
|
||||
|
||||
==== hdata_string
|
||||
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
@@ -18476,7 +18476,7 @@ Cette fonction n'est pas disponible dans l'API script.
|
||||
|
||||
==== hdata_new_var
|
||||
|
||||
_WeeChat ≥ 0.3.6, mis à jour dans la 0.3.7, 0.3.9, 0.4.3, 3.4._
|
||||
_WeeChat ≥ 0.3.6, mis à jour dans la 0.3.7, 0.3.9, 0.4.3, 3.4, 4.3.0._
|
||||
|
||||
Créer une nouvelle variable dans le hdata.
|
||||
|
||||
@@ -18497,6 +18497,7 @@ Paramètres :
|
||||
** _WEECHAT_HDATA_CHAR_
|
||||
** _WEECHAT_HDATA_INTEGER_
|
||||
** _WEECHAT_HDATA_LONG_
|
||||
** _WEECHAT_HDATA_LONGLONG_ (_WeeChat ≥ 4.3.0_)
|
||||
** _WEECHAT_HDATA_STRING_
|
||||
** _WEECHAT_HDATA_SHARED_STRING_ (_WeeChat ≥ 0.4.3_)
|
||||
** _WEECHAT_HDATA_POINTER_
|
||||
@@ -18781,6 +18782,9 @@ switch (type)
|
||||
case WEECHAT_HDATA_LONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
/* ... */
|
||||
break;
|
||||
@@ -19392,7 +19396,7 @@ weechat.prnt("", "number = %d" % weechat.hdata_integer(hdata, buffer, "number"))
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
Retourner la valeur de la variable dans la structure en utilisant le hdata, sous
|
||||
forme d'entier long.
|
||||
forme d'entier "long".
|
||||
|
||||
Prototype :
|
||||
|
||||
@@ -19431,6 +19435,50 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int: ...
|
||||
weechat.prnt("", "longvar = %d" % weechat.hdata_long(hdata, pointer, "longvar"))
|
||||
----
|
||||
|
||||
==== hdata_longlong
|
||||
|
||||
_WeeChat ≥ 4.3.0._
|
||||
|
||||
Retourner la valeur de la variable dans la structure en utilisant le hdata, sous
|
||||
forme d'entier "long long".
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,c]
|
||||
----
|
||||
long long weechat_hdata_longlong (struct t_hdata *hdata, void *pointer, const char *name);
|
||||
----
|
||||
|
||||
Paramètres :
|
||||
|
||||
* _hdata_ : pointeur vers le hdata
|
||||
* _pointer_ : pointeur vers un objet WeeChat ou d'une extension
|
||||
* _name_ : nom de la variable (doit être de type "long long"); pour les tableaux,
|
||||
le nom peut être "N|name" où N est un index dans le tableau (démarrant à 0),
|
||||
par exemple : "2|name"
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* valeur de la variable, sous forme d'entier "long long".
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,c]
|
||||
----
|
||||
weechat_printf (NULL, "longlongvar = %llu", weechat_hdata_longlong (hdata, pointer, "longlongvar"));
|
||||
----
|
||||
|
||||
Script (Python) :
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def hdata_longlong(hdata: str, pointer: str, name: str) -> int: ...
|
||||
|
||||
# exemple
|
||||
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
|
||||
----
|
||||
|
||||
==== hdata_string
|
||||
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
@@ -18923,7 +18923,7 @@ Questa funzione non è disponibile nelle API per lo scripting.
|
||||
==== hdata_new_var
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 0.3.6, updated in 0.3.7, 0.3.9, 0.4.3, 3.4_
|
||||
_WeeChat ≥ 0.3.6, updated in 0.3.7, 0.3.9, 0.4.3, 3.4, 4.3.0_
|
||||
|
||||
Crea una nuova variabile in hdata.
|
||||
|
||||
@@ -18944,6 +18944,7 @@ Argomenti:
|
||||
** _WEECHAT_HDATA_CHAR_
|
||||
** _WEECHAT_HDATA_INTEGER_
|
||||
** _WEECHAT_HDATA_LONG_
|
||||
** _WEECHAT_HDATA_LONGLONG_ (_WeeChat ≥ 4.3.0_)
|
||||
** _WEECHAT_HDATA_STRING_
|
||||
** _WEECHAT_HDATA_SHARED_STRING_ (_WeeChat ≥ 0.4.3_)
|
||||
** _WEECHAT_HDATA_POINTER_
|
||||
@@ -19233,6 +19234,9 @@ switch (type)
|
||||
case WEECHAT_HDATA_LONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
/* ... */
|
||||
break;
|
||||
@@ -19856,7 +19860,7 @@ weechat.prnt("", "number = %d" % weechat.hdata_integer(hdata, buffer, "number"))
|
||||
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
Restituisce il valore della variabile long della struttura usando hdata.
|
||||
Restituisce il valore della variabile "long" della struttura usando hdata.
|
||||
|
||||
Prototipo:
|
||||
|
||||
@@ -19896,6 +19900,52 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int: ...
|
||||
weechat.prnt("", "longvar = %d" % weechat.hdata_long(hdata, pointer, "longvar"))
|
||||
----
|
||||
|
||||
==== hdata_longlong
|
||||
|
||||
_WeeChat ≥ 4.3.0._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Return value of "long long" variable in structure using hdata.
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
long long weechat_hdata_longlong (struct t_hdata *hdata, void *pointer, const char *name);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
|
||||
* _hdata_: puntatore hdata
|
||||
* _pointer_: puntatore all'oggetto di WeeChat/plugin
|
||||
// TRANSLATION MISSING
|
||||
* _name_: nome della variabile (deve essere di tipo "long long"); for arrays,
|
||||
the name can be "N|name" where N is the index in array (starting at 0),
|
||||
for example: "2|name"
|
||||
|
||||
Valore restituito:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* "long long" value of variable
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
weechat_printf (NULL, "longlongvar = %lld", weechat_hdata_longlong (hdata, pointer, "longlongvar"));
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototipo
|
||||
def hdata_longlong(hdata: str, pointer: str, name: str) -> int: ...
|
||||
|
||||
# esempio
|
||||
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
|
||||
----
|
||||
|
||||
==== hdata_string
|
||||
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
@@ -18338,7 +18338,7 @@ struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, 0
|
||||
==== hdata_new_var
|
||||
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 0.3.6, updated in 0.3.7, 0.3.9, 0.4.3, 3.4._
|
||||
_WeeChat ≥ 0.3.6, updated in 0.3.7, 0.3.9, 0.4.3, 3.4, 4.3.0._
|
||||
|
||||
hdata に新しい変数を作成。
|
||||
|
||||
@@ -18359,6 +18359,7 @@ void weechat_hdata_new_var (struct t_hdata *hdata, const char *name, int offset,
|
||||
** _WEECHAT_HDATA_CHAR_
|
||||
** _WEECHAT_HDATA_INTEGER_
|
||||
** _WEECHAT_HDATA_LONG_
|
||||
** _WEECHAT_HDATA_LONGLONG_ (_WeeChat ≥ 4.3.0_)
|
||||
** _WEECHAT_HDATA_STRING_
|
||||
** _WEECHAT_HDATA_SHARED_STRING_ (_WeeChat ≥ 0.4.3_)
|
||||
** _WEECHAT_HDATA_POINTER_
|
||||
@@ -18642,6 +18643,9 @@ switch (type)
|
||||
case WEECHAT_HDATA_LONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
/* ... */
|
||||
break;
|
||||
@@ -19243,7 +19247,7 @@ weechat.prnt("", "number = %d" % weechat.hdata_integer(hdata, buffer, "number"))
|
||||
|
||||
_WeeChat バージョン 0.3.6 以上で利用可。_
|
||||
|
||||
hdata を使って構造体に含まれる long 型変数の値を返す。
|
||||
hdata を使って構造体に含まれる "long" 型変数の値を返す。
|
||||
|
||||
プロトタイプ:
|
||||
|
||||
@@ -19281,6 +19285,50 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int: ...
|
||||
weechat.prnt("", "longvar = %d" % weechat.hdata_long(hdata, pointer, "longvar"))
|
||||
----
|
||||
|
||||
==== hdata_longlong
|
||||
|
||||
_WeeChat バージョン 4.3.0 以上で利用可。_
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Return value of "long long" variable in structure using hdata.
|
||||
|
||||
プロトタイプ:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
long long weechat_hdata_longlong (struct t_hdata *hdata, void *pointer, const char *name);
|
||||
----
|
||||
|
||||
引数:
|
||||
|
||||
* _hdata_: hdata へのポインタ
|
||||
* _pointer_: WeeChat および plugin オブジェクトへのポインタ
|
||||
* _name_: 変数名 (必ず「long long 型」であること); 配列の場合、"N|name"
|
||||
のように名前を指定することが可能。ここで N は配列のインデックス (1 番目は 0)、例: "2|name"
|
||||
|
||||
戻り値:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* "long long" value of variable
|
||||
|
||||
C 言語での使用例:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
weechat_printf (NULL, "longlongvar = %lld", weechat_hdata_longlong (hdata, pointer, "longlongvar"));
|
||||
----
|
||||
|
||||
スクリプト (Python) での使用例:
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# プロトタイプ
|
||||
def hdata_longlong(hdata: str, pointer: str, name: str) -> int: ...
|
||||
|
||||
# 例
|
||||
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
|
||||
----
|
||||
|
||||
==== hdata_string
|
||||
|
||||
_WeeChat バージョン 0.3.6 以上で利用可。_
|
||||
|
||||
@@ -17607,7 +17607,7 @@ struct t_hdata *hdata = weechat_hdata_new ("myplugin_list", "prev", "next", 0, 0
|
||||
|
||||
==== hdata_new_var
|
||||
|
||||
_WeeChat ≥ 0.3.6, ажурирано у верзијама 0.3.7, 0.3.9, 0.4.3 и 3.4._
|
||||
_WeeChat ≥ 0.3.6, ажурирано у верзијама 0.3.7, 0.3.9, 0.4.3, 3.4 и 4.3.0._
|
||||
|
||||
Креира нову променљиву у hdata.
|
||||
|
||||
@@ -17628,6 +17628,7 @@ void weechat_hdata_new_var (struct t_hdata *hdata, const char *name, int offset,
|
||||
** _WEECHAT_HDATA_CHAR_
|
||||
** _WEECHAT_HDATA_INTEGER_
|
||||
** _WEECHAT_HDATA_LONG_
|
||||
** _WEECHAT_HDATA_LONGLONG_ (_WeeChat ≥ 4.3.0_)
|
||||
** _WEECHAT_HDATA_STRING_
|
||||
** _WEECHAT_HDATA_SHARED_STRING_ (_WeeChat ≥ 0.4.3_)
|
||||
** _WEECHAT_HDATA_POINTER_
|
||||
@@ -17902,6 +17903,9 @@ switch (type)
|
||||
case WEECHAT_HDATA_LONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
/* ... */
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
/* ... */
|
||||
break;
|
||||
@@ -18524,6 +18528,49 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int: ...
|
||||
weechat.prnt("", "longvar = %d" % weechat.hdata_long(hdata, pointer, "longvar"))
|
||||
----
|
||||
|
||||
==== hdata_longlong
|
||||
|
||||
_WeeChat ≥ 4.3.0._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Return value of "long long" variable in structure using hdata.
|
||||
|
||||
Прототип:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
long long weechat_hdata_longlong (struct t_hdata *hdata, void *pointer, const char *name);
|
||||
----
|
||||
|
||||
Аргументи:
|
||||
|
||||
* _hdata_: показивач на hdata
|
||||
* _pointer_: показивач на објекат програма WeeChat/додатка
|
||||
* _name_: име променљиве (мора бити типа „long long”); у случају низова, име може да буде „N|име” где је N индекс низа (који почиње од 0), на пример: „2|име”
|
||||
|
||||
Повратна вредност:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
* "long long" value of variable
|
||||
|
||||
C пример:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
weechat_printf (NULL, "longlongvar = %lld", weechat_hdata_longlong (hdata, pointer, "longlongvar"));
|
||||
----
|
||||
|
||||
Скрипта (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# прототип
|
||||
def hdata_longlong(hdata: str, pointer: str, name: str) -> int: ...
|
||||
|
||||
# пример
|
||||
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
|
||||
----
|
||||
|
||||
==== hdata_string
|
||||
|
||||
_WeeChat ≥ 0.3.6._
|
||||
|
||||
@@ -1230,6 +1230,11 @@ eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
|
||||
"%ld", hdata_long (hdata, pointer, var_name));
|
||||
value = strdup (str_value);
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
snprintf (str_value, sizeof (str_value),
|
||||
"%lld", hdata_longlong (hdata, pointer, var_name));
|
||||
value = strdup (str_value);
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
case WEECHAT_HDATA_SHARED_STRING:
|
||||
ptr_value = hdata_string (hdata, pointer, var_name);
|
||||
|
||||
+57
-4
@@ -38,8 +38,8 @@
|
||||
|
||||
struct t_hashtable *weechat_hdata = NULL;
|
||||
|
||||
char *hdata_type_string[9] =
|
||||
{ "other", "char", "integer", "long", "string", "pointer", "time",
|
||||
char *hdata_type_string[WEECHAT_NUM_HDATA_TYPES] =
|
||||
{ "other", "char", "integer", "long", "longlong", "string", "pointer", "time",
|
||||
"hashtable", "shared_string" };
|
||||
|
||||
|
||||
@@ -331,6 +331,8 @@ hdata_get_var_array_size (struct t_hdata *hdata, void *pointer,
|
||||
return *((int *)(pointer + offset));
|
||||
case WEECHAT_HDATA_LONG:
|
||||
return (int)(*((long *)(pointer + offset)));
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
return (int)(*((long long *)(pointer + offset)));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -799,7 +801,41 @@ hdata_long (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets "long long" value of a variable in hdata.
|
||||
*/
|
||||
|
||||
long long
|
||||
hdata_longlong (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
{
|
||||
int index;
|
||||
const char *ptr_name;
|
||||
struct t_hdata_var *var;
|
||||
|
||||
if (!hdata || !pointer || !name)
|
||||
return 0;
|
||||
|
||||
hdata_get_index_and_name (name, &index, &ptr_name);
|
||||
var = hashtable_get (hdata->hash_var, ptr_name);
|
||||
if (var && (var->offset >= 0))
|
||||
{
|
||||
if (var->array_size && (index >= 0))
|
||||
{
|
||||
if (var->array_pointer)
|
||||
return (*((long long **)(pointer + var->offset)))[index];
|
||||
else
|
||||
return ((long long *)(pointer + var->offset))[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return *((long long *)(pointer + var->offset));
|
||||
}
|
||||
}
|
||||
|
||||
return 0LL;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -904,7 +940,7 @@ hdata_time (struct t_hdata *hdata, void *pointer, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return (time_t)0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -958,6 +994,7 @@ hdata_compare (struct t_hdata *hdata, void *pointer1, void *pointer2,
|
||||
{
|
||||
int rc, type, type1, type2, int_value1, int_value2;
|
||||
long long_value1, long_value2;
|
||||
long long longlong_value1, longlong_value2;
|
||||
char *var_name, *property, char_value1, char_value2;
|
||||
const char *ptr_var_name, *pos, *pos_open_paren, *hdata_name;
|
||||
const char *str_value1, *str_value2;
|
||||
@@ -1013,6 +1050,12 @@ hdata_compare (struct t_hdata *hdata, void *pointer1, void *pointer2,
|
||||
rc = (long_value1 < long_value2) ?
|
||||
-1 : ((long_value1 > long_value2) ? 1 : 0);
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
longlong_value1 = hdata_longlong (hdata, pointer1, var_name);
|
||||
longlong_value2 = hdata_longlong (hdata, pointer2, var_name);
|
||||
rc = (longlong_value1 < longlong_value2) ?
|
||||
-1 : ((longlong_value1 > longlong_value2) ? 1 : 0);
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
case WEECHAT_HDATA_SHARED_STRING:
|
||||
str_value1 = hdata_string (hdata, pointer1, var_name);
|
||||
@@ -1181,6 +1224,7 @@ hdata_set (struct t_hdata *hdata, void *pointer, const char *name,
|
||||
struct t_hdata_var *var;
|
||||
char **ptr_string, *error;
|
||||
long number;
|
||||
long long number_longlong;
|
||||
unsigned long ptr;
|
||||
int rc;
|
||||
|
||||
@@ -1220,6 +1264,15 @@ hdata_set (struct t_hdata *hdata, void *pointer, const char *name,
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
error = NULL;
|
||||
number_longlong = strtoll (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
*((long long *)(pointer + var->offset)) = number_longlong;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
ptr_string = (char **)(pointer + var->offset);
|
||||
if (*ptr_string)
|
||||
|
||||
@@ -122,6 +122,8 @@ extern int hdata_integer (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
extern long hdata_long (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
extern long long hdata_longlong (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
extern const char *hdata_string (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
extern void *hdata_pointer (struct t_hdata *hdata, void *pointer,
|
||||
|
||||
@@ -125,6 +125,14 @@ end:
|
||||
ptr_buffer, list_keys[i]) : -1);
|
||||
weechat_hashtable_set (info, list_keys[i], str_value);
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
snprintf (str_value, sizeof (str_value),
|
||||
"%lld",
|
||||
(ptr_buffer) ?
|
||||
weechat_hdata_longlong (buflist_hdata_buffer,
|
||||
ptr_buffer, list_keys[i]) : 0);
|
||||
weechat_hashtable_set (info, list_keys[i], str_value);
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
case WEECHAT_HDATA_SHARED_STRING:
|
||||
ptr_value = weechat_hdata_string (buflist_hdata_buffer,
|
||||
|
||||
@@ -93,6 +93,9 @@
|
||||
#define API_RETURN_LONG(__long) \
|
||||
API_FREE_STRINGS; \
|
||||
return scm_from_long (__long)
|
||||
#define API_RETURN_LONGLONG(__long) \
|
||||
API_FREE_STRINGS; \
|
||||
return scm_from_long_long (__long)
|
||||
#define API_RETURN_OTHER(__scm) \
|
||||
API_FREE_STRINGS; \
|
||||
return __scm
|
||||
@@ -5148,6 +5151,23 @@ weechat_guile_api_hdata_long (SCM hdata, SCM pointer, SCM name)
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_hdata_longlong (SCM hdata, SCM pointer, SCM name)
|
||||
{
|
||||
long long value;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONGLONG(0));
|
||||
if (!scm_is_string (hdata) || !scm_is_string (pointer)
|
||||
|| !scm_is_string (name))
|
||||
API_WRONG_ARGS(API_RETURN_LONGLONG(0));
|
||||
|
||||
value = weechat_hdata_longlong (API_STR2PTR(API_SCM_TO_STRING(hdata)),
|
||||
API_STR2PTR(API_SCM_TO_STRING(pointer)),
|
||||
API_SCM_TO_STRING(name));
|
||||
|
||||
API_RETURN_LONGLONG(value);
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_hdata_string (SCM hdata, SCM pointer, SCM name)
|
||||
{
|
||||
@@ -5631,6 +5651,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(hdata_char, 3);
|
||||
API_DEF_FUNC(hdata_integer, 3);
|
||||
API_DEF_FUNC(hdata_long, 3);
|
||||
API_DEF_FUNC(hdata_longlong, 3);
|
||||
API_DEF_FUNC(hdata_string, 3);
|
||||
API_DEF_FUNC(hdata_pointer, 3);
|
||||
API_DEF_FUNC(hdata_time, 3);
|
||||
|
||||
@@ -5066,6 +5066,24 @@ API_FUNC(hdata_long)
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_longlong)
|
||||
{
|
||||
long long value;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", "sss", API_RETURN_LONG(0));
|
||||
|
||||
v8::String::Utf8Value hdata(args[0]);
|
||||
v8::String::Utf8Value pointer(args[1]);
|
||||
v8::String::Utf8Value name(args[2]);
|
||||
|
||||
value = weechat_hdata_longlong (
|
||||
(struct t_hdata *)API_STR2PTR(*hdata),
|
||||
API_STR2PTR(*pointer),
|
||||
*name);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_string)
|
||||
{
|
||||
const char *result;
|
||||
@@ -5543,6 +5561,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(hdata_char);
|
||||
API_DEF_FUNC(hdata_integer);
|
||||
API_DEF_FUNC(hdata_long);
|
||||
API_DEF_FUNC(hdata_longlong);
|
||||
API_DEF_FUNC(hdata_string);
|
||||
API_DEF_FUNC(hdata_pointer);
|
||||
API_DEF_FUNC(hdata_time);
|
||||
|
||||
@@ -5475,6 +5475,26 @@ API_FUNC(hdata_long)
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_longlong)
|
||||
{
|
||||
const char *hdata, *pointer, *name;
|
||||
long long value;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
|
||||
if (lua_gettop (L) < 3)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
hdata = lua_tostring (L, -3);
|
||||
pointer = lua_tostring (L, -2);
|
||||
name = lua_tostring (L, -1);
|
||||
|
||||
value = weechat_hdata_longlong (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
name);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_string)
|
||||
{
|
||||
const char *hdata, *pointer, *name, *result;
|
||||
@@ -5951,6 +5971,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(hdata_char),
|
||||
API_DEF_FUNC(hdata_integer),
|
||||
API_DEF_FUNC(hdata_long),
|
||||
API_DEF_FUNC(hdata_longlong),
|
||||
API_DEF_FUNC(hdata_string),
|
||||
API_DEF_FUNC(hdata_pointer),
|
||||
API_DEF_FUNC(hdata_time),
|
||||
|
||||
@@ -5392,6 +5392,27 @@ API_FUNC(hdata_long)
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_longlong)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
long long value;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
|
||||
if (items < 3)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
hdata = SvPV_nolen (ST (0));
|
||||
pointer = SvPV_nolen (ST (1));
|
||||
name = SvPV_nolen (ST (2));
|
||||
|
||||
value = weechat_hdata_longlong (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
name);
|
||||
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_string)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
@@ -5888,6 +5909,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(hdata_char);
|
||||
API_DEF_FUNC(hdata_integer);
|
||||
API_DEF_FUNC(hdata_long);
|
||||
API_DEF_FUNC(hdata_longlong);
|
||||
API_DEF_FUNC(hdata_string);
|
||||
API_DEF_FUNC(hdata_pointer);
|
||||
API_DEF_FUNC(hdata_time);
|
||||
|
||||
@@ -5544,6 +5544,28 @@ API_FUNC(hdata_long)
|
||||
API_RETURN_LONG(result);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_longlong)
|
||||
{
|
||||
zend_string *z_hdata, *z_pointer, *z_name;
|
||||
struct t_hdata *hdata;
|
||||
void *pointer;
|
||||
char *name;
|
||||
long long result;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSS", &z_hdata, &z_pointer,
|
||||
&z_name) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
|
||||
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
|
||||
name = ZSTR_VAL(z_name);
|
||||
|
||||
result = weechat_hdata_longlong (hdata, pointer, (const char *)name);
|
||||
|
||||
API_RETURN_LONG(result);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_string)
|
||||
{
|
||||
zend_string *z_hdata, *z_pointer, *z_name;
|
||||
|
||||
@@ -252,6 +252,7 @@ PHP_FUNCTION(weechat_hdata_search);
|
||||
PHP_FUNCTION(weechat_hdata_char);
|
||||
PHP_FUNCTION(weechat_hdata_integer);
|
||||
PHP_FUNCTION(weechat_hdata_long);
|
||||
PHP_FUNCTION(weechat_hdata_longlong);
|
||||
PHP_FUNCTION(weechat_hdata_string);
|
||||
PHP_FUNCTION(weechat_hdata_pointer);
|
||||
PHP_FUNCTION(weechat_hdata_time);
|
||||
|
||||
@@ -310,6 +310,7 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_hdata_char, arginfo_weechat_hdata_char)
|
||||
PHP_FE(weechat_hdata_integer, arginfo_weechat_hdata_integer)
|
||||
PHP_FE(weechat_hdata_long, arginfo_weechat_hdata_long)
|
||||
PHP_FE(weechat_hdata_longlong, arginfo_weechat_hdata_longlong)
|
||||
PHP_FE(weechat_hdata_string, arginfo_weechat_hdata_string)
|
||||
PHP_FE(weechat_hdata_pointer, arginfo_weechat_hdata_pointer)
|
||||
PHP_FE(weechat_hdata_time, arginfo_weechat_hdata_time)
|
||||
|
||||
@@ -218,6 +218,7 @@ function weechat_hdata_search(string $p0, string $p1, string $p2, array $p3, arr
|
||||
function weechat_hdata_char(string $p0, string $p1, string $p2): int {}
|
||||
function weechat_hdata_integer(string $p0, string $p1, string $p2): int {}
|
||||
function weechat_hdata_long(string $p0, string $p1, string $p2): int {}
|
||||
function weechat_hdata_longlong(string $p0, string $p1, string $p2): int {}
|
||||
function weechat_hdata_string(string $p0, string $p1, string $p2): string {}
|
||||
function weechat_hdata_pointer(string $p0, string $p1, string $p2): string {}
|
||||
function weechat_hdata_time(string $p0, string $p1, string $p2): int {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 59292da89eab98ef1f615c173d9722b9fdafad80 */
|
||||
* Stub hash: cf4a06ff974bca04f671e75e22f7d16534ca643f */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
@@ -616,6 +616,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_hdata_long arginfo_weechat_config_write_line
|
||||
|
||||
#define arginfo_weechat_hdata_longlong arginfo_weechat_config_write_line
|
||||
|
||||
#define arginfo_weechat_hdata_string arginfo_weechat_config_search_option
|
||||
|
||||
#define arginfo_weechat_hdata_pointer arginfo_weechat_config_search_option
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 59292da89eab98ef1f615c173d9722b9fdafad80 */
|
||||
* Stub hash: cf4a06ff974bca04f671e75e22f7d16534ca643f */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7)
|
||||
ZEND_ARG_INFO(0, p0)
|
||||
@@ -451,6 +451,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_hdata_long arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_hdata_longlong arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_hdata_string arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_hdata_pointer arginfo_weechat_ngettext
|
||||
|
||||
@@ -932,6 +932,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->hdata_char = &hdata_char;
|
||||
new_plugin->hdata_integer = &hdata_integer;
|
||||
new_plugin->hdata_long = &hdata_long;
|
||||
new_plugin->hdata_longlong = &hdata_longlong;
|
||||
new_plugin->hdata_string = &hdata_string;
|
||||
new_plugin->hdata_pointer = &hdata_pointer;
|
||||
new_plugin->hdata_time = &hdata_time;
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
return PyLong_FromLong ((long)__int)
|
||||
#define API_RETURN_LONG(__long) \
|
||||
return PyLong_FromLong (__long)
|
||||
#define API_RETURN_LONGLONG(__longlong) \
|
||||
return PyLong_FromLongLong (__longlong)
|
||||
#define API_RETURN_ULONGLONG(__ulonglong) \
|
||||
return PyLong_FromUnsignedLongLong (__ulonglong)
|
||||
|
||||
@@ -5345,6 +5347,25 @@ API_FUNC(hdata_long)
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_longlong)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
long long value;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONGLONG(0));
|
||||
hdata = NULL;
|
||||
pointer = NULL;
|
||||
name = NULL;
|
||||
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
|
||||
API_WRONG_ARGS(API_RETURN_LONGLONG(0));
|
||||
|
||||
value = weechat_hdata_longlong (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
name);
|
||||
|
||||
API_RETURN_LONGLONG(value);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_string)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
@@ -5816,6 +5837,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(hdata_char),
|
||||
API_DEF_FUNC(hdata_integer),
|
||||
API_DEF_FUNC(hdata_long),
|
||||
API_DEF_FUNC(hdata_longlong),
|
||||
API_DEF_FUNC(hdata_string),
|
||||
API_DEF_FUNC(hdata_pointer),
|
||||
API_DEF_FUNC(hdata_time),
|
||||
|
||||
@@ -2701,6 +2701,16 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int:
|
||||
...
|
||||
|
||||
|
||||
def hdata_longlong(hdata: str, pointer: str, name: str) -> int:
|
||||
"""`hdata_longlong in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_hdata_longlong>`_
|
||||
::
|
||||
|
||||
# example
|
||||
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
def hdata_string(hdata: str, pointer: str, name: str) -> str:
|
||||
"""`hdata_string in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_hdata_string>`_
|
||||
::
|
||||
|
||||
@@ -175,6 +175,23 @@ relay_weechat_msg_add_long (struct t_relay_weechat_msg *msg, long value)
|
||||
relay_weechat_msg_add_bytes (msg, str_long, length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a long long integer to a message.
|
||||
*/
|
||||
|
||||
void
|
||||
relay_weechat_msg_add_longlong (struct t_relay_weechat_msg *msg,
|
||||
long long value)
|
||||
{
|
||||
char str_longlong[128];
|
||||
unsigned char length;
|
||||
|
||||
snprintf (str_longlong, sizeof (str_longlong), "%lld", value);
|
||||
length = strlen (str_longlong);
|
||||
relay_weechat_msg_add_bytes (msg, &length, 1);
|
||||
relay_weechat_msg_add_bytes (msg, str_longlong, length);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds length + string to a message.
|
||||
*/
|
||||
@@ -434,6 +451,7 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
|
||||
relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INT);
|
||||
break;
|
||||
case WEECHAT_HDATA_LONG:
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_LONG);
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
@@ -480,6 +498,12 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
|
||||
pointer,
|
||||
name));
|
||||
break;
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
relay_weechat_msg_add_longlong (msg,
|
||||
weechat_hdata_longlong (hdata,
|
||||
pointer,
|
||||
name));
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
case WEECHAT_HDATA_SHARED_STRING:
|
||||
relay_weechat_msg_add_string (msg,
|
||||
@@ -694,6 +718,7 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
|
||||
strcat (keys_types, RELAY_WEECHAT_MSG_OBJ_INT);
|
||||
break;
|
||||
case WEECHAT_HDATA_LONG:
|
||||
case WEECHAT_HDATA_LONGLONG:
|
||||
strcat (keys_types, RELAY_WEECHAT_MSG_OBJ_LONG);
|
||||
break;
|
||||
case WEECHAT_HDATA_STRING:
|
||||
|
||||
@@ -62,6 +62,8 @@ extern void relay_weechat_msg_add_int (struct t_relay_weechat_msg *msg,
|
||||
int value);
|
||||
extern void relay_weechat_msg_add_long (struct t_relay_weechat_msg *msg,
|
||||
long value);
|
||||
extern void relay_weechat_msg_add_longlong (struct t_relay_weechat_msg *msg,
|
||||
long long value);
|
||||
extern void relay_weechat_msg_add_string (struct t_relay_weechat_msg *msg,
|
||||
const char *string);
|
||||
extern void relay_weechat_msg_add_buffer (struct t_relay_weechat_msg *msg,
|
||||
|
||||
@@ -6591,6 +6591,32 @@ weechat_ruby_api_hdata_long (VALUE class, VALUE hdata, VALUE pointer,
|
||||
API_RETURN_LONG(value);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_longlong (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name;
|
||||
long long value;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
|
||||
API_WRONG_ARGS(API_RETURN_LONGLONG(0));
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (name, T_STRING);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_name = StringValuePtr (name);
|
||||
|
||||
value = weechat_hdata_longlong (API_STR2PTR(c_hdata),
|
||||
API_STR2PTR(c_pointer),
|
||||
c_name);
|
||||
|
||||
API_RETURN_LONGLONG(value);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_string (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE name)
|
||||
@@ -7147,6 +7173,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(hdata_char, 3);
|
||||
API_DEF_FUNC(hdata_integer, 3);
|
||||
API_DEF_FUNC(hdata_long, 3);
|
||||
API_DEF_FUNC(hdata_longlong, 3);
|
||||
API_DEF_FUNC(hdata_string, 3);
|
||||
API_DEF_FUNC(hdata_pointer, 3);
|
||||
API_DEF_FUNC(hdata_time, 3);
|
||||
|
||||
@@ -5373,6 +5373,26 @@ API_FUNC(hdata_long)
|
||||
API_RETURN_LONG(result);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_longlong)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
long long result;
|
||||
|
||||
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
|
||||
if (objc < 4)
|
||||
API_WRONG_ARGS(API_RETURN_LONG(0));
|
||||
|
||||
hdata = Tcl_GetString (objv[1]);
|
||||
pointer = Tcl_GetString (objv[2]);
|
||||
name = Tcl_GetString (objv[3]);
|
||||
|
||||
result = weechat_hdata_longlong (API_STR2PTR(hdata),
|
||||
API_STR2PTR(pointer),
|
||||
name);
|
||||
|
||||
API_RETURN_LONG(result);
|
||||
}
|
||||
|
||||
API_FUNC(hdata_string)
|
||||
{
|
||||
char *hdata, *pointer, *name;
|
||||
@@ -5887,6 +5907,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(hdata_char);
|
||||
API_DEF_FUNC(hdata_integer);
|
||||
API_DEF_FUNC(hdata_long);
|
||||
API_DEF_FUNC(hdata_longlong);
|
||||
API_DEF_FUNC(hdata_string);
|
||||
API_DEF_FUNC(hdata_pointer);
|
||||
API_DEF_FUNC(hdata_time);
|
||||
|
||||
@@ -71,7 +71,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 "20240304-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20240307-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -137,15 +137,21 @@ struct timeval;
|
||||
#define WEECHAT_HASHTABLE_TIME "time"
|
||||
|
||||
/* types for hdata */
|
||||
#define WEECHAT_HDATA_OTHER 0
|
||||
#define WEECHAT_HDATA_CHAR 1
|
||||
#define WEECHAT_HDATA_INTEGER 2
|
||||
#define WEECHAT_HDATA_LONG 3
|
||||
#define WEECHAT_HDATA_STRING 4
|
||||
#define WEECHAT_HDATA_POINTER 5
|
||||
#define WEECHAT_HDATA_TIME 6
|
||||
#define WEECHAT_HDATA_HASHTABLE 7
|
||||
#define WEECHAT_HDATA_SHARED_STRING 8
|
||||
enum t_weechat_hdata
|
||||
{
|
||||
WEECHAT_HDATA_OTHER = 0,
|
||||
WEECHAT_HDATA_CHAR,
|
||||
WEECHAT_HDATA_INTEGER,
|
||||
WEECHAT_HDATA_LONG,
|
||||
WEECHAT_HDATA_LONGLONG,
|
||||
WEECHAT_HDATA_STRING,
|
||||
WEECHAT_HDATA_POINTER,
|
||||
WEECHAT_HDATA_TIME,
|
||||
WEECHAT_HDATA_HASHTABLE,
|
||||
WEECHAT_HDATA_SHARED_STRING,
|
||||
/* number of hdata types */
|
||||
WEECHAT_NUM_HDATA_TYPES,
|
||||
};
|
||||
|
||||
/* flags for hdata lists */
|
||||
#define WEECHAT_HDATA_LIST_CHECK_POINTERS 1
|
||||
@@ -1213,6 +1219,8 @@ struct t_weechat_plugin
|
||||
const char *name);
|
||||
long (*hdata_long) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
long long (*hdata_longlong) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
const char *(*hdata_string) (struct t_hdata *hdata, void *pointer,
|
||||
const char *name);
|
||||
void *(*hdata_pointer) (struct t_hdata *hdata, void *pointer,
|
||||
@@ -2305,6 +2313,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
(weechat_plugin->hdata_integer)(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_long(__hdata, __pointer, __name) \
|
||||
(weechat_plugin->hdata_long)(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_longlong(__hdata, __pointer, __name) \
|
||||
(weechat_plugin->hdata_longlong)(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_string(__hdata, __pointer, __name) \
|
||||
(weechat_plugin->hdata_string)(__hdata, __pointer, __name)
|
||||
#define weechat_hdata_pointer(__hdata, __pointer, __name) \
|
||||
|
||||
@@ -54,6 +54,12 @@ struct t_test_item
|
||||
long test_array_2_long_fixed_size[2];
|
||||
long *test_ptr_2_long;
|
||||
|
||||
/* long long */
|
||||
long long test_longlong;
|
||||
long long test_count_longlong;
|
||||
long long test_array_2_longlong_fixed_size[2];
|
||||
long long *test_ptr_2_longlong;
|
||||
|
||||
/* string */
|
||||
char *test_string;
|
||||
char *test_string2;
|
||||
@@ -374,6 +380,16 @@ TEST_GROUP(CoreHdataWithList)
|
||||
item->test_ptr_2_long[0] = 123456L;
|
||||
item->test_ptr_2_long[1] = 234567L;
|
||||
|
||||
/* long long */
|
||||
item->test_longlong = 123456789123456L;
|
||||
item->test_count_longlong = 2;
|
||||
item->test_array_2_longlong_fixed_size[0] = 111L;
|
||||
item->test_array_2_longlong_fixed_size[1] = 222L;
|
||||
item->test_ptr_2_longlong = (long long *)malloc (
|
||||
2 * sizeof (item->test_ptr_2_longlong[0]));
|
||||
item->test_ptr_2_longlong[0] = 123456L;
|
||||
item->test_ptr_2_longlong[1] = 234567L;
|
||||
|
||||
/* string */
|
||||
item->test_string = strdup ("item1");
|
||||
item->test_string2 = strdup ("STRING2");
|
||||
@@ -522,6 +538,16 @@ TEST_GROUP(CoreHdataWithList)
|
||||
item->test_ptr_2_long[0] = 789123L;
|
||||
item->test_ptr_2_long[1] = 891234L;
|
||||
|
||||
/* long long */
|
||||
item->test_longlong = 987654321987654L;
|
||||
item->test_count_longlong = 2;
|
||||
item->test_array_2_longlong_fixed_size[0] = 333L;
|
||||
item->test_array_2_longlong_fixed_size[1] = 444L;
|
||||
item->test_ptr_2_longlong = (long long *)malloc (
|
||||
2 * sizeof (item->test_ptr_2_longlong[0]));
|
||||
item->test_ptr_2_longlong[0] = 789123L;
|
||||
item->test_ptr_2_longlong[1] = 891234L;
|
||||
|
||||
/* string */
|
||||
item->test_string = strdup ("item2");
|
||||
item->test_string2 = strdup ("string2");
|
||||
@@ -657,6 +683,12 @@ TEST_GROUP(CoreHdataWithList)
|
||||
HDATA_VAR(struct t_test_item, test_array_2_long_fixed_size, LONG, 0, "2", NULL);
|
||||
HDATA_VAR(struct t_test_item, test_ptr_2_long, LONG, 0, "*,test_count_long", NULL);
|
||||
|
||||
/* long long */
|
||||
HDATA_VAR(struct t_test_item, test_longlong, LONGLONG, 1, NULL, NULL);
|
||||
HDATA_VAR(struct t_test_item, test_count_longlong, LONGLONG, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_test_item, test_array_2_longlong_fixed_size, LONGLONG, 0, "2", NULL);
|
||||
HDATA_VAR(struct t_test_item, test_ptr_2_longlong, LONGLONG, 0, "*,test_count_longlong", NULL);
|
||||
|
||||
/* string */
|
||||
HDATA_VAR(struct t_test_item, test_string, STRING, 1, NULL, NULL);
|
||||
HDATA_VAR(struct t_test_item, test_string2, STRING, 0, NULL, NULL);
|
||||
@@ -740,6 +772,9 @@ TEST_GROUP(CoreHdataWithList)
|
||||
/* long */
|
||||
free (item->test_ptr_2_long);
|
||||
|
||||
/* long long */
|
||||
free (item->test_ptr_2_longlong);
|
||||
|
||||
/* string */
|
||||
free (item->test_string);
|
||||
free (item->test_string2);
|
||||
@@ -821,6 +856,8 @@ TEST(CoreHdataWithList, GetVarType)
|
||||
hdata_get_var_type (ptr_hdata, "test_int"));
|
||||
LONGS_EQUAL(WEECHAT_HDATA_LONG,
|
||||
hdata_get_var_type (ptr_hdata, "test_long"));
|
||||
LONGS_EQUAL(WEECHAT_HDATA_LONGLONG,
|
||||
hdata_get_var_type (ptr_hdata, "test_longlong"));
|
||||
LONGS_EQUAL(WEECHAT_HDATA_STRING,
|
||||
hdata_get_var_type (ptr_hdata, "test_string"));
|
||||
LONGS_EQUAL(WEECHAT_HDATA_SHARED_STRING,
|
||||
@@ -853,6 +890,8 @@ TEST(CoreHdataWithList, GetVarTypeString)
|
||||
hdata_get_var_type_string (ptr_hdata, "test_int"));
|
||||
STRCMP_EQUAL("long",
|
||||
hdata_get_var_type_string (ptr_hdata, "test_long"));
|
||||
STRCMP_EQUAL("longlong",
|
||||
hdata_get_var_type_string (ptr_hdata, "test_longlong"));
|
||||
STRCMP_EQUAL("string",
|
||||
hdata_get_var_type_string (ptr_hdata, "test_string"));
|
||||
STRCMP_EQUAL("shared_string",
|
||||
@@ -898,6 +937,10 @@ TEST(CoreHdataWithList, GetVarArraySize)
|
||||
"test_array_2_long_fixed_size"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item1,
|
||||
"test_ptr_2_long"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item1,
|
||||
"test_array_2_longlong_fixed_size"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item1,
|
||||
"test_ptr_2_longlong"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item1,
|
||||
"test_array_2_words_fixed_size"));
|
||||
LONGS_EQUAL(3, hdata_get_var_array_size (ptr_hdata, ptr_item1,
|
||||
@@ -944,6 +987,10 @@ TEST(CoreHdataWithList, GetVarArraySize)
|
||||
"test_array_2_long_fixed_size"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item2,
|
||||
"test_ptr_2_long"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item2,
|
||||
"test_array_2_longlong_fixed_size"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item2,
|
||||
"test_ptr_2_longlong"));
|
||||
LONGS_EQUAL(2, hdata_get_var_array_size (ptr_hdata, ptr_item2,
|
||||
"test_array_2_words_fixed_size"));
|
||||
LONGS_EQUAL(4, hdata_get_var_array_size (ptr_hdata, ptr_item2,
|
||||
@@ -1020,6 +1067,12 @@ TEST(CoreHdataWithList, GetVarArraySizeString)
|
||||
STRCMP_EQUAL("test_count_long",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item1,
|
||||
"test_ptr_2_long"));
|
||||
STRCMP_EQUAL("2",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item1,
|
||||
"test_array_2_longlong_fixed_size"));
|
||||
STRCMP_EQUAL("test_count_longlong",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item1,
|
||||
"test_ptr_2_longlong"));
|
||||
STRCMP_EQUAL("2",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item1,
|
||||
"test_array_2_words_fixed_size"));
|
||||
@@ -1084,6 +1137,12 @@ TEST(CoreHdataWithList, GetVarArraySizeString)
|
||||
STRCMP_EQUAL("test_count_long",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item2,
|
||||
"test_ptr_2_long"));
|
||||
STRCMP_EQUAL("2",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item2,
|
||||
"test_array_2_longlong_fixed_size"));
|
||||
STRCMP_EQUAL("test_count_longlong",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item2,
|
||||
"test_ptr_2_longlong"));
|
||||
STRCMP_EQUAL("2",
|
||||
hdata_get_var_array_size_string (ptr_hdata, ptr_item2,
|
||||
"test_array_2_words_fixed_size"));
|
||||
@@ -1441,6 +1500,39 @@ TEST(CoreHdataWithList, Search)
|
||||
"${test_item.test_long} == ${value}",
|
||||
NULL, extra_vars, NULL, 1));
|
||||
|
||||
/* search long long */
|
||||
POINTERS_EQUAL(
|
||||
NULL,
|
||||
hdata_search (ptr_hdata, items,
|
||||
"${test_item.test_longlong} == 999",
|
||||
NULL, NULL, NULL, 1));
|
||||
POINTERS_EQUAL(
|
||||
NULL,
|
||||
hdata_search (ptr_hdata, items,
|
||||
"${test_item.test_longlong} == 987654321987654",
|
||||
NULL, NULL, NULL, 2));
|
||||
POINTERS_EQUAL(
|
||||
ptr_item1,
|
||||
hdata_search (ptr_hdata, items,
|
||||
"${test_item.test_longlong} == 123456789123456",
|
||||
NULL, NULL, NULL, 1));
|
||||
POINTERS_EQUAL(
|
||||
ptr_item2,
|
||||
hdata_search (ptr_hdata, items,
|
||||
"${test_item.test_longlong} == 987654321987654",
|
||||
NULL, NULL, NULL, 1));
|
||||
POINTERS_EQUAL(
|
||||
ptr_item1,
|
||||
hdata_search (ptr_hdata, last_item,
|
||||
"${test_item.test_longlong} == 123456789123456",
|
||||
NULL, NULL, NULL, -1));
|
||||
hashtable_set (extra_vars, "value", "987654321987654");
|
||||
POINTERS_EQUAL(
|
||||
ptr_item2,
|
||||
hdata_search (ptr_hdata, items,
|
||||
"${test_item.test_longlong} == ${value}",
|
||||
NULL, extra_vars, NULL, 1));
|
||||
|
||||
/* search string */
|
||||
POINTERS_EQUAL(
|
||||
NULL,
|
||||
@@ -1748,6 +1840,48 @@ TEST(CoreHdataWithList, Long)
|
||||
"1|test_ptr_2_long"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* hdata_longlong
|
||||
*/
|
||||
|
||||
TEST(CoreHdataWithList, LongLong)
|
||||
{
|
||||
LONGS_EQUAL(0, hdata_longlong (NULL, NULL, NULL));
|
||||
LONGS_EQUAL(0, hdata_longlong (ptr_hdata, NULL, NULL));
|
||||
LONGS_EQUAL(0, hdata_longlong (NULL, ptr_item1, NULL));
|
||||
LONGS_EQUAL(0, hdata_longlong (NULL, NULL, "test_longlong"));
|
||||
LONGS_EQUAL(0, hdata_longlong (ptr_hdata, ptr_item1, NULL));
|
||||
LONGS_EQUAL(0, hdata_longlong (ptr_hdata, NULL, "test_longlong"));
|
||||
LONGS_EQUAL(0, hdata_longlong (NULL, ptr_item1, "test_longlong"));
|
||||
|
||||
/* variable not found */
|
||||
LONGS_EQUAL(0, hdata_longlong (ptr_hdata, ptr_item1, "zzz"));
|
||||
LONGS_EQUAL(0, hdata_longlong (ptr_hdata, ptr_item1, "1|zzz"));
|
||||
|
||||
/* item 1 */
|
||||
LONGS_EQUAL(123456789123456L, hdata_longlong (ptr_hdata, ptr_item1, "test_longlong"));
|
||||
LONGS_EQUAL(111L, hdata_longlong (ptr_hdata, ptr_item1,
|
||||
"0|test_array_2_longlong_fixed_size"));
|
||||
LONGS_EQUAL(222L, hdata_longlong (ptr_hdata, ptr_item1,
|
||||
"1|test_array_2_longlong_fixed_size"));
|
||||
LONGS_EQUAL(123456L, hdata_longlong (ptr_hdata, ptr_item1,
|
||||
"0|test_ptr_2_longlong"));
|
||||
LONGS_EQUAL(234567L, hdata_longlong (ptr_hdata, ptr_item1,
|
||||
"1|test_ptr_2_longlong"));
|
||||
|
||||
/* item 2 */
|
||||
LONGS_EQUAL(987654321987654L, hdata_longlong (ptr_hdata, ptr_item2, "test_longlong"));
|
||||
LONGS_EQUAL(333L, hdata_longlong (ptr_hdata, ptr_item2,
|
||||
"0|test_array_2_longlong_fixed_size"));
|
||||
LONGS_EQUAL(444L, hdata_longlong (ptr_hdata, ptr_item2,
|
||||
"1|test_array_2_longlong_fixed_size"));
|
||||
LONGS_EQUAL(789123L, hdata_longlong (ptr_hdata, ptr_item2,
|
||||
"0|test_ptr_2_longlong"));
|
||||
LONGS_EQUAL(891234L, hdata_longlong (ptr_hdata, ptr_item2,
|
||||
"1|test_ptr_2_longlong"));
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests functions:
|
||||
* hdata_string
|
||||
@@ -2101,6 +2235,14 @@ TEST(CoreHdataWithList, Compare)
|
||||
LONGS_EQUAL(1, hdata_compare (ptr_hdata, ptr_item2, ptr_item1,
|
||||
"test_long", 0));
|
||||
|
||||
/* compare long long integers: 123456789123456ULL and 987654321987654ULL */
|
||||
LONGS_EQUAL(0, hdata_compare (ptr_hdata, ptr_item1, ptr_item1,
|
||||
"test_longlong", 0));
|
||||
LONGS_EQUAL(-1, hdata_compare (ptr_hdata, ptr_item1, ptr_item2,
|
||||
"test_longlong", 0));
|
||||
LONGS_EQUAL(1, hdata_compare (ptr_hdata, ptr_item2, ptr_item1,
|
||||
"test_longlong", 0));
|
||||
|
||||
/* compare pointers: 0x123 and 0x456 */
|
||||
LONGS_EQUAL(0, hdata_compare (ptr_hdata, ptr_item1, ptr_item1,
|
||||
"test_pointer", 0));
|
||||
@@ -2291,6 +2433,24 @@ TEST(CoreHdataWithList, Update)
|
||||
LONGS_EQUAL(1, hdata_update (ptr_hdata, ptr_item1, hashtable));
|
||||
LONGS_EQUAL(777, ptr_item1->test_long);
|
||||
|
||||
/* set long long to invalid value */
|
||||
hashtable_remove_all (hashtable);
|
||||
hashtable_set (hashtable, "test_longlong", "abc");
|
||||
LONGS_EQUAL(0, hdata_update (ptr_hdata, ptr_item1, hashtable));
|
||||
LONGS_EQUAL(123456789123456L, ptr_item1->test_longlong);
|
||||
|
||||
/* set long long to -55 */
|
||||
hashtable_remove_all (hashtable);
|
||||
hashtable_set (hashtable, "test_longlong", "-55");
|
||||
LONGS_EQUAL(1, hdata_update (ptr_hdata, ptr_item1, hashtable));
|
||||
LONGS_EQUAL(-55, ptr_item1->test_longlong);
|
||||
|
||||
/* set long long to 777 */
|
||||
hashtable_remove_all (hashtable);
|
||||
hashtable_set (hashtable, "test_longlong", "777");
|
||||
LONGS_EQUAL(1, hdata_update (ptr_hdata, ptr_item1, hashtable));
|
||||
LONGS_EQUAL(777, ptr_item1->test_longlong);
|
||||
|
||||
/* set pointer to invalid value */
|
||||
hashtable_remove_all (hashtable);
|
||||
hashtable_set (hashtable, "test_pointer", "zzz");
|
||||
@@ -2357,9 +2517,11 @@ TEST(CoreHdataWithList, GetString)
|
||||
"test_char,test_count_char,test_array_2_char_fixed_size,"
|
||||
"test_ptr_2_char,test_int,test_count_int,test_array_2_int_fixed_size,"
|
||||
"test_ptr_3_int,test_ptr_1_int_fixed_size,test_long,test_count_long,"
|
||||
"test_array_2_long_fixed_size,test_ptr_2_long,test_string,"
|
||||
"test_string2,test_string3,test_string_null,test_shared_string,"
|
||||
"test_count_words,test_array_2_words_fixed_size,test_ptr_words,"
|
||||
"test_array_2_long_fixed_size,test_ptr_2_long,test_longlong,"
|
||||
"test_count_longlong,test_array_2_longlong_fixed_size,"
|
||||
"test_ptr_2_longlong,test_string,test_string2,test_string3,"
|
||||
"test_string_null,test_shared_string,test_count_words,"
|
||||
"test_array_2_words_fixed_size,test_ptr_words,"
|
||||
"test_ptr_words_dyn,test_ptr_words_dyn_shared,test_pointer,"
|
||||
"test_count_pointer,test_array_2_pointer_fixed_size,"
|
||||
"test_ptr_3_pointer,test_ptr_0_pointer_dyn,test_ptr_1_pointer_dyn,"
|
||||
@@ -2373,12 +2535,12 @@ TEST(CoreHdataWithList, GetString)
|
||||
|
||||
prop = hdata_get_string (ptr_hdata, "var_values");
|
||||
items = string_split (prop, ",", NULL, 0, 0, &num_items);
|
||||
LONGS_EQUAL(45, num_items);
|
||||
LONGS_EQUAL(49, num_items);
|
||||
string_free_split (items);
|
||||
|
||||
prop = hdata_get_string (ptr_hdata, "var_keys_values");
|
||||
items = string_split (prop, ",", NULL, 0, 0, &num_items);
|
||||
LONGS_EQUAL(45, num_items);
|
||||
LONGS_EQUAL(49, num_items);
|
||||
string_free_split (items);
|
||||
|
||||
STRCMP_EQUAL("prev_item", hdata_get_string (ptr_hdata, "var_prev"));
|
||||
|
||||
Reference in New Issue
Block a user