void
cut_setup (void)
{
    config = milter_manager_configuration_new(NULL);
    loop = milter_test_event_loop_new();

    egg = NULL;
    another_egg = NULL;
    condition = NULL;

    expected_children = milter_manager_children_new(config, loop);
    actual_children = NULL;

    expected_load_paths = NULL;

    expected_eggs = NULL;
    expected_applicable_conditions = NULL;

    actual_xml = NULL;

    tmp_dir = g_build_filename(milter_test_get_base_dir(),
                               "tmp",
                               NULL);
    cut_remove_path(tmp_dir, NULL);
    if (g_mkdir_with_parents(tmp_dir, 0700) == -1)
        cut_assert_errno();
}
void
milter_manager_init (int *argc, char ***argv)
{
    GOptionContext *option_context;
    GOptionGroup *milter_group;
    GError *error = NULL;
    MilterManager *manager;
    MilterManagerConfiguration *config;

    if (initialized)
        return;

    initialized = TRUE;

    setlocale(LC_ALL, "");
    bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
    textdomain(GETTEXT_PACKAGE);

    milter_init();
    milter_client_init();
    milter_server_init();
    milter_manager_log_handler_id = MILTER_GLIB_LOG_DELEGATE("milter-manager");

    option_context = g_option_context_new(NULL);
    g_option_context_add_main_entries(option_context, option_entries,
                                      GETTEXT_PACKAGE);

    _milter_manager_configuration_init();
    config = milter_manager_configuration_new(NULL);
    manager = milter_manager_new(config);
    g_object_unref(config);
    milter_group = milter_client_get_option_group(MILTER_CLIENT(manager));
    g_option_context_add_group(option_context, milter_group);

    if (!g_option_context_parse(option_context, argc, argv, &error)) {
        g_print("%s\n", error->message);

        if (g_error_matches(error,
                            G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION)) {
            gchar *help;
            help = g_option_context_get_help(option_context, TRUE, NULL);
            g_print("\n%s", help);
            g_free(help);
        }

        g_error_free(error);
        g_option_context_free(option_context);
        g_object_unref(manager);

        exit(EXIT_FAILURE);
    }

    g_option_context_free(option_context);
    the_manager = manager;
}