Steven Rostedt (VMware) | 6ab025e | 2018-08-16 11:10:15 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: LGPL-2.1 |
Jon Stanley | 2d2481d | 2012-09-08 14:00:51 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> |
| 4 | * |
Jon Stanley | 2d2481d | 2012-09-08 14:00:51 -0400 | [diff] [blame] | 5 | */ |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 6 | #include <stdio.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <string.h> |
| 9 | #include <stdarg.h> |
| 10 | #include <errno.h> |
| 11 | |
| 12 | #define __weak __attribute__((weak)) |
| 13 | |
Steven Rostedt | f7d8235 | 2012-04-06 00:47:53 +0200 | [diff] [blame] | 14 | void __vwarning(const char *fmt, va_list ap) |
| 15 | { |
| 16 | if (errno) |
| 17 | perror("trace-cmd"); |
| 18 | errno = 0; |
| 19 | |
| 20 | fprintf(stderr, " "); |
| 21 | vfprintf(stderr, fmt, ap); |
| 22 | |
| 23 | fprintf(stderr, "\n"); |
| 24 | } |
| 25 | |
| 26 | void __warning(const char *fmt, ...) |
| 27 | { |
| 28 | va_list ap; |
| 29 | |
| 30 | va_start(ap, fmt); |
| 31 | __vwarning(fmt, ap); |
| 32 | va_end(ap); |
| 33 | } |
| 34 | |
| 35 | void __weak warning(const char *fmt, ...) |
| 36 | { |
| 37 | va_list ap; |
| 38 | |
| 39 | va_start(ap, fmt); |
| 40 | __vwarning(fmt, ap); |
| 41 | va_end(ap); |
| 42 | } |
| 43 | |
| 44 | void __vpr_stat(const char *fmt, va_list ap) |
| 45 | { |
| 46 | vprintf(fmt, ap); |
| 47 | printf("\n"); |
| 48 | } |
| 49 | |
| 50 | void __pr_stat(const char *fmt, ...) |
| 51 | { |
| 52 | va_list ap; |
| 53 | |
| 54 | va_start(ap, fmt); |
| 55 | __vpr_stat(fmt, ap); |
| 56 | va_end(ap); |
| 57 | } |
| 58 | |
| 59 | void __weak vpr_stat(const char *fmt, va_list ap) |
| 60 | { |
| 61 | __vpr_stat(fmt, ap); |
| 62 | } |
| 63 | |
| 64 | void __weak pr_stat(const char *fmt, ...) |
| 65 | { |
| 66 | va_list ap; |
| 67 | |
| 68 | va_start(ap, fmt); |
| 69 | __vpr_stat(fmt, ap); |
| 70 | va_end(ap); |
| 71 | } |