From b014fc6f1ed71e5be5abf7bf4d8c9fd4f56025ac Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Fri, 30 Jun 2017 15:23:52 +0200 Subject: core: move core commands to baresip.c --- src/baresip.c | 25 +++++++++++++++++++++++++ src/ua.c | 24 ------------------------ 2 files changed, 25 insertions(+), 24 deletions(-) (limited to 'src') 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); -- cgit v1.2.3