14 #define DATA_IS_STRING(x) (x->type == TYPE_STRING)
16 typedef enum { TYPE_UNSET
, TYPE_STRING
, TYPE_OTHER
, TYPE_ARRAY
, TYPE_INTEGER
, TYPE_FASTCGI
, 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
84 COMP_HTTP_QUERY_STRING
,
86 COMP_HTTP_REQUEST_METHOD
,
91 /* $HTTP["host"] == "incremental.home.kneschke.de" { ... }
92 * for print: comp_key op string
93 * for compare: comp cond string/regex
96 typedef struct data_config data_config
;
97 DEFINE_TYPED_VECTOR_NO_RELEASE(config_weak
, data_config
*);
110 int context_ndx
; /* more or less like an id */
111 vector_config_weak children
;
114 /* for chaining only */
121 pcre_extra
*regex_study
;
125 data_config
*data_config_init(void);
133 data_integer
*data_integer_init(void);
146 int usage
; /* fair-balancing needs the no. of connections active on this host */
147 int last_used_ndx
; /* round robin */
150 data_fastcgi
*data_fastcgi_init(void);
152 array
*array_init(void);
153 array
*array_init_array(array
*a
);
154 void array_free(array
*a
);
155 void array_reset(array
*a
);
156 void array_insert_unique(array
*a
, data_unset
*entry
);
157 data_unset
*array_pop(array
*a
); /* only works on "simple" lists with autogenerated keys */
158 int array_print(array
*a
, int depth
);
159 data_unset
*array_get_unused_element(array
*a
, data_type_t t
);
160 data_unset
*array_get_element(array
*a
, const char *key
);
161 data_unset
*array_extract_element(array
*a
, const char *key
); /* removes found entry from array */
162 void array_set_key_value(array
*hdrs
, const char *key
, size_t key_len
, const char *value
, size_t val_len
);
163 void array_replace(array
*a
, data_unset
*entry
);
164 int array_strcasecmp(const char *a
, size_t a_len
, const char *b
, size_t b_len
);
165 void array_print_indent(int depth
);
166 size_t array_get_max_key_length(array
*a
);