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