gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 02/02: Revert "Revert "Revert "change label processing in names


From: gnunet
Subject: [gnunet] 02/02: Revert "Revert "Revert "change label processing in namestore REST api for gns records"""
Date: Sat, 09 May 2020 19:21:01 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit 02705d16254da837494a9bdf6d61e17ef2a7fc40
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Sat May 9 19:15:56 2020 +0200

    Revert "Revert "Revert "change label processing in namestore REST api for 
gns records"""
    
    This reverts commit 69ea05d2b141226721494d518feabd547ca39e6a.
---
 src/json/json_generator.c | 35 +++++++++++------------------------
 src/json/json_gnsrecord.c | 39 ++++++++++-----------------------------
 2 files changed, 21 insertions(+), 53 deletions(-)

diff --git a/src/json/json_generator.c b/src/json/json_generator.c
index 6a7ffa941..dd875871e 100644
--- a/src/json/json_generator.c
+++ b/src/json/json_generator.c
@@ -166,12 +166,12 @@ GNUNET_JSON_from_time_rel (struct GNUNET_TIME_Relative 
stamp)
 json_t *
 GNUNET_JSON_from_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *pk)
 {
-  char *buf;
+  void *buf;
   size_t buf_len;
   json_t *ret;
 
   buf_len = GNUNET_CRYPTO_rsa_public_key_encode (pk,
-                                                 (void**) &buf);
+                                                 &buf);
   ret = GNUNET_JSON_from_data (buf,
                                buf_len);
   GNUNET_free (buf);
@@ -188,12 +188,12 @@ GNUNET_JSON_from_rsa_public_key (const struct 
GNUNET_CRYPTO_RsaPublicKey *pk)
 json_t *
 GNUNET_JSON_from_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *sig)
 {
-  char *buf;
+  void *buf;
   size_t buf_len;
   json_t *ret;
 
   buf_len = GNUNET_CRYPTO_rsa_signature_encode (sig,
-                                                (void**) &buf);
+                                                &buf);
   ret = GNUNET_JSON_from_data (buf,
                                buf_len);
   GNUNET_free (buf);
@@ -213,8 +213,7 @@ GNUNET_JSON_from_gnsrecord (const char*rname,
                             const struct GNUNET_GNSRECORD_Data *rd,
                             unsigned int rd_count)
 {
-  struct GNUNET_TIME_Absolute abs_exp;
-  struct GNUNET_TIME_Relative rel_exp;
+  struct GNUNET_TIME_Absolute expiration_time;
   const char *expiration_time_str;
   const char *record_type_str;
   char *value_str;
@@ -249,34 +248,22 @@ GNUNET_JSON_from_gnsrecord (const char*rname,
     value_str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
                                                   rd[i].data,
                                                   rd[i].data_size);
-    if (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION & rd[i].flags)
-    {
-      rel_exp.rel_value_us = rd[i].expiration_time;
-      expiration_time_str = GNUNET_STRINGS_relative_time_to_string (rel_exp,
-                                                                    GNUNET_NO);
-    } else {
-      abs_exp.abs_value_us = rd[i].expiration_time;
-      expiration_time_str = GNUNET_STRINGS_absolute_time_to_string (abs_exp);
-    }
+    expiration_time = GNUNET_GNSRECORD_record_get_expiration_time (1, &rd[i]);
+    expiration_time_str = GNUNET_STRINGS_absolute_time_to_string (
+      expiration_time);
     record_type_str = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Packing %s %s %s %d\n",
                 value_str, record_type_str, expiration_time_str, rd[i].flags);
-    record = json_pack ("{s:s,s:s,s:s,s:b,s:b,s:b,s:b}",
+    record = json_pack ("{s:s,s:s,s:s,s:i}",
                         "value",
                         value_str,
                         "record_type",
                         record_type_str,
                         "expiration_time",
                         expiration_time_str,
-                        "private",
-                        rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE,
-                        "relative_expiration",
-                        rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION,
-                        "supplemental",
-                        rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL,
-                        "shadow",
-                        rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD);
+                        "flag",
+                        rd[i].flags);
     GNUNET_free (value_str);
     if (NULL == record)
     {
diff --git a/src/json/json_gnsrecord.c b/src/json/json_gnsrecord.c
index eecf45810..37f0c03da 100644
--- a/src/json/json_gnsrecord.c
+++ b/src/json/json_gnsrecord.c
@@ -31,10 +31,7 @@
 #define GNUNET_JSON_GNSRECORD_RECORD_DATA "data"
 #define GNUNET_JSON_GNSRECORD_TYPE "record_type"
 #define GNUNET_JSON_GNSRECORD_EXPIRATION_TIME "expiration_time"
-#define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE "private"
-#define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL "supplemental"
-#define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE "relative_expiration"
-#define GNUNET_JSON_GNSRECORD_FLAG_SHADOW "shadow"
+#define GNUNET_JSON_GNSRECORD_FLAG "flag"
 #define GNUNET_JSON_GNSRECORD_RECORD_NAME "record_name"
 #define GNUNET_JSON_GNSRECORD_NEVER "never"
 
@@ -53,10 +50,10 @@ cleanup_recordinfo (struct GnsRecordInfo *gnsrecord_info)
 {
   if (NULL != *(gnsrecord_info->rd))
   {
-    for (int i = 0; i < *(gnsrecord_info->rd_count); i++)
+    for (unsigned int i = 0; i < *(gnsrecord_info->rd_count); i++)
     {
       if (NULL != (*(gnsrecord_info->rd))[i].data)
-        GNUNET_free ((char *) (*(gnsrecord_info->rd))[i].data);
+        GNUNET_free_nz ((char *) (*(gnsrecord_info->rd))[i].data);
     }
     GNUNET_free (*(gnsrecord_info->rd));
     *(gnsrecord_info->rd) = NULL;
@@ -83,29 +80,20 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data 
*rd)
   const char *value;
   const char *record_type;
   const char *expiration_time;
-  int private;
-  int supplemental;
-  int rel_exp;
-  int shadow;
+  int flag;
   int unpack_state = 0;
 
   // interpret single gns record
   unpack_state = json_unpack (data,
-                              "{s:s, s:s, s:s, s:b, s:b, s:b, s:b}",
+                              "{s:s, s:s, s:s, s?:i!}",
                               GNUNET_JSON_GNSRECORD_VALUE,
                               &value,
                               GNUNET_JSON_GNSRECORD_TYPE,
                               &record_type,
                               GNUNET_JSON_GNSRECORD_EXPIRATION_TIME,
                               &expiration_time,
-                              GNUNET_JSON_GNSRECORD_FLAG_PRIVATE,
-                              &private,
-                              GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL,
-                              &supplemental,
-                              GNUNET_JSON_GNSRECORD_FLAG_RELATIVE,
-                              &rel_exp,
-                              GNUNET_JSON_GNSRECORD_FLAG_SHADOW,
-                              &shadow);
+                              GNUNET_JSON_GNSRECORD_FLAG,
+                              &flag);
   if (0 != unpack_state)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -131,10 +119,9 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data 
*rd)
   {
     rd->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
   }
-  else if ((1 != rel_exp) &&
-           (GNUNET_OK ==
+  else if (GNUNET_OK ==
            GNUNET_STRINGS_fancy_time_to_absolute (expiration_time,
-                                                  &abs_expiration_time)))
+                                                  &abs_expiration_time))
   {
     rd->expiration_time = abs_expiration_time.abs_value_us;
   }
@@ -142,7 +129,6 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data 
*rd)
            GNUNET_STRINGS_fancy_time_to_relative (expiration_time,
                                                   &rel_expiration_time))
   {
-    rd->flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
     rd->expiration_time = rel_expiration_time.rel_value_us;
   }
   else
@@ -150,12 +136,7 @@ parse_record (json_t *data, struct GNUNET_GNSRECORD_Data 
*rd)
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expiration time invalid\n");
     return GNUNET_SYSERR;
   }
-  if (1 == private)
-    rd->flags |= GNUNET_GNSRECORD_RF_PRIVATE;
-  if (1 == supplemental)
-    rd->flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
-  if (1 == shadow)
-    rd->flags |= GNUNET_GNSRECORD_RF_SHADOW_RECORD;
+  rd->flags = (enum GNUNET_GNSRECORD_Flags) flag;
   return GNUNET_OK;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]