34 #define TAILQ_HEAD(name, type) \
36 struct type *tqh_first; \
37 struct type **tqh_last; \
40 #define TAILQ_ENTRY(type) \
42 struct type *tqe_next; \
43 struct type **tqe_prev; \
49 #define TAILQ_CONCAT(head1, head2) do { \
50 if (!TAILQ_EMPTY(head2)) { \
51 *(head1)->tqh_last = (head2)->tqh_first; \
52 (head2)->tqh_first->next.tqe_prev = (head1)->tqh_last; \
53 (head1)->tqh_last = (head2)->tqh_last; \
54 TAILQ_INIT((head2)); \
58 #define TAILQ_EMPTY(head) ((head)->tqh_first == NULL)
60 #define TAILQ_FIRST(head) ((head)->tqh_first)
62 #define TAILQ_FOREACH(var, head) \
63 for ((var) = TAILQ_FIRST((head)); \
65 (var) = TAILQ_NEXT((var)))
67 #define TAILQ_FOREACH_SAFE(var, head, tvar) \
68 for ((var) = TAILQ_FIRST((head)); \
69 (var) && ((tvar) = TAILQ_NEXT((var)), 1); \
72 #define TAILQ_INIT(head) do { \
73 TAILQ_FIRST((head)) = NULL; \
74 (head)->tqh_last = &TAILQ_FIRST((head)); \
77 #define TAILQ_INSERT_AFTER(head, listelm, elm) do { \
78 if ((TAILQ_NEXT((elm)) = TAILQ_NEXT((listelm))) != NULL) \
79 TAILQ_NEXT((elm))->next.tqe_prev = \
82 (head)->tqh_last = &TAILQ_NEXT((elm)); \
84 TAILQ_NEXT((listelm)) = (elm); \
85 (elm)->next.tqe_prev = &TAILQ_NEXT((listelm)); \
88 #define TAILQ_INSERT_BEFORE(listelm, elm) do { \
89 (elm)->next.tqe_prev = (listelm)->next.tqe_prev; \
90 TAILQ_NEXT((elm)) = (listelm); \
91 *(listelm)->next.tqe_prev = (elm); \
92 (listelm)->next.tqe_prev = &TAILQ_NEXT((elm)); \
95 #define TAILQ_INSERT_HEAD(head, elm) do { \
96 if ((TAILQ_NEXT((elm)) = TAILQ_FIRST((head))) != NULL) \
97 TAILQ_FIRST((head))->next.tqe_prev = \
100 (head)->tqh_last = &TAILQ_NEXT((elm)); \
101 TAILQ_FIRST((head)) = (elm); \
102 (elm)->next.tqe_prev = &TAILQ_FIRST((head)); \
105 #define TAILQ_INSERT_TAIL(head, elm) do { \
106 TAILQ_NEXT((elm)) = NULL; \
107 (elm)->next.tqe_prev = (head)->tqh_last; \
108 *(head)->tqh_last = (elm); \
109 (head)->tqh_last = &TAILQ_NEXT((elm)); \
112 #define TAILQ_LAST(head, headname) \
113 (*(((struct headname *)((head)->tqh_last))->tqh_last))
115 #define TAILQ_NEXT(elm) ((elm)->next.tqe_next)
117 #define TAILQ_PREV(elm, headname) \
118 (*(((struct headname *)((elm)->next.tqe_prev))->tqh_last))
120 #define TAILQ_REMOVE(head, elm) do { \
121 if ((TAILQ_NEXT((elm))) != NULL) \
122 TAILQ_NEXT((elm))->next.tqe_prev = \
123 (elm)->next.tqe_prev; \
125 (head)->tqh_last = (elm)->next.tqe_prev; \
126 *(elm)->next.tqe_prev = TAILQ_NEXT((elm)); \
127 (elm)->next.tqe_next = (void *)-1; \
128 (elm)->next.tqe_prev = (void *)-1; \
131 #define TAILQ_SWAP(head1, head2, type) do { \
132 struct type *swap_first = (head1)->tqh_first; \
133 struct type **swap_last = (head1)->tqh_last; \
134 (head1)->tqh_first = (head2)->tqh_first; \
135 (head1)->tqh_last = (head2)->tqh_last; \
136 (head2)->tqh_first = swap_first; \
137 (head2)->tqh_last = swap_last; \
138 if ((swap_first = (head1)->tqh_first) != NULL) \
139 swap_first->next.tqe_prev = &(head1)->tqh_first; \
141 (head1)->tqh_last = &(head1)->tqh_first; \
142 if ((swap_first = (head2)->tqh_first) != NULL) \
143 swap_first->next.tqe_prev = &(head2)->tqh_first; \
145 (head2)->tqh_last = &(head2)->tqh_first; \
152 #define ISC_FALSE isc_boolean_false
153 #define ISC_TRUE isc_boolean_true
154 #define ISC_TF(x) ((x) ? ISC_TRUE : ISC_FALSE)
161 #define ELEMENT_NONE 0
162 #define ELEMENT_INTEGER 1
163 #define ELEMENT_REAL 2
164 #define ELEMENT_BOOLEAN 3
165 #define ELEMENT_NULL 4
166 #define ELEMENT_STRING 5
167 #define ELEMENT_LIST 6
168 #define ELEMENT_MAP 7
184 void concatString(
struct string *s,
const struct string *a);
275 void printList(FILE *fp,
const struct list *l,
277 void printMap(FILE *fp,
const struct map *m,
279 void printString(FILE *fp,
const struct string *s);
void concatString(struct string *s, const struct string *a)
void listPush(struct element *l, struct element *e)
struct handle * mapPop(struct element *)
struct string * quote(struct string *)
void resetInt(struct element *e, int64_t i)
isc_boolean_t eqString(const struct string *s, const struct string *o)
struct comment * createComment(const char *line)
struct string * makeString(int l, const char *s)
isc_boolean_t boolValue(const struct element *e)
void listRemove(struct element *l, int i)
struct element * create(void)
struct element * createBool(isc_boolean_t b)
struct element * mapGet(struct element *m, const char *k)
void resetBool(struct element *e, isc_boolean_t b)
size_t mapSize(const struct element *m)
struct element * createList(void)
struct string * stringValue(struct element *e)
void appendString(struct string *s, const char *a)
#define TAILQ_HEAD(name, type)
double doubleValue(const struct element *e)
struct element * createInt(int64_t i)
void resetNull(struct element *e)
void resetDouble(struct element *e, double d)
struct element * createHexa(struct string *)
void resetList(struct element *e)
void concat(struct element *l, struct element *o)
void printString(FILE *fp, const struct string *s)
struct element * createNull(void)
isc_boolean_t mapContains(const struct element *m, const char *k)
struct element * copyMap(struct element *m)
struct string * allocString(void)
struct element * createString(const struct string *s)
struct element * copy(struct element *e)
struct element * createDouble(double d)
void printMap(FILE *fp, const struct map *m, isc_boolean_t skip, unsigned indent)
struct map * mapValue(struct element *e)
struct string * makeStringArray(int l, const char *s, char fmt)
struct element * listGet(struct element *l, int i)
struct string * makeStringExt(int l, const char *s, char fmt)
int name2type(const char *n)
void merge(struct element *m, struct element *o)
void mapSet(struct element *m, struct element *e, const char *k)
isc_boolean_t skip_to_end(const struct element *e)
void listSet(struct element *l, struct element *e, int i)
struct string * hexaValue(struct element *)
size_t listSize(const struct element *l)
void resetString(struct element *e, const struct string *s)
void print(FILE *fp, const struct element *e, isc_boolean_t skip, unsigned indent)
struct element * copyList(struct element *l)
void printList(FILE *fp, const struct list *l, isc_boolean_t skip, unsigned indent)
void resetBy(struct element *e, struct element *o)
struct element * createMap(void)
void mapRemove(struct element *m, const char *k)
const char * type2name(int t)
int64_t intValue(const struct element *e)
struct list * listValue(struct element *e)
void derive(struct handle *, struct handle *)
void resetMap(struct element *e)
TAILQ_ENTRY(element) next
struct string string_value