return t_strconcat(t_strdup_until(input->path, p+1), path, NULL);
}
-void config_parse_file(const char *path, const char *service)
+void config_parse_file(const char *path)
{
enum settings_parser_flags parser_flags =
SETTINGS_PARSER_FLAG_IGNORE_UNKNOWN_KEYS;
unsigned int counter = 0, auth_counter = 0, cur_counter;
const char *errormsg, *name, *type_name;
char *line, *key, *p;
- int fd, ret, ignore;
+ int fd, ret;
string_t *str, *full_line;
size_t len;
pool_t pool;
str = t_str_new(256);
full_line = t_str_new(512);
- errormsg = NULL; ignore = 0;
+ errormsg = NULL;
newfile:
input->input = i_stream_create_fd(fd, (size_t)-1, TRUE);
i_stream_set_return_partial_line(input->input, TRUE);
str_append(str, key);
str_append_c(str, '=');
str_append(str, line);
- if (ignore > 0) {
- /* ignore this setting */
- } else if (pathlen == 0 &&
- strncmp(str_c(str), "auth_", 5) == 0) {
+ if (pathlen == 0 &&
+ strncmp(str_c(str), "auth_", 5) == 0) {
/* verify that the setting is valid,
but delay actually adding it */
const char *s = t_strdup(str_c(str) + 5);
if (*line != '{')
errormsg = "Expecting '='";
- else if (ignore > 0) {
- ignore++;
- } else if (strcmp(key, "protocol") == 0) {
+ if (strcmp(key, "protocol") == 0) {
array_append(&pathlen_stack, &pathlen, 1);
- ignore = strcmp(name, service) != 0;
} else {
array_append(&pathlen_stack, &pathlen, 1);
unsigned int pathlen_count;
const unsigned int *arr;
- if (ignore > 0)
- ignore--;
-
arr = array_get(&pathlen_stack, &pathlen_count);
if (pathlen_count == 0)
errormsg = "Unexpected '}'";
#ifndef CONFIG_PARSER_H
#define CONFIG_PARSER_H
-void config_parse_file(const char *path, const char *service);
+void config_parse_file(const char *path);
#endif
char **exec_args = NULL;
int c;
- service = master_service_init("config", 0, argc, argv);
+ service = master_service_init("config", MASTER_SERVICE_FLAG_STANDALONE,
+ argc, argv);
getopt_str = t_strconcat("anp:e", master_service_getopt_string(), NULL);
while ((c = getopt(argc, argv, getopt_str)) > 0) {
}
if (argv[optind] != NULL)
exec_args = &argv[optind];
-
- master_service_init_log(service, "doveconf: ", 0);
master_service_init_finish(service);
- config_parse_file(master_service_get_config_path(service),
- service_name);
+ config_parse_file(master_service_get_config_path(service));
if (exec_args == NULL)
config_dump_human(service_name, flags);
static struct master_service *service;
-static void main_init(const char *service_name)
-{
- config_parse_file(master_service_get_config_path(service),
- service_name);
-}
-
static void client_connected(const struct master_service_connection *conn)
{
config_connection_create(conn->fd);
int main(int argc, char *argv[])
{
- const char *getopt_str, *service_name = "";
- char **exec_args = NULL;
int c;
service = master_service_init("config", 0, argc, argv);
-
- getopt_str = t_strconcat("anp:e", master_service_getopt_string(), NULL);
- while ((c = getopt(argc, argv, getopt_str)) > 0) {
- if (c == 'e')
- break;
- switch (c) {
- case 'p':
- service_name = optarg;
- break;
- default:
- if (!master_service_parse_option(service, c, optarg))
- exit(FATAL_DEFAULT);
- }
+ while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) {
+ if (!master_service_parse_option(service, c, optarg))
+ exit(FATAL_DEFAULT);
}
- if (argv[optind] != NULL)
- exec_args = &argv[optind];
- master_service_init_log(service, "doveconf: ", 0);
+ master_service_init_log(service, "config: ", 0);
master_service_init_finish(service);
- main_init(service_name);
+ config_parse_file(master_service_get_config_path(service));
master_service_run(service, client_connected);
config_connections_destroy_all();