14 #define DATA_IS_STRING(x) (x->type == TYPE_STRING)
16 typedef enum { TYPE_UNSET
, TYPE_STRING
, TYPE_OTHER
, TYPE_ARRAY
, TYPE_INTEGER
, TYPE_DONOTUSE
, TYPE_CONFIG
} data_type_t
;
20 int is_index_key; /* 1 if key is a array index (autogenerated keys) */ \
21 struct data_unset *(*copy)(const struct data_unset *src); \
22 void (* free)(struct data_unset *p); \
23 void (* reset)(struct data_unset *p); \
24 int (*insert_dup)(struct data_unset *dst, struct data_unset *src); \
25 void (*print)(const struct data_unset *p, int depth)
27 typedef struct data_unset
{
36 size_t used
; /* <= SSIZE_MAX */
48 data_string
*data_string_init(void);
49 data_string
*data_response_init(void);
57 data_array
*data_array_init(void);
60 * possible compare ops in the configfile parser
64 CONFIG_COND_EQ
, /** == */
65 CONFIG_COND_MATCH
, /** =~ */
66 CONFIG_COND_NE
, /** != */
67 CONFIG_COND_NOMATCH
, /** !~ */
68 CONFIG_COND_ELSE
/** (always true if reached) */
72 * possible fields to match against
79 COMP_HTTP_REFERER
, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
80 COMP_HTTP_USER_AGENT
, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
81 COMP_HTTP_LANGUAGE
, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
82 COMP_HTTP_COOKIE
, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
84 COMP_HTTP_QUERY_STRING
,
86 COMP_HTTP_REQUEST_METHOD
,
87 COMP_HTTP_REQUEST_HEADER
,
92 /* $HTTP["host"] == "incremental.home.kneschke.de" { ... }
93 * for print: comp_key op string
94 * for compare: comp cond string/regex
97 typedef struct data_config data_config
;
98 DEFINE_TYPED_VECTOR_NO_RELEASE(config_weak
, data_config
*);
112 int context_ndx
; /* more or less like an id */
113 vector_config_weak children
;
116 /* for chaining only */
123 pcre_extra
*regex_study
;
127 data_config
*data_config_init(void);
135 data_integer
*data_integer_init(void);
137 array
*array_init(void);
138 array
*array_init_array(array
*a
);
139 void array_free(array
*a
);
140 void array_reset(array
*a
);
141 void array_insert_unique(array
*a
, data_unset
*entry
);
142 data_unset
*array_pop(array
*a
); /* only works on "simple" lists with autogenerated keys */
143 int array_is_vlist(array
*a
);
144 int array_is_kvany(array
*a
);
145 int array_is_kvarray(array
*a
);
146 int array_is_kvstring(array
*a
);
147 int array_print(array
*a
, int depth
);
148 data_unset
*array_get_unused_element(array
*a
, data_type_t t
);
149 #define array_get_element(a, key) array_get_element_klen((a), (key), sizeof(key)-1)
150 data_unset
*array_get_element_klen(array
*a
, const char *key
, size_t klen
);
151 data_unset
*array_extract_element_klen(array
*a
, const char *key
, size_t klen
); /* removes found entry from array */
152 void array_set_key_value(array
*hdrs
, const char *key
, size_t key_len
, const char *value
, size_t val_len
);
153 void array_replace(array
*a
, data_unset
*entry
);
154 int array_strcasecmp(const char *a
, size_t a_len
, const char *b
, size_t b_len
);
155 void array_print_indent(int depth
);
156 size_t array_get_max_key_length(array
*a
);