drm/i915/dsi: Move vlv/icl_dphy_param_init call out of intel_dsi_vbt_init (v2)
[linux/fpc-iii.git] / tools / perf / ui / helpline.c
blobb3c421429ed440b1eebcdbdefa9c223a74c81920
1 // SPDX-License-Identifier: GPL-2.0
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <string.h>
6 #include "../debug.h"
7 #include "helpline.h"
8 #include "ui.h"
9 #include "../util.h"
11 char ui_helpline__current[512];
13 static void nop_helpline__pop(void)
17 static void nop_helpline__push(const char *msg __maybe_unused)
21 static int nop_helpline__show(const char *fmt __maybe_unused,
22 va_list ap __maybe_unused)
24 return 0;
27 static struct ui_helpline default_helpline_fns = {
28 .pop = nop_helpline__pop,
29 .push = nop_helpline__push,
30 .show = nop_helpline__show,
33 struct ui_helpline *helpline_fns = &default_helpline_fns;
35 void ui_helpline__pop(void)
37 helpline_fns->pop();
40 void ui_helpline__push(const char *msg)
42 helpline_fns->push(msg);
45 void ui_helpline__vpush(const char *fmt, va_list ap)
47 char *s;
49 if (vasprintf(&s, fmt, ap) < 0)
50 vfprintf(stderr, fmt, ap);
51 else {
52 ui_helpline__push(s);
53 free(s);
57 void ui_helpline__fpush(const char *fmt, ...)
59 va_list ap;
61 va_start(ap, fmt);
62 ui_helpline__vpush(fmt, ap);
63 va_end(ap);
66 void ui_helpline__puts(const char *msg)
68 ui_helpline__pop();
69 ui_helpline__push(msg);
72 int ui_helpline__vshow(const char *fmt, va_list ap)
74 return helpline_fns->show(fmt, ap);
77 void ui_helpline__printf(const char *fmt, ...)
79 va_list ap;
81 ui_helpline__pop();
82 va_start(ap, fmt);
83 ui_helpline__vpush(fmt, ap);
84 va_end(ap);