2005-02-20 14:27:00 +00:00
|
|
|
#ifndef _CONFIG_PARSER_H_
|
|
|
|
#define _CONFIG_PARSER_H_
|
2016-03-19 15:14:35 +00:00
|
|
|
#include "first.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "base_decls.h"
|
2019-11-21 03:25:28 +00:00
|
|
|
#include "plugin_config.h"
|
2005-02-20 14:27:00 +00:00
|
|
|
#include "array.h"
|
|
|
|
#include "buffer.h"
|
2018-03-25 07:45:05 +00:00
|
|
|
#include "vector.h"
|
|
|
|
|
|
|
|
/* $HTTP["host"] == "incremental.home.kneschke.de" { ... }
|
|
|
|
* for print: comp_key op string
|
|
|
|
* for compare: comp cond string/regex
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_PCRE_H
|
|
|
|
struct pcre_extra; /* declaration */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct data_config data_config;
|
|
|
|
DEFINE_TYPED_VECTOR_NO_RELEASE(config_weak, data_config*);
|
|
|
|
|
|
|
|
struct data_config {
|
|
|
|
DATA_UNSET;
|
2019-10-14 02:47:47 +00:00
|
|
|
int context_ndx; /* more or less like an id */
|
2018-03-25 07:45:05 +00:00
|
|
|
comp_key_t comp;
|
|
|
|
config_cond_t cond;
|
|
|
|
|
|
|
|
/* nested */
|
|
|
|
data_config *parent;
|
|
|
|
/* for chaining only */
|
|
|
|
data_config *prev;
|
|
|
|
data_config *next;
|
|
|
|
|
2019-10-14 00:14:09 +00:00
|
|
|
buffer string;
|
2018-03-25 07:45:05 +00:00
|
|
|
#ifdef HAVE_PCRE_H
|
|
|
|
void *regex;
|
|
|
|
struct pcre_extra *regex_study;
|
|
|
|
#endif
|
2020-09-11 21:25:43 +00:00
|
|
|
int ext;
|
2021-01-28 03:39:39 +00:00
|
|
|
buffer comp_tag;
|
|
|
|
const char *comp_key;
|
2019-10-14 02:47:47 +00:00
|
|
|
|
|
|
|
vector_config_weak children;
|
|
|
|
array *value;
|
2018-03-25 07:45:05 +00:00
|
|
|
};
|
|
|
|
|
2019-02-04 04:27:57 +00:00
|
|
|
__attribute_cold__
|
2021-03-17 00:27:05 +00:00
|
|
|
__attribute_returns_nonnull__
|
2018-03-25 07:45:05 +00:00
|
|
|
data_config *data_config_init(void);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2021-03-14 12:09:58 +00:00
|
|
|
int data_config_pcre_compile(data_config *dc, int pcre_jit, log_error_st *errh);
|
2019-11-21 03:25:28 +00:00
|
|
|
/*struct cond_cache_t;*/ /* declaration */ /*(moved to plugin_config.h)*/
|
2019-10-11 03:52:07 +00:00
|
|
|
/*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/
|
2005-02-20 14:27:00 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2005-08-08 14:40:47 +00:00
|
|
|
server *srv;
|
2005-02-20 14:27:00 +00:00
|
|
|
int ok;
|
2005-08-08 13:48:33 +00:00
|
|
|
array *all_configs;
|
2016-03-19 15:27:38 +00:00
|
|
|
vector_config_weak configs_stack; /* to parse nested block */
|
2005-08-08 13:48:33 +00:00
|
|
|
data_config *current; /* current started with { */
|
2005-08-08 14:40:47 +00:00
|
|
|
buffer *basedir;
|
2005-02-20 14:27:00 +00:00
|
|
|
} config_t;
|
|
|
|
|
2019-02-04 04:27:57 +00:00
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
void *configparserAlloc(void *(*mallocProc)(size_t));
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
void configparserFree(void *p, void (*freeProc)(void*));
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-02-20 14:27:00 +00:00
|
|
|
void configparser(void *yyp, int yymajor, buffer *yyminor, config_t *ctx);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-08-08 14:40:47 +00:00
|
|
|
int config_parse_file(server *srv, config_t *context, const char *fn);
|
2019-02-04 04:27:57 +00:00
|
|
|
|
|
|
|
__attribute_cold__
|
2005-08-09 06:42:33 +00:00
|
|
|
int config_parse_cmd(server *srv, config_t *context, const char *cmd);
|
2005-02-20 14:27:00 +00:00
|
|
|
|
2021-06-20 02:39:20 +00:00
|
|
|
__attribute_cold__
|
|
|
|
int config_remoteip_normalize(buffer *b, buffer *tb);
|
|
|
|
|
2005-02-20 14:27:00 +00:00
|
|
|
#endif
|