2 * Copyright (c) 2018 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
26 * Non-standard, Darwin-specific additions to the err(3) family of APIs. The
27 * following additions are provided:
29 * - support for the error code additions in os/errno.h
30 * - automatic conversion of an error code into a sysexits(3) code
31 * - a debug_*() family of routines
33 * There are no direct equivalents for err(3), warn(3), verr(3), or vwarn(3)
34 * because those routines query errno for error information, and it is not valid
35 * to store error codes from os/error.h in errno. Therefore when evaluating the
36 * output of normal POSIX routines, use the err(1) family of routines. When
37 * evaluating the output of routines that can return the error codes in
38 * os/error.h, you may use these routines and always explicitly pass the error
41 * There are no equivalents for errx(3), warnx(3), verrx(3), or vwarnx(3)
42 * because those routines do not query error information.
44 #ifndef __DARWIN_ERR_H
45 #define __DARWIN_ERR_H
50 #include <sys/errno.h>
51 #include <sys/types.h>
52 #include <sys/cdefs.h>
53 #include <uuid/uuid.h>
66 * Writes a formatted error message to stderr(4) and exits the program.
69 * The error code to query in the output.
72 * The printf(3)-like format string representing the message to print.
75 * The arguments corresponding to the format string.
78 * This routine will look up an appropriate sysexits(3) code using the given
79 * error code using {@link darwin_sysexit} and pass it to exit(3).
81 DARWIN_API_AVAILABLE_20170407
82 OS_EXPORT OS_NORETURN OS_COLD OS_NONNULL2
OS_FORMAT_PRINTF(2, 3)
84 err_np(errno_t code
, const char *fmt
, ...);
88 * Writes a formatted error message to stderr(4) and exits the program.
91 * The code to pass to exit(3). This should be a code defined in sysexits(3).
94 * The error code to query in the output.
97 * The printf(3)-like format string representing the message to print.
100 * The arguments corresponding to the format string.
102 DARWIN_API_AVAILABLE_20170407
103 OS_EXPORT OS_NORETURN OS_COLD OS_NONNULL3
OS_FORMAT_PRINTF(3, 4)
105 errc_np(int eval
, errno_t code
, const char *fmt
, ...);
109 * Writes a formatted warning message to stderr(4).
112 * The error code to query in the output.
115 * The printf(3)-like format string representing the message to print.
118 * The arguments corresponding to the format string.
120 DARWIN_API_AVAILABLE_20170407
121 OS_EXPORT OS_COLD OS_NONNULL2
OS_FORMAT_PRINTF(2, 3)
123 warn_np(errno_t code
, const char *fmt
, ...);
127 * Writes a formatted error message to stderr(4) and exits the program.
130 * The error code to query in the output.
133 * The printf(3)-like format string representing the message to print.
136 * The argument pointer corresponding to the format string.
139 * This routine will look up an appropriate sysexits(3) code using the given
140 * error code using {@link darwin_sysexit} and pass it to exit(3).
142 DARWIN_API_AVAILABLE_20170407
143 OS_EXPORT OS_NORETURN OS_COLD OS_NONNULL2 OS_NONNULL3
145 verr_np(errno_t code
, const char *fmt
, va_list ap
);
149 * Writes a formatted error message to stderr(4) and exits the program.
152 * The code to pass to exit(3). This should be a code defined in sysexits(3).
155 * The error code to query in the output.
158 * The printf(3)-like format string representing the message to print.
161 * The argument pointer corresponding to the format string.
163 DARWIN_API_AVAILABLE_20170407
164 OS_EXPORT OS_NORETURN OS_COLD OS_NONNULL3 OS_NONNULL4
166 verrc_np(int eval
, errno_t code
, const char *fmt
, va_list ap
);
170 * Writes a formatted warning message to stderr(4).
173 * The error code to query in the output.
176 * The printf(3)-like format string representing the message to print.
179 * The arguments corresponding to the format string.
181 DARWIN_API_AVAILABLE_20170407
182 OS_EXPORT OS_COLD OS_NONNULL2 OS_NONNULL3
184 vwarn_np(errno_t code
, const char *fmt
, va_list ap
);
188 #endif // __DARWIN_ERR_H