main.c revision e0740628f6ca05f4bc79a9d8a90b650f4d38d4d0
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden/* Copyright (C) 2005-2009 Dovecot authors, see the included COPYING file */
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "lib.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "array.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "env-util.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "master-service.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "config-connection.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "config-parser.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include "config-request.h"
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include <stdlib.h>
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden#include <unistd.h>
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Maddenstatic void client_connected(const struct master_service_connection *conn)
4dc8bf8db4b0422db4c958bb68a450f04c56431aJoel Pearson{
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden config_connection_create(conn->fd);
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden}
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Maddenint main(int argc, char *argv[])
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden{
4dc8bf8db4b0422db4c958bb68a450f04c56431aJoel Pearson const char *path, *error;
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden int c;
4dc8bf8db4b0422db4c958bb68a450f04c56431aJoel Pearson
965c9c7794176a6815b197f53aa146a29e181b99Neil Madden master_service = master_service_init("config", 0, argc, argv);
965c9c7794176a6815b197f53aa146a29e181b99Neil Madden while ((c = getopt(argc, argv, master_service_getopt_string())) > 0) {
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden if (!master_service_parse_option(master_service, c, optarg))
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden exit(FATAL_DEFAULT);
4dc8bf8db4b0422db4c958bb68a450f04c56431aJoel Pearson }
4dc8bf8db4b0422db4c958bb68a450f04c56431aJoel Pearson
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden master_service_init_log(master_service, "config: ");
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden master_service_init_finish(master_service);
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden path = master_service_get_config_path(master_service);
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden if (config_parse_file(path, TRUE, &error) <= 0)
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden i_fatal("%s", error);
4dc8bf8db4b0422db4c958bb68a450f04c56431aJoel Pearson
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden master_service_run(master_service, client_connected);
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden config_connections_destroy_all();
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden config_filter_deinit(&config_filter);
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden master_service_deinit(&master_service);
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden return 0;
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden}
c8ab19d28fde5eda3b2daab4b1124887681fedf9Neil Madden