1251875Speter/* Licensed to the Apache Software Foundation (ASF) under one or more
2251875Speter * contributor license agreements.  See the NOTICE file distributed with
3251875Speter * this work for additional information regarding copyright ownership.
4251875Speter * The ASF licenses this file to You under the Apache License, Version 2.0
5251875Speter * (the "License"); you may not use this file except in compliance with
6251875Speter * the License.  You may obtain a copy of the License at
7251875Speter *
8251875Speter *     http://www.apache.org/licenses/LICENSE-2.0
9251875Speter *
10251875Speter * Unless required by applicable law or agreed to in writing, software
11251875Speter * distributed under the License is distributed on an "AS IS" BASIS,
12251875Speter * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13251875Speter * See the License for the specific language governing permissions and
14251875Speter * limitations under the License.
15251875Speter */
16251875Speter
17251875Speter#ifndef APR_ERRNO_H
18251875Speter#define APR_ERRNO_H
19251875Speter
20251875Speter/**
21251875Speter * @file apr_errno.h
22251875Speter * @brief APR Error Codes
23251875Speter */
24251875Speter
25251875Speter#include "apr.h"
26251875Speter
27251875Speter#if APR_HAVE_ERRNO_H
28251875Speter#include <errno.h>
29251875Speter#endif
30251875Speter
31251875Speter#ifdef __cplusplus
32251875Speterextern "C" {
33251875Speter#endif /* __cplusplus */
34251875Speter
35251875Speter/**
36251875Speter * @defgroup apr_errno Error Codes
37251875Speter * @ingroup APR
38251875Speter * @{
39251875Speter */
40251875Speter
41251875Speter/**
42251875Speter * Type for specifying an error or status code.
43251875Speter */
44251875Spetertypedef int apr_status_t;
45251875Speter
46251875Speter/**
47251875Speter * Return a human readable string describing the specified error.
48266735Speter * @param statcode The error code to get a string for.
49251875Speter * @param buf A buffer to hold the error string.
50251875Speter * @param bufsize Size of the buffer to hold the string.
51251875Speter */
52251875SpeterAPR_DECLARE(char *) apr_strerror(apr_status_t statcode, char *buf,
53251875Speter                                 apr_size_t bufsize);
54251875Speter
55251875Speter#if defined(DOXYGEN)
56251875Speter/**
57251875Speter * @def APR_FROM_OS_ERROR(os_err_type syserr)
58251875Speter * Fold a platform specific error into an apr_status_t code.
59251875Speter * @return apr_status_t
60251875Speter * @param e The platform os error code.
61251875Speter * @warning  macro implementation; the syserr argument may be evaluated
62251875Speter *      multiple times.
63251875Speter */
64251875Speter#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
65251875Speter
66251875Speter/**
67251875Speter * @def APR_TO_OS_ERROR(apr_status_t statcode)
68251875Speter * @return os_err_type
69251875Speter * Fold an apr_status_t code back to the native platform defined error.
70251875Speter * @param e The apr_status_t folded platform os error code.
71251875Speter * @warning  macro implementation; the statcode argument may be evaluated
72251875Speter *      multiple times.  If the statcode was not created by apr_get_os_error
73251875Speter *      or APR_FROM_OS_ERROR, the results are undefined.
74251875Speter */
75251875Speter#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
76251875Speter
77251875Speter/** @def apr_get_os_error()
78251875Speter * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
79251875Speter * @remark This retrieves errno, or calls a GetLastError() style function, and
80251875Speter *      folds it with APR_FROM_OS_ERROR.  Some platforms (such as OS2) have no
81251875Speter *      such mechanism, so this call may be unsupported.  Do NOT use this
82251875Speter *      call for socket errors from socket, send, recv etc!
83251875Speter */
84251875Speter
85251875Speter/** @def apr_set_os_error(e)
86251875Speter * Reset the last platform error, unfolded from an apr_status_t, on some platforms
87251875Speter * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR()
88251875Speter * @warning This is a macro implementation; the statcode argument may be evaluated
89251875Speter *      multiple times.  If the statcode was not created by apr_get_os_error
90251875Speter *      or APR_FROM_OS_ERROR, the results are undefined.  This macro sets
91251875Speter *      errno, or calls a SetLastError() style function, unfolding statcode
92251875Speter *      with APR_TO_OS_ERROR.  Some platforms (such as OS2) have no such
93251875Speter *      mechanism, so this call may be unsupported.
94251875Speter */
95251875Speter
96251875Speter/** @def apr_get_netos_error()
97251875Speter * Return the last socket error, folded into apr_status_t, on all platforms
98251875Speter * @remark This retrieves errno or calls a GetLastSocketError() style function,
99251875Speter *      and folds it with APR_FROM_OS_ERROR.
100251875Speter */
101251875Speter
102251875Speter/** @def apr_set_netos_error(e)
103251875Speter * Reset the last socket error, unfolded from an apr_status_t
104251875Speter * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR()
105251875Speter * @warning This is a macro implementation; the statcode argument may be evaluated
106251875Speter *      multiple times.  If the statcode was not created by apr_get_os_error
107251875Speter *      or APR_FROM_OS_ERROR, the results are undefined.  This macro sets
108251875Speter *      errno, or calls a WSASetLastError() style function, unfolding
109251875Speter *      socketcode with APR_TO_OS_ERROR.
110251875Speter */
111251875Speter
112251875Speter#endif /* defined(DOXYGEN) */
113251875Speter
114251875Speter/**
115251875Speter * APR_OS_START_ERROR is where the APR specific error values start.
116251875Speter */
117251875Speter#define APR_OS_START_ERROR     20000
118251875Speter/**
119251875Speter * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
120251875Speter *    into one of the error/status ranges below -- except for
121251875Speter *    APR_OS_START_USERERR, which see.
122251875Speter */
123251875Speter#define APR_OS_ERRSPACE_SIZE 50000
124251875Speter/**
125251875Speter * APR_UTIL_ERRSPACE_SIZE is the size of the space that is reserved for
126251875Speter * use within apr-util. This space is reserved above that used by APR
127251875Speter * internally.
128251875Speter * @note This number MUST be smaller than APR_OS_ERRSPACE_SIZE by a
129266735Speter *       large enough amount that APR has sufficient room for its
130251875Speter *       codes.
131251875Speter */
132251875Speter#define APR_UTIL_ERRSPACE_SIZE 20000
133251875Speter/**
134251875Speter * APR_OS_START_STATUS is where the APR specific status codes start.
135251875Speter */
136251875Speter#define APR_OS_START_STATUS    (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE)
137251875Speter/**
138266735Speter * APR_UTIL_START_STATUS is where APR-Util starts defining its
139251875Speter * status codes.
140251875Speter */
141251875Speter#define APR_UTIL_START_STATUS   (APR_OS_START_STATUS + \
142251875Speter                           (APR_OS_ERRSPACE_SIZE - APR_UTIL_ERRSPACE_SIZE))
143251875Speter/**
144251875Speter * APR_OS_START_USERERR are reserved for applications that use APR that
145251875Speter *     layer their own error codes along with APR's.  Note that the
146251875Speter *     error immediately following this one is set ten times farther
147251875Speter *     away than usual, so that users of apr have a lot of room in
148251875Speter *     which to declare custom error codes.
149251875Speter *
150251875Speter * In general applications should try and create unique error codes. To try
151251875Speter * and assist in finding suitable ranges of numbers to use, the following
152251875Speter * ranges are known to be used by the listed applications. If your
153251875Speter * application defines error codes please advise the range of numbers it
154251875Speter * uses to dev@apr.apache.org for inclusion in this list.
155251875Speter *
156251875Speter * Ranges shown are in relation to APR_OS_START_USERERR
157251875Speter *
158251875Speter * Subversion - Defined ranges, of less than 100, at intervals of 5000
159251875Speter *              starting at an offset of 5000, e.g.
160251875Speter *               +5000 to 5100,  +10000 to 10100
161251875Speter *
162251875Speter * Apache HTTPD - +2000 to 2999
163251875Speter */
164251875Speter#define APR_OS_START_USERERR    (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE)
165251875Speter/**
166251875Speter * APR_OS_START_USEERR is obsolete, defined for compatibility only.
167251875Speter * Use APR_OS_START_USERERR instead.
168251875Speter */
169251875Speter#define APR_OS_START_USEERR     APR_OS_START_USERERR
170251875Speter/**
171251875Speter * APR_OS_START_CANONERR is where APR versions of errno values are defined
172251875Speter *     on systems which don't have the corresponding errno.
173251875Speter */
174251875Speter#define APR_OS_START_CANONERR  (APR_OS_START_USERERR \
175251875Speter                                 + (APR_OS_ERRSPACE_SIZE * 10))
176251875Speter/**
177251875Speter * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into
178251875Speter *     apr_status_t values.
179251875Speter */
180251875Speter#define APR_OS_START_EAIERR    (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE)
181251875Speter/**
182251875Speter * APR_OS_START_SYSERR folds platform-specific system error values into
183251875Speter *     apr_status_t values.
184251875Speter */
185251875Speter#define APR_OS_START_SYSERR    (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE)
186251875Speter
187251875Speter/**
188251875Speter * @defgroup APR_ERROR_map APR Error Space
189251875Speter * <PRE>
190251875Speter * The following attempts to show the relation of the various constants
191251875Speter * used for mapping APR Status codes.
192251875Speter *
193251875Speter *       0
194251875Speter *
195251875Speter *  20,000     APR_OS_START_ERROR
196251875Speter *
197251875Speter *         + APR_OS_ERRSPACE_SIZE (50,000)
198251875Speter *
199251875Speter *  70,000      APR_OS_START_STATUS
200251875Speter *
201251875Speter *         + APR_OS_ERRSPACE_SIZE - APR_UTIL_ERRSPACE_SIZE (30,000)
202251875Speter *
203251875Speter * 100,000      APR_UTIL_START_STATUS
204251875Speter *
205251875Speter *         + APR_UTIL_ERRSPACE_SIZE (20,000)
206251875Speter *
207251875Speter * 120,000      APR_OS_START_USERERR
208251875Speter *
209251875Speter *         + 10 x APR_OS_ERRSPACE_SIZE (50,000 * 10)
210251875Speter *
211251875Speter * 620,000      APR_OS_START_CANONERR
212251875Speter *
213251875Speter *         + APR_OS_ERRSPACE_SIZE (50,000)
214251875Speter *
215251875Speter * 670,000      APR_OS_START_EAIERR
216251875Speter *
217251875Speter *         + APR_OS_ERRSPACE_SIZE (50,000)
218251875Speter *
219251875Speter * 720,000      APR_OS_START_SYSERR
220251875Speter *
221251875Speter * </PRE>
222251875Speter */
223251875Speter
224251875Speter/** no error. */
225251875Speter#define APR_SUCCESS 0
226251875Speter
227251875Speter/**
228251875Speter * @defgroup APR_Error APR Error Values
229251875Speter * <PRE>
230251875Speter * <b>APR ERROR VALUES</b>
231251875Speter * APR_ENOSTAT      APR was unable to perform a stat on the file
232251875Speter * APR_ENOPOOL      APR was not provided a pool with which to allocate memory
233251875Speter * APR_EBADDATE     APR was given an invalid date
234251875Speter * APR_EINVALSOCK   APR was given an invalid socket
235251875Speter * APR_ENOPROC      APR was not given a process structure
236251875Speter * APR_ENOTIME      APR was not given a time structure
237251875Speter * APR_ENODIR       APR was not given a directory structure
238251875Speter * APR_ENOLOCK      APR was not given a lock structure
239251875Speter * APR_ENOPOLL      APR was not given a poll structure
240251875Speter * APR_ENOSOCKET    APR was not given a socket
241251875Speter * APR_ENOTHREAD    APR was not given a thread structure
242251875Speter * APR_ENOTHDKEY    APR was not given a thread key structure
243251875Speter * APR_ENOSHMAVAIL  There is no more shared memory available
244251875Speter * APR_EDSOOPEN     APR was unable to open the dso object.  For more
245251875Speter *                  information call apr_dso_error().
246251875Speter * APR_EGENERAL     General failure (specific information not available)
247251875Speter * APR_EBADIP       The specified IP address is invalid
248251875Speter * APR_EBADMASK     The specified netmask is invalid
249251875Speter * APR_ESYMNOTFOUND Could not find the requested symbol
250251875Speter * APR_ENOTENOUGHENTROPY Not enough entropy to continue
251251875Speter * </PRE>
252251875Speter *
253251875Speter * <PRE>
254251875Speter * <b>APR STATUS VALUES</b>
255251875Speter * APR_INCHILD        Program is currently executing in the child
256251875Speter * APR_INPARENT       Program is currently executing in the parent
257251875Speter * APR_DETACH         The thread is detached
258251875Speter * APR_NOTDETACH      The thread is not detached
259251875Speter * APR_CHILD_DONE     The child has finished executing
260251875Speter * APR_CHILD_NOTDONE  The child has not finished executing
261251875Speter * APR_TIMEUP         The operation did not finish before the timeout
262251875Speter * APR_INCOMPLETE     The operation was incomplete although some processing
263251875Speter *                    was performed and the results are partially valid
264251875Speter * APR_BADCH          Getopt found an option not in the option string
265251875Speter * APR_BADARG         Getopt found an option that is missing an argument
266251875Speter *                    and an argument was specified in the option string
267251875Speter * APR_EOF            APR has encountered the end of the file
268251875Speter * APR_NOTFOUND       APR was unable to find the socket in the poll structure
269251875Speter * APR_ANONYMOUS      APR is using anonymous shared memory
270251875Speter * APR_FILEBASED      APR is using a file name as the key to the shared memory
271251875Speter * APR_KEYBASED       APR is using a shared key as the key to the shared memory
272251875Speter * APR_EINIT          Ininitalizer value.  If no option has been found, but
273251875Speter *                    the status variable requires a value, this should be used
274251875Speter * APR_ENOTIMPL       The APR function has not been implemented on this
275251875Speter *                    platform, either because nobody has gotten to it yet,
276251875Speter *                    or the function is impossible on this platform.
277251875Speter * APR_EMISMATCH      Two passwords do not match.
278251875Speter * APR_EABSOLUTE      The given path was absolute.
279251875Speter * APR_ERELATIVE      The given path was relative.
280251875Speter * APR_EINCOMPLETE    The given path was neither relative nor absolute.
281251875Speter * APR_EABOVEROOT     The given path was above the root path.
282251875Speter * APR_EBUSY          The given lock was busy.
283251875Speter * APR_EPROC_UNKNOWN  The given process wasn't recognized by APR
284251875Speter * </PRE>
285251875Speter * @{
286251875Speter */
287251875Speter/** @see APR_STATUS_IS_ENOSTAT */
288251875Speter#define APR_ENOSTAT        (APR_OS_START_ERROR + 1)
289251875Speter/** @see APR_STATUS_IS_ENOPOOL */
290251875Speter#define APR_ENOPOOL        (APR_OS_START_ERROR + 2)
291251875Speter/* empty slot: +3 */
292251875Speter/** @see APR_STATUS_IS_EBADDATE */
293251875Speter#define APR_EBADDATE       (APR_OS_START_ERROR + 4)
294251875Speter/** @see APR_STATUS_IS_EINVALSOCK */
295251875Speter#define APR_EINVALSOCK     (APR_OS_START_ERROR + 5)
296251875Speter/** @see APR_STATUS_IS_ENOPROC */
297251875Speter#define APR_ENOPROC        (APR_OS_START_ERROR + 6)
298251875Speter/** @see APR_STATUS_IS_ENOTIME */
299251875Speter#define APR_ENOTIME        (APR_OS_START_ERROR + 7)
300251875Speter/** @see APR_STATUS_IS_ENODIR */
301251875Speter#define APR_ENODIR         (APR_OS_START_ERROR + 8)
302251875Speter/** @see APR_STATUS_IS_ENOLOCK */
303251875Speter#define APR_ENOLOCK        (APR_OS_START_ERROR + 9)
304251875Speter/** @see APR_STATUS_IS_ENOPOLL */
305251875Speter#define APR_ENOPOLL        (APR_OS_START_ERROR + 10)
306251875Speter/** @see APR_STATUS_IS_ENOSOCKET */
307251875Speter#define APR_ENOSOCKET      (APR_OS_START_ERROR + 11)
308251875Speter/** @see APR_STATUS_IS_ENOTHREAD */
309251875Speter#define APR_ENOTHREAD      (APR_OS_START_ERROR + 12)
310251875Speter/** @see APR_STATUS_IS_ENOTHDKEY */
311251875Speter#define APR_ENOTHDKEY      (APR_OS_START_ERROR + 13)
312251875Speter/** @see APR_STATUS_IS_EGENERAL */
313251875Speter#define APR_EGENERAL       (APR_OS_START_ERROR + 14)
314251875Speter/** @see APR_STATUS_IS_ENOSHMAVAIL */
315251875Speter#define APR_ENOSHMAVAIL    (APR_OS_START_ERROR + 15)
316251875Speter/** @see APR_STATUS_IS_EBADIP */
317251875Speter#define APR_EBADIP         (APR_OS_START_ERROR + 16)
318251875Speter/** @see APR_STATUS_IS_EBADMASK */
319251875Speter#define APR_EBADMASK       (APR_OS_START_ERROR + 17)
320251875Speter/* empty slot: +18 */
321251875Speter/** @see APR_STATUS_IS_EDSOPEN */
322251875Speter#define APR_EDSOOPEN       (APR_OS_START_ERROR + 19)
323251875Speter/** @see APR_STATUS_IS_EABSOLUTE */
324251875Speter#define APR_EABSOLUTE      (APR_OS_START_ERROR + 20)
325251875Speter/** @see APR_STATUS_IS_ERELATIVE */
326251875Speter#define APR_ERELATIVE      (APR_OS_START_ERROR + 21)
327251875Speter/** @see APR_STATUS_IS_EINCOMPLETE */
328251875Speter#define APR_EINCOMPLETE    (APR_OS_START_ERROR + 22)
329251875Speter/** @see APR_STATUS_IS_EABOVEROOT */
330251875Speter#define APR_EABOVEROOT     (APR_OS_START_ERROR + 23)
331251875Speter/** @see APR_STATUS_IS_EBADPATH */
332251875Speter#define APR_EBADPATH       (APR_OS_START_ERROR + 24)
333251875Speter/** @see APR_STATUS_IS_EPATHWILD */
334251875Speter#define APR_EPATHWILD      (APR_OS_START_ERROR + 25)
335251875Speter/** @see APR_STATUS_IS_ESYMNOTFOUND */
336251875Speter#define APR_ESYMNOTFOUND   (APR_OS_START_ERROR + 26)
337251875Speter/** @see APR_STATUS_IS_EPROC_UNKNOWN */
338251875Speter#define APR_EPROC_UNKNOWN  (APR_OS_START_ERROR + 27)
339251875Speter/** @see APR_STATUS_IS_ENOTENOUGHENTROPY */
340251875Speter#define APR_ENOTENOUGHENTROPY (APR_OS_START_ERROR + 28)
341251875Speter/** @} */
342251875Speter
343251875Speter/**
344251875Speter * @defgroup APR_STATUS_IS Status Value Tests
345251875Speter * @warning For any particular error condition, more than one of these tests
346251875Speter *      may match. This is because platform-specific error codes may not
347251875Speter *      always match the semantics of the POSIX codes these tests (and the
348251875Speter *      corresponding APR error codes) are named after. A notable example
349251875Speter *      are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on
350251875Speter *      Win32 platforms. The programmer should always be aware of this and
351251875Speter *      adjust the order of the tests accordingly.
352251875Speter * @{
353251875Speter */
354251875Speter/**
355251875Speter * APR was unable to perform a stat on the file
356251875Speter * @warning always use this test, as platform-specific variances may meet this
357251875Speter * more than one error code
358251875Speter */
359251875Speter#define APR_STATUS_IS_ENOSTAT(s)        ((s) == APR_ENOSTAT)
360251875Speter/**
361251875Speter * APR was not provided a pool with which to allocate memory
362251875Speter * @warning always use this test, as platform-specific variances may meet this
363251875Speter * more than one error code
364251875Speter */
365251875Speter#define APR_STATUS_IS_ENOPOOL(s)        ((s) == APR_ENOPOOL)
366251875Speter/** APR was given an invalid date  */
367251875Speter#define APR_STATUS_IS_EBADDATE(s)       ((s) == APR_EBADDATE)
368251875Speter/** APR was given an invalid socket */
369251875Speter#define APR_STATUS_IS_EINVALSOCK(s)     ((s) == APR_EINVALSOCK)
370251875Speter/** APR was not given a process structure */
371251875Speter#define APR_STATUS_IS_ENOPROC(s)        ((s) == APR_ENOPROC)
372251875Speter/** APR was not given a time structure */
373251875Speter#define APR_STATUS_IS_ENOTIME(s)        ((s) == APR_ENOTIME)
374251875Speter/** APR was not given a directory structure */
375251875Speter#define APR_STATUS_IS_ENODIR(s)         ((s) == APR_ENODIR)
376251875Speter/** APR was not given a lock structure */
377251875Speter#define APR_STATUS_IS_ENOLOCK(s)        ((s) == APR_ENOLOCK)
378251875Speter/** APR was not given a poll structure */
379251875Speter#define APR_STATUS_IS_ENOPOLL(s)        ((s) == APR_ENOPOLL)
380251875Speter/** APR was not given a socket */
381251875Speter#define APR_STATUS_IS_ENOSOCKET(s)      ((s) == APR_ENOSOCKET)
382251875Speter/** APR was not given a thread structure */
383251875Speter#define APR_STATUS_IS_ENOTHREAD(s)      ((s) == APR_ENOTHREAD)
384251875Speter/** APR was not given a thread key structure */
385251875Speter#define APR_STATUS_IS_ENOTHDKEY(s)      ((s) == APR_ENOTHDKEY)
386251875Speter/** Generic Error which can not be put into another spot */
387251875Speter#define APR_STATUS_IS_EGENERAL(s)       ((s) == APR_EGENERAL)
388251875Speter/** There is no more shared memory available */
389251875Speter#define APR_STATUS_IS_ENOSHMAVAIL(s)    ((s) == APR_ENOSHMAVAIL)
390251875Speter/** The specified IP address is invalid */
391251875Speter#define APR_STATUS_IS_EBADIP(s)         ((s) == APR_EBADIP)
392251875Speter/** The specified netmask is invalid */
393251875Speter#define APR_STATUS_IS_EBADMASK(s)       ((s) == APR_EBADMASK)
394251875Speter/* empty slot: +18 */
395251875Speter/**
396251875Speter * APR was unable to open the dso object.
397251875Speter * For more information call apr_dso_error().
398251875Speter */
399251875Speter#if defined(WIN32)
400251875Speter#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN \
401251875Speter                       || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND)
402251875Speter#else
403251875Speter#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN)
404251875Speter#endif
405251875Speter/** The given path was absolute. */
406251875Speter#define APR_STATUS_IS_EABSOLUTE(s)      ((s) == APR_EABSOLUTE)
407251875Speter/** The given path was relative. */
408251875Speter#define APR_STATUS_IS_ERELATIVE(s)      ((s) == APR_ERELATIVE)
409251875Speter/** The given path was neither relative nor absolute. */
410251875Speter#define APR_STATUS_IS_EINCOMPLETE(s)    ((s) == APR_EINCOMPLETE)
411251875Speter/** The given path was above the root path. */
412251875Speter#define APR_STATUS_IS_EABOVEROOT(s)     ((s) == APR_EABOVEROOT)
413251875Speter/** The given path was bad. */
414251875Speter#define APR_STATUS_IS_EBADPATH(s)       ((s) == APR_EBADPATH)
415251875Speter/** The given path contained wildcards. */
416251875Speter#define APR_STATUS_IS_EPATHWILD(s)      ((s) == APR_EPATHWILD)
417251875Speter/** Could not find the requested symbol.
418251875Speter * For more information call apr_dso_error().
419251875Speter */
420251875Speter#if defined(WIN32)
421251875Speter#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND \
422251875Speter                       || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
423251875Speter#else
424251875Speter#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND)
425251875Speter#endif
426251875Speter/** The given process was not recognized by APR. */
427251875Speter#define APR_STATUS_IS_EPROC_UNKNOWN(s)  ((s) == APR_EPROC_UNKNOWN)
428251875Speter/** APR could not gather enough entropy to continue. */
429251875Speter#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY)
430251875Speter
431251875Speter/** @} */
432251875Speter
433251875Speter/**
434251875Speter * @addtogroup APR_Error
435251875Speter * @{
436251875Speter */
437251875Speter/** @see APR_STATUS_IS_INCHILD */
438251875Speter#define APR_INCHILD        (APR_OS_START_STATUS + 1)
439251875Speter/** @see APR_STATUS_IS_INPARENT */
440251875Speter#define APR_INPARENT       (APR_OS_START_STATUS + 2)
441251875Speter/** @see APR_STATUS_IS_DETACH */
442251875Speter#define APR_DETACH         (APR_OS_START_STATUS + 3)
443251875Speter/** @see APR_STATUS_IS_NOTDETACH */
444251875Speter#define APR_NOTDETACH      (APR_OS_START_STATUS + 4)
445251875Speter/** @see APR_STATUS_IS_CHILD_DONE */
446251875Speter#define APR_CHILD_DONE     (APR_OS_START_STATUS + 5)
447251875Speter/** @see APR_STATUS_IS_CHILD_NOTDONE */
448251875Speter#define APR_CHILD_NOTDONE  (APR_OS_START_STATUS + 6)
449251875Speter/** @see APR_STATUS_IS_TIMEUP */
450251875Speter#define APR_TIMEUP         (APR_OS_START_STATUS + 7)
451251875Speter/** @see APR_STATUS_IS_INCOMPLETE */
452251875Speter#define APR_INCOMPLETE     (APR_OS_START_STATUS + 8)
453251875Speter/* empty slot: +9 */
454251875Speter/* empty slot: +10 */
455251875Speter/* empty slot: +11 */
456251875Speter/** @see APR_STATUS_IS_BADCH */
457251875Speter#define APR_BADCH          (APR_OS_START_STATUS + 12)
458251875Speter/** @see APR_STATUS_IS_BADARG */
459251875Speter#define APR_BADARG         (APR_OS_START_STATUS + 13)
460251875Speter/** @see APR_STATUS_IS_EOF */
461251875Speter#define APR_EOF            (APR_OS_START_STATUS + 14)
462251875Speter/** @see APR_STATUS_IS_NOTFOUND */
463251875Speter#define APR_NOTFOUND       (APR_OS_START_STATUS + 15)
464251875Speter/* empty slot: +16 */
465251875Speter/* empty slot: +17 */
466251875Speter/* empty slot: +18 */
467251875Speter/** @see APR_STATUS_IS_ANONYMOUS */
468251875Speter#define APR_ANONYMOUS      (APR_OS_START_STATUS + 19)
469251875Speter/** @see APR_STATUS_IS_FILEBASED */
470251875Speter#define APR_FILEBASED      (APR_OS_START_STATUS + 20)
471251875Speter/** @see APR_STATUS_IS_KEYBASED */
472251875Speter#define APR_KEYBASED       (APR_OS_START_STATUS + 21)
473251875Speter/** @see APR_STATUS_IS_EINIT */
474251875Speter#define APR_EINIT          (APR_OS_START_STATUS + 22)
475251875Speter/** @see APR_STATUS_IS_ENOTIMPL */
476251875Speter#define APR_ENOTIMPL       (APR_OS_START_STATUS + 23)
477251875Speter/** @see APR_STATUS_IS_EMISMATCH */
478251875Speter#define APR_EMISMATCH      (APR_OS_START_STATUS + 24)
479251875Speter/** @see APR_STATUS_IS_EBUSY */
480251875Speter#define APR_EBUSY          (APR_OS_START_STATUS + 25)
481251875Speter/** @} */
482251875Speter
483251875Speter/**
484251875Speter * @addtogroup APR_STATUS_IS
485251875Speter * @{
486251875Speter */
487251875Speter/**
488251875Speter * Program is currently executing in the child
489251875Speter * @warning
490251875Speter * always use this test, as platform-specific variances may meet this
491251875Speter * more than one error code */
492251875Speter#define APR_STATUS_IS_INCHILD(s)        ((s) == APR_INCHILD)
493251875Speter/**
494251875Speter * Program is currently executing in the parent
495251875Speter * @warning
496251875Speter * always use this test, as platform-specific variances may meet this
497251875Speter * more than one error code
498251875Speter */
499251875Speter#define APR_STATUS_IS_INPARENT(s)       ((s) == APR_INPARENT)
500251875Speter/**
501251875Speter * The thread is detached
502251875Speter * @warning
503251875Speter * always use this test, as platform-specific variances may meet this
504251875Speter * more than one error code
505251875Speter */
506251875Speter#define APR_STATUS_IS_DETACH(s)         ((s) == APR_DETACH)
507251875Speter/**
508251875Speter * The thread is not detached
509251875Speter * @warning
510251875Speter * always use this test, as platform-specific variances may meet this
511251875Speter * more than one error code
512251875Speter */
513251875Speter#define APR_STATUS_IS_NOTDETACH(s)      ((s) == APR_NOTDETACH)
514251875Speter/**
515251875Speter * The child has finished executing
516251875Speter * @warning
517251875Speter * always use this test, as platform-specific variances may meet this
518251875Speter * more than one error code
519251875Speter */
520251875Speter#define APR_STATUS_IS_CHILD_DONE(s)     ((s) == APR_CHILD_DONE)
521251875Speter/**
522251875Speter * The child has not finished executing
523251875Speter * @warning
524251875Speter * always use this test, as platform-specific variances may meet this
525251875Speter * more than one error code
526251875Speter */
527251875Speter#define APR_STATUS_IS_CHILD_NOTDONE(s)  ((s) == APR_CHILD_NOTDONE)
528251875Speter/**
529251875Speter * The operation did not finish before the timeout
530251875Speter * @warning
531251875Speter * always use this test, as platform-specific variances may meet this
532251875Speter * more than one error code
533251875Speter */
534251875Speter#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP)
535251875Speter/**
536251875Speter * The operation was incomplete although some processing was performed
537251875Speter * and the results are partially valid.
538251875Speter * @warning
539251875Speter * always use this test, as platform-specific variances may meet this
540251875Speter * more than one error code
541251875Speter */
542251875Speter#define APR_STATUS_IS_INCOMPLETE(s)     ((s) == APR_INCOMPLETE)
543251875Speter/* empty slot: +9 */
544251875Speter/* empty slot: +10 */
545251875Speter/* empty slot: +11 */
546251875Speter/**
547251875Speter * Getopt found an option not in the option string
548251875Speter * @warning
549251875Speter * always use this test, as platform-specific variances may meet this
550251875Speter * more than one error code
551251875Speter */
552251875Speter#define APR_STATUS_IS_BADCH(s)          ((s) == APR_BADCH)
553251875Speter/**
554251875Speter * Getopt found an option not in the option string and an argument was
555251875Speter * specified in the option string
556251875Speter * @warning
557251875Speter * always use this test, as platform-specific variances may meet this
558251875Speter * more than one error code
559251875Speter */
560251875Speter#define APR_STATUS_IS_BADARG(s)         ((s) == APR_BADARG)
561251875Speter/**
562251875Speter * APR has encountered the end of the file
563251875Speter * @warning
564251875Speter * always use this test, as platform-specific variances may meet this
565251875Speter * more than one error code
566251875Speter */
567251875Speter#define APR_STATUS_IS_EOF(s)            ((s) == APR_EOF)
568251875Speter/**
569251875Speter * APR was unable to find the socket in the poll structure
570251875Speter * @warning
571251875Speter * always use this test, as platform-specific variances may meet this
572251875Speter * more than one error code
573251875Speter */
574251875Speter#define APR_STATUS_IS_NOTFOUND(s)       ((s) == APR_NOTFOUND)
575251875Speter/* empty slot: +16 */
576251875Speter/* empty slot: +17 */
577251875Speter/* empty slot: +18 */
578251875Speter/**
579251875Speter * APR is using anonymous shared memory
580251875Speter * @warning
581251875Speter * always use this test, as platform-specific variances may meet this
582251875Speter * more than one error code
583251875Speter */
584251875Speter#define APR_STATUS_IS_ANONYMOUS(s)      ((s) == APR_ANONYMOUS)
585251875Speter/**
586251875Speter * APR is using a file name as the key to the shared memory
587251875Speter * @warning
588251875Speter * always use this test, as platform-specific variances may meet this
589251875Speter * more than one error code
590251875Speter */
591251875Speter#define APR_STATUS_IS_FILEBASED(s)      ((s) == APR_FILEBASED)
592251875Speter/**
593251875Speter * APR is using a shared key as the key to the shared memory
594251875Speter * @warning
595251875Speter * always use this test, as platform-specific variances may meet this
596251875Speter * more than one error code
597251875Speter */
598251875Speter#define APR_STATUS_IS_KEYBASED(s)       ((s) == APR_KEYBASED)
599251875Speter/**
600251875Speter * Ininitalizer value.  If no option has been found, but
601251875Speter * the status variable requires a value, this should be used
602251875Speter * @warning
603251875Speter * always use this test, as platform-specific variances may meet this
604251875Speter * more than one error code
605251875Speter */
606251875Speter#define APR_STATUS_IS_EINIT(s)          ((s) == APR_EINIT)
607251875Speter/**
608251875Speter * The APR function has not been implemented on this
609251875Speter * platform, either because nobody has gotten to it yet,
610251875Speter * or the function is impossible on this platform.
611251875Speter * @warning
612251875Speter * always use this test, as platform-specific variances may meet this
613251875Speter * more than one error code
614251875Speter */
615251875Speter#define APR_STATUS_IS_ENOTIMPL(s)       ((s) == APR_ENOTIMPL)
616251875Speter/**
617251875Speter * Two passwords do not match.
618251875Speter * @warning
619251875Speter * always use this test, as platform-specific variances may meet this
620251875Speter * more than one error code
621251875Speter */
622251875Speter#define APR_STATUS_IS_EMISMATCH(s)      ((s) == APR_EMISMATCH)
623251875Speter/**
624251875Speter * The given lock was busy
625251875Speter * @warning always use this test, as platform-specific variances may meet this
626251875Speter * more than one error code
627251875Speter */
628251875Speter#define APR_STATUS_IS_EBUSY(s)          ((s) == APR_EBUSY)
629251875Speter
630251875Speter/** @} */
631251875Speter
632251875Speter/**
633251875Speter * @addtogroup APR_Error APR Error Values
634251875Speter * @{
635251875Speter */
636251875Speter/* APR CANONICAL ERROR VALUES */
637251875Speter/** @see APR_STATUS_IS_EACCES */
638251875Speter#ifdef EACCES
639251875Speter#define APR_EACCES EACCES
640251875Speter#else
641251875Speter#define APR_EACCES         (APR_OS_START_CANONERR + 1)
642251875Speter#endif
643251875Speter
644251875Speter/** @see APR_STATUS_IS_EEXIST */
645251875Speter#ifdef EEXIST
646251875Speter#define APR_EEXIST EEXIST
647251875Speter#else
648251875Speter#define APR_EEXIST         (APR_OS_START_CANONERR + 2)
649251875Speter#endif
650251875Speter
651251875Speter/** @see APR_STATUS_IS_ENAMETOOLONG */
652251875Speter#ifdef ENAMETOOLONG
653251875Speter#define APR_ENAMETOOLONG ENAMETOOLONG
654251875Speter#else
655251875Speter#define APR_ENAMETOOLONG   (APR_OS_START_CANONERR + 3)
656251875Speter#endif
657251875Speter
658251875Speter/** @see APR_STATUS_IS_ENOENT */
659251875Speter#ifdef ENOENT
660251875Speter#define APR_ENOENT ENOENT
661251875Speter#else
662251875Speter#define APR_ENOENT         (APR_OS_START_CANONERR + 4)
663251875Speter#endif
664251875Speter
665251875Speter/** @see APR_STATUS_IS_ENOTDIR */
666251875Speter#ifdef ENOTDIR
667251875Speter#define APR_ENOTDIR ENOTDIR
668251875Speter#else
669251875Speter#define APR_ENOTDIR        (APR_OS_START_CANONERR + 5)
670251875Speter#endif
671251875Speter
672251875Speter/** @see APR_STATUS_IS_ENOSPC */
673251875Speter#ifdef ENOSPC
674251875Speter#define APR_ENOSPC ENOSPC
675251875Speter#else
676251875Speter#define APR_ENOSPC         (APR_OS_START_CANONERR + 6)
677251875Speter#endif
678251875Speter
679251875Speter/** @see APR_STATUS_IS_ENOMEM */
680251875Speter#ifdef ENOMEM
681251875Speter#define APR_ENOMEM ENOMEM
682251875Speter#else
683251875Speter#define APR_ENOMEM         (APR_OS_START_CANONERR + 7)
684251875Speter#endif
685251875Speter
686251875Speter/** @see APR_STATUS_IS_EMFILE */
687251875Speter#ifdef EMFILE
688251875Speter#define APR_EMFILE EMFILE
689251875Speter#else
690251875Speter#define APR_EMFILE         (APR_OS_START_CANONERR + 8)
691251875Speter#endif
692251875Speter
693251875Speter/** @see APR_STATUS_IS_ENFILE */
694251875Speter#ifdef ENFILE
695251875Speter#define APR_ENFILE ENFILE
696251875Speter#else
697251875Speter#define APR_ENFILE         (APR_OS_START_CANONERR + 9)
698251875Speter#endif
699251875Speter
700251875Speter/** @see APR_STATUS_IS_EBADF */
701251875Speter#ifdef EBADF
702251875Speter#define APR_EBADF EBADF
703251875Speter#else
704251875Speter#define APR_EBADF          (APR_OS_START_CANONERR + 10)
705251875Speter#endif
706251875Speter
707251875Speter/** @see APR_STATUS_IS_EINVAL */
708251875Speter#ifdef EINVAL
709251875Speter#define APR_EINVAL EINVAL
710251875Speter#else
711251875Speter#define APR_EINVAL         (APR_OS_START_CANONERR + 11)
712251875Speter#endif
713251875Speter
714251875Speter/** @see APR_STATUS_IS_ESPIPE */
715251875Speter#ifdef ESPIPE
716251875Speter#define APR_ESPIPE ESPIPE
717251875Speter#else
718251875Speter#define APR_ESPIPE         (APR_OS_START_CANONERR + 12)
719251875Speter#endif
720251875Speter
721251875Speter/**
722251875Speter * @see APR_STATUS_IS_EAGAIN
723251875Speter * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
724251875Speter */
725251875Speter#ifdef EAGAIN
726251875Speter#define APR_EAGAIN EAGAIN
727251875Speter#elif defined(EWOULDBLOCK)
728251875Speter#define APR_EAGAIN EWOULDBLOCK
729251875Speter#else
730251875Speter#define APR_EAGAIN         (APR_OS_START_CANONERR + 13)
731251875Speter#endif
732251875Speter
733251875Speter/** @see APR_STATUS_IS_EINTR */
734251875Speter#ifdef EINTR
735251875Speter#define APR_EINTR EINTR
736251875Speter#else
737251875Speter#define APR_EINTR          (APR_OS_START_CANONERR + 14)
738251875Speter#endif
739251875Speter
740251875Speter/** @see APR_STATUS_IS_ENOTSOCK */
741251875Speter#ifdef ENOTSOCK
742251875Speter#define APR_ENOTSOCK ENOTSOCK
743251875Speter#else
744251875Speter#define APR_ENOTSOCK       (APR_OS_START_CANONERR + 15)
745251875Speter#endif
746251875Speter
747251875Speter/** @see APR_STATUS_IS_ECONNREFUSED */
748251875Speter#ifdef ECONNREFUSED
749251875Speter#define APR_ECONNREFUSED ECONNREFUSED
750251875Speter#else
751251875Speter#define APR_ECONNREFUSED   (APR_OS_START_CANONERR + 16)
752251875Speter#endif
753251875Speter
754251875Speter/** @see APR_STATUS_IS_EINPROGRESS */
755251875Speter#ifdef EINPROGRESS
756251875Speter#define APR_EINPROGRESS EINPROGRESS
757251875Speter#else
758251875Speter#define APR_EINPROGRESS    (APR_OS_START_CANONERR + 17)
759251875Speter#endif
760251875Speter
761251875Speter/**
762251875Speter * @see APR_STATUS_IS_ECONNABORTED
763251875Speter * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
764251875Speter */
765251875Speter
766251875Speter#ifdef ECONNABORTED
767251875Speter#define APR_ECONNABORTED ECONNABORTED
768251875Speter#else
769251875Speter#define APR_ECONNABORTED   (APR_OS_START_CANONERR + 18)
770251875Speter#endif
771251875Speter
772251875Speter/** @see APR_STATUS_IS_ECONNRESET */
773251875Speter#ifdef ECONNRESET
774251875Speter#define APR_ECONNRESET ECONNRESET
775251875Speter#else
776251875Speter#define APR_ECONNRESET     (APR_OS_START_CANONERR + 19)
777251875Speter#endif
778251875Speter
779251875Speter/** @see APR_STATUS_IS_ETIMEDOUT
780251875Speter *  @deprecated */
781251875Speter#ifdef ETIMEDOUT
782251875Speter#define APR_ETIMEDOUT ETIMEDOUT
783251875Speter#else
784251875Speter#define APR_ETIMEDOUT      (APR_OS_START_CANONERR + 20)
785251875Speter#endif
786251875Speter
787251875Speter/** @see APR_STATUS_IS_EHOSTUNREACH */
788251875Speter#ifdef EHOSTUNREACH
789251875Speter#define APR_EHOSTUNREACH EHOSTUNREACH
790251875Speter#else
791251875Speter#define APR_EHOSTUNREACH   (APR_OS_START_CANONERR + 21)
792251875Speter#endif
793251875Speter
794251875Speter/** @see APR_STATUS_IS_ENETUNREACH */
795251875Speter#ifdef ENETUNREACH
796251875Speter#define APR_ENETUNREACH ENETUNREACH
797251875Speter#else
798251875Speter#define APR_ENETUNREACH    (APR_OS_START_CANONERR + 22)
799251875Speter#endif
800251875Speter
801251875Speter/** @see APR_STATUS_IS_EFTYPE */
802251875Speter#ifdef EFTYPE
803251875Speter#define APR_EFTYPE EFTYPE
804251875Speter#else
805251875Speter#define APR_EFTYPE        (APR_OS_START_CANONERR + 23)
806251875Speter#endif
807251875Speter
808251875Speter/** @see APR_STATUS_IS_EPIPE */
809251875Speter#ifdef EPIPE
810251875Speter#define APR_EPIPE EPIPE
811251875Speter#else
812251875Speter#define APR_EPIPE         (APR_OS_START_CANONERR + 24)
813251875Speter#endif
814251875Speter
815251875Speter/** @see APR_STATUS_IS_EXDEV */
816251875Speter#ifdef EXDEV
817251875Speter#define APR_EXDEV EXDEV
818251875Speter#else
819251875Speter#define APR_EXDEV         (APR_OS_START_CANONERR + 25)
820251875Speter#endif
821251875Speter
822251875Speter/** @see APR_STATUS_IS_ENOTEMPTY */
823251875Speter#ifdef ENOTEMPTY
824251875Speter#define APR_ENOTEMPTY ENOTEMPTY
825251875Speter#else
826251875Speter#define APR_ENOTEMPTY     (APR_OS_START_CANONERR + 26)
827251875Speter#endif
828251875Speter
829251875Speter/** @see APR_STATUS_IS_EAFNOSUPPORT */
830251875Speter#ifdef EAFNOSUPPORT
831251875Speter#define APR_EAFNOSUPPORT EAFNOSUPPORT
832251875Speter#else
833251875Speter#define APR_EAFNOSUPPORT  (APR_OS_START_CANONERR + 27)
834251875Speter#endif
835251875Speter
836362181Sdim/** @see APR_STATUS_IS_EOPNOTSUPP */
837362181Sdim#ifdef EOPNOTSUPP
838362181Sdim#define APR_EOPNOTSUPP EOPNOTSUPP
839362181Sdim#else
840362181Sdim#define APR_EOPNOTSUPP    (APR_OS_START_CANONERR + 28)
841362181Sdim#endif
842362181Sdim
843362181Sdim/** @see APR_STATUS_IS_ERANGE */
844362181Sdim#ifdef ERANGE
845362181Sdim#define APR_ERANGE ERANGE
846362181Sdim#else
847362181Sdim#define APR_ERANGE          (APR_OS_START_CANONERR + 29)
848362181Sdim#endif
849362181Sdim
850251875Speter/** @} */
851251875Speter
852251875Speter#if defined(OS2) && !defined(DOXYGEN)
853251875Speter
854251875Speter#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
855251875Speter#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
856251875Speter
857251875Speter#define INCL_DOSERRORS
858251875Speter#define INCL_DOS
859251875Speter
860251875Speter/* Leave these undefined.
861251875Speter * OS2 doesn't rely on the errno concept.
862251875Speter * The API calls always return a result codes which
863251875Speter * should be filtered through APR_FROM_OS_ERROR().
864251875Speter *
865251875Speter * #define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
866251875Speter * #define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
867251875Speter */
868251875Speter
869251875Speter/* A special case, only socket calls require this;
870251875Speter */
871251875Speter#define apr_get_netos_error()   (APR_FROM_OS_ERROR(errno))
872251875Speter#define apr_set_netos_error(e)  (errno = APR_TO_OS_ERROR(e))
873251875Speter
874251875Speter/* And this needs to be greped away for good:
875251875Speter */
876251875Speter#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
877251875Speter
878251875Speter/* These can't sit in a private header, so in spite of the extra size,
879251875Speter * they need to be made available here.
880251875Speter */
881251875Speter#define SOCBASEERR              10000
882251875Speter#define SOCEPERM                (SOCBASEERR+1)             /* Not owner */
883251875Speter#define SOCESRCH                (SOCBASEERR+3)             /* No such process */
884251875Speter#define SOCEINTR                (SOCBASEERR+4)             /* Interrupted system call */
885251875Speter#define SOCENXIO                (SOCBASEERR+6)             /* No such device or address */
886251875Speter#define SOCEBADF                (SOCBASEERR+9)             /* Bad file number */
887251875Speter#define SOCEACCES               (SOCBASEERR+13)            /* Permission denied */
888251875Speter#define SOCEFAULT               (SOCBASEERR+14)            /* Bad address */
889251875Speter#define SOCEINVAL               (SOCBASEERR+22)            /* Invalid argument */
890251875Speter#define SOCEMFILE               (SOCBASEERR+24)            /* Too many open files */
891251875Speter#define SOCEPIPE                (SOCBASEERR+32)            /* Broken pipe */
892251875Speter#define SOCEOS2ERR              (SOCBASEERR+100)           /* OS/2 Error */
893251875Speter#define SOCEWOULDBLOCK          (SOCBASEERR+35)            /* Operation would block */
894251875Speter#define SOCEINPROGRESS          (SOCBASEERR+36)            /* Operation now in progress */
895251875Speter#define SOCEALREADY             (SOCBASEERR+37)            /* Operation already in progress */
896251875Speter#define SOCENOTSOCK             (SOCBASEERR+38)            /* Socket operation on non-socket */
897251875Speter#define SOCEDESTADDRREQ         (SOCBASEERR+39)            /* Destination address required */
898251875Speter#define SOCEMSGSIZE             (SOCBASEERR+40)            /* Message too long */
899251875Speter#define SOCEPROTOTYPE           (SOCBASEERR+41)            /* Protocol wrong type for socket */
900251875Speter#define SOCENOPROTOOPT          (SOCBASEERR+42)            /* Protocol not available */
901251875Speter#define SOCEPROTONOSUPPORT      (SOCBASEERR+43)            /* Protocol not supported */
902251875Speter#define SOCESOCKTNOSUPPORT      (SOCBASEERR+44)            /* Socket type not supported */
903251875Speter#define SOCEOPNOTSUPP           (SOCBASEERR+45)            /* Operation not supported on socket */
904251875Speter#define SOCEPFNOSUPPORT         (SOCBASEERR+46)            /* Protocol family not supported */
905251875Speter#define SOCEAFNOSUPPORT         (SOCBASEERR+47)            /* Address family not supported by protocol family */
906251875Speter#define SOCEADDRINUSE           (SOCBASEERR+48)            /* Address already in use */
907251875Speter#define SOCEADDRNOTAVAIL        (SOCBASEERR+49)            /* Can't assign requested address */
908251875Speter#define SOCENETDOWN             (SOCBASEERR+50)            /* Network is down */
909251875Speter#define SOCENETUNREACH          (SOCBASEERR+51)            /* Network is unreachable */
910251875Speter#define SOCENETRESET            (SOCBASEERR+52)            /* Network dropped connection on reset */
911251875Speter#define SOCECONNABORTED         (SOCBASEERR+53)            /* Software caused connection abort */
912251875Speter#define SOCECONNRESET           (SOCBASEERR+54)            /* Connection reset by peer */
913251875Speter#define SOCENOBUFS              (SOCBASEERR+55)            /* No buffer space available */
914251875Speter#define SOCEISCONN              (SOCBASEERR+56)            /* Socket is already connected */
915251875Speter#define SOCENOTCONN             (SOCBASEERR+57)            /* Socket is not connected */
916251875Speter#define SOCESHUTDOWN            (SOCBASEERR+58)            /* Can't send after socket shutdown */
917251875Speter#define SOCETOOMANYREFS         (SOCBASEERR+59)            /* Too many references: can't splice */
918251875Speter#define SOCETIMEDOUT            (SOCBASEERR+60)            /* Connection timed out */
919251875Speter#define SOCECONNREFUSED         (SOCBASEERR+61)            /* Connection refused */
920251875Speter#define SOCELOOP                (SOCBASEERR+62)            /* Too many levels of symbolic links */
921251875Speter#define SOCENAMETOOLONG         (SOCBASEERR+63)            /* File name too long */
922251875Speter#define SOCEHOSTDOWN            (SOCBASEERR+64)            /* Host is down */
923251875Speter#define SOCEHOSTUNREACH         (SOCBASEERR+65)            /* No route to host */
924251875Speter#define SOCENOTEMPTY            (SOCBASEERR+66)            /* Directory not empty */
925251875Speter
926251875Speter/* APR CANONICAL ERROR TESTS */
927251875Speter#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
928251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
929251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
930251875Speter#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
931251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
932251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
933251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
934251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
935251875Speter#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
936251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
937251875Speter                || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
938251875Speter#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
939251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
940251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
941251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
942251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
943251875Speter#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
944251875Speter#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
945251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
946251875Speter#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
947251875Speter#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
948251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
949251875Speter#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
950251875Speter#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
951251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
952251875Speter#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
953251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
954251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
955251875Speter#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
956251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
957251875Speter#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
958251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
959251875Speter                || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
960251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
961251875Speter#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
962251875Speter                || (s) == APR_OS_START_SYSERR + SOCEINTR)
963251875Speter#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
964251875Speter                || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
965251875Speter#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
966251875Speter                || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
967251875Speter#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
968251875Speter                || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
969251875Speter#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
970251875Speter                || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
971251875Speter#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
972251875Speter                || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
973251875Speter/* XXX deprecated */
974251875Speter#define APR_STATUS_IS_ETIMEDOUT(s)         ((s) == APR_ETIMEDOUT \
975251875Speter                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
976251875Speter#undef APR_STATUS_IS_TIMEUP
977251875Speter#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
978251875Speter                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
979251875Speter#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
980251875Speter                || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
981251875Speter#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
982251875Speter                || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
983251875Speter#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
984251875Speter#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
985251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
986251875Speter                || (s) == APR_OS_START_SYSERR + SOCEPIPE)
987251875Speter#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
988251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
989251875Speter#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
990251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
991251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
992251875Speter#define APR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == APR_AFNOSUPPORT \
993251875Speter                || (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
994362181Sdim#define APR_STATUS_IS_EOPNOTSUPP(s)     ((s) == APR_EOPNOTSUPP \
995362181Sdim                || (s) == APR_OS_START_SYSERR + SOCEOPNOTSUPP)
996362181Sdim#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
997251875Speter
998251875Speter/*
999251875Speter    Sorry, too tired to wrap this up for OS2... feel free to
1000251875Speter    fit the following into their best matches.
1001251875Speter
1002251875Speter    { ERROR_NO_SIGNAL_SENT,     ESRCH           },
1003251875Speter    { SOCEALREADY,              EALREADY        },
1004251875Speter    { SOCEDESTADDRREQ,          EDESTADDRREQ    },
1005251875Speter    { SOCEMSGSIZE,              EMSGSIZE        },
1006251875Speter    { SOCEPROTOTYPE,            EPROTOTYPE      },
1007251875Speter    { SOCENOPROTOOPT,           ENOPROTOOPT     },
1008251875Speter    { SOCEPROTONOSUPPORT,       EPROTONOSUPPORT },
1009251875Speter    { SOCESOCKTNOSUPPORT,       ESOCKTNOSUPPORT },
1010251875Speter    { SOCEPFNOSUPPORT,          EPFNOSUPPORT    },
1011251875Speter    { SOCEADDRINUSE,            EADDRINUSE      },
1012251875Speter    { SOCEADDRNOTAVAIL,         EADDRNOTAVAIL   },
1013251875Speter    { SOCENETDOWN,              ENETDOWN        },
1014251875Speter    { SOCENETRESET,             ENETRESET       },
1015251875Speter    { SOCENOBUFS,               ENOBUFS         },
1016251875Speter    { SOCEISCONN,               EISCONN         },
1017251875Speter    { SOCENOTCONN,              ENOTCONN        },
1018251875Speter    { SOCESHUTDOWN,             ESHUTDOWN       },
1019251875Speter    { SOCETOOMANYREFS,          ETOOMANYREFS    },
1020251875Speter    { SOCELOOP,                 ELOOP           },
1021251875Speter    { SOCEHOSTDOWN,             EHOSTDOWN       },
1022251875Speter    { SOCENOTEMPTY,             ENOTEMPTY       },
1023251875Speter    { SOCEPIPE,                 EPIPE           }
1024251875Speter*/
1025251875Speter
1026251875Speter#elif defined(WIN32) && !defined(DOXYGEN) /* !defined(OS2) */
1027251875Speter
1028251875Speter#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
1029251875Speter#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
1030251875Speter
1031251875Speter#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
1032251875Speter#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
1033251875Speter
1034251875Speter/* A special case, only socket calls require this:
1035251875Speter */
1036251875Speter#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
1037251875Speter#define apr_set_netos_error(e)   (WSASetLastError(APR_TO_OS_ERROR(e)))
1038251875Speter
1039251875Speter/* APR CANONICAL ERROR TESTS */
1040251875Speter#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
1041251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
1042251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
1043251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
1044251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
1045251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
1046251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
1047251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
1048251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
1049251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
1050251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
1051251875Speter#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
1052251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
1053251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
1054251875Speter#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
1055251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
1056251875Speter                || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
1057251875Speter#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
1058251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
1059251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
1060251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
1061251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
1062251875Speter#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR \
1063251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
1064251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
1065251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
1066251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
1067251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE \
1068251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_DIRECTORY)
1069251875Speter#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
1070251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
1071251875Speter#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM \
1072251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
1073251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
1074251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
1075251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
1076251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
1077251875Speter#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
1078251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
1079251875Speter#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
1080251875Speter#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
1081251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
1082251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
1083251875Speter#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
1084251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
1085251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
1086251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
1087251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
1088251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
1089251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
1090251875Speter#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
1091251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
1092251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
1093251875Speter#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
1094251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
1095251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
1096251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
1097251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
1098251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
1099251875Speter                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
1100251875Speter#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
1101251875Speter                || (s) == APR_OS_START_SYSERR + WSAEINTR)
1102251875Speter#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
1103251875Speter                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
1104251875Speter#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
1105251875Speter                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
1106251875Speter#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
1107251875Speter                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
1108251875Speter#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
1109251875Speter                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
1110251875Speter#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
1111251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
1112251875Speter                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
1113251875Speter/* XXX deprecated */
1114251875Speter#define APR_STATUS_IS_ETIMEDOUT(s)         ((s) == APR_ETIMEDOUT \
1115251875Speter                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1116251875Speter                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1117251875Speter#undef APR_STATUS_IS_TIMEUP
1118251875Speter#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
1119251875Speter                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1120251875Speter                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1121251875Speter#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
1122251875Speter                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
1123251875Speter#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
1124251875Speter                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
1125251875Speter#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE \
1126251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
1127251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
1128251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
1129251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
1130251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
1131251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
1132251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
1133251875Speter#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
1134251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
1135251875Speter#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
1136251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
1137251875Speter#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
1138251875Speter                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
1139251875Speter#define APR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == APR_EAFNOSUPPORT \
1140251875Speter                || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
1141362181Sdim#define APR_STATUS_IS_EOPNOTSUPP(s)     ((s) == APR_EOPNOTSUPP \
1142362181Sdim                || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
1143362181Sdim#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
1144251875Speter
1145251875Speter#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
1146251875Speter
1147251875Speter#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
1148251875Speter#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
1149251875Speter
1150251875Speter#define apr_get_os_error()    (errno)
1151251875Speter#define apr_set_os_error(e)   (errno = (e))
1152251875Speter
1153251875Speter/* A special case, only socket calls require this: */
1154251875Speter#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
1155251875Speter#define apr_set_netos_error(e)  (WSASetLastError(APR_TO_OS_ERROR(e)))
1156251875Speter
1157251875Speter/* APR CANONICAL ERROR TESTS */
1158251875Speter#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
1159251875Speter#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
1160251875Speter#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
1161251875Speter#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
1162251875Speter#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
1163251875Speter#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
1164251875Speter#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
1165251875Speter#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
1166251875Speter#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
1167251875Speter#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
1168251875Speter#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
1169251875Speter#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
1170251875Speter
1171251875Speter#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
1172251875Speter                || (s) ==                       EWOULDBLOCK \
1173251875Speter                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
1174251875Speter#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
1175251875Speter                || (s) == APR_OS_START_SYSERR + WSAEINTR)
1176251875Speter#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
1177251875Speter                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
1178251875Speter#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
1179251875Speter                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
1180251875Speter#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
1181251875Speter                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
1182251875Speter#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
1183251875Speter                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
1184251875Speter#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
1185251875Speter                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
1186251875Speter/* XXX deprecated */
1187251875Speter#define APR_STATUS_IS_ETIMEDOUT(s)       ((s) == APR_ETIMEDOUT \
1188251875Speter                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1189251875Speter                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1190251875Speter#undef APR_STATUS_IS_TIMEUP
1191251875Speter#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
1192251875Speter                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
1193251875Speter                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
1194251875Speter#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
1195251875Speter                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
1196251875Speter#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
1197251875Speter                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
1198251875Speter#define APR_STATUS_IS_ENETDOWN(s)       ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
1199251875Speter#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
1200251875Speter#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE)
1201251875Speter#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV)
1202251875Speter#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY)
1203251875Speter#define APR_STATUS_IS_EAFNOSUPPORT(s)   ((s) == APR_EAFNOSUPPORT \
1204251875Speter                || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
1205362181Sdim#define APR_STATUS_IS_EOPNOTSUPP(s)     ((s) == APR_EOPNOTSUPP \
1206362181Sdim                || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
1207362181Sdim#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
1208251875Speter
1209251875Speter#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
1210251875Speter
1211251875Speter/*
1212251875Speter *  os error codes are clib error codes
1213251875Speter */
1214251875Speter#define APR_FROM_OS_ERROR(e)  (e)
1215251875Speter#define APR_TO_OS_ERROR(e)    (e)
1216251875Speter
1217251875Speter#define apr_get_os_error()    (errno)
1218251875Speter#define apr_set_os_error(e)   (errno = (e))
1219251875Speter
1220251875Speter/* A special case, only socket calls require this:
1221251875Speter */
1222251875Speter#define apr_get_netos_error() (errno)
1223251875Speter#define apr_set_netos_error(e) (errno = (e))
1224251875Speter
1225251875Speter/**
1226251875Speter * @addtogroup APR_STATUS_IS
1227251875Speter * @{
1228251875Speter */
1229251875Speter
1230251875Speter/** permission denied */
1231251875Speter#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
1232251875Speter/** file exists */
1233251875Speter#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
1234251875Speter/** path name is too long */
1235251875Speter#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
1236251875Speter/**
1237251875Speter * no such file or directory
1238251875Speter * @remark
1239251875Speter * EMVSCATLG can be returned by the automounter on z/OS for
1240251875Speter * paths which do not exist.
1241251875Speter */
1242251875Speter#ifdef EMVSCATLG
1243251875Speter#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
1244251875Speter                                      || (s) == EMVSCATLG)
1245251875Speter#else
1246251875Speter#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
1247251875Speter#endif
1248251875Speter/** not a directory */
1249251875Speter#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
1250251875Speter/** no space left on device */
1251251875Speter#ifdef EDQUOT
1252251875Speter#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
1253251875Speter                                      || (s) == EDQUOT)
1254251875Speter#else
1255251875Speter#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
1256251875Speter#endif
1257251875Speter/** not enough memory */
1258251875Speter#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
1259251875Speter/** too many open files */
1260251875Speter#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
1261251875Speter/** file table overflow */
1262251875Speter#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
1263251875Speter/** bad file # */
1264251875Speter#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
1265251875Speter/** invalid argument */
1266251875Speter#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
1267251875Speter/** illegal seek */
1268251875Speter#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
1269251875Speter
1270251875Speter/** operation would block */
1271251875Speter#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
1272251875Speter#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
1273251875Speter#elif (EWOULDBLOCK == EAGAIN)
1274251875Speter#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
1275251875Speter#else
1276251875Speter#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
1277251875Speter                                      || (s) == EWOULDBLOCK)
1278251875Speter#endif
1279251875Speter
1280251875Speter/** interrupted system call */
1281251875Speter#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR)
1282251875Speter/** socket operation on a non-socket */
1283251875Speter#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK)
1284251875Speter/** Connection Refused */
1285251875Speter#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED)
1286251875Speter/** operation now in progress */
1287251875Speter#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS)
1288251875Speter
1289251875Speter/**
1290251875Speter * Software caused connection abort
1291251875Speter * @remark
1292251875Speter * EPROTO on certain older kernels really means ECONNABORTED, so we need to
1293251875Speter * ignore it for them.  See discussion in new-httpd archives nh.9701 & nh.9603
1294251875Speter *
1295251875Speter * There is potentially a bug in Solaris 2.x x<6, and other boxes that
1296251875Speter * implement tcp sockets in userland (i.e. on top of STREAMS).  On these
1297251875Speter * systems, EPROTO can actually result in a fatal loop.  See PR#981 for
1298251875Speter * example.  It's hard to handle both uses of EPROTO.
1299251875Speter */
1300251875Speter#ifdef EPROTO
1301251875Speter#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED \
1302251875Speter                                       || (s) == EPROTO)
1303251875Speter#else
1304251875Speter#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED)
1305251875Speter#endif
1306251875Speter
1307251875Speter/** Connection Reset by peer */
1308251875Speter#define APR_STATUS_IS_ECONNRESET(s)      ((s) == APR_ECONNRESET)
1309251875Speter/** Operation timed out
1310251875Speter *  @deprecated */
1311251875Speter#define APR_STATUS_IS_ETIMEDOUT(s)      ((s) == APR_ETIMEDOUT)
1312251875Speter/** no route to host */
1313251875Speter#define APR_STATUS_IS_EHOSTUNREACH(s)    ((s) == APR_EHOSTUNREACH)
1314251875Speter/** network is unreachable */
1315251875Speter#define APR_STATUS_IS_ENETUNREACH(s)     ((s) == APR_ENETUNREACH)
1316362181Sdim/** inappropriate file type or format */
1317251875Speter#define APR_STATUS_IS_EFTYPE(s)          ((s) == APR_EFTYPE)
1318251875Speter/** broken pipe */
1319251875Speter#define APR_STATUS_IS_EPIPE(s)           ((s) == APR_EPIPE)
1320251875Speter/** cross device link */
1321251875Speter#define APR_STATUS_IS_EXDEV(s)           ((s) == APR_EXDEV)
1322251875Speter/** Directory Not Empty */
1323251875Speter#define APR_STATUS_IS_ENOTEMPTY(s)       ((s) == APR_ENOTEMPTY || \
1324251875Speter                                          (s) == APR_EEXIST)
1325251875Speter/** Address Family not supported */
1326251875Speter#define APR_STATUS_IS_EAFNOSUPPORT(s)    ((s) == APR_EAFNOSUPPORT)
1327362181Sdim/** Socket operation not supported */
1328362181Sdim#define APR_STATUS_IS_EOPNOTSUPP(s)      ((s) == APR_EOPNOTSUPP)
1329362181Sdim
1330362181Sdim/** Numeric value not representable */
1331362181Sdim#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
1332251875Speter/** @} */
1333251875Speter
1334251875Speter#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
1335251875Speter
1336251875Speter/** @} */
1337251875Speter
1338251875Speter#ifdef __cplusplus
1339251875Speter}
1340251875Speter#endif
1341251875Speter
1342251875Speter#endif  /* ! APR_ERRNO_H */
1343