]> git.saurik.com Git - apple/libc.git/blob - libdarwin/h/errno.h
Libc-1353.41.1.tar.gz
[apple/libc.git] / libdarwin / h / errno.h
1 /*
2 * Copyright (c) 2018 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /*
25 * @header
26 * Non-standard, Darwin-specific additions to the error codes enumerated in
27 * intro(2) and sys/errno.h.
28 */
29 #ifndef __DARWIN_ERRNO_H
30 #define __DARWIN_ERRNO_H
31
32 #include <os/base.h>
33 #include <os/api.h>
34 #include <sys/errno.h>
35 #include <sys/cdefs.h>
36 #include <sysexits.h>
37
38 /*!
39 * @enum
40 * Additional POSIX-flavor error codes that are meaningful to Darwin. These
41 * definitions all have a "_NP" suffix to distinguish them from POSIX error
42 * codes (meaning "not POSIX").
43 */
44 #define EBASE_NP 200
45 #define _ENPERR(__c) (EBASE_NP + __c)
46
47 /*!
48 * @const ENOTENTITLED_NP
49 * The remote process lacked a required entitlement to perform the operation.
50 */
51 #define ENOTENTITLED_NP _ENPERR(0)
52
53 /*!
54 * @const ENOTPLATFORM_NP
55 * The operation may only be invoked by platform binaries.
56 */
57 #define ENOTPLATFORM_NP _ENPERR(1)
58
59 /*!
60 * @const EROOTLESS_NP
61 * The operation was denied by System Integrity Protection.
62 */
63 #define EROOTLESS_NP _ENPERR(2)
64
65 /*!
66 * @const ETAINTED_NP
67 * The operation may only be invoked by processes which are not tainted by
68 * debugging and introspection functionality (e.g. dyld(1) environment
69 * variables, debugger attachment, etc.).
70 */
71 #define ETAINTED_NP _ENPERR(3)
72
73 /*!
74 * @const EQUARANTINE_NP
75 * The operation is not permitted on quarantined file.
76 */
77 #define EQUARANTINE_NP _ENPERR(4)
78
79 /*!
80 * @const EBADUSER_NP
81 * The operation referenced a user name or identifier that was invalid.
82 */
83 #define EBADUSER_NP _ENPERR(5)
84
85 /*!
86 * @const EBADGROUP_NP
87 * The operation referenced a group name or identifier that was invalid.
88 */
89 #define EBADGROUP_NP _ENPERR(6)
90
91 /*!
92 * @const EOWNERSHIP_NP
93 * Ownership or access permissions on a file were too permissive.
94 */
95 #define EOWNERSHIP_NP _ENPERR(7)
96
97 /*!
98 * @const ENOOOO_NP
99 * A series of operations was executed in the improper order (no out-of-order
100 * operations allowed).
101 */
102 #define ENOOOO_NP _ENPERR(8)
103
104 /*!
105 * @const ENOTBUNDLE_NP
106 * The path given to the operation did not refer to a bundle.
107 */
108 #define ENOTBUNDLE_NP _ENPERR(9)
109
110 /*!
111 * @const EBADBUNDLE_NP
112 * The path given to the operation did not refer to a valid bundle.
113 */
114 #define EBADBUNDLE_NP _ENPERR(10)
115
116 /*!
117 * @const EBADPATH_NP
118 * The path given to the operation was not valid.
119 */
120 #define EBADPATH_NP _ENPERR(11)
121
122 /*!
123 * @const EBADPLIST_NP
124 * The plist given to the operation was invalid.
125 */
126 #define EBADPLIST_NP _ENPERR(12)
127
128 /*!
129 * @const EBADKEY_NP
130 * A key in the given plist was unrecognized.
131 */
132 #define EBADKEY_NP _ENPERR(13)
133
134 /*!
135 * @const EBADVAL_NP
136 * The value for a key in the given plist was either not present (and was
137 * required to be) or was present but not of the appropriate type.
138 */
139 #define EBADVAL_NP _ENPERR(14)
140
141 /*!
142 @const EBADSUBSYS_NP
143 * The request referenced a subsystem that did not exist.
144 */
145 #define EBADSUBSYS_NP _ENPERR(15)
146
147 /*!
148 * @const E2BIMPL_NP
149 * The operation has not yet been implemented.
150 */
151 #define E2BIMPL_NP _ENPERR(16)
152
153 /*!
154 * @const EDEPRECATED_NP
155 * The operation has been deprecated.
156 */
157 #define EDEPRECATED_NP _ENPERR(17)
158
159 /*!
160 * @const EREMOVED_NP
161 * The operation has been removed from the implementation.
162 */
163 #define EREMOVED_NP _ENPERR(18)
164
165 /*!
166 * @const EDROPPED_NP
167 * The request referenced a data structure that will never achieve the state
168 * required to perform the operation.
169 */
170 #define EDROPPED_NP _ENPERR(19)
171
172 /*!
173 * @const EDEFERRED_NP
174 * The request referenced a data structure that was not in the state required
175 * to perform the operation, and the request has been pended until the object
176 * reaches the required state. This code is meant to be used for control flow
177 * purposes in the server and should not be returned to the caller.
178 */
179 #define EDEFERRED_NP _ENPERR(20)
180
181 /*!
182 * @const EUSAGE_NP
183 * Improper command line usage. This code is meant to be used for control flow
184 * purposes in a command line tool so that routines may return an error code
185 * indicating improper usage without having to use EX_USAGE, which collides with
186 * the POSIX error space. It should not be passed to exit(3), _exit(2), et al.
187 * and should instead be translated into EX_USAGE either directly or with
188 * {@link darwin_sysexit}.
189 */
190 #define EUSAGE_NP _ENPERR(21)
191
192 /*!
193 * @const EUNKNOWN_NP
194 * An error occurred in a subsystem, and insufficient detail as to the nature of
195 * the failure was available to translate it into a more descriptive error code.
196 */
197 #define EUNKNOWN_NP _ENPERR(22)
198 #define __ELAST_NP _ENPERR(22)
199
200 /*!
201 * @const EX_BADRECEIPT_NP
202 * An exit code indicating that the program could not verify its purchase
203 * receipt from the Mac App Store. This exit code is inspected by the system to
204 * trigger a re-validation of the purchase receipt. It must be passed to the
205 * exit(3) Libc API and not to _exit(2) system call. This exit code is only
206 * relevant to the macOS variant of Darwin.
207 */
208 #define EX_BADRECEIPT_NP (173)
209
210 __BEGIN_DECLS;
211
212 /*!
213 * @function sysexit_np
214 * Translates a {@link errno_t} or POSIX error code into an exit code
215 * defined in sysexits(3).
216 *
217 * @param code
218 * The error code to translate.
219 *
220 * @result
221 * The sysexits(3) exit code most appropriate for the given error. If no
222 * appropriate exit code could be determined, the designated ¯\_(ツ)_/¯ exit
223 * code, EX_UNAVAILABLE, is returned (cf. sysexits(3)).
224 */
225 DARWIN_API_AVAILABLE_20170407
226 OS_EXPORT OS_WARN_RESULT OS_CONST
227 int
228 sysexit_np(int code);
229
230 __END_DECLS;
231
232 #endif // __DARWIN_ERRNO_H