summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-02-26 07:33:12 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-03-12 20:37:11 +0100
commit9e0dd1815278e189b6fd84046fc78e883cf85704 (patch)
treea7d8c6ed636ca02227cd140889d2bcc45aa2676e /src
parentc85b57b8b399b980c5d6725fc33bef83d9727bfb (diff)
downloadweechat-9e0dd1815278e189b6fd84046fc78e883cf85704.zip
api: add function "hdata_longlong" (issue #2081)
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-eval.c5
-rw-r--r--src/core/wee-hdata.c61
-rw-r--r--src/core/wee-hdata.h2
-rw-r--r--src/plugins/buflist/buflist-mouse.c8
-rw-r--r--src/plugins/guile/weechat-guile-api.c21
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp19
-rw-r--r--src/plugins/lua/weechat-lua-api.c21
-rw-r--r--src/plugins/perl/weechat-perl-api.c22
-rw-r--r--src/plugins/php/weechat-php-api.c22
-rw-r--r--src/plugins/php/weechat-php-api.h1
-rw-r--r--src/plugins/php/weechat-php.c1
-rw-r--r--src/plugins/php/weechat-php.stub.php1
-rw-r--r--src/plugins/php/weechat-php_arginfo.h4
-rw-r--r--src/plugins/php/weechat-php_legacy_arginfo.h4
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/python/weechat-python-api.c22
-rw-r--r--src/plugins/python/weechat.pyi10
-rw-r--r--src/plugins/relay/weechat/relay-weechat-msg.c25
-rw-r--r--src/plugins/relay/weechat/relay-weechat-msg.h2
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c27
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c21
-rw-r--r--src/plugins/weechat-plugin.h30
22 files changed, 314 insertions, 16 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c
index 7909f05d0..fef8a8949 100644
--- a/src/core/wee-eval.c
+++ b/src/core/wee-eval.c
@@ -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);
diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c
index 933d92d64..0a3dc6a30 100644
--- a/src/core/wee-hdata.c
+++ b/src/core/wee-hdata.c
@@ -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)
diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h
index d70d24b9f..078c06f47 100644
--- a/src/core/wee-hdata.h
+++ b/src/core/wee-hdata.h
@@ -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,
diff --git a/src/plugins/buflist/buflist-mouse.c b/src/plugins/buflist/buflist-mouse.c
index 8ed15eb6b..5f349d29d 100644
--- a/src/plugins/buflist/buflist-mouse.c
+++ b/src/plugins/buflist/buflist-mouse.c
@@ -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,
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index dc012ca9c..535b0707f 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -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
@@ -5149,6 +5152,23 @@ weechat_guile_api_hdata_long (SCM hdata, SCM pointer, SCM name)
}
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)
{
const char *result;
@@ -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);
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index d477c40e0..c17fe046a 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -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);
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index fcc0f09a3..c13fdb38e 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -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),
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 89280fb8e..7c0c386bb 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -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);
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c
index 43ec87cab..3624ba7ea 100644
--- a/src/plugins/php/weechat-php-api.c
+++ b/src/plugins/php/weechat-php-api.c
@@ -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;
diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h
index 240053c4e..40d30d4a6 100644
--- a/src/plugins/php/weechat-php-api.h
+++ b/src/plugins/php/weechat-php-api.h
@@ -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);
diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c
index 3ef3df50a..4c5dafd82 100644
--- a/src/plugins/php/weechat-php.c
+++ b/src/plugins/php/weechat-php.c
@@ -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)
diff --git a/src/plugins/php/weechat-php.stub.php b/src/plugins/php/weechat-php.stub.php
index 5ed87ae77..82dee73df 100644
--- a/src/plugins/php/weechat-php.stub.php
+++ b/src/plugins/php/weechat-php.stub.php
@@ -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 {}
diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h
index a4d83439f..f5353b4d6 100644
--- a/src/plugins/php/weechat-php_arginfo.h
+++ b/src/plugins/php/weechat-php_arginfo.h
@@ -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
diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h
index 224fe77f8..36716de6c 100644
--- a/src/plugins/php/weechat-php_legacy_arginfo.h
+++ b/src/plugins/php/weechat-php_legacy_arginfo.h
@@ -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
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index ada30e87d..aa0792d8e 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -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;
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 298db8ff1..654b33cec 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -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),
diff --git a/src/plugins/python/weechat.pyi b/src/plugins/python/weechat.pyi
index e3e5c72b4..432927b64 100644
--- a/src/plugins/python/weechat.pyi
+++ b/src/plugins/python/weechat.pyi
@@ -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>`_
::
diff --git a/src/plugins/relay/weechat/relay-weechat-msg.c b/src/plugins/relay/weechat/relay-weechat-msg.c
index 4dde883a5..a1e373bdb 100644
--- a/src/plugins/relay/weechat/relay-weechat-msg.c
+++ b/src/plugins/relay/weechat/relay-weechat-msg.c
@@ -176,6 +176,23 @@ relay_weechat_msg_add_long (struct t_relay_weechat_msg *msg, long value)
}
/*
+ * 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:
diff --git a/src/plugins/relay/weechat/relay-weechat-msg.h b/src/plugins/relay/weechat/relay-weechat-msg.h
index 554007549..2596f625f 100644
--- a/src/plugins/relay/weechat/relay-weechat-msg.h
+++ b/src/plugins/relay/weechat/relay-weechat-msg.h
@@ -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,
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 46bdcf950..d70108878 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -6592,6 +6592,32 @@ weechat_ruby_api_hdata_long (VALUE class, VALUE hdata, VALUE pointer,
}
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);
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index 5a040c3f6..f6c26b276 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -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);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index 26733e8c2..fde3a1db4 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -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) \