From 21e28d6d049a948fe71817da7cb3e3b0f1639eb6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 19 Jan 2022 14:38:57 +0100 Subject: implement routine to download meta data and decrypt to libanastasis; improve API to include timestamp --- src/restclient/anastasis_api_policy_meta_lookup.c | 33 +++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/restclient') 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 /* just for HTTP status codes */ #include "anastasis_service.h" #include "anastasis_api_curl_defaults.h" +#include #include @@ -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) -- cgit v1.2.3