Linux Perf
helpline.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
5 
6 #include "../debug.h"
7 #include "helpline.h"
8 #include "ui.h"
9 #include "../util.h"
10 
12 
13 static void nop_helpline__pop(void)
14 {
15 }
16 
17 static void nop_helpline__push(const char *msg __maybe_unused)
18 {
19 }
20 
21 static int nop_helpline__show(const char *fmt __maybe_unused,
22  va_list ap __maybe_unused)
23 {
24  return 0;
25 }
26 
29  .push = nop_helpline__push,
30  .show = nop_helpline__show,
31 };
32 
34 
35 void ui_helpline__pop(void)
36 {
37  helpline_fns->pop();
38 }
39 
40 void ui_helpline__push(const char *msg)
41 {
42  helpline_fns->push(msg);
43 }
44 
45 void ui_helpline__vpush(const char *fmt, va_list ap)
46 {
47  char *s;
48 
49  if (vasprintf(&s, fmt, ap) < 0)
50  vfprintf(stderr, fmt, ap);
51  else {
53  free(s);
54  }
55 }
56 
57 void ui_helpline__fpush(const char *fmt, ...)
58 {
59  va_list ap;
60 
61  va_start(ap, fmt);
62  ui_helpline__vpush(fmt, ap);
63  va_end(ap);
64 }
65 
66 void ui_helpline__puts(const char *msg)
67 {
69  ui_helpline__push(msg);
70 }
71 
72 int ui_helpline__vshow(const char *fmt, va_list ap)
73 {
74  return helpline_fns->show(fmt, ap);
75 }
76 
77 void ui_helpline__printf(const char *fmt, ...)
78 {
79  va_list ap;
80 
82  va_start(ap, fmt);
83  ui_helpline__vpush(fmt, ap);
84  va_end(ap);
85 }
static void nop_helpline__push(const char *msg __maybe_unused)
Definition: helpline.c:17
static struct ui_helpline default_helpline_fns
Definition: helpline.c:27
char ui_helpline__current[512]
Definition: helpline.c:11
void(* push)(const char *msg)
Definition: helpline.h:12
void ui_helpline__push(const char *msg)
Definition: helpline.c:40
void(* pop)(void)
Definition: helpline.h:11
const char * fmt
Definition: dso.c:193
static void nop_helpline__pop(void)
Definition: helpline.c:13
int(* show)(const char *fmt, va_list ap)
Definition: helpline.h:13
void ui_helpline__puts(const char *msg)
Definition: helpline.c:66
void ui_helpline__fpush(const char *fmt,...)
Definition: helpline.c:57
void ui_helpline__vpush(const char *fmt, va_list ap)
Definition: helpline.c:45
void ui_helpline__printf(const char *fmt,...)
Definition: helpline.c:77
static int nop_helpline__show(const char *fmt __maybe_unused, va_list ap __maybe_unused)
Definition: helpline.c:21
void ui_helpline__pop(void)
Definition: helpline.c:35
void free(void *)
int ui_helpline__vshow(const char *fmt, va_list ap)
Definition: helpline.c:72
struct ui_helpline * helpline_fns
Definition: helpline.c:33