chibipub

experimental activitypub node in C
git clone git://jb55.com/chibipub
Log | Files | Refs | README | LICENSE

ubjson.h (931B)


      1 
      2 #ifndef CHIBIPUB_UBJSON
      3 #define CHIBIPUB_UBJSON
      4 
      5 #include "cursor.h"
      6 #include "errors.h"
      7 #include "json.h"
      8 
      9 struct ubjson {
     10 	struct cursor cur;
     11 	unsigned char *data_end;
     12 	struct errors errs;
     13 };
     14 
     15 enum json_value_type {
     16 	JSON_NUMBER,
     17 	JSON_NUMBER_INT,
     18 	JSON_STRING,
     19 	JSON_NULL,
     20 	JSON_BOOL,
     21 	JSON_OBJECT,
     22 	JSON_ARRAY,
     23 };
     24 
     25 struct json {
     26 	enum json_value_type type;
     27 	unsigned int len;
     28 	union {
     29 		struct ubjson container;
     30 		double number;
     31 		unsigned int number_int;
     32 		const char *string;
     33 		int boolean;
     34 	};
     35 };
     36 
     37 void make_ubjson_handlers(struct json_handlers *h, struct cursor *ubjson);
     38 void init_ubjson(struct ubjson *ubjson, unsigned char *buf, size_t bufsize);
     39 int print_ubjson(struct ubjson *json);
     40 int parse_ubjson(unsigned char *buf, size_t buf_size, struct ubjson *out);
     41 int ubjson_lookup(struct ubjson *ubjson, const char **path, int path_len, struct json *val);
     42 void print_value(struct json *val);
     43 
     44 #endif /* CHIBIPUB_UBJSON */