helpline.c 625 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #define _GNU_SOURCE
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <newt.h>
  5. #include "helpline.h"
  6. void ui_helpline__pop(void)
  7. {
  8. newtPopHelpLine();
  9. }
  10. void ui_helpline__push(const char *msg)
  11. {
  12. newtPushHelpLine(msg);
  13. }
  14. static void ui_helpline__vpush(const char *fmt, va_list ap)
  15. {
  16. char *s;
  17. if (vasprintf(&s, fmt, ap) < 0)
  18. vfprintf(stderr, fmt, ap);
  19. else {
  20. ui_helpline__push(s);
  21. free(s);
  22. }
  23. }
  24. void ui_helpline__fpush(const char *fmt, ...)
  25. {
  26. va_list ap;
  27. va_start(ap, fmt);
  28. ui_helpline__vpush(fmt, ap);
  29. va_end(ap);
  30. }
  31. void ui_helpline__puts(const char *msg)
  32. {
  33. ui_helpline__pop();
  34. ui_helpline__push(msg);
  35. }