Arnaldo Carvalho de Melo | 5575536 | 2010-08-08 19:48:31 -0300 | [diff] [blame^] | 1 | #define _GNU_SOURCE |
| 2 | #include <stdio.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <newt.h> |
| 5 | |
| 6 | #include "helpline.h" |
| 7 | |
| 8 | void ui_helpline__pop(void) |
| 9 | { |
| 10 | newtPopHelpLine(); |
| 11 | } |
| 12 | |
| 13 | void ui_helpline__push(const char *msg) |
| 14 | { |
| 15 | newtPushHelpLine(msg); |
| 16 | } |
| 17 | |
| 18 | static void ui_helpline__vpush(const char *fmt, va_list ap) |
| 19 | { |
| 20 | char *s; |
| 21 | |
| 22 | if (vasprintf(&s, fmt, ap) < 0) |
| 23 | vfprintf(stderr, fmt, ap); |
| 24 | else { |
| 25 | ui_helpline__push(s); |
| 26 | free(s); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | void ui_helpline__fpush(const char *fmt, ...) |
| 31 | { |
| 32 | va_list ap; |
| 33 | |
| 34 | va_start(ap, fmt); |
| 35 | ui_helpline__vpush(fmt, ap); |
| 36 | va_end(ap); |
| 37 | } |
| 38 | |
| 39 | void ui_helpline__puts(const char *msg) |
| 40 | { |
| 41 | ui_helpline__pop(); |
| 42 | ui_helpline__push(msg); |
| 43 | } |