Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
helpline.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 
5 #include "../debug.h"
6 #include "helpline.h"
7 #include "ui.h"
8 
10 
11 static void nop_helpline__pop(void)
12 {
13 }
14 
15 static void nop_helpline__push(const char *msg __maybe_unused)
16 {
17 }
18 
19 static struct ui_helpline default_helpline_fns = {
20  .pop = nop_helpline__pop,
21  .push = nop_helpline__push,
22 };
23 
24 struct ui_helpline *helpline_fns = &default_helpline_fns;
25 
26 void ui_helpline__pop(void)
27 {
28  helpline_fns->pop();
29 }
30 
31 void ui_helpline__push(const char *msg)
32 {
33  helpline_fns->push(msg);
34 }
35 
36 void ui_helpline__vpush(const char *fmt, va_list ap)
37 {
38  char *s;
39 
40  if (vasprintf(&s, fmt, ap) < 0)
41  vfprintf(stderr, fmt, ap);
42  else {
44  free(s);
45  }
46 }
47 
48 void ui_helpline__fpush(const char *fmt, ...)
49 {
50  va_list ap;
51 
52  va_start(ap, fmt);
53  ui_helpline__vpush(fmt, ap);
54  va_end(ap);
55 }
56 
57 void ui_helpline__puts(const char *msg)
58 {
60  ui_helpline__push(msg);
61 }