This source file includes following definitions.
- perf_stdio__error
- perf_stdio__warning
- ui__error
- ui__warning
- perf_error__register
- perf_error__unregister
1
2 #include "util.h"
3 #include "../util/debug.h"
4 #include <stdio.h>
5
6
7
8
9 static int perf_stdio__error(const char *format, va_list args)
10 {
11 fprintf(stderr, "Error:\n");
12 vfprintf(stderr, format, args);
13 return 0;
14 }
15
16 static int perf_stdio__warning(const char *format, va_list args)
17 {
18 fprintf(stderr, "Warning:\n");
19 vfprintf(stderr, format, args);
20 return 0;
21 }
22
23 static struct perf_error_ops default_eops =
24 {
25 .error = perf_stdio__error,
26 .warning = perf_stdio__warning,
27 };
28
29 static struct perf_error_ops *perf_eops = &default_eops;
30
31
32 int ui__error(const char *format, ...)
33 {
34 int ret;
35 va_list args;
36
37 va_start(args, format);
38 ret = perf_eops->error(format, args);
39 va_end(args);
40
41 return ret;
42 }
43
44 int ui__warning(const char *format, ...)
45 {
46 int ret;
47 va_list args;
48
49 va_start(args, format);
50 ret = perf_eops->warning(format, args);
51 va_end(args);
52
53 return ret;
54 }
55
56
57
58
59
60
61
62
63 int perf_error__register(struct perf_error_ops *eops)
64 {
65 if (perf_eops != &default_eops)
66 return -1;
67
68 perf_eops = eops;
69 return 0;
70 }
71
72
73
74
75
76
77
78 int perf_error__unregister(struct perf_error_ops *eops)
79 {
80 if (perf_eops != eops)
81 return -1;
82
83 perf_eops = &default_eops;
84 return 0;
85 }