diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-01-19 14:38:57 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-01-19 14:38:57 +0100 |
commit | 21e28d6d049a948fe71817da7cb3e3b0f1639eb6 (patch) | |
tree | 40dc5e591676cf64d67d4986ab580402d5db498b /src/restclient | |
parent | 18c53ce9ac45efbf6bcb53995eb5d10a357c5846 (diff) | |
download | anastasis-21e28d6d049a948fe71817da7cb3e3b0f1639eb6.tar.gz anastasis-21e28d6d049a948fe71817da7cb3e3b0f1639eb6.tar.bz2 anastasis-21e28d6d049a948fe71817da7cb3e3b0f1639eb6.zip |
implement routine to download meta data and decrypt to libanastasis; improve API to include timestamp
Diffstat (limited to 'src/restclient')
-rw-r--r-- | src/restclient/anastasis_api_policy_meta_lookup.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/restclient/anastasis_api_policy_meta_lookup.c b/src/restclient/anastasis_api_policy_meta_lookup.c index 9be49ca..b49d1b8 100644 --- a/src/restclient/anastasis_api_policy_meta_lookup.c +++ b/src/restclient/anastasis_api_policy_meta_lookup.c @@ -28,6 +28,7 @@ #include <microhttpd.h> /* just for HTTP status codes */ #include "anastasis_service.h" #include "anastasis_api_curl_defaults.h" +#include <gnunet/gnunet_json_lib.h> #include <taler/taler_signatures.h> @@ -132,7 +133,15 @@ handle_policy_meta_lookup_finished (void *cls, { unsigned int ver; char dummy; - const char *vals; + struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_varsize ("meta", + &md[off], + &metas[off].meta_data_size)), + GNUNET_JSON_spec_timestamp ("upload_time", + &metas[off].server_time), + GNUNET_JSON_spec_end () + }; if (1 != sscanf (label, "%u%c", @@ -142,27 +151,15 @@ handle_policy_meta_lookup_finished (void *cls, GNUNET_break (0); break; } - metas[off].version = (uint32_t) ver; - if (json_is_null (val)) - { - metas[off].meta_data = NULL; - metas[off].meta_data_size = 0; - off++; - continue; - } - vals = json_string_value (val); - if ( (NULL == vals) || - (GNUNET_OK != - GNUNET_STRINGS_string_to_data_alloc (vals, - strlen (vals), - &md[off], - &metas[off].meta_data_size)) ) + if (GNUNET_OK != + GNUNET_JSON_parse (val, + spec, + NULL, NULL)) { - GNUNET_break (0); + GNUNET_break_op (0); break; } metas[off].version = (uint32_t) ver; - metas[off].meta_data = md[off]; off++; } if (off < mlen) |