2
0

fspr_errno.h 50 KB

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