2 83f0f95a 2022-09-29 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 83f0f95a 2022-09-29 op * Permission to use, copy, modify, and distribute this software for any
5 83f0f95a 2022-09-29 op * purpose with or without fee is hereby granted, provided that the above
6 83f0f95a 2022-09-29 op * copyright notice and this permission notice appear in all copies.
8 83f0f95a 2022-09-29 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 83f0f95a 2022-09-29 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 83f0f95a 2022-09-29 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 83f0f95a 2022-09-29 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 83f0f95a 2022-09-29 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 83f0f95a 2022-09-29 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 83f0f95a 2022-09-29 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 83f0f95a 2022-09-29 op #include <errno.h>
18 83f0f95a 2022-09-29 op #include <stdarg.h>
19 83f0f95a 2022-09-29 op #include <stdio.h>
20 83f0f95a 2022-09-29 op #include <stdlib.h>
21 83f0f95a 2022-09-29 op #include <string.h>
23 83f0f95a 2022-09-29 op static void vwarn_impl(const char*, va_list);
24 83f0f95a 2022-09-29 op static void vwarnx_impl(const char*, va_list);
27 83f0f95a 2022-09-29 op vwarn_impl(const char *fmt, va_list ap)
29 83f0f95a 2022-09-29 op fprintf(stderr, "%s: ", getprogname());
30 83f0f95a 2022-09-29 op vfprintf(stderr, fmt, ap);
31 83f0f95a 2022-09-29 op fprintf(stderr, ": %s\n", strerror(errno));
35 83f0f95a 2022-09-29 op vwarnx_impl(const char *fmt, va_list ap)
37 83f0f95a 2022-09-29 op fprintf(stderr, "%s: ", getprogname());
38 83f0f95a 2022-09-29 op vfprintf(stderr, fmt, ap);
39 83f0f95a 2022-09-29 op fprintf(stderr, "\n");
43 83f0f95a 2022-09-29 op err(int ret, const char *fmt, ...)
47 83f0f95a 2022-09-29 op va_start(ap, fmt);
48 83f0f95a 2022-09-29 op vwarn_impl(fmt, ap);
54 83f0f95a 2022-09-29 op errx(int ret, const char *fmt, ...)
58 83f0f95a 2022-09-29 op va_start(ap, fmt);
59 83f0f95a 2022-09-29 op vwarnx_impl(fmt, ap);
65 83f0f95a 2022-09-29 op warn(const char *fmt, ...)
69 83f0f95a 2022-09-29 op va_start(ap, fmt);
70 83f0f95a 2022-09-29 op vwarn_impl(fmt, ap);
75 83f0f95a 2022-09-29 op warnx(const char *fmt, ...)
79 83f0f95a 2022-09-29 op va_start(ap, fmt);
80 83f0f95a 2022-09-29 op vwarnx_impl(fmt, ap);