httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <trawi...@bellsouth.net>
Subject [PATCH] encoding of different error types in ap_status_t
Date Sat, 01 Apr 2000 21:36:43 GMT
Some useful macros recently discussed (e.g., macro to tell if an
ap_status_t value is an OS error, macro to retrieve OS error from
ap_status_t) are not in this patch and should be added later.

This patch should handle UNIX (handled already, really), Win32, 
and OS/2, and probably any other systems unless they have bizarre
requirements like Win32.

In addition, it fixes some bugs in the definition of
APR_EHOSTNOTFOUND, APR_ENODATA, APR_ENOADDRESS, and APR_ENORECOVERY.

Index: lib/apr/include/apr_errno.h
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/include/apr_errno.h,v
retrieving revision 1.16
diff -u -u -r1.16 apr_errno.h
--- apr_errno.h	2000/03/31 08:35:55	1.16
+++ apr_errno.h	2000/04/01 21:39:26
@@ -66,11 +66,27 @@
 extern "C" {
 #endif /* __cplusplus */
 
-/* Define four layers of status code offsets so that we don't interfere
- * with the predefined errno codes on the operating system.  Codes beyond
- * APR_OS_START_USEERR are reserved for applications that use APR that
- * layer their own error codes along with APR's.
+typedef int ap_status_t;
+
+char *ap_strerror(ap_status_t status, char *buf, size_t buf_size);
+
+/* Define five layers of status code offsets so that we don't interfere
+ * with the predefined errno codes on the operating system.  
+ * 
+ * For platforms such as Windows and OS/2 which have OS-specific error 
+ * codes:
+ * 
+ * Codes between APR_OS_START_USEERR and APR_OS_START_OSERR are reserved 
+ * for applications that use APR that layer their own error codes along 
+ * with APR's.
+ *
+ * For platforms such as UNIX where the system uses errno:
+ *
+ * APR_OS_START_OSERR is not used, so codes beyond APR_OS_START_USEERR are 
+ * reserved for applications that use APR that layer their own error codes 
+ * along with APR's.
  */
+
 #ifndef APR_OS_START_ERROR
 #define APR_OS_START_ERROR   4000
 #endif
@@ -84,11 +100,20 @@
 #define APR_OS_START_USEERR  (APR_OS_START_SYSERR + 500)
 #endif
 
-/* If this definition of APRStatus changes, then we can remove this, but right
- * now, the decision was to use an errno-like implementation.
- */
-typedef int ap_status_t;
+#ifndef APR_OS_START_OSERR      
 
+#ifdef WIN32
+#define APR_OS_START_OSERR      0x20000000
+#else
+#define APR_OS_START_OSERR      (APR_START_USEERR + 30000)
+#endif
+
+#endif /* WIN32 */
+
+#ifndef APR_STATUS_FROM_OSERR
+#define APR_STATUS_FROM_OSERR(err) ((err) + APR_OS_START_OSERR)
+#endif
+
 #define APR_SUCCESS 0
 
 /* APR ERROR VALUES */
@@ -366,29 +391,20 @@
 #define APR_EOPNOTSUPP (APR_OS_START_SYSERR + 35)
 #endif
 
-#ifdef HOST_NOT_FOUND
-#define APR_EHOSTNOTFOUND HOST_NOT_FOUND
-#else
+/* never use h_errno values as-is because doing so makes them 
+ * indistinguishable from errno values
+ * APR_EHOSTNOTFOUND corresponds to HOST_NOT_FOUND
+ * APR_ENODATA corresponds to NO_DATA
+ * APR_ENOADDRESS corresponds to NO_ADDRESS
+ * APR_ENORECOVERY corresponds to NO_RECOVERY
+ */
 #define APR_EHOSTNOTFOUND (APR_OS_START_SYSERR + 36)
-#endif
 
-#ifdef NO_DATA
-#define APR_ENODATA NO_DATA
-#else
 #define APR_ENODATA (APR_OS_START_SYSERR + 37)
-#endif
 
-#ifdef NO_ADDRESS
-#define APR_ENOADDRESS NO_ADDRESS
-#else
 #define APR_ENOADDRESS (APR_OS_START_SYSERR + 38)
-#endif
 
-#ifdef NO_RECOVERY
-#define APR_ENORECOVERY NO_RECOVERY
-#else
 #define APR_ENORECOVERY (APR_OS_START_SYSERR + 39)
-#endif
 
 #ifdef EISCONN
 #define APR_EISCONN EISCONN


-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Mime
View raw message