config-parser.c revision ebded144e74a668973ec9ba6e7e169d4e6dc766c
/* Copyright (C) 2005-2009 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "hash.h"
#include "strescape.h"
#include "istream.h"
#include "settings-parser.h"
#include "config-filter.h"
#include "config-parser.h"
#include <unistd.h>
#include <fcntl.h>
struct config_filter_stack {
struct config_filter_stack *prev;
struct config_filter filter;
unsigned int pathlen;
};
struct input_stack {
struct input_stack *prev;
const char *path;
unsigned int linenum;
};
struct parser_context {
const char *path;
/* parsers matching cur_filter */
struct config_filter_stack *cur_filter;
struct input_stack *cur_input;
struct config_filter_context *filter;
};
struct config_filter_context *config_filter;
{
unsigned int i;
}
i_panic("setting parser: Invalid type_offset value");
return NULL;
}
const char *line, const char *section_name)
{
const struct setting_parser_info *info;
const char *p;
int ret;
return;
}
static const char *
const char *section_name)
{
struct config_setting_parser_list *l;
int ret;
if (ret > 0) {
if (section_name != NULL)
} else if (ret < 0)
return settings_parser_get_error(l->parser);
}
}
static const char *
{
const char *ret;
return ret;
}
return NULL;
}
static const char *
{
const char *p;
if (*path == '/')
return path;
if (p == NULL)
return path;
}
static struct config_setting_parser_list *
const struct config_setting_parser_list *src)
{
struct config_setting_parser_list *dest;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
return dest;
}
static struct config_filter_parser_list *
{
struct config_filter_parser_list *parser;
struct config_setting_parser_list *const *cur_parsers;
unsigned int count;
if (count == 0) {
/* first one */
} else {
/* duplicate the first settings list */
cur_parsers[0]);
}
return parser;
}
{
struct config_filter_stack *filter;
}
static struct config_setting_parser_list *const *
{
struct config_filter_parser_list *const *all_parsers;
unsigned int i, count;
bool full_found = FALSE;
for (i = 0; i < count; i++) {
&all_parsers[i]->filter))
continue;
full_found = TRUE;
} else {
}
}
}
static void
struct config_filter_parser_list *parser)
{
const char *errormsg;
for (; l->module_name != NULL; l++) {
i_fatal("Error in configuration file %s: %s",
}
}
}
static void
{
struct config_filter_parser_list *const *parsers;
unsigned int i, count;
for (i = 0; i < count; i++)
}
static void
const char **error_r)
{
unsigned char buf[1024];
int fd;
if (fd == -1) {
return;
}
if (ret < 0) {
}
}
{
struct config_setting_parser_list *l, *const *parsers;
struct parser_context ctx;
unsigned int pathlen = 0;
if (fd < 0)
}
/* @UNSAFE: line is modified */
/* skip whitespace */
line++;
/* ignore comments or empty lines */
continue;
/* strip away comments. pretty kludgy way really.. */
for (p = line; *p != '\0'; p++) {
if (*p == '\'' || *p == '"') {
char quote = *p;
for (p++; *p != quote && *p != '\0'; p++) {
if (*p == '\\' && p[1] != '\0')
p++;
}
if (*p == '\0')
break;
} else if (*p == '#') {
*p = '\0';
break;
}
}
/* remove whitespace from end of line */
len--;
/* continues in next line */
continue;
}
}
/* a) key = value
b) section_type [section_name] {
c) } */
line++;
*line++ = '\0';
}
ret = 1;
struct input_stack *tmp;
const char *path;
break;
}
errormsg = "Recursive include";
goto newfile;
} else {
/* failed, but ignore failures with include_try. */
"Couldn't open include file %s: %m", line);
}
}
} else if (*line == '=') {
/* a) */
*line++ = '\0';
if (len > 0 &&
}
else
/* file reading failed */
} else if (pathlen == 0 &&
/* verify that the setting is valid,
but delay actually adding it */
str_truncate(str, 0);
else
} else {
}
/* b) + errors */
if (*line == '{')
name = "";
else {
line++;
if (*line != '\0') {
*line++ = '\0';
line++;
}
}
if (*line != '{')
errormsg = "Expecting '='";
errormsg = "Invalid network mask";
errormsg = "Invalid network mask";
} else {
cur_counter = auth_counter++;
cur_counter = auth_counter++;
} else {
cur_counter = counter++;
}
/* already added this */
} else {
}
/* add auth default settings */
const char *const *lines;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
}
} else {
/* c) */
errormsg = "Unexpected '}'";
else {
}
}
i_fatal("Error in configuration file %s line %d: %s",
errormsg);
break;
}
str_truncate(full_line, 0);
}
goto prevfile;
}