diff options
-rw-r--r-- | include/baresip.h | 2 | ||||
-rw-r--r-- | modules/menu/menu.c | 8 | ||||
-rw-r--r-- | modules/mwi/mwi.c | 4 | ||||
-rw-r--r-- | modules/quicktime/quicktime.c | 5 | ||||
-rw-r--r-- | modules/stdio/stdio.c | 9 | ||||
-rw-r--r-- | src/account.c | 1 | ||||
-rw-r--r-- | src/ui.c | 16 |
7 files changed, 30 insertions, 15 deletions
diff --git a/include/baresip.h b/include/baresip.h index 4685426..741a69c 100644 --- a/include/baresip.h +++ b/include/baresip.h @@ -551,7 +551,7 @@ void ui_input(char key); void ui_input_key(char key, struct re_printf *pf); void ui_input_str(const char *str); int ui_input_pl(struct re_printf *pf, const struct pl *pl); -void ui_output(const char *str); +void ui_output(const char *fmt, ...); bool ui_isediting(void); diff --git a/modules/menu/menu.c b/modules/menu/menu.c index 9701515..32512ef 100644 --- a/modules/menu/menu.c +++ b/modules/menu/menu.c @@ -47,10 +47,10 @@ static void check_registrations(void) n = list_count(uag_list()); /* We are ready */ - (void)re_printf("\x1b[32mAll %u useragent%s registered successfully!" - " (%u ms)\x1b[;m\n", - n, n==1 ? "" : "s", - (uint32_t)(tmr_jiffies() - start_ticks)); + ui_output("\x1b[32mAll %u useragent%s registered successfully!" + " (%u ms)\x1b[;m\n", + n, n==1 ? "" : "s", + (uint32_t)(tmr_jiffies() - start_ticks)); ual_ready = true; } diff --git a/modules/mwi/mwi.c b/modules/mwi/mwi.c index 9bea26a..a04e6bf 100644 --- a/modules/mwi/mwi.c +++ b/modules/mwi/mwi.c @@ -41,8 +41,8 @@ static void notify_handler(struct sip *sip, const struct sip_msg *msg, struct mwi *mwi = arg; if (mbuf_get_left(msg->mb)) { - re_printf("----- MWI for %s -----\n", ua_aor(mwi->ua)); - re_printf("%b\n", mbuf_buf(msg->mb), mbuf_get_left(msg->mb)); + ui_output("----- MWI for %s -----\n", ua_aor(mwi->ua)); + ui_output("%b\n", mbuf_buf(msg->mb), mbuf_get_left(msg->mb)); } (void)sip_treply(NULL, sip, msg, 200, "OK"); diff --git a/modules/quicktime/quicktime.c b/modules/quicktime/quicktime.c index 5aa6bd9..84fab4b 100644 --- a/modules/quicktime/quicktime.c +++ b/modules/quicktime/quicktime.c @@ -94,7 +94,7 @@ static OSErr frame_handler(SGChannel c, Ptr p, long len, long *offset, result = SGGetChannelSampleDescription(c,(Handle)imageDesc); if (result != noErr) { - re_printf("GetChanSampDesc: %d\n", result); + warning("quicktime: GetChanSampDesc: %d\n", result); DisposeHandle((Handle)imageDesc); return noErr; } @@ -192,9 +192,6 @@ static int alloc(struct vidsrc_st **stp, struct vidsrc *vs, (void)dev; (void)errorh; - re_printf("quicktime alloc: %u x %u fps=%d\n", - prm->size.w, prm->size.h, prm->fps); - st = mem_zalloc(sizeof(*st), destructor); if (!st) return ENOMEM; diff --git a/modules/stdio/stdio.c b/modules/stdio/stdio.c index 244dc01..3121322 100644 --- a/modules/stdio/stdio.c +++ b/modules/stdio/stdio.c @@ -150,8 +150,15 @@ static int ui_alloc(struct ui_st **stp) } +static int output_handler(const char *str) +{ + return print_handler(str, str_len(str), NULL); +} + + static struct ui ui_stdio = { - .name = "stdio" + .name = "stdio", + .outputh = output_handler }; diff --git a/src/account.c b/src/account.c index 0269b04..1ddab6f 100644 --- a/src/account.c +++ b/src/account.c @@ -323,6 +323,7 @@ static int encode_uri_user(struct re_printf *pf, const struct uri *uri) } +/* TODO: move interactive code away from CORE, to a module */ static int password_prompt(struct account *acc) { char pwd[64]; @@ -129,17 +129,27 @@ int ui_input_pl(struct re_printf *pf, const struct pl *pl) /** * Send output to all modules registered in the UI subsystem * - * @param str Output string + * @param fmt Formatted output string */ -void ui_output(const char *str) +void ui_output(const char *fmt, ...) { + char buf[512]; struct le *le; + va_list ap; + int n; + + va_start(ap, fmt); + n = re_vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + if (n < 0) + return; for (le = uil.head; le; le = le->next) { const struct ui *ui = le->data; if (ui->outputh) - ui->outputh(str); + ui->outputh(buf); } } |