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