apr_errno.h revision 266735
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#else
403#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN)
404#endif
405/** The given path was absolute. */
406#define APR_STATUS_IS_EABSOLUTE(s)      ((s) == APR_EABSOLUTE)
407/** The given path was relative. */
408#define APR_STATUS_IS_ERELATIVE(s)      ((s) == APR_ERELATIVE)
409/** The given path was neither relative nor absolute. */
410#define APR_STATUS_IS_EINCOMPLETE(s)    ((s) == APR_EINCOMPLETE)
411/** The given path was above the root path. */
412#define APR_STATUS_IS_EABOVEROOT(s)     ((s) == APR_EABOVEROOT)
413/** The given path was bad. */
414#define APR_STATUS_IS_EBADPATH(s)       ((s) == APR_EBADPATH)
415/** The given path contained wildcards. */
416#define APR_STATUS_IS_EPATHWILD(s)      ((s) == APR_EPATHWILD)
417/** Could not find the requested symbol.
418 * For more information call apr_dso_error().
419 */
420#if defined(WIN32)
421#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND \
422                       || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
423#else
424#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND)
425#endif
426/** The given process was not recognized by APR. */
427#define APR_STATUS_IS_EPROC_UNKNOWN(s)  ((s) == APR_EPROC_UNKNOWN)
428/** APR could not gather enough entropy to continue. */
429#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY)
430
431/** @} */
432
433/**
434 * @addtogroup APR_Error
435 * @{
436 */
437/** @see APR_STATUS_IS_INCHILD */
438#define APR_INCHILD        (APR_OS_START_STATUS + 1)
439/** @see APR_STATUS_IS_INPARENT */
440#define APR_INPARENT       (APR_OS_START_STATUS + 2)
441/** @see APR_STATUS_IS_DETACH */
442#define APR_DETACH         (APR_OS_START_STATUS + 3)
443/** @see APR_STATUS_IS_NOTDETACH */
444#define APR_NOTDETACH      (APR_OS_START_STATUS + 4)
445/** @see APR_STATUS_IS_CHILD_DONE */
446#define APR_CHILD_DONE     (APR_OS_START_STATUS + 5)
447/** @see APR_STATUS_IS_CHILD_NOTDONE */
448#define APR_CHILD_NOTDONE  (APR_OS_START_STATUS + 6)
449/** @see APR_STATUS_IS_TIMEUP */
450#define APR_TIMEUP         (APR_OS_START_STATUS + 7)
451/** @see APR_STATUS_IS_INCOMPLETE */
452#define APR_INCOMPLETE     (APR_OS_START_STATUS + 8)
453/* empty slot: +9 */
454/* empty slot: +10 */
455/* empty slot: +11 */
456/** @see APR_STATUS_IS_BADCH */
457#define APR_BADCH          (APR_OS_START_STATUS + 12)
458/** @see APR_STATUS_IS_BADARG */
459#define APR_BADARG         (APR_OS_START_STATUS + 13)
460/** @see APR_STATUS_IS_EOF */
461#define APR_EOF            (APR_OS_START_STATUS + 14)
462/** @see APR_STATUS_IS_NOTFOUND */
463#define APR_NOTFOUND       (APR_OS_START_STATUS + 15)
464/* empty slot: +16 */
465/* empty slot: +17 */
466/* empty slot: +18 */
467/** @see APR_STATUS_IS_ANONYMOUS */
468#define APR_ANONYMOUS      (APR_OS_START_STATUS + 19)
469/** @see APR_STATUS_IS_FILEBASED */
470#define APR_FILEBASED      (APR_OS_START_STATUS + 20)
471/** @see APR_STATUS_IS_KEYBASED */
472#define APR_KEYBASED       (APR_OS_START_STATUS + 21)
473/** @see APR_STATUS_IS_EINIT */
474#define APR_EINIT          (APR_OS_START_STATUS + 22)
475/** @see APR_STATUS_IS_ENOTIMPL */
476#define APR_ENOTIMPL       (APR_OS_START_STATUS + 23)
477/** @see APR_STATUS_IS_EMISMATCH */
478#define APR_EMISMATCH      (APR_OS_START_STATUS + 24)
479/** @see APR_STATUS_IS_EBUSY */
480#define APR_EBUSY          (APR_OS_START_STATUS + 25)
481/** @} */
482
483/**
484 * @addtogroup APR_STATUS_IS
485 * @{
486 */
487/**
488 * Program is currently executing in the child
489 * @warning
490 * always use this test, as platform-specific variances may meet this
491 * more than one error code */
492#define APR_STATUS_IS_INCHILD(s)        ((s) == APR_INCHILD)
493/**
494 * Program is currently executing in the parent
495 * @warning
496 * always use this test, as platform-specific variances may meet this
497 * more than one error code
498 */
499#define APR_STATUS_IS_INPARENT(s)       ((s) == APR_INPARENT)
500/**
501 * The thread is detached
502 * @warning
503 * always use this test, as platform-specific variances may meet this
504 * more than one error code
505 */
506#define APR_STATUS_IS_DETACH(s)         ((s) == APR_DETACH)
507/**
508 * The thread is not detached
509 * @warning
510 * always use this test, as platform-specific variances may meet this
511 * more than one error code
512 */
513#define APR_STATUS_IS_NOTDETACH(s)      ((s) == APR_NOTDETACH)
514/**
515 * The child has finished executing
516 * @warning
517 * always use this test, as platform-specific variances may meet this
518 * more than one error code
519 */
520#define APR_STATUS_IS_CHILD_DONE(s)     ((s) == APR_CHILD_DONE)
521/**
522 * The child has not finished executing
523 * @warning
524 * always use this test, as platform-specific variances may meet this
525 * more than one error code
526 */
527#define APR_STATUS_IS_CHILD_NOTDONE(s)  ((s) == APR_CHILD_NOTDONE)
528/**
529 * The operation did not finish before the timeout
530 * @warning
531 * always use this test, as platform-specific variances may meet this
532 * more than one error code
533 */
534#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP)
535/**
536 * The operation was incomplete although some processing was performed
537 * and the results are partially valid.
538 * @warning
539 * always use this test, as platform-specific variances may meet this
540 * more than one error code
541 */
542#define APR_STATUS_IS_INCOMPLETE(s)     ((s) == APR_INCOMPLETE)
543/* empty slot: +9 */
544/* empty slot: +10 */
545/* empty slot: +11 */
546/**
547 * Getopt found an option not in the option string
548 * @warning
549 * always use this test, as platform-specific variances may meet this
550 * more than one error code
551 */
552#define APR_STATUS_IS_BADCH(s)          ((s) == APR_BADCH)
553/**
554 * Getopt found an option not in the option string and an argument was
555 * specified in the option string
556 * @warning
557 * always use this test, as platform-specific variances may meet this
558 * more than one error code
559 */
560#define APR_STATUS_IS_BADARG(s)         ((s) == APR_BADARG)
561/**
562 * APR has encountered the end of the file
563 * @warning
564 * always use this test, as platform-specific variances may meet this
565 * more than one error code
566 */
567#define APR_STATUS_IS_EOF(s)            ((s) == APR_EOF)
568/**
569 * APR was unable to find the socket in the poll structure
570 * @warning
571 * always use this test, as platform-specific variances may meet this
572 * more than one error code
573 */
574#define APR_STATUS_IS_NOTFOUND(s)       ((s) == APR_NOTFOUND)
575/* empty slot: +16 */
576/* empty slot: +17 */
577/* empty slot: +18 */
578/**
579 * APR is using anonymous shared memory
580 * @warning
581 * always use this test, as platform-specific variances may meet this
582 * more than one error code
583 */
584#define APR_STATUS_IS_ANONYMOUS(s)      ((s) == APR_ANONYMOUS)
585/**
586 * APR is using a file name as the key to the shared memory
587 * @warning
588 * always use this test, as platform-specific variances may meet this
589 * more than one error code
590 */
591#define APR_STATUS_IS_FILEBASED(s)      ((s) == APR_FILEBASED)
592/**
593 * APR is using a shared key as the key to the shared memory
594 * @warning
595 * always use this test, as platform-specific variances may meet this
596 * more than one error code
597 */
598#define APR_STATUS_IS_KEYBASED(s)       ((s) == APR_KEYBASED)
599/**
600 * Ininitalizer value.  If no option has been found, but
601 * the status variable requires a value, this should be used
602 * @warning
603 * always use this test, as platform-specific variances may meet this
604 * more than one error code
605 */
606#define APR_STATUS_IS_EINIT(s)          ((s) == APR_EINIT)
607/**
608 * The APR function has not been implemented on this
609 * platform, either because nobody has gotten to it yet,
610 * or the function is impossible on this platform.
611 * @warning
612 * always use this test, as platform-specific variances may meet this
613 * more than one error code
614 */
615#define APR_STATUS_IS_ENOTIMPL(s)       ((s) == APR_ENOTIMPL)
616/**
617 * Two passwords do not match.
618 * @warning
619 * always use this test, as platform-specific variances may meet this
620 * more than one error code
621 */
622#define APR_STATUS_IS_EMISMATCH(s)      ((s) == APR_EMISMATCH)
623/**
624 * The given lock was busy
625 * @warning always use this test, as platform-specific variances may meet this
626 * more than one error code
627 */
628#define APR_STATUS_IS_EBUSY(s)          ((s) == APR_EBUSY)
629
630/** @} */
631
632/**
633 * @addtogroup APR_Error APR Error Values
634 * @{
635 */
636/* APR CANONICAL ERROR VALUES */
637/** @see APR_STATUS_IS_EACCES */
638#ifdef EACCES
639#define APR_EACCES EACCES
640#else
641#define APR_EACCES         (APR_OS_START_CANONERR + 1)
642#endif
643
644/** @see APR_STATUS_IS_EEXIST */
645#ifdef EEXIST
646#define APR_EEXIST EEXIST
647#else
648#define APR_EEXIST         (APR_OS_START_CANONERR + 2)
649#endif
650
651/** @see APR_STATUS_IS_ENAMETOOLONG */
652#ifdef ENAMETOOLONG
653#define APR_ENAMETOOLONG ENAMETOOLONG
654#else
655#define APR_ENAMETOOLONG   (APR_OS_START_CANONERR + 3)
656#endif
657
658/** @see APR_STATUS_IS_ENOENT */
659#ifdef ENOENT
660#define APR_ENOENT ENOENT
661#else
662#define APR_ENOENT         (APR_OS_START_CANONERR + 4)
663#endif
664
665/** @see APR_STATUS_IS_ENOTDIR */
666#ifdef ENOTDIR
667#define APR_ENOTDIR ENOTDIR
668#else
669#define APR_ENOTDIR        (APR_OS_START_CANONERR + 5)
670#endif
671
672/** @see APR_STATUS_IS_ENOSPC */
673#ifdef ENOSPC
674#define APR_ENOSPC ENOSPC
675#else
676#define APR_ENOSPC         (APR_OS_START_CANONERR + 6)
677#endif
678
679/** @see APR_STATUS_IS_ENOMEM */
680#ifdef ENOMEM
681#define APR_ENOMEM ENOMEM
682#else
683#define APR_ENOMEM         (APR_OS_START_CANONERR + 7)
684#endif
685
686/** @see APR_STATUS_IS_EMFILE */
687#ifdef EMFILE
688#define APR_EMFILE EMFILE
689#else
690#define APR_EMFILE         (APR_OS_START_CANONERR + 8)
691#endif
692
693/** @see APR_STATUS_IS_ENFILE */
694#ifdef ENFILE
695#define APR_ENFILE ENFILE
696#else
697#define APR_ENFILE         (APR_OS_START_CANONERR + 9)
698#endif
699
700/** @see APR_STATUS_IS_EBADF */
701#ifdef EBADF
702#define APR_EBADF EBADF
703#else
704#define APR_EBADF          (APR_OS_START_CANONERR + 10)
705#endif
706
707/** @see APR_STATUS_IS_EINVAL */
708#ifdef EINVAL
709#define APR_EINVAL EINVAL
710#else
711#define APR_EINVAL         (APR_OS_START_CANONERR + 11)
712#endif
713
714/** @see APR_STATUS_IS_ESPIPE */
715#ifdef ESPIPE
716#define APR_ESPIPE ESPIPE
717#else
718#define APR_ESPIPE         (APR_OS_START_CANONERR + 12)
719#endif
720
721/**
722 * @see APR_STATUS_IS_EAGAIN
723 * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
724 */
725#ifdef EAGAIN
726#define APR_EAGAIN EAGAIN
727#elif defined(EWOULDBLOCK)
728#define APR_EAGAIN EWOULDBLOCK
729#else
730#define APR_EAGAIN         (APR_OS_START_CANONERR + 13)
731#endif
732
733/** @see APR_STATUS_IS_EINTR */
734#ifdef EINTR
735#define APR_EINTR EINTR
736#else
737#define APR_EINTR          (APR_OS_START_CANONERR + 14)
738#endif
739
740/** @see APR_STATUS_IS_ENOTSOCK */
741#ifdef ENOTSOCK
742#define APR_ENOTSOCK ENOTSOCK
743#else
744#define APR_ENOTSOCK       (APR_OS_START_CANONERR + 15)
745#endif
746
747/** @see APR_STATUS_IS_ECONNREFUSED */
748#ifdef ECONNREFUSED
749#define APR_ECONNREFUSED ECONNREFUSED
750#else
751#define APR_ECONNREFUSED   (APR_OS_START_CANONERR + 16)
752#endif
753
754/** @see APR_STATUS_IS_EINPROGRESS */
755#ifdef EINPROGRESS
756#define APR_EINPROGRESS EINPROGRESS
757#else
758#define APR_EINPROGRESS    (APR_OS_START_CANONERR + 17)
759#endif
760
761/**
762 * @see APR_STATUS_IS_ECONNABORTED
763 * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
764 */
765
766#ifdef ECONNABORTED
767#define APR_ECONNABORTED ECONNABORTED
768#else
769#define APR_ECONNABORTED   (APR_OS_START_CANONERR + 18)
770#endif
771
772/** @see APR_STATUS_IS_ECONNRESET */
773#ifdef ECONNRESET
774#define APR_ECONNRESET ECONNRESET
775#else
776#define APR_ECONNRESET     (APR_OS_START_CANONERR + 19)
777#endif
778
779/** @see APR_STATUS_IS_ETIMEDOUT
780 *  @deprecated */
781#ifdef ETIMEDOUT
782#define APR_ETIMEDOUT ETIMEDOUT
783#else
784#define APR_ETIMEDOUT      (APR_OS_START_CANONERR + 20)
785#endif
786
787/** @see APR_STATUS_IS_EHOSTUNREACH */
788#ifdef EHOSTUNREACH
789#define APR_EHOSTUNREACH EHOSTUNREACH
790#else
791#define APR_EHOSTUNREACH   (APR_OS_START_CANONERR + 21)
792#endif
793
794/** @see APR_STATUS_IS_ENETUNREACH */
795#ifdef ENETUNREACH
796#define APR_ENETUNREACH ENETUNREACH
797#else
798#define APR_ENETUNREACH    (APR_OS_START_CANONERR + 22)
799#endif
800
801/** @see APR_STATUS_IS_EFTYPE */
802#ifdef EFTYPE
803#define APR_EFTYPE EFTYPE
804#else
805#define APR_EFTYPE        (APR_OS_START_CANONERR + 23)
806#endif
807
808/** @see APR_STATUS_IS_EPIPE */
809#ifdef EPIPE
810#define APR_EPIPE EPIPE
811#else
812#define APR_EPIPE         (APR_OS_START_CANONERR + 24)
813#endif
814
815/** @see APR_STATUS_IS_EXDEV */
816#ifdef EXDEV
817#define APR_EXDEV EXDEV
818#else
819#define APR_EXDEV         (APR_OS_START_CANONERR + 25)
820#endif
821
822/** @see APR_STATUS_IS_ENOTEMPTY */
823#ifdef ENOTEMPTY
824#define APR_ENOTEMPTY ENOTEMPTY
825#else
826#define APR_ENOTEMPTY     (APR_OS_START_CANONERR + 26)
827#endif
828
829/** @see APR_STATUS_IS_EAFNOSUPPORT */
830#ifdef EAFNOSUPPORT
831#define APR_EAFNOSUPPORT EAFNOSUPPORT
832#else
833#define APR_EAFNOSUPPORT  (APR_OS_START_CANONERR + 27)
834#endif
835
836/** @} */
837
838#if defined(OS2) && !defined(DOXYGEN)
839
840#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
841#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
842
843#define INCL_DOSERRORS
844#define INCL_DOS
845
846/* Leave these undefined.
847 * OS2 doesn't rely on the errno concept.
848 * The API calls always return a result codes which
849 * should be filtered through APR_FROM_OS_ERROR().
850 *
851 * #define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
852 * #define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
853 */
854
855/* A special case, only socket calls require this;
856 */
857#define apr_get_netos_error()   (APR_FROM_OS_ERROR(errno))
858#define apr_set_netos_error(e)  (errno = APR_TO_OS_ERROR(e))
859
860/* And this needs to be greped away for good:
861 */
862#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
863
864/* These can't sit in a private header, so in spite of the extra size,
865 * they need to be made available here.
866 */
867#define SOCBASEERR              10000
868#define SOCEPERM                (SOCBASEERR+1)             /* Not owner */
869#define SOCESRCH                (SOCBASEERR+3)             /* No such process */
870#define SOCEINTR                (SOCBASEERR+4)             /* Interrupted system call */
871#define SOCENXIO                (SOCBASEERR+6)             /* No such device or address */
872#define SOCEBADF                (SOCBASEERR+9)             /* Bad file number */
873#define SOCEACCES               (SOCBASEERR+13)            /* Permission denied */
874#define SOCEFAULT               (SOCBASEERR+14)            /* Bad address */
875#define SOCEINVAL               (SOCBASEERR+22)            /* Invalid argument */
876#define SOCEMFILE               (SOCBASEERR+24)            /* Too many open files */
877#define SOCEPIPE                (SOCBASEERR+32)            /* Broken pipe */
878#define SOCEOS2ERR              (SOCBASEERR+100)           /* OS/2 Error */
879#define SOCEWOULDBLOCK          (SOCBASEERR+35)            /* Operation would block */
880#define SOCEINPROGRESS          (SOCBASEERR+36)            /* Operation now in progress */
881#define SOCEALREADY             (SOCBASEERR+37)            /* Operation already in progress */
882#define SOCENOTSOCK             (SOCBASEERR+38)            /* Socket operation on non-socket */
883#define SOCEDESTADDRREQ         (SOCBASEERR+39)            /* Destination address required */
884#define SOCEMSGSIZE             (SOCBASEERR+40)            /* Message too long */
885#define SOCEPROTOTYPE           (SOCBASEERR+41)            /* Protocol wrong type for socket */
886#define SOCENOPROTOOPT          (SOCBASEERR+42)            /* Protocol not available */
887#define SOCEPROTONOSUPPORT      (SOCBASEERR+43)            /* Protocol not supported */
888#define SOCESOCKTNOSUPPORT      (SOCBASEERR+44)            /* Socket type not supported */
889#define SOCEOPNOTSUPP           (SOCBASEERR+45)            /* Operation not supported on socket */
890#define SOCEPFNOSUPPORT         (SOCBASEERR+46)            /* Protocol family not supported */
891#define SOCEAFNOSUPPORT         (SOCBASEERR+47)            /* Address family not supported by protocol family */
892#define SOCEADDRINUSE           (SOCBASEERR+48)            /* Address already in use */
893#define SOCEADDRNOTAVAIL        (SOCBASEERR+49)            /* Can't assign requested address */
894#define SOCENETDOWN             (SOCBASEERR+50)            /* Network is down */
895#define SOCENETUNREACH          (SOCBASEERR+51)            /* Network is unreachable */
896#define SOCENETRESET            (SOCBASEERR+52)            /* Network dropped connection on reset */
897#define SOCECONNABORTED         (SOCBASEERR+53)            /* Software caused connection abort */
898#define SOCECONNRESET           (SOCBASEERR+54)            /* Connection reset by peer */
899#define SOCENOBUFS              (SOCBASEERR+55)            /* No buffer space available */
900#define SOCEISCONN              (SOCBASEERR+56)            /* Socket is already connected */
901#define SOCENOTCONN             (SOCBASEERR+57)            /* Socket is not connected */
902#define SOCESHUTDOWN            (SOCBASEERR+58)            /* Can't send after socket shutdown */
903#define SOCETOOMANYREFS         (SOCBASEERR+59)            /* Too many references: can't splice */
904#define SOCETIMEDOUT            (SOCBASEERR+60)            /* Connection timed out */
905#define SOCECONNREFUSED         (SOCBASEERR+61)            /* Connection refused */
906#define SOCELOOP                (SOCBASEERR+62)            /* Too many levels of symbolic links */
907#define SOCENAMETOOLONG         (SOCBASEERR+63)            /* File name too long */
908#define SOCEHOSTDOWN            (SOCBASEERR+64)            /* Host is down */
909#define SOCEHOSTUNREACH         (SOCBASEERR+65)            /* No route to host */
910#define SOCENOTEMPTY            (SOCBASEERR+66)            /* Directory not empty */
911
912/* APR CANONICAL ERROR TESTS */
913#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
914                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
915                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
916#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
917                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
918                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
919                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
920                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
921#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
922                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
923                || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
924#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
925                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
926                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
927                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
928                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
929#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
930#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
931                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
932#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
933#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
934                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
935#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
936#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
937                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
938#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
939                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
940                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
941#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
942                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
943#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
944                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
945                || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
946                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
947#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
948                || (s) == APR_OS_START_SYSERR + SOCEINTR)
949#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
950                || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
951#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
952                || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
953#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
954                || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
955#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
956                || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
957#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
958                || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
959/* XXX deprecated */
960#define APR_STATUS_IS_ETIMEDOUT(s)         ((s) == APR_ETIMEDOUT \
961                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
962#undef APR_STATUS_IS_TIMEUP
963#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
964                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
965#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
966                || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
967#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
968                || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
969#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
970#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
971                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
972                || (s) == APR_OS_START_SYSERR + SOCEPIPE)
973#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
974                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
975#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
976                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
977                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
978#define APR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == APR_AFNOSUPPORT \
979                || (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
980
981/*
982    Sorry, too tired to wrap this up for OS2... feel free to
983    fit the following into their best matches.
984
985    { ERROR_NO_SIGNAL_SENT,     ESRCH           },
986    { SOCEALREADY,              EALREADY        },
987    { SOCEDESTADDRREQ,          EDESTADDRREQ    },
988    { SOCEMSGSIZE,              EMSGSIZE        },
989    { SOCEPROTOTYPE,            EPROTOTYPE      },
990    { SOCENOPROTOOPT,           ENOPROTOOPT     },
991    { SOCEPROTONOSUPPORT,       EPROTONOSUPPORT },
992    { SOCESOCKTNOSUPPORT,       ESOCKTNOSUPPORT },
993    { SOCEOPNOTSUPP,            EOPNOTSUPP      },
994    { SOCEPFNOSUPPORT,          EPFNOSUPPORT    },
995    { SOCEADDRINUSE,            EADDRINUSE      },
996    { SOCEADDRNOTAVAIL,         EADDRNOTAVAIL   },
997    { SOCENETDOWN,              ENETDOWN        },
998    { SOCENETRESET,             ENETRESET       },
999    { SOCENOBUFS,               ENOBUFS         },
1000    { SOCEISCONN,               EISCONN         },
1001    { SOCENOTCONN,              ENOTCONN        },
1002    { SOCESHUTDOWN,             ESHUTDOWN       },
1003    { SOCETOOMANYREFS,          ETOOMANYREFS    },
1004    { SOCELOOP,                 ELOOP           },
1005    { SOCEHOSTDOWN,             EHOSTDOWN       },
1006    { SOCENOTEMPTY,             ENOTEMPTY       },
1007    { SOCEPIPE,                 EPIPE           }
1008*/
1009
1010#elif defined(WIN32) && !defined(DOXYGEN) /* !defined(OS2) */
1011
1012#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
1013#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
1014
1015#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
1016#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
1017
1018/* A special case, only socket calls require this:
1019 */
1020#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
1021#define apr_set_netos_error(e)   (WSASetLastError(APR_TO_OS_ERROR(e)))
1022
1023/* APR CANONICAL ERROR TESTS */
1024#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
1025                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
1026                || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
1027                || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
1028                || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
1029                || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
1030                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
1031                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
1032                || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
1033                || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
1034                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
1035#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
1036                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
1037                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
1038#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
1039                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
1040                || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
1041#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
1042                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
1043                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
1044                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
1045                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
1046#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR \
1047                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
1048                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
1049                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
1050                || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
1051                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE \
1052                || (s) == APR_OS_START_SYSERR + ERROR_DIRECTORY)
1053#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
1054                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
1055#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM \
1056                || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
1057                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
1058                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
1059                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
1060                || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
1061#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
1062                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
1063#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
1064#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
1065                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
1066                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
1067#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
1068                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
1069                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
1070                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
1071                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
1072                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
1073                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
1074#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
1075                || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
1076                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
1077#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
1078                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
1079                || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
1080                || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
1081                || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
1082                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
1083                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
1084#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
1085                || (s) == APR_OS_START_SYSERR + WSAEINTR)
1086#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
1087                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
1088#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
1089                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
1090#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
1091                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
1092#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
1093                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
1094#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
1095                || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
1096                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
1097/* XXX deprecated */
1098#define APR_STATUS_IS_ETIMEDOUT(s)         ((s) == APR_ETIMEDOUT \
1099                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1100                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1101#undef APR_STATUS_IS_TIMEUP
1102#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
1103                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1104                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1105#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
1106                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
1107#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
1108                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
1109#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE \
1110                || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
1111                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
1112                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
1113                || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
1114                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
1115                || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
1116                || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
1117#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
1118                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
1119#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
1120                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
1121#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
1122                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
1123#define APR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == APR_EAFNOSUPPORT \
1124                || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
1125
1126#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
1127
1128#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
1129#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
1130
1131#define apr_get_os_error()    (errno)
1132#define apr_set_os_error(e)   (errno = (e))
1133
1134/* A special case, only socket calls require this: */
1135#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
1136#define apr_set_netos_error(e)  (WSASetLastError(APR_TO_OS_ERROR(e)))
1137
1138/* APR CANONICAL ERROR TESTS */
1139#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
1140#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
1141#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
1142#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
1143#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
1144#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
1145#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
1146#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
1147#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
1148#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
1149#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
1150#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
1151
1152#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
1153                || (s) ==                       EWOULDBLOCK \
1154                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
1155#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
1156                || (s) == APR_OS_START_SYSERR + WSAEINTR)
1157#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
1158                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
1159#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
1160                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
1161#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
1162                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
1163#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
1164                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
1165#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
1166                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
1167/* XXX deprecated */
1168#define APR_STATUS_IS_ETIMEDOUT(s)       ((s) == APR_ETIMEDOUT \
1169                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1170                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1171#undef APR_STATUS_IS_TIMEUP
1172#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
1173                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1174                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1175#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
1176                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
1177#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
1178                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
1179#define APR_STATUS_IS_ENETDOWN(s)       ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
1180#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
1181#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE)
1182#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV)
1183#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY)
1184#define APR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == APR_EAFNOSUPPORT \
1185                || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
1186
1187#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
1188
1189/*
1190 *  os error codes are clib error codes
1191 */
1192#define APR_FROM_OS_ERROR(e)  (e)
1193#define APR_TO_OS_ERROR(e)    (e)
1194
1195#define apr_get_os_error()    (errno)
1196#define apr_set_os_error(e)   (errno = (e))
1197
1198/* A special case, only socket calls require this:
1199 */
1200#define apr_get_netos_error() (errno)
1201#define apr_set_netos_error(e) (errno = (e))
1202
1203/**
1204 * @addtogroup APR_STATUS_IS
1205 * @{
1206 */
1207
1208/** permission denied */
1209#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
1210/** file exists */
1211#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
1212/** path name is too long */
1213#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
1214/**
1215 * no such file or directory
1216 * @remark
1217 * EMVSCATLG can be returned by the automounter on z/OS for
1218 * paths which do not exist.
1219 */
1220#ifdef EMVSCATLG
1221#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
1222                                      || (s) == EMVSCATLG)
1223#else
1224#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
1225#endif
1226/** not a directory */
1227#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
1228/** no space left on device */
1229#ifdef EDQUOT
1230#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
1231                                      || (s) == EDQUOT)
1232#else
1233#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
1234#endif
1235/** not enough memory */
1236#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
1237/** too many open files */
1238#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
1239/** file table overflow */
1240#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
1241/** bad file # */
1242#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
1243/** invalid argument */
1244#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
1245/** illegal seek */
1246#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
1247
1248/** operation would block */
1249#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
1250#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
1251#elif (EWOULDBLOCK == EAGAIN)
1252#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
1253#else
1254#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
1255                                      || (s) == EWOULDBLOCK)
1256#endif
1257
1258/** interrupted system call */
1259#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR)
1260/** socket operation on a non-socket */
1261#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK)
1262/** Connection Refused */
1263#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED)
1264/** operation now in progress */
1265#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS)
1266
1267/**
1268 * Software caused connection abort
1269 * @remark
1270 * EPROTO on certain older kernels really means ECONNABORTED, so we need to
1271 * ignore it for them.  See discussion in new-httpd archives nh.9701 & nh.9603
1272 *
1273 * There is potentially a bug in Solaris 2.x x<6, and other boxes that
1274 * implement tcp sockets in userland (i.e. on top of STREAMS).  On these
1275 * systems, EPROTO can actually result in a fatal loop.  See PR#981 for
1276 * example.  It's hard to handle both uses of EPROTO.
1277 */
1278#ifdef EPROTO
1279#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED \
1280                                       || (s) == EPROTO)
1281#else
1282#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED)
1283#endif
1284
1285/** Connection Reset by peer */
1286#define APR_STATUS_IS_ECONNRESET(s)      ((s) == APR_ECONNRESET)
1287/** Operation timed out
1288 *  @deprecated */
1289#define APR_STATUS_IS_ETIMEDOUT(s)      ((s) == APR_ETIMEDOUT)
1290/** no route to host */
1291#define APR_STATUS_IS_EHOSTUNREACH(s)    ((s) == APR_EHOSTUNREACH)
1292/** network is unreachable */
1293#define APR_STATUS_IS_ENETUNREACH(s)     ((s) == APR_ENETUNREACH)
1294/** inappropiate file type or format */
1295#define APR_STATUS_IS_EFTYPE(s)          ((s) == APR_EFTYPE)
1296/** broken pipe */
1297#define APR_STATUS_IS_EPIPE(s)           ((s) == APR_EPIPE)
1298/** cross device link */
1299#define APR_STATUS_IS_EXDEV(s)           ((s) == APR_EXDEV)
1300/** Directory Not Empty */
1301#define APR_STATUS_IS_ENOTEMPTY(s)       ((s) == APR_ENOTEMPTY || \
1302                                          (s) == APR_EEXIST)
1303/** Address Family not supported */
1304#define APR_STATUS_IS_EAFNOSUPPORT(s)    ((s) == APR_EAFNOSUPPORT)
1305/** @} */
1306
1307#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
1308
1309/** @} */
1310
1311#ifdef __cplusplus
1312}
1313#endif
1314
1315#endif  /* ! APR_ERRNO_H */
1316