diff options
-rw-r--r-- | include/baresip.h | 4 | ||||
-rw-r--r-- | modules/account/account.c | 5 | ||||
-rw-r--r-- | modules/contact/contact.c | 10 | ||||
-rw-r--r-- | src/conf.c | 5 |
4 files changed, 14 insertions, 10 deletions
diff --git a/include/baresip.h b/include/baresip.h index c6d8ae8..4173313 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -110,13 +110,13 @@ uint32_t call_linenum(const struct call *call); /** Defines the configuration line handler */ -typedef int (confline_h)(const struct pl *addr); +typedef int (confline_h)(const struct pl *addr, void *arg); int conf_configure(void); int conf_modules(void); void conf_path_set(const char *path); int conf_path_get(char *path, size_t sz); -int conf_parse(const char *filename, confline_h *ch); +int conf_parse(const char *filename, confline_h *ch, void *arg); 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); diff --git a/modules/account/account.c b/modules/account/account.c index 9cd4235..c70a216 100644 --- a/modules/account/account.c +++ b/modules/account/account.c @@ -104,9 +104,10 @@ static int account_write_template(const char *file) * * @return 0 if success, otherwise errorcode */ -static int line_handler(const struct pl *addr) +static int line_handler(const struct pl *addr, void *arg) { char buf[512]; + (void)arg; (void)pl_strcpy(addr, buf, sizeof(buf)); @@ -143,7 +144,7 @@ static int account_read_file(void) return err; } - err = conf_parse(file, line_handler); + err = conf_parse(file, line_handler, NULL); if (err) return err; diff --git a/modules/contact/contact.c b/modules/contact/contact.c index 2a566eb..c71c370 100644 --- a/modules/contact/contact.c +++ b/modules/contact/contact.c @@ -22,9 +22,10 @@ static const char *chat_peer; /**< Selected chat peer */ static char cmd_desc[128] = "Send MESSAGE to peer"; -static int confline_handler(const struct pl *addr) +static int confline_handler(const struct pl *addr, void *arg) { - return contact_add(baresip_contacts(), NULL, addr); + struct contacts *contacts = arg; + return contact_add(contacts, NULL, addr); } @@ -182,6 +183,7 @@ static int write_template(const char *file) static int module_init(void) { + struct contacts *contacts = baresip_contacts(); char path[256] = "", file[256] = ""; int err; @@ -201,7 +203,7 @@ static int module_init(void) return err; } - err = conf_parse(file, confline_handler); + err = conf_parse(file, confline_handler, contacts); if (err) return err; @@ -210,7 +212,7 @@ static int module_init(void) return err; info("Populated %u contacts\n", - list_count(contact_list(baresip_contacts()))); + list_count(contact_list(contacts))); return err; } @@ -78,10 +78,11 @@ static void print_populated(const char *what, uint32_t n) * * @param filename Config file * @param ch Line handler + * @param arg Handler argument * * @return 0 if success, otherwise errorcode */ -int conf_parse(const char *filename, confline_h *ch) +int conf_parse(const char *filename, confline_h *ch, void *arg) { struct pl pl, val; struct mbuf *mb; @@ -122,7 +123,7 @@ int conf_parse(const char *filename, confline_h *ch) if (!val.l || val.p[0] == '#') continue; - err = ch(&val); + err = ch(&val, arg); } out: |