e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen#ifndef CONFIG_PARSER_PRIVATE_H
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen#define CONFIG_PARSER_PRIVATE_H
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen#include "config-parser.h"
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen#include "config-filter.h"
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainenenum config_line_type {
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_SKIP,
0fa40bfd73cedc311ff2e0ae90707836382bfc8cTimo Sirainen CONFIG_LINE_TYPE_CONTINUE,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_ERROR,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_KEYVALUE,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_KEYFILE,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_KEYVARIABLE,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_SECTION_BEGIN,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_SECTION_END,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_INCLUDE,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen CONFIG_LINE_TYPE_INCLUDE_TRY
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen};
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainenstruct config_section_stack {
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct config_section_stack *prev;
e3d797bc851dc90fb88e68ae715c204d0f46e6ffTimo Sirainen const char *key;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct config_filter filter;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen /* root=NULL-terminated list of parsers */
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct config_module_parser *parsers;
2ac5f36aa7c2e7a07ba8815d43a6d7483f62e74cTimo Sirainen size_t pathlen;
1618629fd55e914c8d2e28fc01b8264613f00a99Timo Sirainen
1618629fd55e914c8d2e28fc01b8264613f00a99Timo Sirainen const char *open_path;
1618629fd55e914c8d2e28fc01b8264613f00a99Timo Sirainen unsigned int open_linenum;
e3d797bc851dc90fb88e68ae715c204d0f46e6ffTimo Sirainen bool is_filter;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen};
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainenstruct input_stack {
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct input_stack *prev;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct istream *input;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen const char *path;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen unsigned int linenum;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen};
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainenstruct config_parser_context {
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen pool_t pool;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen const char *path;
633a3da9d3e9a5befd3405f6651043a6bdd327cbTimo Sirainen const char *const *modules;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
4ee00532a265bdfb38539d811fcd12d51210ac35Timo Sirainen ARRAY(struct config_filter_parser *) all_parsers;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct config_module_parser *root_parsers;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct config_section_stack *cur_section;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct input_stack *cur_input;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen string_t *str;
2ac5f36aa7c2e7a07ba8815d43a6d7483f62e74cTimo Sirainen size_t pathlen;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen unsigned int section_counter;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen const char *error;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct old_set_parser *old;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
87404eae4581d7ef834f490507503e59a500066eTimo Sirainen HASH_TABLE(const char *, const char *) seen_settings;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen struct config_filter_context *filter;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool expand_values:1;
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen bool hide_errors:1;
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen};
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
0171540a6764f714b8b753ba209ec9a83c213d25Timo Sirainenextern void (*hook_config_parser_begin)(struct config_parser_context *ctx);
0df566822360dd8ca963864a51a8bd56054c3331Timo Sirainenextern int (*hook_config_parser_end)(struct config_parser_context *ctx,
0df566822360dd8ca963864a51a8bd56054c3331Timo Sirainen const char **error_r);
0171540a6764f714b8b753ba209ec9a83c213d25Timo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainenint config_apply_line(struct config_parser_context *ctx, const char *key,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen const char *line, const char *section_name) ATTR_NULL(4);
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainenvoid config_parser_apply_line(struct config_parser_context *ctx,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen enum config_line_type type,
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen const char *key, const char *value);
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen
e71a9e2e752ddbff1d04570bd6d14964ac4f890bTimo Sirainen#endif