summaryrefslogtreecommitdiff
path: root/src/ui.c
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 /src/ui.c
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)
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c16
1 files changed, 13 insertions, 3 deletions
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);
}
}