GNUnet  0.10.x
json_helper.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2014, 2015, 2016 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
27 #include "platform.h"
28 #include "gnunet_json_lib.h"
29 
30 
36 {
37  struct GNUNET_JSON_Specification ret = {
38  .parser = NULL,
39  .cleaner = NULL,
40  .cls = NULL
41  };
42 
43  return ret;
44 }
45 
46 
55 static int
57  json_t *root,
58  struct GNUNET_JSON_Specification *spec)
59 {
60  const char *enc;
61  unsigned int len;
62 
63  if (NULL == (enc = json_string_value(root)))
64  {
65  GNUNET_break_op(0);
66  return GNUNET_SYSERR;
67  }
68  len = strlen(enc);
69  if (((len * 5) / 8) != spec->ptr_size)
70  {
71  GNUNET_break_op(0);
72  return GNUNET_SYSERR;
73  }
74  if (GNUNET_OK !=
76  len,
77  spec->ptr,
78  spec->ptr_size))
79  {
80  GNUNET_break_op(0);
81  return GNUNET_SYSERR;
82  }
83  return GNUNET_OK;
84 }
85 
86 
97  void *obj,
98  size_t size)
99 {
100  struct GNUNET_JSON_Specification ret = {
102  .cleaner = NULL,
103  .cls = NULL,
104  .field = name,
105  .ptr = obj,
106  .ptr_size = size,
107  .size_ptr = NULL
108  };
109 
110  return ret;
111 }
112 
113 
122 static int
124  json_t *root,
125  struct GNUNET_JSON_Specification *spec)
126 {
127  const char *str;
128  size_t size;
129  void *data;
130  int res;
131 
132  str = json_string_value(root);
133  if (NULL == str)
134  {
135  GNUNET_break_op(0);
136  return GNUNET_SYSERR;
137  }
138  size = (strlen(str) * 5) / 8;
139  if (size >= 1024)
140  {
141  GNUNET_break_op(0);
142  return GNUNET_SYSERR;
143  }
144  data = GNUNET_malloc(size);
146  strlen(str),
147  data,
148  size);
149  if (GNUNET_OK != res)
150  {
151  GNUNET_break_op(0);
152  GNUNET_free(data);
153  return GNUNET_SYSERR;
154  }
155  *(void**)spec->ptr = data;
156  *spec->size_ptr = size;
157  return GNUNET_OK;
158 }
159 
160 
167 static void
169  struct GNUNET_JSON_Specification *spec)
170 {
171  if (0 != *spec->size_ptr)
172  {
173  GNUNET_free(*(void **)spec->ptr);
174  *(void**)spec->ptr = NULL;
175  *spec->size_ptr = 0;
176  }
177 }
178 
179 
190  void **obj,
191  size_t *size)
192 {
193  struct GNUNET_JSON_Specification ret = {
195  .cleaner = &clean_variable_data,
196  .cls = NULL,
197  .field = name,
198  .ptr = obj,
199  .ptr_size = 0,
200  .size_ptr = size
201  };
202 
203  *obj = NULL;
204  *size = 0;
205  return ret;
206 }
207 
208 
217 static int
219  json_t *root,
220  struct GNUNET_JSON_Specification *spec)
221 {
222  const char *str;
223 
224  str = json_string_value(root);
225  if (NULL == str)
226  {
227  GNUNET_break_op(0);
228  return GNUNET_SYSERR;
229  }
230  *(const char **)spec->ptr = str;
231  return GNUNET_OK;
232 }
233 
234 
243  const char **strptr)
244 {
245  struct GNUNET_JSON_Specification ret = {
246  .parser = &parse_string,
247  .cleaner = NULL,
248  .cls = NULL,
249  .field = name,
250  .ptr = strptr,
251  .ptr_size = 0,
252  .size_ptr = NULL
253  };
254 
255  *strptr = NULL;
256  return ret;
257 }
258 
259 
268 static int
270  json_t *root,
271  struct GNUNET_JSON_Specification *spec)
272 {
273  if (!(json_is_object(root) || json_is_array(root)))
274  {
275  GNUNET_break_op(0);
276  return GNUNET_SYSERR;
277  }
278  json_incref(root);
279  *(json_t **)spec->ptr = root;
280  return GNUNET_OK;
281 }
282 
283 
290 static void
292  struct GNUNET_JSON_Specification *spec)
293 {
294  json_t **ptr = (json_t **)spec->ptr;
295 
296  if (NULL != *ptr)
297  {
298  json_decref(*ptr);
299  *ptr = NULL;
300  }
301 }
302 
303 
312  json_t **jsonp)
313 {
314  struct GNUNET_JSON_Specification ret = {
315  .parser = &parse_object,
316  .cleaner = &clean_object,
317  .cls = NULL,
318  .field = name,
319  .ptr = jsonp,
320  .ptr_size = 0,
321  .size_ptr = NULL
322  };
323 
324  *jsonp = NULL;
325  return ret;
326 }
327 
328 
337 static int
338 parse_u8(void *cls,
339  json_t *root,
340  struct GNUNET_JSON_Specification *spec)
341 {
342  json_int_t val;
343  uint8_t *up = spec->ptr;
344 
345  if (!json_is_integer(root))
346  {
347  GNUNET_break_op(0);
348  return GNUNET_SYSERR;
349  }
350  val = json_integer_value(root);
351  if ((0 > val) || (val > UINT8_MAX))
352  {
353  GNUNET_break_op(0);
354  return GNUNET_SYSERR;
355  }
356  *up = (uint8_t)val;
357  return GNUNET_OK;
358 }
359 
360 
369  uint8_t *u8)
370 {
371  struct GNUNET_JSON_Specification ret = {
372  .parser = &parse_u8,
373  .cleaner = NULL,
374  .cls = NULL,
375  .field = name,
376  .ptr = u8,
377  .ptr_size = sizeof(uint8_t),
378  .size_ptr = NULL
379  };
380 
381  return ret;
382 }
383 
384 
393 static int
395  json_t *root,
396  struct GNUNET_JSON_Specification *spec)
397 {
398  json_int_t val;
399  uint16_t *up = spec->ptr;
400 
401  if (!json_is_integer(root))
402  {
403  GNUNET_break_op(0);
404  return GNUNET_SYSERR;
405  }
406  val = json_integer_value(root);
407  if ((0 > val) || (val > UINT16_MAX))
408  {
409  GNUNET_break_op(0);
410  return GNUNET_SYSERR;
411  }
412  *up = (uint16_t)val;
413  return GNUNET_OK;
414 }
415 
416 
425  uint16_t *u16)
426 {
427  struct GNUNET_JSON_Specification ret = {
428  .parser = &parse_u16,
429  .cleaner = NULL,
430  .cls = NULL,
431  .field = name,
432  .ptr = u16,
433  .ptr_size = sizeof(uint16_t),
434  .size_ptr = NULL
435  };
436 
437  return ret;
438 }
439 
440 
449 static int
451  json_t *root,
452  struct GNUNET_JSON_Specification *spec)
453 {
454  json_int_t val;
455  uint32_t *up = spec->ptr;
456 
457  if (!json_is_integer(root))
458  {
459  GNUNET_break_op(0);
460  return GNUNET_SYSERR;
461  }
462  val = json_integer_value(root);
463  if ((0 > val) || (val > UINT32_MAX))
464  {
465  GNUNET_break_op(0);
466  return GNUNET_SYSERR;
467  }
468  *up = (uint32_t)val;
469  return GNUNET_OK;
470 }
471 
472 
481  uint32_t *u32)
482 {
483  struct GNUNET_JSON_Specification ret = {
484  .parser = &parse_u32,
485  .cleaner = NULL,
486  .cls = NULL,
487  .field = name,
488  .ptr = u32,
489  .ptr_size = sizeof(uint32_t),
490  .size_ptr = NULL
491  };
492 
493  return ret;
494 }
495 
496 
505 static int
507  json_t *root,
508  struct GNUNET_JSON_Specification *spec)
509 {
510  json_int_t val;
511  uint64_t *up = spec->ptr;
512 
513  if (!json_is_integer(root))
514  {
515  GNUNET_break_op(0);
516  return GNUNET_SYSERR;
517  }
518  val = json_integer_value(root);
519  *up = (uint64_t)val;
520  return GNUNET_OK;
521 }
522 
523 
532  uint64_t *u64)
533 {
534  struct GNUNET_JSON_Specification ret = {
535  .parser = &parse_u64,
536  .cleaner = NULL,
537  .cls = NULL,
538  .field = name,
539  .ptr = u64,
540  .ptr_size = sizeof(uint64_t),
541  .size_ptr = NULL
542  };
543 
544  return ret;
545 }
546 
547 
548 /* ************ GNUnet-specific parser specifications ******************* */
549 
558 static int
560  json_t *root,
561  struct GNUNET_JSON_Specification *spec)
562 {
563  struct GNUNET_TIME_Absolute *abs = spec->ptr;
564  const char *val;
565  unsigned long long int tval;
566 
567  val = json_string_value(root);
568  if (NULL == val)
569  {
570  GNUNET_break_op(0);
571  return GNUNET_SYSERR;
572  }
573  if ((0 == strcasecmp(val,
574  "/forever/")) ||
575  (0 == strcasecmp(val,
576  "/end of time/")) ||
577  (0 == strcasecmp(val,
578  "/never/")))
579  {
581  return GNUNET_OK;
582  }
583  if (1 != sscanf(val,
584  "/Date(%llu)/",
585  &tval))
586  {
587  GNUNET_break_op(0);
588  return GNUNET_SYSERR;
589  }
590  /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
591  abs->abs_value_us = tval * 1000LL * 1000LL;
592  if ((abs->abs_value_us) / 1000LL / 1000LL != tval)
593  {
594  /* Integer overflow */
595  GNUNET_break_op(0);
596  return GNUNET_SYSERR;
597  }
598  return GNUNET_OK;
599 }
600 
601 
610  struct GNUNET_TIME_Absolute *at)
611 {
612  struct GNUNET_JSON_Specification ret = {
614  .cleaner = NULL,
615  .cls = NULL,
616  .field = name,
617  .ptr = at,
618  .ptr_size = sizeof(uint64_t),
619  .size_ptr = NULL
620  };
621 
622  return ret;
623 }
624 
625 
634 static int
636  json_t *root,
637  struct GNUNET_JSON_Specification *spec)
638 {
639  struct GNUNET_TIME_AbsoluteNBO *abs = spec->ptr;
640  const char *val;
641  unsigned long long int tval;
642  struct GNUNET_TIME_Absolute a;
643 
644  val = json_string_value(root);
645  if (NULL == val)
646  {
647  GNUNET_break_op(0);
648  return GNUNET_SYSERR;
649  }
650  if ((0 == strcasecmp(val,
651  "/forever/")) ||
652  (0 == strcasecmp(val,
653  "/end of time/")) ||
654  (0 == strcasecmp(val,
655  "/never/")))
656  {
658  return GNUNET_OK;
659  }
660  if (1 != sscanf(val,
661  "/Date(%llu)/",
662  &tval))
663  {
664  GNUNET_break_op(0);
665  return GNUNET_SYSERR;
666  }
667  /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
668  a.abs_value_us = tval * 1000LL * 1000LL;
669  if ((a.abs_value_us) / 1000LL / 1000LL != tval)
670  {
671  /* Integer overflow */
672  GNUNET_break_op(0);
673  return GNUNET_SYSERR;
674  }
675  *abs = GNUNET_TIME_absolute_hton(a);
676  return GNUNET_OK;
677 }
678 
679 
688  struct GNUNET_TIME_AbsoluteNBO *at)
689 {
690  struct GNUNET_JSON_Specification ret = {
692  .cleaner = NULL,
693  .cls = NULL,
694  .field = name,
695  .ptr = at,
696  .ptr_size = sizeof(uint64_t),
697  .size_ptr = NULL
698  };
699 
700  return ret;
701 }
702 
703 
712 static int
714  json_t *root,
715  struct GNUNET_JSON_Specification *spec)
716 {
717  struct GNUNET_TIME_Relative *rel = spec->ptr;
718  const char *val;
719  unsigned long long int tval;
720 
721  val = json_string_value(root);
722  if (NULL == val)
723  {
724  GNUNET_break_op(0);
725  return GNUNET_SYSERR;
726  }
727  if ((0 == strcasecmp(val,
728  "/forever/")))
729  {
731  return GNUNET_OK;
732  }
733  if (1 != sscanf(val,
734  "/Delay(%llu)/",
735  &tval))
736  {
737  GNUNET_break_op(0);
738  return GNUNET_SYSERR;
739  }
740  /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Relative */
741  rel->rel_value_us = tval * 1000LL * 1000LL;
742  if ((rel->rel_value_us) / 1000LL / 1000LL != tval)
743  {
744  /* Integer overflow */
745  GNUNET_break_op(0);
746  return GNUNET_SYSERR;
747  }
748  return GNUNET_OK;
749 }
750 
751 
760  struct GNUNET_TIME_Relative *rt)
761 {
762  struct GNUNET_JSON_Specification ret = {
764  .cleaner = NULL,
765  .cls = NULL,
766  .field = name,
767  .ptr = rt,
768  .ptr_size = sizeof(uint64_t),
769  .size_ptr = NULL
770  };
771 
772  return ret;
773 }
774 
775 
784 static int
786  json_t *root,
787  struct GNUNET_JSON_Specification *spec)
788 {
789  struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
790  const char *enc;
791  char *buf;
792  size_t len;
793  size_t buf_len;
794 
795  if (NULL == (enc = json_string_value(root)))
796  {
797  GNUNET_break_op(0);
798  return GNUNET_SYSERR;
799  }
800  len = strlen(enc);
801  buf_len = (len * 5) / 8;
802  buf = GNUNET_malloc(buf_len);
803  if (GNUNET_OK !=
805  len,
806  buf,
807  buf_len))
808  {
809  GNUNET_break_op(0);
810  GNUNET_free(buf);
811  return GNUNET_SYSERR;
812  }
813  if (NULL == (*pk = GNUNET_CRYPTO_rsa_public_key_decode(buf,
814  buf_len)))
815  {
816  GNUNET_break_op(0);
817  GNUNET_free(buf);
818  return GNUNET_SYSERR;
819  }
820  GNUNET_free(buf);
821  return GNUNET_OK;
822 }
823 
824 
831 static void
833  struct GNUNET_JSON_Specification *spec)
834 {
835  struct GNUNET_CRYPTO_RsaPublicKey **pk = spec->ptr;
836 
837  if (NULL != *pk)
838  {
840  *pk = NULL;
841  }
842 }
843 
844 
854 {
855  struct GNUNET_JSON_Specification ret = {
857  .cleaner = &clean_rsa_public_key,
858  .cls = NULL,
859  .field = name,
860  .ptr = pk,
861  .ptr_size = 0,
862  .size_ptr = NULL
863  };
864 
865  *pk = NULL;
866  return ret;
867 }
868 
869 
878 static int
880  json_t *root,
881  struct GNUNET_JSON_Specification *spec)
882 {
883  struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
884  size_t size;
885  const char *str;
886  int res;
887  void *buf;
888 
889  str = json_string_value(root);
890  if (NULL == str)
891  {
892  GNUNET_break_op(0);
893  return GNUNET_SYSERR;
894  }
895  size = (strlen(str) * 5) / 8;
896  buf = GNUNET_malloc(size);
898  strlen(str),
899  buf,
900  size);
901  if (GNUNET_OK != res)
902  {
903  GNUNET_free(buf);
904  GNUNET_break_op(0);
905  return GNUNET_SYSERR;
906  }
907  if (NULL == (*sig = GNUNET_CRYPTO_rsa_signature_decode(buf,
908  size)))
909  {
910  GNUNET_break_op(0);
911  GNUNET_free(buf);
912  return GNUNET_SYSERR;
913  }
914  GNUNET_free(buf);
915  return GNUNET_OK;
916 }
917 
918 
925 static void
927  struct GNUNET_JSON_Specification *spec)
928 {
929  struct GNUNET_CRYPTO_RsaSignature **sig = spec->ptr;
930 
931  if (NULL != *sig)
932  {
934  *sig = NULL;
935  }
936 }
937 
938 
947  struct GNUNET_CRYPTO_RsaSignature **sig)
948 {
949  struct GNUNET_JSON_Specification ret = {
951  .cleaner = &clean_rsa_signature,
952  .cls = NULL,
953  .field = name,
954  .ptr = sig,
955  .ptr_size = 0,
956  .size_ptr = NULL
957  };
958 
959  *sig = NULL;
960  return ret;
961 }
962 
963 
972 static int
974  json_t *root,
975  struct GNUNET_JSON_Specification *spec)
976 {
977  int *bp = spec->ptr;
978 
979  if (!json_is_boolean(root))
980  {
981  GNUNET_break_op(0);
982  return GNUNET_SYSERR;
983  }
984  *bp = json_boolean_value(root) ? GNUNET_YES : GNUNET_NO;
985  return GNUNET_OK;
986 }
987 
988 
997  int *boolean)
998 {
999  struct GNUNET_JSON_Specification ret = {
1000  .parser = &parse_boolean,
1001  .cleaner = NULL,
1002  .cls = NULL,
1003  .field = name,
1004  .ptr = boolean,
1005  .ptr_size = sizeof(int),
1006  .size_ptr = NULL
1007  };
1008 
1009  return ret;
1010 }
1011 
1012 
1013 /* end of json_helper.c */
void * cls
Closure for parser and cleaner.
static void clean_variable_data(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing variable size data.
Definition: json_helper.c:168
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32(const char *name, uint32_t *u32)
32-bit integer.
Definition: json_helper.c:480
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
uint64_t rel_value_us
The actual value.
an RSA signature
Definition: crypto_rsa.c:61
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
Definition: crypto_rsa.c:950
functions to parse JSON objects into GNUnet objects
static int parse_rsa_public_key(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA public key.
Definition: json_helper.c:785
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json(const char *name, json_t **jsonp)
JSON object.
Definition: json_helper.c:311
static int parse_u16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint16_t.
Definition: json_helper.c:394
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16(const char *name, uint16_t *u16)
16-bit integer.
Definition: json_helper.c:424
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time_nbo(const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
Absolute time in network byte order.
Definition: json_helper.c:687
#define GNUNET_NO
Definition: gnunet_common.h:78
Entry in parser specification for GNUNET_JSON_parse().
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static int parse_rsa_signature(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA signature.
Definition: json_helper.c:879
static void clean_rsa_signature(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA signature.
Definition: json_helper.c:926
static int ret
Final status code.
Definition: gnunet-arm.c:89
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
The public information of an RSA key pair.
Definition: crypto_rsa.c:50
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static int parse_u32(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint32_t.
Definition: json_helper.c:450
static int parse_object(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
Definition: json_helper.c:269
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format. ...
Definition: crypto_rsa.c:367
static char buf[2048]
static void clean_rsa_public_key(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA public key.
Definition: json_helper.c:832
static void clean_object(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing JSON object.
Definition: json_helper.c:291
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_JSON_Specification GNUNET_JSON_spec_fixed(const char *name, void *obj, size_t size)
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
Definition: json_helper.c:96
GNUNET_JSON_Parser parser
Function for how to parse this type of entry.
static int res
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end()
End of a parser specification.
Definition: json_helper.c:35
static int parse_boolean(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an int as a boolean.
Definition: json_helper.c:973
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
static int parse_variable_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to variable size data.
Definition: json_helper.c:123
const char * name
void * ptr
Pointer, details specific to the parser.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8(const char *name, uint8_t *u8)
8-bit integer.
Definition: json_helper.c:368
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
Specification for parsing an RSA signature.
Definition: json_helper.c:946
static int parse_u64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:506
static int parse_string(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string.
Definition: json_helper.c:218
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64(const char *name, uint64_t *u64)
64-bit integer.
Definition: json_helper.c:531
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
Definition: json_helper.c:242
static int parse_rel_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to relative time.
Definition: json_helper.c:713
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time.
Definition: json_helper.c:759
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean(const char *name, int *boolean)
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
Definition: json_helper.c:996
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const char *buf, size_t len)
Decode the signature from the data-format back to the "normal", internal format.
Definition: crypto_rsa.c:995
static int parse_fixed_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to fixed size data.
Definition: json_helper.c:56
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time(const char *name, struct GNUNET_TIME_Absolute *at)
Absolute time.
Definition: json_helper.c:609
size_t ptr_size
Number of bytes available in ptr.
size_t * size_ptr
Where should we store the final size of ptr.
static int parse_u8(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
Definition: json_helper.c:338
struct GNUNET_JSON_Specification GNUNET_JSON_spec_varsize(const char *name, void **obj, size_t *size)
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
Definition: json_helper.c:189
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_public_key(const char *name, struct GNUNET_CRYPTO_RsaPublicKey **pk)
Specification for parsing an RSA public key.
Definition: json_helper.c:852
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Definition: crypto_rsa.c:299
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:77
static int parse_abs_time_nbo(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:635
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:655
static int parse_abs_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
Definition: json_helper.c:559
#define GNUNET_malloc(size)
Wrapper around malloc.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
Definition: strings.c:953
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...