summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2015-06-27 10:04:47 +0200
committerAlfred E. Heggestad <aeh@db.org>2015-06-27 10:04:47 +0200
commitf8873153be5480ca6b79741e7cbdf667080e562d (patch)
tree1dd9688f8bc8dfbdd203bbfa631d234fa1ee2054
parent8f5b65ec11c21035eca2cf87d40cc2f1578e5627 (diff)
added -m option to pre-load modules before config is parsed
-rw-r--r--include/baresip.h3
-rw-r--r--src/main.c54
-rw-r--r--src/module.c14
3 files changed, 52 insertions, 19 deletions
diff --git a/include/baresip.h b/include/baresip.h
index 0482db2..675d8f0 100644
--- a/include/baresip.h
+++ b/include/baresip.h
@@ -900,6 +900,9 @@ const char *sdp_rattr(const struct sdp_session *s, const struct sdp_media *m,
#endif
+int module_preload(const char *module);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/main.c b/src/main.c
index 51dc3d0..029eacc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -34,6 +34,26 @@ static void signal_handler(int sig)
}
+static void usage(void)
+{
+ (void)re_fprintf(stderr,
+ "Usage: baresip [options]\n"
+ "options:\n"
+#if HAVE_INET6
+ "\t-6 Prefer IPv6\n"
+#endif
+ "\t-d Daemon\n"
+ "\t-e <commands> Exec commands\n"
+ "\t-f <path> Config path\n"
+ "\t-m <module> Pre-load module\n"
+ "\t-p <path> Audio files\n"
+ "\t-h -? Help\n"
+ "\t-t Test and exit\n"
+ "\t-v Verbose debug\n"
+ );
+}
+
+
int main(int argc, char *argv[])
{
bool prefer_ipv6 = false, run_daemon = false, test = false;
@@ -47,9 +67,13 @@ int main(int argc, char *argv[])
(void)sys_coredump_set(true);
+ err = libre_init();
+ if (err)
+ goto out;
+
#ifdef HAVE_GETOPT
for (;;) {
- const int c = getopt(argc, argv, "6de:f:p:hvt");
+ const int c = getopt(argc, argv, "6de:f:p:hvtm:");
if (0 > c)
break;
@@ -57,20 +81,7 @@ int main(int argc, char *argv[])
case '?':
case 'h':
- (void)re_fprintf(stderr,
- "Usage: baresip [options]\n"
- "options:\n"
-#if HAVE_INET6
- "\t-6 Prefer IPv6\n"
-#endif
- "\t-d Daemon\n"
- "\t-e <commands> Exec commands\n"
- "\t-f <path> Config path\n"
- "\t-p <path> Audio files\n"
- "\t-h -? Help\n"
- "\t-t Test and exit\n"
- "\t-v Verbose debug\n"
- );
+ usage();
return -2;
#if HAVE_INET6
@@ -91,6 +102,15 @@ int main(int argc, char *argv[])
conf_path_set(optarg);
break;
+ case 'm':
+ err = module_preload(optarg);
+ if (err) {
+ re_fprintf(stderr,
+ "could not pre-load module"
+ " '%s' (%m)\n", optarg, err);
+ }
+ break;
+
case 'p':
play_set_path(optarg);
break;
@@ -112,10 +132,6 @@ int main(int argc, char *argv[])
(void)argv;
#endif
- err = libre_init();
- if (err)
- goto out;
-
err = conf_configure();
if (err) {
warning("main: configure failed: %m\n", err);
diff --git a/src/module.c b/src/module.c
index 12b3d13..d9c7584 100644
--- a/src/module.c
+++ b/src/module.c
@@ -154,3 +154,17 @@ void module_app_unload(void)
{
list_flush(&modappl);
}
+
+
+int module_preload(const char *module)
+{
+ struct pl path, name;
+
+ if (!module)
+ return EINVAL;
+
+ pl_set_str(&path, ".");
+ pl_set_str(&name, module);
+
+ return load_module(NULL, &path, &name);
+}