2 d444fd2e 2022-12-21 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
4 d444fd2e 2022-12-21 op * Permission to use, copy, modify, and distribute this software for any
5 d444fd2e 2022-12-21 op * purpose with or without fee is hereby granted, provided that the above
6 d444fd2e 2022-12-21 op * copyright notice and this permission notice appear in all copies.
8 d444fd2e 2022-12-21 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 d444fd2e 2022-12-21 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 d444fd2e 2022-12-21 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 d444fd2e 2022-12-21 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 d444fd2e 2022-12-21 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 d444fd2e 2022-12-21 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 d444fd2e 2022-12-21 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 d444fd2e 2022-12-21 op #include <errno.h>
18 d444fd2e 2022-12-21 op #include <stdarg.h>
19 d444fd2e 2022-12-21 op #include <stdio.h>
20 d444fd2e 2022-12-21 op #include <stdlib.h>
21 d444fd2e 2022-12-21 op #include <string.h>
23 d444fd2e 2022-12-21 op #include "compat.h"
25 d444fd2e 2022-12-21 op static void vwarn(const char*, va_list);
26 d444fd2e 2022-12-21 op static void vwarnx(const char*, va_list);
29 d444fd2e 2022-12-21 op vwarn(const char *fmt, va_list ap)
31 d444fd2e 2022-12-21 op fprintf(stderr, "%s: ", getprogname());
32 d444fd2e 2022-12-21 op vfprintf(stderr, fmt, ap);
33 d444fd2e 2022-12-21 op fprintf(stderr, ": %s\n", strerror(errno));
37 d444fd2e 2022-12-21 op vwarnx(const char *fmt, va_list ap)
39 d444fd2e 2022-12-21 op fprintf(stderr, "%s: ", getprogname());
40 d444fd2e 2022-12-21 op vfprintf(stderr, fmt, ap);
41 d444fd2e 2022-12-21 op fprintf(stderr, "\n");
45 d444fd2e 2022-12-21 op err(int ret, const char *fmt, ...)
49 d444fd2e 2022-12-21 op va_start(ap, fmt);
50 d444fd2e 2022-12-21 op vwarn(fmt, ap);
56 d444fd2e 2022-12-21 op errc(int ret, int code, const char *fmt, ...)
62 d444fd2e 2022-12-21 op va_start(ap, fmt);
63 d444fd2e 2022-12-21 op vwarn(fmt, ap);
69 d444fd2e 2022-12-21 op errx(int ret, const char *fmt, ...)
73 d444fd2e 2022-12-21 op va_start(ap, fmt);
74 d444fd2e 2022-12-21 op vwarnx(fmt, ap);
80 d444fd2e 2022-12-21 op warn(const char *fmt, ...)
84 d444fd2e 2022-12-21 op va_start(ap, fmt);
85 d444fd2e 2022-12-21 op vwarn(fmt, ap);
90 d444fd2e 2022-12-21 op warnc(int code, const char *fmt, ...)
96 d444fd2e 2022-12-21 op va_start(ap, fmt);
97 d444fd2e 2022-12-21 op vwarn(fmt, ap);
102 d444fd2e 2022-12-21 op warnx(const char *fmt, ...)
106 d444fd2e 2022-12-21 op va_start(ap, fmt);
107 d444fd2e 2022-12-21 op vwarnx(fmt, ap);