summaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/account.c1
-rw-r--r--src/ui.c16
2 files changed, 14 insertions, 3 deletions
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);
}
}