diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2012-08-27 09:47:46 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2012-08-27 09:47:46 +0200 |
commit | df80aa5fc92bd5481fc8099a63dad4093405f2f4 (patch) | |
tree | 49388757d0b7d625e8dc25f484792c65d913d594 /src/plugins/guile | |
parent | e767346a193f0eb53a9324a04a75080d359b1951 (diff) | |
download | weechat-df80aa5fc92bd5481fc8099a63dad4093405f2f4.zip |
api: allow update for some variables of hdata, add new functions hdata_update and hdata_set
Diffstat (limited to 'src/plugins/guile')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 5033e785c..071b3a0ff 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -5102,7 +5102,6 @@ weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name) { char timebuffer[64], *result; time_t time; - struct tm *date_tmp; SCM return_value; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); @@ -5113,9 +5112,7 @@ weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name) time = weechat_hdata_time (API_STR2PTR(scm_i_string_chars (hdata)), API_STR2PTR(scm_i_string_chars (pointer)), scm_i_string_chars (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); @@ -5145,6 +5142,33 @@ weechat_guile_api_hdata_hashtable (SCM hdata, SCM pointer, SCM name) } /* + * weechat_guile_api_hdata_update: update data in a hdata + */ + +SCM +weechat_guile_api_hdata_update (SCM hdata, SCM pointer, SCM hashtable) +{ + struct t_hashtable *c_hashtable; + int value; + + API_FUNC(1, "hdata_update", API_RETURN_INT(0)); + if (!scm_is_string (hdata) || !scm_is_string (pointer) || !scm_list_p (hashtable)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + c_hashtable = weechat_guile_alist_to_hashtable (hashtable, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE); + + value = weechat_hdata_update (API_STR2PTR(scm_i_string_chars (hdata)), + API_STR2PTR(scm_i_string_chars (pointer)), + c_hashtable); + + if (c_hashtable) + weechat_hashtable_free (c_hashtable); + + API_RETURN_INT(value); +} + +/* * weechat_guile_api_hdata_get_string: get hdata property as string */ @@ -5494,6 +5518,7 @@ weechat_guile_api_module_init (void *data) 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); |