summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/TODO4
-rw-r--r--include/baresip.h1
-rw-r--r--src/conf.c27
-rw-r--r--src/main.c14
4 files changed, 23 insertions, 23 deletions
diff --git a/docs/TODO b/docs/TODO
index 2cf0ee9..9e518fa 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -3,8 +3,8 @@ TODO:
-------------------------------------------------------------------------------
Version v0.x.y:
- config-object is not available during pre-loading of modules
- keep config-object around, add support for appending config
+ config: add support for pre-pending or appending config items
+ from command-line options
conf: move generation of config template to a module ('config.so') ?
diff --git a/include/baresip.h b/include/baresip.h
index 401b7fc..b8d92aa 100644
--- a/include/baresip.h
+++ b/include/baresip.h
@@ -105,6 +105,7 @@ int conf_get_vidsz(const struct conf *conf, const char *name,
struct vidsz *sz);
int conf_get_sa(const struct conf *conf, const char *name, struct sa *sa);
bool conf_fileexist(const char *path);
+void conf_close(void);
struct conf *conf_cur(void);
diff --git a/src/conf.c b/src/conf.c
index 4f08d70..bc29ba7 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -315,6 +315,7 @@ int conf_configure(void)
goto out;
}
+ conf_obj = mem_deref(conf_obj);
err = conf_alloc(&conf_obj, file);
if (err)
goto out;
@@ -324,7 +325,6 @@ int conf_configure(void)
goto out;
out:
- conf_obj = mem_deref(conf_obj);
return err;
}
@@ -333,23 +333,13 @@ int conf_configure(void)
* Load all modules from config file
*
* @return 0 if success, otherwise errorcode
+ *
+ * @note conf_configure must be called first
*/
int conf_modules(void)
{
- char path[256], file[256];
int err;
- err = conf_path_get(path, sizeof(path));
- if (err)
- return err;
-
- if (re_snprintf(file, sizeof(file), "%s/config", path) < 0)
- return ENOMEM;
-
- err = conf_alloc(&conf_obj, file);
- if (err)
- goto out;
-
err = module_init(conf_obj);
if (err) {
warning("conf: configure module parse error (%m)\n", err);
@@ -364,7 +354,6 @@ int conf_modules(void)
#endif
out:
- conf_obj = mem_deref(conf_obj);
return err;
}
@@ -378,5 +367,15 @@ int conf_modules(void)
*/
struct conf *conf_cur(void)
{
+ if (!conf_obj) {
+ warning("conf: no config object\n");
+ }
return conf_obj;
}
+
+
+void conf_close(void)
+{
+ mod_close();
+ conf_obj = mem_deref(conf_obj);
+}
diff --git a/src/main.c b/src/main.c
index a7aee59..1760dc7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -141,6 +141,12 @@ int main(int argc, char *argv[])
(void)argv;
#endif
+ err = conf_configure();
+ if (err) {
+ warning("main: configure failed: %m\n", err);
+ goto out;
+ }
+
/* NOTE: must be done after all arguments are processed */
if (modc) {
size_t i;
@@ -158,12 +164,6 @@ int main(int argc, char *argv[])
}
}
- err = conf_configure();
- if (err) {
- warning("main: configure failed: %m\n", err);
- goto out;
- }
-
/* Initialise User Agents */
err = ua_init("baresip v" BARESIP_VERSION " (" ARCH "/" OS ")",
true, true, true, prefer_ipv6);
@@ -205,7 +205,7 @@ int main(int argc, char *argv[])
ua_stop_all(true);
ua_close();
- mod_close();
+ conf_close();
libre_close();