libtnccs: Move settings to <ns>.tnc and <ns>.plugins with fallback
authorTobias Brunner <tobias@strongswan.org>
Fri, 7 Feb 2014 12:43:01 +0000 (13:43 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 12 Feb 2014 13:34:34 +0000 (14:34 +0100)
src/libtnccs/plugins/tnc_imc/tnc_imc.c
src/libtnccs/plugins/tnc_imc/tnc_imc_manager.c
src/libtnccs/plugins/tnc_imv/tnc_imv.c
src/libtnccs/plugins/tnc_imv/tnc_imv_manager.c
src/libtnccs/plugins/tnccs_11/tnccs_11.c
src/libtnccs/plugins/tnccs_20/tnccs_20.c
src/libtnccs/tnc/tnc.c

index 7c52ab3..2d556d9 100644 (file)
@@ -302,7 +302,7 @@ METHOD(imc_t, destroy, void,
        private_tnc_imc_t *this)
 {
        if (this->handle && lib->settings->get_bool(lib->settings,
-               "libtnccs.plugins.tnc-imc.dlclose", TRUE))
+               "%s.plugins.tnc-imc.dlclose", TRUE, lib->ns))
        {
                dlclose(this->handle);
        }
index 311598f..459b6d7 100644 (file)
@@ -224,7 +224,7 @@ METHOD(imc_manager_t, get_preferred_language, char*,
        private_tnc_imc_manager_t *this)
 {
        return lib->settings->get_str(lib->settings,
-                               "libtnccs.plugins.tnc-imc.preferred_language", "en");
+                               "%s.plugins.tnc-imc.preferred_language", "en", lib->ns);
 }
 
 METHOD(imc_manager_t, notify_connection_change, void,
index ebf9045..ab2e552 100644 (file)
@@ -298,7 +298,7 @@ METHOD(imv_t, destroy, void,
        private_tnc_imv_t *this)
 {
        if (this->handle && lib->settings->get_bool(lib->settings,
-                               "libtnccs.plugins.tnc-imv.dlclose", TRUE))
+                               "%s.plugins.tnc-imv.dlclose", TRUE, lib->ns))
        {
                dlclose(this->handle);
        }
index 12ea203..5624501 100644 (file)
@@ -460,7 +460,8 @@ imv_manager_t* tnc_imv_manager_create(void)
 
        policy = enum_from_name(recommendation_policy_names,
                                lib->settings->get_str(lib->settings,
-                                       "libtnccs.plugins.tnc-imv.recommendation_policy", "default"));
+                                       "%s.plugins.tnc-imv.recommendation_policy",
+                                       "default", lib->ns));
        this->policy = (policy != -1) ? policy : RECOMMENDATION_POLICY_DEFAULT;
        DBG1(DBG_TNC, "TNC recommendation policy is '%N'",
                                   recommendation_policy_names, this->policy);
index 91854b5..28c5e52 100644 (file)
@@ -662,7 +662,7 @@ tnccs_t* tnccs_11_create(bool is_server,
                .callback = cb,
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .max_msg_len = lib->settings->get_int(lib->settings,
-                                                       "libtnccs.plugins.tnccs-11.max_message_size", 45000),
+                                               "%s.plugins.tnccs-11.max_message_size", 45000, lib->ns),
                .ref = 1,
        );
 
index b631ef5..f78b85a 100644 (file)
@@ -1063,9 +1063,9 @@ tnccs_t* tnccs_20_create(bool is_server,
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .messages = linked_list_create(),
                .max_batch_len = lib->settings->get_int(lib->settings,
-                                                       "libtnccs.plugins.tnccs-20.max_batch_size", 65522),
+                                               "%s.plugins.tnccs-20.max_batch_size", 65522, lib->ns),
                .max_msg_len = lib->settings->get_int(lib->settings,
-                                                       "libtnccs.plugins.tnccs-20.max_message_size", 65490),
+                                               "%s.plugins.tnccs-20.max_message_size", 65490, lib->ns),
                .ref = 1,
        );
 
index fdf0412..7cdd363 100644 (file)
@@ -70,8 +70,10 @@ void libtnccs_init(void)
                },
                .ref = 1,
        );
-
        tnc = &this->public;
+       lib->settings->add_fallback(lib->settings, "%s.tnc", "libtnccs", lib->ns);
+       lib->settings->add_fallback(lib->settings, "%s.plugins", "libtnccs.plugins",
+                                                               lib->ns);
 }
 
 /**
@@ -247,7 +249,7 @@ bool tnc_manager_register(plugin_t *plugin, plugin_feature_t *feature,
                {
                        load_imcvs_from_config(
                                                lib->settings->get_str(lib->settings,
-                                                                       "libtnccs.tnc_config", "/etc/tnc_config"),
+                                                               "%s.tnc.tnc_config", "/etc/tnc_config", lib->ns),
                                                is_imc);
                }
        }