Apache Portable Runtime
Loading...
Searching...
No Matches
apr_errno.h
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef APR_ERRNO_H
18#define APR_ERRNO_H
19
20/**
21 * @file apr_errno.h
22 * @brief APR Error Codes
23 */
24
25#include "apr.h"
26
27#if APR_HAVE_ERRNO_H
28#include <errno.h>
29#endif
30
31#ifdef __cplusplus
32extern "C" {
33#endif /* __cplusplus */
34
35/**
36 * @defgroup apr_errno Error Codes
37 * @ingroup APR
38 * @{
39 */
40
41/**
42 * Type for specifying an error or status code.
43 */
44typedef int apr_status_t;
45
46/**
47 * Return a human readable string describing the specified error.
48 * @param statcode The error code to get a string for.
49 * @param buf A buffer to hold the error string.
50 * @param bufsize Size of the buffer to hold the string.
51 */
52APR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
53 apr_size_t bufsize);
54
55#if defined(DOXYGEN)
56/**
57 * @def APR_FROM_OS_ERROR(os_err_type syserr)
58 * Fold a platform specific error into an apr_status_t code.
59 * @return apr_status_t
60 * @param e The platform os error code.
61 * @warning macro implementation; the syserr argument may be evaluated
62 * multiple times.
63 */
64#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
65
66/**
67 * @def APR_TO_OS_ERROR(apr_status_t statcode)
68 * @return os_err_type
69 * Fold an apr_status_t code back to the native platform defined error.
70 * @param e The apr_status_t folded platform os error code.
71 * @warning macro implementation; the statcode argument may be evaluated
72 * multiple times. If the statcode was not created by apr_get_os_error
73 * or APR_FROM_OS_ERROR, the results are undefined.
74 */
75#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
76
77/** @def apr_get_os_error()
78 * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
79 * @remark This retrieves errno, or calls a GetLastError() style function, and
80 * folds it with APR_FROM_OS_ERROR. Some platforms (such as OS2) have no
81 * such mechanism, so this call may be unsupported. Do NOT use this
82 * call for socket errors from socket, send, recv etc!
83 */
84
85/** @def apr_set_os_error(e)
86 * Reset the last platform error, unfolded from an apr_status_t, on some platforms
87 * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR()
88 * @warning This is a macro implementation; the statcode argument may be evaluated
89 * multiple times. If the statcode was not created by apr_get_os_error
90 * or APR_FROM_OS_ERROR, the results are undefined. This macro sets
91 * errno, or calls a SetLastError() style function, unfolding statcode
92 * with APR_TO_OS_ERROR. Some platforms (such as OS2) have no such
93 * mechanism, so this call may be unsupported.
94 */
95
96/** @def apr_get_netos_error()
97 * Return the last socket error, folded into apr_status_t, on all platforms
98 * @remark This retrieves errno or calls a GetLastSocketError() style function,
99 * and folds it with APR_FROM_OS_ERROR.
100 */
101
102/** @def apr_set_netos_error(e)
103 * Reset the last socket error, unfolded from an apr_status_t
104 * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR()
105 * @warning This is a macro implementation; the statcode argument may be evaluated
106 * multiple times. If the statcode was not created by apr_get_os_error
107 * or APR_FROM_OS_ERROR, the results are undefined. This macro sets
108 * errno, or calls a WSASetLastError() style function, unfolding
109 * socketcode with APR_TO_OS_ERROR.
110 */
111
112#endif /* defined(DOXYGEN) */
113
114/**
115 * APR_OS_START_ERROR is where the APR specific error values start.
116 */
117#define APR_OS_START_ERROR 20000
118/**
119 * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
120 * into one of the error/status ranges below -- except for
121 * APR_OS_START_USERERR, which see.
122 */
123#define APR_OS_ERRSPACE_SIZE 50000
124/**
125 * APR_UTIL_ERRSPACE_SIZE is the size of the space that is reserved for
126 * use within apr-util. This space is reserved above that used by APR
127 * internally.
128 * @note This number MUST be smaller than APR_OS_ERRSPACE_SIZE by a
129 * large enough amount that APR has sufficient room for its
130 * codes.
131 */
132#define APR_UTIL_ERRSPACE_SIZE 20000
133/**
134 * APR_OS_START_STATUS is where the APR specific status codes start.
135 */
136#define APR_OS_START_STATUS (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
137/**
138 * APR_UTIL_START_STATUS is where APR-Util starts defining its
139 * status codes.
140 */
141#define APR_UTIL_START_STATUS (APR_OS_START_STATUS + \
142 (APR_OS_ERRSPACE_SIZE - APR_UTIL_ERRSPACE_SIZE))
143/**
144 * APR_OS_START_USERERR are reserved for applications that use APR that
145 * layer their own error codes along with APR's. Note that the
146 * error immediately following this one is set ten times farther
147 * away than usual, so that users of apr have a lot of room in
148 * which to declare custom error codes.
149 *
150 * In general applications should try and create unique error codes. To try
151 * and assist in finding suitable ranges of numbers to use, the following
152 * ranges are known to be used by the listed applications. If your
153 * application defines error codes please advise the range of numbers it
154 * uses to dev@apr.apache.org for inclusion in this list.
155 *
156 * Ranges shown are in relation to APR_OS_START_USERERR
157 *
158 * Subversion - Defined ranges, of less than 100, at intervals of 5000
159 * starting at an offset of 5000, e.g.
160 * +5000 to 5100, +10000 to 10100
161 *
162 * Apache HTTPD - +2000 to 2999
163 */
164#define APR_OS_START_USERERR (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE)
165/**
166 * APR_OS_START_USEERR is obsolete, defined for compatibility only.
167 * Use APR_OS_START_USERERR instead.
168 */
169#define APR_OS_START_USEERR APR_OS_START_USERERR
170/**
171 * APR_OS_START_CANONERR is where APR versions of errno values are defined
172 * on systems which don't have the corresponding errno.
173 */
174#define APR_OS_START_CANONERR (APR_OS_START_USERERR \
175 + (APR_OS_ERRSPACE_SIZE * 10))
176/**
177 * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into
178 * apr_status_t values.
179 */
180#define APR_OS_START_EAIERR (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE)
181/**
182 * APR_OS_START_SYSERR folds platform-specific system error values into
183 * apr_status_t values.
184 */
185#define APR_OS_START_SYSERR (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE)
186
187/**
188 * @defgroup APR_ERROR_map APR Error Space
189 * <PRE>
190 * The following attempts to show the relation of the various constants
191 * used for mapping APR Status codes.
192 *
193 * 0
194 *
195 * 20,000 APR_OS_START_ERROR
196 *
197 * + APR_OS_ERRSPACE_SIZE (50,000)
198 *
199 * 70,000 APR_OS_START_STATUS
200 *
201 * + APR_OS_ERRSPACE_SIZE - APR_UTIL_ERRSPACE_SIZE (30,000)
202 *
203 * 100,000 APR_UTIL_START_STATUS
204 *
205 * + APR_UTIL_ERRSPACE_SIZE (20,000)
206 *
207 * 120,000 APR_OS_START_USERERR
208 *
209 * + 10 x APR_OS_ERRSPACE_SIZE (50,000 * 10)
210 *
211 * 620,000 APR_OS_START_CANONERR
212 *
213 * + APR_OS_ERRSPACE_SIZE (50,000)
214 *
215 * 670,000 APR_OS_START_EAIERR
216 *
217 * + APR_OS_ERRSPACE_SIZE (50,000)
218 *
219 * 720,000 APR_OS_START_SYSERR
220 *
221 * </PRE>
222 */
223
224/** no error. */
225#define APR_SUCCESS 0
226
227/**
228 * @defgroup APR_Error APR Error Values
229 * <PRE>
230 * <b>APR ERROR VALUES</b>
231 * APR_ENOSTAT APR was unable to perform a stat on the file
232 * APR_ENOPOOL APR was not provided a pool with which to allocate memory
233 * APR_EBADDATE APR was given an invalid date
234 * APR_EINVALSOCK APR was given an invalid socket
235 * APR_ENOPROC APR was not given a process structure
236 * APR_ENOTIME APR was not given a time structure
237 * APR_ENODIR APR was not given a directory structure
238 * APR_ENOLOCK APR was not given a lock structure
239 * APR_ENOPOLL APR was not given a poll structure
240 * APR_ENOSOCKET APR was not given a socket
241 * APR_ENOTHREAD APR was not given a thread structure
242 * APR_ENOTHDKEY APR was not given a thread key structure
243 * APR_ENOSHMAVAIL There is no more shared memory available
244 * APR_EDSOOPEN APR was unable to open the dso object. For more
245 * information call apr_dso_error().
246 * APR_EGENERAL General failure (specific information not available)
247 * APR_EBADIP The specified IP address is invalid
248 * APR_EBADMASK The specified netmask is invalid
249 * APR_ESYMNOTFOUND Could not find the requested symbol
250 * APR_ENOTENOUGHENTROPY Not enough entropy to continue
251 * </PRE>
252 *
253 * <PRE>
254 * <b>APR STATUS VALUES</b>
255 * APR_INCHILD Program is currently executing in the child
256 * APR_INPARENT Program is currently executing in the parent
257 * APR_DETACH The thread is detached
258 * APR_NOTDETACH The thread is not detached
259 * APR_CHILD_DONE The child has finished executing
260 * APR_CHILD_NOTDONE The child has not finished executing
261 * APR_TIMEUP The operation did not finish before the timeout
262 * APR_INCOMPLETE The operation was incomplete although some processing
263 * was performed and the results are partially valid
264 * APR_BADCH Getopt found an option not in the option string
265 * APR_BADARG Getopt found an option that is missing an argument
266 * and an argument was specified in the option string
267 * APR_EOF APR has encountered the end of the file
268 * APR_NOTFOUND APR was unable to find the socket in the poll structure
269 * APR_ANONYMOUS APR is using anonymous shared memory
270 * APR_FILEBASED APR is using a file name as the key to the shared memory
271 * APR_KEYBASED APR is using a shared key as the key to the shared memory
272 * APR_EINIT Ininitalizer value. If no option has been found, but
273 * the status variable requires a value, this should be used
274 * APR_ENOTIMPL The APR function has not been implemented on this
275 * platform, either because nobody has gotten to it yet,
276 * or the function is impossible on this platform.
277 * APR_EMISMATCH Two passwords do not match.
278 * APR_EABSOLUTE The given path was absolute.
279 * APR_ERELATIVE The given path was relative.
280 * APR_EINCOMPLETE The given path was neither relative nor absolute.
281 * APR_EABOVEROOT The given path was above the root path.
282 * APR_EBUSY The given lock was busy.
283 * APR_EPROC_UNKNOWN The given process wasn't recognized by APR
284 * </PRE>
285 * @{
286 */
287/** @see APR_STATUS_IS_ENOSTAT */
288#define APR_ENOSTAT (APR_OS_START_ERROR + 1)
289/** @see APR_STATUS_IS_ENOPOOL */
290#define APR_ENOPOOL (APR_OS_START_ERROR + 2)
291/* empty slot: +3 */
292/** @see APR_STATUS_IS_EBADDATE */
293#define APR_EBADDATE (APR_OS_START_ERROR + 4)
294/** @see APR_STATUS_IS_EINVALSOCK */
295#define APR_EINVALSOCK (APR_OS_START_ERROR + 5)
296/** @see APR_STATUS_IS_ENOPROC */
297#define APR_ENOPROC (APR_OS_START_ERROR + 6)
298/** @see APR_STATUS_IS_ENOTIME */
299#define APR_ENOTIME (APR_OS_START_ERROR + 7)
300/** @see APR_STATUS_IS_ENODIR */
301#define APR_ENODIR (APR_OS_START_ERROR + 8)
302/** @see APR_STATUS_IS_ENOLOCK */
303#define APR_ENOLOCK (APR_OS_START_ERROR + 9)
304/** @see APR_STATUS_IS_ENOPOLL */
305#define APR_ENOPOLL (APR_OS_START_ERROR + 10)
306/** @see APR_STATUS_IS_ENOSOCKET */
307#define APR_ENOSOCKET (APR_OS_START_ERROR + 11)
308/** @see APR_STATUS_IS_ENOTHREAD */
309#define APR_ENOTHREAD (APR_OS_START_ERROR + 12)
310/** @see APR_STATUS_IS_ENOTHDKEY */
311#define APR_ENOTHDKEY (APR_OS_START_ERROR + 13)
312/** @see APR_STATUS_IS_EGENERAL */
313#define APR_EGENERAL (APR_OS_START_ERROR + 14)
314/** @see APR_STATUS_IS_ENOSHMAVAIL */
315#define APR_ENOSHMAVAIL (APR_OS_START_ERROR + 15)
316/** @see APR_STATUS_IS_EBADIP */
317#define APR_EBADIP (APR_OS_START_ERROR + 16)
318/** @see APR_STATUS_IS_EBADMASK */
319#define APR_EBADMASK (APR_OS_START_ERROR + 17)
320/* empty slot: +18 */
321/** @see APR_STATUS_IS_EDSOPEN */
322#define APR_EDSOOPEN (APR_OS_START_ERROR + 19)
323/** @see APR_STATUS_IS_EABSOLUTE */
324#define APR_EABSOLUTE (APR_OS_START_ERROR + 20)
325/** @see APR_STATUS_IS_ERELATIVE */
326#define APR_ERELATIVE (APR_OS_START_ERROR + 21)
327/** @see APR_STATUS_IS_EINCOMPLETE */
328#define APR_EINCOMPLETE (APR_OS_START_ERROR + 22)
329/** @see APR_STATUS_IS_EABOVEROOT */
330#define APR_EABOVEROOT (APR_OS_START_ERROR + 23)
331/** @see APR_STATUS_IS_EBADPATH */
332#define APR_EBADPATH (APR_OS_START_ERROR + 24)
333/** @see APR_STATUS_IS_EPATHWILD */
334#define APR_EPATHWILD (APR_OS_START_ERROR + 25)
335/** @see APR_STATUS_IS_ESYMNOTFOUND */
336#define APR_ESYMNOTFOUND (APR_OS_START_ERROR + 26)
337/** @see APR_STATUS_IS_EPROC_UNKNOWN */
338#define APR_EPROC_UNKNOWN (APR_OS_START_ERROR + 27)
339/** @see APR_STATUS_IS_ENOTENOUGHENTROPY */
340#define APR_ENOTENOUGHENTROPY (APR_OS_START_ERROR + 28)
341/** @} */
342
343/**
344 * @defgroup APR_STATUS_IS Status Value Tests
345 * @warning For any particular error condition, more than one of these tests
346 * may match. This is because platform-specific error codes may not
347 * always match the semantics of the POSIX codes these tests (and the
348 * corresponding APR error codes) are named after. A notable example
349 * are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on
350 * Win32 platforms. The programmer should always be aware of this and
351 * adjust the order of the tests accordingly.
352 * @{
353 */
354/**
355 * APR was unable to perform a stat on the file
356 * @warning always use this test, as platform-specific variances may meet this
357 * more than one error code
358 */
359#define APR_STATUS_IS_ENOSTAT(s) ((s) == APR_ENOSTAT)
360/**
361 * APR was not provided a pool with which to allocate memory
362 * @warning always use this test, as platform-specific variances may meet this
363 * more than one error code
364 */
365#define APR_STATUS_IS_ENOPOOL(s) ((s) == APR_ENOPOOL)
366/** APR was given an invalid date */
367#define APR_STATUS_IS_EBADDATE(s) ((s) == APR_EBADDATE)
368/** APR was given an invalid socket */
369#define APR_STATUS_IS_EINVALSOCK(s) ((s) == APR_EINVALSOCK)
370/** APR was not given a process structure */
371#define APR_STATUS_IS_ENOPROC(s) ((s) == APR_ENOPROC)
372/** APR was not given a time structure */
373#define APR_STATUS_IS_ENOTIME(s) ((s) == APR_ENOTIME)
374/** APR was not given a directory structure */
375#define APR_STATUS_IS_ENODIR(s) ((s) == APR_ENODIR)
376/** APR was not given a lock structure */
377#define APR_STATUS_IS_ENOLOCK(s) ((s) == APR_ENOLOCK)
378/** APR was not given a poll structure */
379#define APR_STATUS_IS_ENOPOLL(s) ((s) == APR_ENOPOLL)
380/** APR was not given a socket */
381#define APR_STATUS_IS_ENOSOCKET(s) ((s) == APR_ENOSOCKET)
382/** APR was not given a thread structure */
383#define APR_STATUS_IS_ENOTHREAD(s) ((s) == APR_ENOTHREAD)
384/** APR was not given a thread key structure */
385#define APR_STATUS_IS_ENOTHDKEY(s) ((s) == APR_ENOTHDKEY)
386/** Generic Error which can not be put into another spot */
387#define APR_STATUS_IS_EGENERAL(s) ((s) == APR_EGENERAL)
388/** There is no more shared memory available */
389#define APR_STATUS_IS_ENOSHMAVAIL(s) ((s) == APR_ENOSHMAVAIL)
390/** The specified IP address is invalid */
391#define APR_STATUS_IS_EBADIP(s) ((s) == APR_EBADIP)
392/** The specified netmask is invalid */
393#define APR_STATUS_IS_EBADMASK(s) ((s) == APR_EBADMASK)
394/* empty slot: +18 */
395/**
396 * APR was unable to open the dso object.
397 * For more information call apr_dso_error().
398 */
399#if defined(WIN32)
400#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \
401 || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND)
402#elif defined(OS2)
403#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN \
404 || APR_TO_OS_ERROR(s) == ERROR_FILE_NOT_FOUND)
405#else
406#define APR_STATUS_IS_EDSOOPEN(s) ((s) == APR_EDSOOPEN)
407#endif
408/** The given path was absolute. */
409#define APR_STATUS_IS_EABSOLUTE(s) ((s) == APR_EABSOLUTE)
410/** The given path was relative. */
411#define APR_STATUS_IS_ERELATIVE(s) ((s) == APR_ERELATIVE)
412/** The given path was neither relative nor absolute. */
413#define APR_STATUS_IS_EINCOMPLETE(s) ((s) == APR_EINCOMPLETE)
414/** The given path was above the root path. */
415#define APR_STATUS_IS_EABOVEROOT(s) ((s) == APR_EABOVEROOT)
416/** The given path was bad. */
417#define APR_STATUS_IS_EBADPATH(s) ((s) == APR_EBADPATH)
418/** The given path contained wildcards. */
419#define APR_STATUS_IS_EPATHWILD(s) ((s) == APR_EPATHWILD)
420/** Could not find the requested symbol.
421 * For more information call apr_dso_error().
422 */
423#if defined(WIN32)
424#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \
425 || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
426#elif defined(OS2)
427#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND \
428 || APR_TO_OS_ERROR(s) == ERROR_INVALID_NAME)
429#else
430#define APR_STATUS_IS_ESYMNOTFOUND(s) ((s) == APR_ESYMNOTFOUND)
431#endif
432/** The given process was not recognized by APR. */
433#define APR_STATUS_IS_EPROC_UNKNOWN(s) ((s) == APR_EPROC_UNKNOWN)
434/** APR could not gather enough entropy to continue. */
435#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY)
436
437/** @} */
438
439/**
440 * @addtogroup APR_Error
441 * @{
442 */
443/** @see APR_STATUS_IS_INCHILD */
444#define APR_INCHILD (APR_OS_START_STATUS + 1)
445/** @see APR_STATUS_IS_INPARENT */
446#define APR_INPARENT (APR_OS_START_STATUS + 2)
447/** @see APR_STATUS_IS_DETACH */
448#define APR_DETACH (APR_OS_START_STATUS + 3)
449/** @see APR_STATUS_IS_NOTDETACH */
450#define APR_NOTDETACH (APR_OS_START_STATUS + 4)
451/** @see APR_STATUS_IS_CHILD_DONE */
452#define APR_CHILD_DONE (APR_OS_START_STATUS + 5)
453/** @see APR_STATUS_IS_CHILD_NOTDONE */
454#define APR_CHILD_NOTDONE (APR_OS_START_STATUS + 6)
455/** @see APR_STATUS_IS_TIMEUP */
456#define APR_TIMEUP (APR_OS_START_STATUS + 7)
457/** @see APR_STATUS_IS_INCOMPLETE */
458#define APR_INCOMPLETE (APR_OS_START_STATUS + 8)
459/* empty slot: +9 */
460/* empty slot: +10 */
461/* empty slot: +11 */
462/** @see APR_STATUS_IS_BADCH */
463#define APR_BADCH (APR_OS_START_STATUS + 12)
464/** @see APR_STATUS_IS_BADARG */
465#define APR_BADARG (APR_OS_START_STATUS + 13)
466/** @see APR_STATUS_IS_EOF */
467#define APR_EOF (APR_OS_START_STATUS + 14)
468/** @see APR_STATUS_IS_NOTFOUND */
469#define APR_NOTFOUND (APR_OS_START_STATUS + 15)
470/* empty slot: +16 */
471/* empty slot: +17 */
472/* empty slot: +18 */
473/** @see APR_STATUS_IS_ANONYMOUS */
474#define APR_ANONYMOUS (APR_OS_START_STATUS + 19)
475/** @see APR_STATUS_IS_FILEBASED */
476#define APR_FILEBASED (APR_OS_START_STATUS + 20)
477/** @see APR_STATUS_IS_KEYBASED */
478#define APR_KEYBASED (APR_OS_START_STATUS + 21)
479/** @see APR_STATUS_IS_EINIT */
480#define APR_EINIT (APR_OS_START_STATUS + 22)
481/** @see APR_STATUS_IS_ENOTIMPL */
482#define APR_ENOTIMPL (APR_OS_START_STATUS + 23)
483/** @see APR_STATUS_IS_EMISMATCH */
484#define APR_EMISMATCH (APR_OS_START_STATUS + 24)
485/** @see APR_STATUS_IS_EBUSY */
486#define APR_EBUSY (APR_OS_START_STATUS + 25)
487/** @} */
488
489/**
490 * @addtogroup APR_STATUS_IS
491 * @{
492 */
493/**
494 * Program is currently executing in the child
495 * @warning
496 * always use this test, as platform-specific variances may meet this
497 * more than one error code */
498#define APR_STATUS_IS_INCHILD(s) ((s) == APR_INCHILD)
499/**
500 * Program is currently executing in the parent
501 * @warning
502 * always use this test, as platform-specific variances may meet this
503 * more than one error code
504 */
505#define APR_STATUS_IS_INPARENT(s) ((s) == APR_INPARENT)
506/**
507 * The thread is detached
508 * @warning
509 * always use this test, as platform-specific variances may meet this
510 * more than one error code
511 */
512#define APR_STATUS_IS_DETACH(s) ((s) == APR_DETACH)
513/**
514 * The thread is not detached
515 * @warning
516 * always use this test, as platform-specific variances may meet this
517 * more than one error code
518 */
519#define APR_STATUS_IS_NOTDETACH(s) ((s) == APR_NOTDETACH)
520/**
521 * The child has finished executing
522 * @warning
523 * always use this test, as platform-specific variances may meet this
524 * more than one error code
525 */
526#define APR_STATUS_IS_CHILD_DONE(s) ((s) == APR_CHILD_DONE)
527/**
528 * The child has not finished executing
529 * @warning
530 * always use this test, as platform-specific variances may meet this
531 * more than one error code
532 */
533#define APR_STATUS_IS_CHILD_NOTDONE(s) ((s) == APR_CHILD_NOTDONE)
534/**
535 * The operation did not finish before the timeout
536 * @warning
537 * always use this test, as platform-specific variances may meet this
538 * more than one error code
539 */
540#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP)
541/**
542 * The operation was incomplete although some processing was performed
543 * and the results are partially valid.
544 * @warning
545 * always use this test, as platform-specific variances may meet this
546 * more than one error code
547 */
548#define APR_STATUS_IS_INCOMPLETE(s) ((s) == APR_INCOMPLETE)
549/* empty slot: +9 */
550/* empty slot: +10 */
551/* empty slot: +11 */
552/**
553 * Getopt found an option not in the option string
554 * @warning
555 * always use this test, as platform-specific variances may meet this
556 * more than one error code
557 */
558#define APR_STATUS_IS_BADCH(s) ((s) == APR_BADCH)
559/**
560 * Getopt found an option not in the option string and an argument was
561 * specified in the option string
562 * @warning
563 * always use this test, as platform-specific variances may meet this
564 * more than one error code
565 */
566#define APR_STATUS_IS_BADARG(s) ((s) == APR_BADARG)
567/**
568 * APR has encountered the end of the file
569 * @warning
570 * always use this test, as platform-specific variances may meet this
571 * more than one error code
572 */
573#define APR_STATUS_IS_EOF(s) ((s) == APR_EOF)
574/**
575 * APR was unable to find the socket in the poll structure
576 * @warning
577 * always use this test, as platform-specific variances may meet this
578 * more than one error code
579 */
580#define APR_STATUS_IS_NOTFOUND(s) ((s) == APR_NOTFOUND)
581/* empty slot: +16 */
582/* empty slot: +17 */
583/* empty slot: +18 */
584/**
585 * APR is using anonymous shared memory
586 * @warning
587 * always use this test, as platform-specific variances may meet this
588 * more than one error code
589 */
590#define APR_STATUS_IS_ANONYMOUS(s) ((s) == APR_ANONYMOUS)
591/**
592 * APR is using a file name as the key to the shared memory
593 * @warning
594 * always use this test, as platform-specific variances may meet this
595 * more than one error code
596 */
597#define APR_STATUS_IS_FILEBASED(s) ((s) == APR_FILEBASED)
598/**
599 * APR is using a shared key as the key to the shared memory
600 * @warning
601 * always use this test, as platform-specific variances may meet this
602 * more than one error code
603 */
604#define APR_STATUS_IS_KEYBASED(s) ((s) == APR_KEYBASED)
605/**
606 * Ininitalizer value. If no option has been found, but
607 * the status variable requires a value, this should be used
608 * @warning
609 * always use this test, as platform-specific variances may meet this
610 * more than one error code
611 */
612#define APR_STATUS_IS_EINIT(s) ((s) == APR_EINIT)
613/**
614 * The APR function has not been implemented on this
615 * platform, either because nobody has gotten to it yet,
616 * or the function is impossible on this platform.
617 * @warning
618 * always use this test, as platform-specific variances may meet this
619 * more than one error code
620 */
621#define APR_STATUS_IS_ENOTIMPL(s) ((s) == APR_ENOTIMPL)
622/**
623 * Two passwords do not match.
624 * @warning
625 * always use this test, as platform-specific variances may meet this
626 * more than one error code
627 */
628#define APR_STATUS_IS_EMISMATCH(s) ((s) == APR_EMISMATCH)
629/**
630 * The given lock was busy
631 * @warning always use this test, as platform-specific variances may meet this
632 * more than one error code
633 */
634#define APR_STATUS_IS_EBUSY(s) ((s) == APR_EBUSY)
635
636/** @} */
637
638/**
639 * @addtogroup APR_Error APR Error Values
640 * @{
641 */
642/* APR CANONICAL ERROR VALUES */
643/** @see APR_STATUS_IS_EACCES */
644#ifdef EACCES
645#define APR_EACCES EACCES
646#else
647#define APR_EACCES (APR_OS_START_CANONERR + 1)
648#endif
649
650/** @see APR_STATUS_IS_EEXIST */
651#ifdef EEXIST
652#define APR_EEXIST EEXIST
653#else
654#define APR_EEXIST (APR_OS_START_CANONERR + 2)
655#endif
656
657/** @see APR_STATUS_IS_ENAMETOOLONG */
658#ifdef ENAMETOOLONG
659#define APR_ENAMETOOLONG ENAMETOOLONG
660#else
661#define APR_ENAMETOOLONG (APR_OS_START_CANONERR + 3)
662#endif
663
664/** @see APR_STATUS_IS_ENOENT */
665#ifdef ENOENT
666#define APR_ENOENT ENOENT
667#else
668#define APR_ENOENT (APR_OS_START_CANONERR + 4)
669#endif
670
671/** @see APR_STATUS_IS_ENOTDIR */
672#ifdef ENOTDIR
673#define APR_ENOTDIR ENOTDIR
674#else
675#define APR_ENOTDIR (APR_OS_START_CANONERR + 5)
676#endif
677
678/** @see APR_STATUS_IS_ENOSPC */
679#ifdef ENOSPC
680#define APR_ENOSPC ENOSPC
681#else
682#define APR_ENOSPC (APR_OS_START_CANONERR + 6)
683#endif
684
685/** @see APR_STATUS_IS_ENOMEM */
686#ifdef ENOMEM
687#define APR_ENOMEM ENOMEM
688#else
689#define APR_ENOMEM (APR_OS_START_CANONERR + 7)
690#endif
691
692/** @see APR_STATUS_IS_EMFILE */
693#ifdef EMFILE
694#define APR_EMFILE EMFILE
695#else
696#define APR_EMFILE (APR_OS_START_CANONERR + 8)
697#endif
698
699/** @see APR_STATUS_IS_ENFILE */
700#ifdef ENFILE
701#define APR_ENFILE ENFILE
702#else
703#define APR_ENFILE (APR_OS_START_CANONERR + 9)
704#endif
705
706/** @see APR_STATUS_IS_EBADF */
707#ifdef EBADF
708#define APR_EBADF EBADF
709#else
710#define APR_EBADF (APR_OS_START_CANONERR + 10)
711#endif
712
713/** @see APR_STATUS_IS_EINVAL */
714#ifdef EINVAL
715#define APR_EINVAL EINVAL
716#else
717#define APR_EINVAL (APR_OS_START_CANONERR + 11)
718#endif
719
720/** @see APR_STATUS_IS_ESPIPE */
721#ifdef ESPIPE
722#define APR_ESPIPE ESPIPE
723#else
724#define APR_ESPIPE (APR_OS_START_CANONERR + 12)
725#endif
726
727/**
728 * @see APR_STATUS_IS_EAGAIN
729 * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
730 */
731#ifdef EAGAIN
732#define APR_EAGAIN EAGAIN
733#elif defined(EWOULDBLOCK)
734#define APR_EAGAIN EWOULDBLOCK
735#else
736#define APR_EAGAIN (APR_OS_START_CANONERR + 13)
737#endif
738
739/** @see APR_STATUS_IS_EINTR */
740#ifdef EINTR
741#define APR_EINTR EINTR
742#else
743#define APR_EINTR (APR_OS_START_CANONERR + 14)
744#endif
745
746/** @see APR_STATUS_IS_ENOTSOCK */
747#ifdef ENOTSOCK
748#define APR_ENOTSOCK ENOTSOCK
749#else
750#define APR_ENOTSOCK (APR_OS_START_CANONERR + 15)
751#endif
752
753/** @see APR_STATUS_IS_ECONNREFUSED */
754#ifdef ECONNREFUSED
755#define APR_ECONNREFUSED ECONNREFUSED
756#else
757#define APR_ECONNREFUSED (APR_OS_START_CANONERR + 16)
758#endif
759
760/** @see APR_STATUS_IS_EINPROGRESS */
761#ifdef EINPROGRESS
762#define APR_EINPROGRESS EINPROGRESS
763#else
764#define APR_EINPROGRESS (APR_OS_START_CANONERR + 17)
765#endif
766
767/**
768 * @see APR_STATUS_IS_ECONNABORTED
769 * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
770 */
771
772#ifdef ECONNABORTED
773#define APR_ECONNABORTED ECONNABORTED
774#else
775#define APR_ECONNABORTED (APR_OS_START_CANONERR + 18)
776#endif
777
778/** @see APR_STATUS_IS_ECONNRESET */
779#ifdef ECONNRESET
780#define APR_ECONNRESET ECONNRESET
781#else
782#define APR_ECONNRESET (APR_OS_START_CANONERR + 19)
783#endif
784
785/** @see APR_STATUS_IS_ETIMEDOUT
786 * @deprecated */
787#ifdef ETIMEDOUT
788#define APR_ETIMEDOUT ETIMEDOUT
789#else
790#define APR_ETIMEDOUT (APR_OS_START_CANONERR + 20)
791#endif
792
793/** @see APR_STATUS_IS_EHOSTUNREACH */
794#ifdef EHOSTUNREACH
795#define APR_EHOSTUNREACH EHOSTUNREACH
796#else
797#define APR_EHOSTUNREACH (APR_OS_START_CANONERR + 21)
798#endif
799
800/** @see APR_STATUS_IS_ENETUNREACH */
801#ifdef ENETUNREACH
802#define APR_ENETUNREACH ENETUNREACH
803#else
804#define APR_ENETUNREACH (APR_OS_START_CANONERR + 22)
805#endif
806
807/** @see APR_STATUS_IS_EFTYPE */
808#ifdef EFTYPE
809#define APR_EFTYPE EFTYPE
810#else
811#define APR_EFTYPE (APR_OS_START_CANONERR + 23)
812#endif
813
814/** @see APR_STATUS_IS_EPIPE */
815#ifdef EPIPE
816#define APR_EPIPE EPIPE
817#else
818#define APR_EPIPE (APR_OS_START_CANONERR + 24)
819#endif
820
821/** @see APR_STATUS_IS_EXDEV */
822#ifdef EXDEV
823#define APR_EXDEV EXDEV
824#else
825#define APR_EXDEV (APR_OS_START_CANONERR + 25)
826#endif
827
828/** @see APR_STATUS_IS_ENOTEMPTY */
829#ifdef ENOTEMPTY
830#define APR_ENOTEMPTY ENOTEMPTY
831#else
832#define APR_ENOTEMPTY (APR_OS_START_CANONERR + 26)
833#endif
834
835/** @see APR_STATUS_IS_EAFNOSUPPORT */
836#ifdef EAFNOSUPPORT
837#define APR_EAFNOSUPPORT EAFNOSUPPORT
838#else
839#define APR_EAFNOSUPPORT (APR_OS_START_CANONERR + 27)
840#endif
841
842/** @see APR_STATUS_IS_EOPNOTSUPP */
843#ifdef EOPNOTSUPP
844#define APR_EOPNOTSUPP EOPNOTSUPP
845#else
846#define APR_EOPNOTSUPP (APR_OS_START_CANONERR + 28)
847#endif
848
849/** @see APR_STATUS_IS_ERANGE */
850#ifdef ERANGE
851#define APR_ERANGE ERANGE
852#else
853#define APR_ERANGE (APR_OS_START_CANONERR + 29)
854#endif
855
856/** @see APR_STATUS_IS_EALREADY */
857#ifdef EALREADY
858#define APR_EALREADY EALREADY
859#else
860#define APR_EALREADY (APR_OS_START_CANONERR + 30)
861#endif
862
863/** @} */
864
865#if defined(OS2) && !defined(DOXYGEN)
866
867#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
868#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
869
870#define INCL_DOSERRORS
871#define INCL_DOS
872
873/* Leave these undefined.
874 * OS2 doesn't rely on the errno concept.
875 * The API calls always return a result codes which
876 * should be filtered through APR_FROM_OS_ERROR().
877 *
878 * #define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError()))
879 * #define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))
880 */
881
882/* A special case, only socket calls require this;
883 */
884#define apr_get_netos_error() (APR_FROM_OS_ERROR(errno))
885#define apr_set_netos_error(e) (errno = APR_TO_OS_ERROR(e))
886
887/* These can't sit in a private header, so in spite of the extra size,
888 * they need to be made available here.
889 */
890#define SOCBASEERR 10000
891#define SOCEPERM (SOCBASEERR+1) /* Not owner */
892#define SOCESRCH (SOCBASEERR+3) /* No such process */
893#define SOCEINTR (SOCBASEERR+4) /* Interrupted system call */
894#define SOCENXIO (SOCBASEERR+6) /* No such device or address */
895#define SOCEBADF (SOCBASEERR+9) /* Bad file number */
896#define SOCEACCES (SOCBASEERR+13) /* Permission denied */
897#define SOCEFAULT (SOCBASEERR+14) /* Bad address */
898#define SOCEINVAL (SOCBASEERR+22) /* Invalid argument */
899#define SOCEMFILE (SOCBASEERR+24) /* Too many open files */
900#define SOCEPIPE (SOCBASEERR+32) /* Broken pipe */
901#define SOCEOS2ERR (SOCBASEERR+100) /* OS/2 Error */
902#define SOCEWOULDBLOCK (SOCBASEERR+35) /* Operation would block */
903#define SOCEINPROGRESS (SOCBASEERR+36) /* Operation now in progress */
904#define SOCEALREADY (SOCBASEERR+37) /* Operation already in progress */
905#define SOCENOTSOCK (SOCBASEERR+38) /* Socket operation on non-socket */
906#define SOCEDESTADDRREQ (SOCBASEERR+39) /* Destination address required */
907#define SOCEMSGSIZE (SOCBASEERR+40) /* Message too long */
908#define SOCEPROTOTYPE (SOCBASEERR+41) /* Protocol wrong type for socket */
909#define SOCENOPROTOOPT (SOCBASEERR+42) /* Protocol not available */
910#define SOCEPROTONOSUPPORT (SOCBASEERR+43) /* Protocol not supported */
911#define SOCESOCKTNOSUPPORT (SOCBASEERR+44) /* Socket type not supported */
912#define SOCEOPNOTSUPP (SOCBASEERR+45) /* Operation not supported on socket */
913#define SOCEPFNOSUPPORT (SOCBASEERR+46) /* Protocol family not supported */
914#define SOCEAFNOSUPPORT (SOCBASEERR+47) /* Address family not supported by protocol family */
915#define SOCEADDRINUSE (SOCBASEERR+48) /* Address already in use */
916#define SOCEADDRNOTAVAIL (SOCBASEERR+49) /* Can't assign requested address */
917#define SOCENETDOWN (SOCBASEERR+50) /* Network is down */
918#define SOCENETUNREACH (SOCBASEERR+51) /* Network is unreachable */
919#define SOCENETRESET (SOCBASEERR+52) /* Network dropped connection on reset */
920#define SOCECONNABORTED (SOCBASEERR+53) /* Software caused connection abort */
921#define SOCECONNRESET (SOCBASEERR+54) /* Connection reset by peer */
922#define SOCENOBUFS (SOCBASEERR+55) /* No buffer space available */
923#define SOCEISCONN (SOCBASEERR+56) /* Socket is already connected */
924#define SOCENOTCONN (SOCBASEERR+57) /* Socket is not connected */
925#define SOCESHUTDOWN (SOCBASEERR+58) /* Can't send after socket shutdown */
926#define SOCETOOMANYREFS (SOCBASEERR+59) /* Too many references: can't splice */
927#define SOCETIMEDOUT (SOCBASEERR+60) /* Connection timed out */
928#define SOCECONNREFUSED (SOCBASEERR+61) /* Connection refused */
929#define SOCELOOP (SOCBASEERR+62) /* Too many levels of symbolic links */
930#define SOCENAMETOOLONG (SOCBASEERR+63) /* File name too long */
931#define SOCEHOSTDOWN (SOCBASEERR+64) /* Host is down */
932#define SOCEHOSTUNREACH (SOCBASEERR+65) /* No route to host */
933#define SOCENOTEMPTY (SOCBASEERR+66) /* Directory not empty */
934
935/* APR CANONICAL ERROR TESTS */
936#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \
937 || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
938 || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
939#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \
940 || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
941 || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
942 || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
943 || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
944#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \
945 || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
946 || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
947#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
948 || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
949 || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
950 || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
951 || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
952#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
953#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
954 || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
955#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
956#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \
957 || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
958#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
959#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \
960 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
961#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \
962 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
963 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
964#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \
965 || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
966#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
967 || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
968 || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
969 || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
970#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
971 || (s) == APR_OS_START_SYSERR + SOCEINTR)
972#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
973 || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
974#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
975 || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
976#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
977 || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
978#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
979 || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
980#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
981 || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
982/* XXX deprecated */
983#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
984 || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
985#undef APR_STATUS_IS_TIMEUP
986#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
987 || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
988#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
989 || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
990#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
991 || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
992#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
993#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \
994 || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
995 || (s) == APR_OS_START_SYSERR + SOCEPIPE)
996#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \
997 || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
998#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \
999 || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
1000 || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
1001#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_AFNOSUPPORT \
1002 || (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
1003#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP \
1004 || (s) == APR_OS_START_SYSERR + SOCEOPNOTSUPP)
1005#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
1006#define APR_STATUS_IS_EALREADY(s) ((s) == APR_EALREADY \
1007 || (s) == APR_OS_START_SYSERR + SOCEALREADY)
1008
1009/*
1010 Sorry, too tired to wrap this up for OS2... feel free to
1011 fit the following into their best matches.
1012
1013 { ERROR_NO_SIGNAL_SENT, ESRCH },
1014 { SOCEDESTADDRREQ, EDESTADDRREQ },
1015 { SOCEMSGSIZE, EMSGSIZE },
1016 { SOCEPROTOTYPE, EPROTOTYPE },
1017 { SOCENOPROTOOPT, ENOPROTOOPT },
1018 { SOCEPROTONOSUPPORT, EPROTONOSUPPORT },
1019 { SOCESOCKTNOSUPPORT, ESOCKTNOSUPPORT },
1020 { SOCEPFNOSUPPORT, EPFNOSUPPORT },
1021 { SOCEADDRINUSE, EADDRINUSE },
1022 { SOCEADDRNOTAVAIL, EADDRNOTAVAIL },
1023 { SOCENETDOWN, ENETDOWN },
1024 { SOCENETRESET, ENETRESET },
1025 { SOCENOBUFS, ENOBUFS },
1026 { SOCEISCONN, EISCONN },
1027 { SOCENOTCONN, ENOTCONN },
1028 { SOCESHUTDOWN, ESHUTDOWN },
1029 { SOCETOOMANYREFS, ETOOMANYREFS },
1030 { SOCELOOP, ELOOP },
1031 { SOCEHOSTDOWN, EHOSTDOWN },
1032 { SOCENOTEMPTY, ENOTEMPTY },
1033 { SOCEPIPE, EPIPE }
1034*/
1035
1036#elif defined(WIN32) && !defined(DOXYGEN) /* !defined(OS2) */
1037
1038#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
1039#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
1040
1041#define apr_get_os_error() (APR_FROM_OS_ERROR(GetLastError()))
1042#define apr_set_os_error(e) (SetLastError(APR_TO_OS_ERROR(e)))
1043
1044/* A special case, only socket calls require this:
1045 */
1046#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError()))
1047#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e)))
1048
1049/* APR CANONICAL ERROR TESTS */
1050#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES \
1051 || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
1052 || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
1053 || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
1054 || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
1055 || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
1056 || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
1057 || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
1058 || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
1059 || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
1060 || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
1061#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST \
1062 || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
1063 || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
1064#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG \
1065 || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
1066 || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
1067#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
1068 || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
1069 || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
1070 || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
1071 || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
1072#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR \
1073 || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
1074 || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
1075 || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
1076 || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
1077 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE \
1078 || (s) == APR_OS_START_SYSERR + ERROR_DIRECTORY)
1079#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
1080 || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
1081#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM \
1082 || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
1083 || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
1084 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
1085 || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
1086 || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
1087#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE \
1088 || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
1089#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
1090#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF \
1091 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
1092 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
1093#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL \
1094 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
1095 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
1096 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
1097 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
1098 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
1099 || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
1100#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE \
1101 || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
1102 || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
1103#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
1104 || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
1105 || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
1106 || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
1107 || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
1108 || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
1109 || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
1110#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
1111 || (s) == APR_OS_START_SYSERR + WSAEINTR)
1112#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
1113 || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
1114#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
1115 || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
1116#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
1117 || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
1118#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
1119 || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
1120#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
1121 || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
1122 || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
1123/* XXX deprecated */
1124#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
1125 || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1126 || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1127#undef APR_STATUS_IS_TIMEUP
1128#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
1129 || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1130 || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1131#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
1132 || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
1133#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
1134 || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
1135#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE \
1136 || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
1137 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
1138 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
1139 || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
1140 || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
1141 || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
1142 || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
1143#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE \
1144 || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
1145#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV \
1146 || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
1147#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY \
1148 || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
1149#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
1150 || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
1151#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP \
1152 || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
1153#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
1154#define APR_STATUS_IS_EALREADY(s) ((s) == APR_EALREADY \
1155 || (s) == APR_OS_START_SYSERR + WSAEALREADY)
1156
1157#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
1158
1159#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
1160#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
1161
1162#define apr_get_os_error() (errno)
1163#define apr_set_os_error(e) (errno = (e))
1164
1165/* A special case, only socket calls require this: */
1166#define apr_get_netos_error() (APR_FROM_OS_ERROR(WSAGetLastError()))
1167#define apr_set_netos_error(e) (WSASetLastError(APR_TO_OS_ERROR(e)))
1168
1169/* APR CANONICAL ERROR TESTS */
1170#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES)
1171#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST)
1172#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG)
1173#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT)
1174#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
1175#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC)
1176#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
1177#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE)
1178#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
1179#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF)
1180#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL)
1181#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE)
1182
1183#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
1184 || (s) == EWOULDBLOCK \
1185 || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
1186#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR \
1187 || (s) == APR_OS_START_SYSERR + WSAEINTR)
1188#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK \
1189 || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
1190#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED \
1191 || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
1192#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS \
1193 || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
1194#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
1195 || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
1196#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET \
1197 || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
1198/* XXX deprecated */
1199#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT \
1200 || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1201 || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1202#undef APR_STATUS_IS_TIMEUP
1203#define APR_STATUS_IS_TIMEUP(s) ((s) == APR_TIMEUP \
1204 || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1205 || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1206#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH \
1207 || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
1208#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH \
1209 || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
1210#define APR_STATUS_IS_ENETDOWN(s) ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
1211#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
1212#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
1213#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV)
1214#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY)
1215#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
1216 || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
1217#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP \
1218 || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
1219#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
1220#define APR_STATUS_IS_EALREADY(s) ((s) == APR_EALREADY \
1221 || (s) == APR_OS_START_SYSERR + WSAEALREADY)
1222
1223#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
1224
1225/*
1226 * os error codes are clib error codes
1227 */
1228#define APR_FROM_OS_ERROR(e) (e)
1229#define APR_TO_OS_ERROR(e) (e)
1230
1231#define apr_get_os_error() (errno)
1232#define apr_set_os_error(e) (errno = (e))
1233
1234/* A special case, only socket calls require this:
1235 */
1236#define apr_get_netos_error() (errno)
1237#define apr_set_netos_error(e) (errno = (e))
1238
1239/**
1240 * @addtogroup APR_STATUS_IS
1241 * @{
1242 */
1243
1244/** permission denied */
1245#define APR_STATUS_IS_EACCES(s) ((s) == APR_EACCES)
1246/** file exists */
1247#define APR_STATUS_IS_EEXIST(s) ((s) == APR_EEXIST)
1248/** path name is too long */
1249#define APR_STATUS_IS_ENAMETOOLONG(s) ((s) == APR_ENAMETOOLONG)
1250/**
1251 * no such file or directory
1252 * @remark
1253 * EMVSCATLG can be returned by the automounter on z/OS for
1254 * paths which do not exist.
1255 */
1256#ifdef EMVSCATLG
1257#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT \
1258 || (s) == EMVSCATLG)
1259#else
1260#define APR_STATUS_IS_ENOENT(s) ((s) == APR_ENOENT)
1261#endif
1262/** not a directory */
1263#define APR_STATUS_IS_ENOTDIR(s) ((s) == APR_ENOTDIR)
1264/** no space left on device */
1265#ifdef EDQUOT
1266#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC \
1267 || (s) == EDQUOT)
1268#else
1269#define APR_STATUS_IS_ENOSPC(s) ((s) == APR_ENOSPC)
1270#endif
1271/** not enough memory */
1272#define APR_STATUS_IS_ENOMEM(s) ((s) == APR_ENOMEM)
1273/** too many open files */
1274#define APR_STATUS_IS_EMFILE(s) ((s) == APR_EMFILE)
1275/** file table overflow */
1276#define APR_STATUS_IS_ENFILE(s) ((s) == APR_ENFILE)
1277/** bad file # */
1278#define APR_STATUS_IS_EBADF(s) ((s) == APR_EBADF)
1279/** invalid argument */
1280#define APR_STATUS_IS_EINVAL(s) ((s) == APR_EINVAL)
1281/** illegal seek */
1282#define APR_STATUS_IS_ESPIPE(s) ((s) == APR_ESPIPE)
1283
1284/** operation would block */
1285#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
1286#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN)
1287#elif (EWOULDBLOCK == EAGAIN)
1288#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN)
1289#else
1290#define APR_STATUS_IS_EAGAIN(s) ((s) == APR_EAGAIN \
1291 || (s) == EWOULDBLOCK)
1292#endif
1293
1294/** interrupted system call */
1295#define APR_STATUS_IS_EINTR(s) ((s) == APR_EINTR)
1296/** socket operation on a non-socket */
1297#define APR_STATUS_IS_ENOTSOCK(s) ((s) == APR_ENOTSOCK)
1298/** Connection Refused */
1299#define APR_STATUS_IS_ECONNREFUSED(s) ((s) == APR_ECONNREFUSED)
1300/** operation now in progress */
1301#define APR_STATUS_IS_EINPROGRESS(s) ((s) == APR_EINPROGRESS)
1302
1303/**
1304 * Software caused connection abort
1305 * @remark
1306 * EPROTO on certain older kernels really means ECONNABORTED, so we need to
1307 * ignore it for them. See discussion in new-httpd archives nh.9701 & nh.9603
1308 *
1309 * There is potentially a bug in Solaris 2.x x<6, and other boxes that
1310 * implement tcp sockets in userland (i.e. on top of STREAMS). On these
1311 * systems, EPROTO can actually result in a fatal loop. See PR#981 for
1312 * example. It's hard to handle both uses of EPROTO.
1313 */
1314#ifdef EPROTO
1315#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED \
1316 || (s) == EPROTO)
1317#else
1318#define APR_STATUS_IS_ECONNABORTED(s) ((s) == APR_ECONNABORTED)
1319#endif
1320
1321/** Connection Reset by peer */
1322#define APR_STATUS_IS_ECONNRESET(s) ((s) == APR_ECONNRESET)
1323/** Operation timed out
1324 * @deprecated */
1325#define APR_STATUS_IS_ETIMEDOUT(s) ((s) == APR_ETIMEDOUT)
1326/** no route to host */
1327#define APR_STATUS_IS_EHOSTUNREACH(s) ((s) == APR_EHOSTUNREACH)
1328/** network is unreachable */
1329#define APR_STATUS_IS_ENETUNREACH(s) ((s) == APR_ENETUNREACH)
1330/** inappropriate file type or format */
1331#define APR_STATUS_IS_EFTYPE(s) ((s) == APR_EFTYPE)
1332/** broken pipe */
1333#define APR_STATUS_IS_EPIPE(s) ((s) == APR_EPIPE)
1334/** cross device link */
1335#define APR_STATUS_IS_EXDEV(s) ((s) == APR_EXDEV)
1336/** Directory Not Empty */
1337#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY || \
1338 (s) == APR_EEXIST)
1339/** Address Family not supported */
1340#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT)
1341/** Socket operation not supported */
1342#define APR_STATUS_IS_EOPNOTSUPP(s) ((s) == APR_EOPNOTSUPP)
1343
1344/** Numeric value not representable */
1345#define APR_STATUS_IS_ERANGE(s) ((s) == APR_ERANGE)
1346
1347/** Operation already in progress */
1348#define APR_STATUS_IS_EALREADY(s) ((s) == APR_EALREADY)
1349/** @} */
1350
1351#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
1352
1353/** @} */
1354
1355#ifdef __cplusplus
1356}
1357#endif
1358
1359#endif /* ! APR_ERRNO_H */
APR Platform Definitions.
char * apr_strerror(apr_status_t statcode, char *buf, apr_size_t bufsize)
int apr_status_t
Definition apr_errno.h:44
#define APR_DECLARE(type)
Definition apr.h:523