コード例 #1
0
void
eventd_config_parse(EventdConfig *config, gboolean system_mode)
{
    _eventd_config_clean(config);

    config->loaded = TRUE;

    _eventd_config_defaults(config);

    GHashTable *action_files;
    GHashTable *event_files;

    action_files = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_key_file_free);
    event_files = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_key_file_free);

    gchar **dirs, **dir;
    dirs = evhelpers_dirs_get_config("EVENTD_CONFIG_DIR", system_mode, NULL);
    for ( dir = dirs ; *dir != NULL ; ++dir )
    {
        _eventd_config_load_dir(config, action_files, event_files, *dir);
        g_free(*dir);
    }
    g_free(dirs);
    if ( g_file_test(config->arg_dir, G_FILE_TEST_IS_DIR) )
        _eventd_config_load_dir(config, action_files, event_files, config->arg_dir);

    /*
     * We check the env early, and skip the configuration if found
     * so here, we can override it safely
     */
    if ( config->gnutls_priorities != NULL )
        g_setenv("G_TLS_GNUTLS_PRIORITY", config->gnutls_priorities, TRUE);

    GHashTableIter iter;
    gchar *id;
    GKeyFile *config_file;

    g_hash_table_iter_init(&iter, event_files);
    while ( g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&config_file) )
    {
        if ( ( config_file = _eventd_config_process_config_file(event_files, id, config_file) ) != NULL )
            eventd_events_parse(config->events, config_file);
    }
    g_hash_table_unref(event_files);

    g_hash_table_iter_init(&iter, action_files);
    while ( g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&config_file) )
    {
        if ( ( config_file = _eventd_config_process_config_file(action_files, id, config_file) ) != NULL )
            eventd_actions_parse(config->actions, config_file, id);
    }
    g_hash_table_unref(action_files);

    eventd_actions_link_actions(config->actions);
    eventd_events_link_actions(config->events, config->actions);
}
コード例 #2
0
ファイル: config.c プロジェクト: worr/eventd
void
eventd_config_free(EventdConfig *config)
{
    _eventd_config_clean(config);

    g_hash_table_unref(config->events);
    g_hash_table_unref(config->event_ids);

    g_free(config);
}
コード例 #3
0
void
eventd_config_free(EventdConfig *config)
{
    _eventd_config_clean(config);

    eventd_actions_free(config->actions);
    eventd_events_free(config->events);

    g_free(config);
}
コード例 #4
0
ファイル: config.c プロジェクト: Keruspe/eventd
void
eventd_config_parse(EventdConfig *config)
{
    _eventd_config_clean(config);

    config->loaded = TRUE;

    _eventd_config_defaults(config);
    eventd_plugins_config_init_all();

    GHashTable *config_files;

    config_files = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_key_file_free);

    _eventd_config_load_dir(config, config_files, DATADIR G_DIR_SEPARATOR_S PACKAGE_NAME);
    _eventd_config_load_dir(config, config_files, SYSCONFDIR G_DIR_SEPARATOR_S PACKAGE_NAME);

    gchar *user_config_dir;
    user_config_dir = g_build_filename(g_get_user_config_dir(), PACKAGE_NAME, NULL);
    _eventd_config_load_dir(config, config_files, user_config_dir);
    g_free(user_config_dir);

    const gchar *env_config_dir;
    env_config_dir = g_getenv("EVENTD_CONFIG_DIR");
    if ( env_config_dir != NULL )
        _eventd_config_load_dir(config, config_files, env_config_dir);

    GHashTableIter iter;
    gchar *id;
    GKeyFile *config_file;
    g_hash_table_iter_init(&iter, config_files);
    while ( g_hash_table_iter_next(&iter, (gpointer *)&id, (gpointer *)&config_file) )
    {
        if ( ( config_file = _eventd_config_process_config_file(config_files, id, config_file) ) != NULL )
            _eventd_config_parse_event_file(config, id, config_file);
    }
    g_hash_table_unref(config_files);
}