summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred E. Heggestad <aeh@db.org>2014-11-30 21:10:26 +0100
committerAlfred E. Heggestad <aeh@db.org>2014-11-30 21:10:26 +0100
commit847c497d84366caaae4e575a7cb700a5f092279d (patch)
treef58c0beb48549c77aa0ec1da74ee4c2a1de48fc5
parent9f1cc4b054088b9437462f44b8f4dbe435f88b2d (diff)
ui: make ui_output() take a formatted string
- minor cleanup in logging - use ui_output() for interactive output - avoid using re_printf() - stdio: added an output_handler (to stderr)
-rw-r--r--include/baresip.h2
-rw-r--r--modules/menu/menu.c8
-rw-r--r--modules/mwi/mwi.c4
-rw-r--r--modules/quicktime/quicktime.c5
-rw-r--r--modules/stdio/stdio.c9
-rw-r--r--src/account.c1
-rw-r--r--src/ui.c16
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];
diff --git a/src/ui.c b/src/ui.c
index 836dcdc..14e8723 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -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);
}
}