curl: reschedule uses GNUNET_CURL_perform2.
[oweals/gnunet.git] / src / include / gnunet_json_lib.h
index ce721d8d81bd4b9918f878b9f437aad4e0d953a7..781d5698b7d2ff4aed78f9cfff0dda6c0e2b1e95 100644 (file)
@@ -2,16 +2,18 @@
   This file is part of GNUnet
   Copyright (C) 2014, 2015, 2016 GNUnet e.V.
 
-  GNUnet is free software; you can redistribute it and/or modify it under the
-  terms of the GNU General Public License as published by the Free Software
-  Foundation; either version 3, or (at your option) any later version.
-
-  GNUnet is distributed in the hope that it will be useful, but WITHOUT ANY
-  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License along with
-  GNUnet; see the file COPYING.  If not, If not, see <http://www.gnu.org/licenses/>
+  GNUnet is free software: you can redistribute it and/or modify it
+  under the terms of the GNU Affero General Public License as published
+  by the Free Software Foundation, either version 3 of the License,
+  or (at your option) any later version.
+
+  GNUnet is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Affero General Public License for more details.
+  You should have received a copy of the GNU Affero General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 /**
  * @file gnunet_json_lib.h
@@ -24,6 +26,7 @@
 #define GNUNET_JSON_LIB_H
 
 #include "gnunet_util_lib.h"
+#include "gnunet_gnsrecord_lib.h"
 #include <jansson.h>
 
 
@@ -248,6 +251,16 @@ struct GNUNET_JSON_Specification
 GNUNET_JSON_spec_uint64 (const char *name,
                          uint64_t *u64);
 
+/**
+ * Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
+ *
+ * @param name name of the JSON field
+ * @param[out] boolean where to store the boolean found under @a name
+ */
+struct GNUNET_JSON_Specification
+GNUNET_JSON_spec_boolean (const char *name,
+                          int *boolean);
+
 
 /* ************ GNUnet-specific parser specifications ******************* */
 
@@ -262,6 +275,17 @@ GNUNET_JSON_spec_absolute_time (const char *name,
                                 struct GNUNET_TIME_Absolute *at);
 
 
+/**
+ * Absolute time in network byte order.
+ *
+ * @param name name of the JSON field
+ * @param[out] at where to store the absolute time found under @a name
+ */
+struct GNUNET_JSON_Specification
+GNUNET_JSON_spec_absolute_time_nbo (const char *name,
+                                   struct GNUNET_TIME_AbsoluteNBO *at);
+
+
 /**
  * Relative time.
  *
@@ -295,6 +319,17 @@ GNUNET_JSON_spec_rsa_signature (const char *name,
                                 struct GNUNET_CRYPTO_RsaSignature **sig);
 
 
+
+/**
+ * JSON Specification for GNS Records.
+ *
+ * @param gnsrecord_object struct of GNUNET_GNSRECORD_Data to fill
+ * @return JSON Specification
+ */
+struct GNUNET_JSON_Specification
+GNUNET_JSON_spec_gnsrecord_data (struct GNUNET_GNSRECORD_Data **gnsrecord_object);
+
+
 /* ****************** Generic generator interface ******************* */
 
 
@@ -331,6 +366,16 @@ json_t *
 GNUNET_JSON_from_time_abs (struct GNUNET_TIME_Absolute stamp);
 
 
+/**
+ * Convert absolute timestamp to a json string.
+ *
+ * @param stamp the time stamp
+ * @return a json string with the timestamp in @a stamp
+ */
+json_t *
+GNUNET_JSON_from_time_abs_nbo (struct GNUNET_TIME_AbsoluteNBO stamp);
+
+
 /**
  * Convert relative timestamp to a json string.
  *
@@ -360,6 +405,16 @@ 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);
 
+/**
+ * Convert Gns record to JSON.
+ *
+ * @param rname name of record
+ * @param rd record data
+ * @return corresponding JSON encoding
+ */
+json_t *
+GNUNET_JSON_from_gns_record (const char* rname,
+                               const struct GNUNET_GNSRECORD_Data *rd);
 
 /* ******************* Helpers for MHD upload handling ******************* */
 
@@ -446,7 +501,6 @@ GNUNET_JSON_getopt (char shortName,
                     const char *description,
                     json_t **json);
 
-
 #endif
 
 /* end of gnunet_json_lib.h */