summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-30 15:23:52 +0200
committerAlfred E. Heggestad <alfred.heggestad@gmail.com>2017-06-30 15:23:52 +0200
commitb014fc6f1ed71e5be5abf7bf4d8c9fd4f56025ac (patch)
tree38ec3f4414cb87bccb516604a0c26a221cb98237 /src
parent16fdf8e19fe7a4a658d940a25d1a53c8d242f9fd (diff)
core: move core commands to baresip.c
Diffstat (limited to 'src')
-rw-r--r--src/baresip.c25
-rw-r--r--src/ua.c24
2 files changed, 25 insertions, 24 deletions
diff --git a/src/baresip.c b/src/baresip.c
index 2d63287..0705f38 100644
--- a/src/baresip.c
+++ b/src/baresip.c
@@ -31,6 +31,25 @@ static struct baresip {
} baresip;
+static int cmd_quit(struct re_printf *pf, void *unused)
+{
+ int err;
+
+ (void)unused;
+
+ err = re_hprintf(pf, "Quit\n");
+
+ ua_stop_all(false);
+
+ return err;
+}
+
+
+static const struct cmd corecmdv[] = {
+ {"quit", 'q', 0, "Quit", cmd_quit },
+};
+
+
int baresip_init(struct config *cfg, bool prefer_ipv6)
{
int err;
@@ -76,12 +95,18 @@ int baresip_init(struct config *cfg, bool prefer_ipv6)
return err;
}
+ err = cmd_register(baresip.commands, corecmdv, ARRAY_SIZE(corecmdv));
+ if (err)
+ return err;
+
return 0;
}
void baresip_close(void)
{
+ cmd_unregister(baresip.commands, corecmdv);
+
baresip.message = mem_deref(baresip.message);
baresip.player = mem_deref(baresip.player);
baresip.commands = mem_deref(baresip.commands);
diff --git a/src/ua.c b/src/ua.c
index 36c54d2..bceae63 100644
--- a/src/ua.c
+++ b/src/ua.c
@@ -1297,25 +1297,6 @@ static void net_change_handler(void *arg)
}
-static int cmd_quit(struct re_printf *pf, void *unused)
-{
- int err;
-
- (void)unused;
-
- err = re_hprintf(pf, "Quit\n");
-
- ua_stop_all(false);
-
- return err;
-}
-
-
-static const struct cmd cmdv[] = {
- {"quit", 'q', 0, "Quit", cmd_quit },
-};
-
-
static bool sub_handler(const struct sip_msg *msg, void *arg)
{
struct ua *ua;
@@ -1395,10 +1376,6 @@ int ua_init(const char *software, bool udp, bool tcp, bool tls,
if (err)
goto out;
- err = cmd_register(baresip_commands(), cmdv, ARRAY_SIZE(cmdv));
- if (err)
- goto out;
-
net_change(net, 60, net_change_handler, NULL);
out:
@@ -1415,7 +1392,6 @@ int ua_init(const char *software, bool udp, bool tcp, bool tls,
*/
void ua_close(void)
{
- cmd_unregister(baresip_commands(), cmdv);
ui_reset();
uag.evsock = mem_deref(uag.evsock);