mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 22:36:38 +02:00
api: allow update for some variables of hdata, add new functions hdata_update and hdata_set
This commit is contained in:
@@ -6382,7 +6382,6 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
|
||||
{
|
||||
char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result;
|
||||
time_t time;
|
||||
struct tm *date_tmp;
|
||||
VALUE return_value;
|
||||
|
||||
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
|
||||
@@ -6401,9 +6400,7 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
|
||||
time = weechat_hdata_time (API_STR2PTR(c_hdata),
|
||||
API_STR2PTR(c_pointer),
|
||||
c_name);
|
||||
date_tmp = localtime (&time);
|
||||
if (date_tmp)
|
||||
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
|
||||
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
|
||||
result = strdup (timebuffer);
|
||||
|
||||
API_RETURN_STRING_FREE(result);
|
||||
@@ -6441,6 +6438,41 @@ weechat_ruby_api_hdata_hashtable (VALUE class, VALUE hdata, VALUE pointer,
|
||||
return result_hash;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_update: update data in a hdata
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hdata_update (VALUE class, VALUE hdata, VALUE pointer,
|
||||
VALUE hashtable)
|
||||
{
|
||||
char *c_hdata, *c_pointer;
|
||||
struct t_hashtable *c_hashtable;
|
||||
int value;
|
||||
|
||||
API_FUNC(1, "hdata_update", API_RETURN_INT(0));
|
||||
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (hashtable))
|
||||
API_WRONG_ARGS(API_RETURN_INT(0));
|
||||
|
||||
Check_Type (hdata, T_STRING);
|
||||
Check_Type (pointer, T_STRING);
|
||||
Check_Type (hashtable, T_HASH);
|
||||
|
||||
c_hdata = StringValuePtr (hdata);
|
||||
c_pointer = StringValuePtr (pointer);
|
||||
c_hashtable = weechat_ruby_hash_to_hashtable (hashtable,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
|
||||
|
||||
value = weechat_hdata_update (API_STR2PTR(c_hdata),
|
||||
API_STR2PTR(c_pointer),
|
||||
c_hashtable);
|
||||
|
||||
if (c_hashtable)
|
||||
weechat_hashtable_free (c_hashtable);
|
||||
|
||||
API_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hdata_get_string: get hdata property as string
|
||||
*/
|
||||
@@ -6859,6 +6891,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(hdata_pointer, 3);
|
||||
API_DEF_FUNC(hdata_time, 3);
|
||||
API_DEF_FUNC(hdata_hashtable, 3);
|
||||
API_DEF_FUNC(hdata_update, 3);
|
||||
API_DEF_FUNC(hdata_get_string, 2);
|
||||
API_DEF_FUNC(upgrade_new, 2);
|
||||
API_DEF_FUNC(upgrade_write_object, 3);
|
||||
|
||||
Reference in New Issue
Block a user