Make json_error_t transparent again
[jansson.git] / src / jansson_private.h
1 /*
2  * Copyright (c) 2009, 2010 Petri Lehtinen <petri@digip.org>
3  *
4  * Jansson is free software; you can redistribute it and/or modify
5  * it under the terms of the MIT license. See LICENSE for details.
6  */
7
8 #ifndef JANSSON_PRIVATE_H
9 #define JANSSON_PRIVATE_H
10
11 #include <stddef.h>
12 #include "jansson.h"
13 #include "hashtable.h"
14
15 #define container_of(ptr_, type_, member_)  \
16     ((type_ *)((char *)ptr_ - offsetof(type_, member_)))
17
18 /* On some platforms, max() may already be defined */
19 #ifndef max
20 #define max(a, b)  ((a) > (b) ? (a) : (b))
21 #endif
22
23 typedef struct {
24     json_t json;
25     hashtable_t hashtable;
26     size_t serial;
27     int visited;
28 } json_object_t;
29
30 typedef struct {
31     json_t json;
32     size_t size;
33     size_t entries;
34     json_t **table;
35     int visited;
36 } json_array_t;
37
38 typedef struct {
39     json_t json;
40     char *value;
41 } json_string_t;
42
43 typedef struct {
44     json_t json;
45     double value;
46 } json_real_t;
47
48 typedef struct {
49     json_t json;
50     json_int_t value;
51 } json_integer_t;
52
53 #define json_to_object(json_)  container_of(json_, json_object_t, json)
54 #define json_to_array(json_)   container_of(json_, json_array_t, json)
55 #define json_to_string(json_)  container_of(json_, json_string_t, json)
56 #define json_to_real(json_)   container_of(json_, json_real_t, json)
57 #define json_to_integer(json_) container_of(json_, json_integer_t, json)
58
59 typedef struct {
60     size_t serial;
61     char key[1];
62 } object_key_t;
63
64 const object_key_t *jsonp_object_iter_fullkey(void *iter);
65
66 #endif