Mercurial > projects > libpws
annotate compat/err.c @ 5:b3fc9f7e2b43
Fix manpage title
author | Guido Berhoerster <guido+libpws@berhoerster.name> |
---|---|
date | Thu, 10 Jan 2019 08:05:32 +0100 |
parents | 97097b4b6bfb |
children |
rev | line source |
---|---|
2
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
1 /* |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
2 * Copyright (C) 2011 Guido Berhoerster <guido+libpws@berhoerster.name> |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
3 * |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
4 * Permission is hereby granted, free of charge, to any person obtaining |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
5 * a copy of this software and associated documentation files (the |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
6 * "Software"), to deal in the Software without restriction, including |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
7 * without limitation the rights to use, copy, modify, merge, publish, |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
8 * distribute, sublicense, and/or sell copies of the Software, and to |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
9 * permit persons to whom the Software is furnished to do so, subject to |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
10 * the following conditions: |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
11 * |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
12 * The above copyright notice and this permission notice shall be included |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
13 * in all copies or substantial portions of the Software. |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
14 * |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
22 */ |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
23 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
24 #include <stdlib.h> |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
25 #include <stdio.h> |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
26 #include <string.h> |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
27 #include <errno.h> |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
28 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
29 #include "pws-compat.h" |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
30 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
31 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
32 vwarn(const char *fmt, va_list args) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
33 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
34 int old_errno = errno; |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
35 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
36 fprintf(stderr, "%s: ", getprogname()); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
37 if (fmt != NULL) { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
38 vfprintf(stderr, fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
39 fprintf(stderr, ": "); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
40 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
41 fprintf(stderr, "%s\n", strerror(old_errno)); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
42 errno = old_errno; |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
43 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
44 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
45 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
46 vwarnx(const char *fmt, va_list args) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
47 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
48 fprintf(stderr, "%s: ", getprogname()); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
49 if (fmt != NULL) { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
50 vfprintf(stderr, fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
51 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
52 fputc('\n', stderr); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
53 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
54 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
55 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
56 verr(int eval, const char *fmt, va_list args) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
57 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
58 vwarn(fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
59 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
60 exit(eval); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
61 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
62 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
63 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
64 verrx(int eval, const char *fmt, va_list args) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
65 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
66 vwarnx(fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
67 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
68 exit(eval); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
69 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
70 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
71 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
72 err(int eval, const char *fmt, ...) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
73 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
74 va_list args; |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
75 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
76 va_start(args, fmt); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
77 vwarn(fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
78 va_end(args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
79 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
80 exit(eval); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
81 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
82 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
83 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
84 errx(int eval, const char *fmt, ...) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
85 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
86 va_list args; |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
87 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
88 va_start(args, fmt); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
89 vwarnx(fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
90 va_end(args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
91 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
92 exit(eval); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
93 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
94 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
95 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
96 warn(const char *fmt, ...) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
97 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
98 va_list args; |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
99 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
100 va_start(args, fmt); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
101 vwarn(fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
102 va_end(args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
103 } |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
104 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
105 void |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
106 warnx(const char *fmt, ...) |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
107 { |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
108 va_list args; |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
109 |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
110 va_start(args, fmt); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
111 vwarnx(fmt, args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
112 va_end(args); |
97097b4b6bfb
Add pwsdump utility
Guido Berhoerster <guido+libpws@berhoerster.name>
parents:
diff
changeset
|
113 } |