commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r898763 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_error.h os/win32/fsysrw.c shared/error.c test/testsuite.c
Date Wed, 13 Jan 2010 14:18:39 GMT
Author: mturk
Date: Wed Jan 13 14:18:39 2010
New Revision: 898763

URL: http://svn.apache.org/viewvc?rev=898763&view=rev
Log:
For win32 use cononical error codes instead mixing crt and win errors

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysrw.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c
    commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h?rev=898763&r1=898762&r2=898763&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h Wed Jan 13 14:18:39
2010
@@ -776,7 +776,193 @@
  * @addtogroup ACR_Error ACR Error Values
  * @{
  */
-/* ACR CANONICAL ERROR VALUES */
+#if defined(WIN32)
+/* Windows ACR CANONICAL ERROR VALUES */
+/** Operation not permitted */
+#define ACR_EPERM               (ACR_OS_START_CANONERR +  1)
+/** No such file or directory */
+#define ACR_ENOENT              (ACR_OS_START_CANONERR +  2)
+/** No such process */
+#define ACR_ESRCH               (ACR_OS_START_CANONERR +  3)
+/** Interrupted system call */
+#define ACR_EINTR               (ACR_OS_START_CANONERR +  4)
+/** Input/output error */
+#define ACR_EIO                 (ACR_OS_START_CANONERR +  5)
+/** Device not configured */
+#define ACR_ENXIO               (ACR_OS_START_CANONERR +  6)
+/** Argument list too long */
+#define ACR_E2BIG               (ACR_OS_START_CANONERR +  7)
+/** Exec format error */
+#define ACR_ENOEXEC             (ACR_OS_START_CANONERR +  8)
+/** Bad file descriptor */
+#define ACR_EBADF               (ACR_OS_START_CANONERR +  9)
+/** No child processes */
+#define ACR_ECHILD              (ACR_OS_START_CANONERR + 10)
+/** Resource deadlock avoided */
+#define ACR_EDEADLK             (ACR_OS_START_CANONERR + 11)
+/** Cannot allocate memory */
+#define ACR_ENOMEM              (ACR_OS_START_CANONERR + 12)
+/** Permission denied */
+#define ACR_EACCES              (ACR_OS_START_CANONERR + 13)
+/** Bad address */
+#define ACR_EFAULT              (ACR_OS_START_CANONERR + 14)
+/** Block device required */
+#define ACR_ENOTBLK             (ACR_OS_START_CANONERR + 15)
+/** Device busy */
+#define ACR_EBUSY               (ACR_OS_START_CANONERR + 16)
+/** File exists */
+#define ACR_EEXIST              (ACR_OS_START_CANONERR + 17)
+/** Cross-device link */
+#define ACR_EXDEV               (ACR_OS_START_CANONERR + 18)
+/** Operation not supported by device */
+#define ACR_ENODEV              (ACR_OS_START_CANONERR + 19)
+/** Not a directory */
+#define ACR_ENOTDIR             (ACR_OS_START_CANONERR + 20)
+/** Is a directory */
+#define ACR_EISDIR              (ACR_OS_START_CANONERR + 21)
+/** Invalid argument */
+#define ACR_EINVAL              (ACR_OS_START_CANONERR + 22)
+/** Too many open files in system */
+#define ACR_ENFILE              (ACR_OS_START_CANONERR + 23)
+/** Too many open files */
+#define ACR_EMFILE              (ACR_OS_START_CANONERR + 24)
+/** Inappropriate ioctl for device */
+#define ACR_ENOTTY              (ACR_OS_START_CANONERR + 25)
+/** Text file busy */
+#define ACR_ETXTBSY             (ACR_OS_START_CANONERR + 26)
+/** File too large */
+#define ACR_EFBIG               (ACR_OS_START_CANONERR + 27)
+/** No space left on device */
+#define ACR_ENOSPC              (ACR_OS_START_CANONERR + 28)
+/** Illegal seek */
+#define ACR_ESPIPE              (ACR_OS_START_CANONERR + 29)
+/** Read-only file system */
+#define ACR_EROFS               (ACR_OS_START_CANONERR + 30)
+/** Too many links */
+#define ACR_EMLINK              (ACR_OS_START_CANONERR + 31)
+/** Broken pipe */
+#define ACR_EPIPE               (ACR_OS_START_CANONERR + 32)
+/** Numerical argument out of domain */
+#define ACR_EDOM                (ACR_OS_START_CANONERR + 33)
+/** Result too large */
+#define ACR_ERANGE              (ACR_OS_START_CANONERR + 34)
+/** Resource temporarily unavailable */
+#define ACR_EAGAIN              (ACR_OS_START_CANONERR + 35)
+/** Operation would block */
+#define ACR_EWOULDBLOCK         (ACR_OS_START_CANONERR + 35)
+/** Operation now in progress */
+#define ACR_EINPROGRESS         (ACR_OS_START_CANONERR + 36)
+/** Operation already in progress */
+#define ACR_EALREADY            (ACR_OS_START_CANONERR + 37)
+/** Socket operation on non-socket */
+#define ACR_ENOTSOCK            (ACR_OS_START_CANONERR + 38)
+/** Destination address required */
+#define ACR_EDESTADDRREQ        (ACR_OS_START_CANONERR + 39)
+/** Message too long */
+#define ACR_EMSGSIZE            (ACR_OS_START_CANONERR + 40)
+/** Protocol wrong type for socket */
+#define ACR_EPROTOTYPE          (ACR_OS_START_CANONERR + 41)
+/** Protocol not available */
+#define ACR_ENOPROTOOPT         (ACR_OS_START_CANONERR + 42)
+/** Protocol not supported */
+#define ACR_EPROTONOSUPPORT     (ACR_OS_START_CANONERR + 43)
+/** Socket type not supported */
+#define ACR_ESOCKTNOSUPPORT     (ACR_OS_START_CANONERR + 44)
+/** Operation not supported */
+#define ACR_EOPNOTSUPP          (ACR_OS_START_CANONERR + 45)
+/** Protocol family not supported */
+#define ACR_EPFNOSUPPORT        (ACR_OS_START_CANONERR + 46)
+/** Address family not supported by protocol family */
+#define ACR_EAFNOSUPPORT        (ACR_OS_START_CANONERR + 47)
+/** Address already in use */
+#define ACR_EADDRINUSE          (ACR_OS_START_CANONERR + 48)
+/** Can't assign requested address */
+#define ACR_EADDRNOTAVAIL       (ACR_OS_START_CANONERR + 49)
+/** Network is down */
+#define ACR_ENETDOWN            (ACR_OS_START_CANONERR + 50)
+/** Network is unreachable */
+#define ACR_ENETUNREACH         (ACR_OS_START_CANONERR + 51)
+/** Network dropped connection on reset */
+#define ACR_ENETRESET           (ACR_OS_START_CANONERR + 52)
+/** Software caused connection abort */
+#define ACR_ECONNABORTED        (ACR_OS_START_CANONERR + 53)
+/** Connection reset by peer */
+#define ACR_ECONNRESET          (ACR_OS_START_CANONERR + 54)
+/** No buffer space available */
+#define ACR_ENOBUFS             (ACR_OS_START_CANONERR + 55)
+/** Socket is already connected */
+#define ACR_EISCONN             (ACR_OS_START_CANONERR + 56)
+/** Socket is not connected */
+#define ACR_ENOTCONN            (ACR_OS_START_CANONERR + 57)
+/** Can't send after socket shutdown */
+#define ACR_ESHUTDOWN           (ACR_OS_START_CANONERR + 58)
+/** Too many references: can't splice */
+#define ACR_ETOOMANYREFS        (ACR_OS_START_CANONERR + 59)
+/** Operation timed out */
+#define ACR_ETIMEDOUT           (ACR_OS_START_CANONERR + 60)
+/** Connection refused */
+#define ACR_ECONNREFUSED        (ACR_OS_START_CANONERR + 61)
+/** Too many levels of symbolic links */
+#define ACR_ELOOP               (ACR_OS_START_CANONERR + 62)
+/** File name too long */
+#define ACR_ENAMETOOLONG        (ACR_OS_START_CANONERR + 63)
+/** Host is down */
+#define ACR_EHOSTDOWN           (ACR_OS_START_CANONERR + 64)
+/** No route to host */
+#define ACR_EHOSTUNREACH        (ACR_OS_START_CANONERR + 65)
+/** Directory not empty */
+#define ACR_ENOTEMPTY           (ACR_OS_START_CANONERR + 66)
+/** Too many processes */
+#define ACR_EPROCLIM            (ACR_OS_START_CANONERR + 67)
+/** Too many users */
+#define ACR_EUSERS              (ACR_OS_START_CANONERR + 68)
+/** Disk quota exceeded */
+#define ACR_EDQUOT              (ACR_OS_START_CANONERR + 69)
+/** Stale NFS file handle */
+#define ACR_ESTALE              (ACR_OS_START_CANONERR + 70)
+/** Too many levels of remote in path */
+#define ACR_EREMOTE             (ACR_OS_START_CANONERR + 71)
+/** RPC struct is bad */
+#define ACR_EBADRPC             (ACR_OS_START_CANONERR + 72)
+/** RPC version wrong */
+#define ACR_ERPCMISMATCH        (ACR_OS_START_CANONERR + 73)
+/** RPC prog. not avail */
+#define ACR_EPROGUNAVAIL        (ACR_OS_START_CANONERR + 74)
+/** Program version wrong */
+#define ACR_EPROGMISMATCH       (ACR_OS_START_CANONERR + 75)
+/** Bad procedure for program */
+#define ACR_EPROCUNAVAIL        (ACR_OS_START_CANONERR + 76)
+/** No locks available */
+#define ACR_ENOLCK              (ACR_OS_START_CANONERR + 77)
+/** Function not implemented */
+#define ACR_ENOSYS              (ACR_OS_START_CANONERR + 78)
+/** Inappropriate file type or format */
+#define ACR_EFTYPE              (ACR_OS_START_CANONERR + 79)
+/** Authentication error */
+#define ACR_EAUTH               (ACR_OS_START_CANONERR + 80)
+/** Need authenticator */
+#define ACR_ENEEDAUTH           (ACR_OS_START_CANONERR + 81)
+/** IPsec processing failure */
+#define ACR_EIPSEC              (ACR_OS_START_CANONERR + 82)
+/** Attribute not found */
+#define ACR_ENOATTR             (ACR_OS_START_CANONERR + 83)
+/** Illegal byte sequence */
+#define ACR_EILSEQ              (ACR_OS_START_CANONERR + 84)
+/** No medium found */
+#define ACR_ENOMEDIUM           (ACR_OS_START_CANONERR + 85)
+/** Wrong Medium Type */
+#define ACR_EMEDIUMTYPE         (ACR_OS_START_CANONERR + 86)
+/** Conversion overflow */
+#define ACR_EOVERFLOW           (ACR_OS_START_CANONERR + 87)
+/** Operation canceled */
+#define ACR_ECANCELED           (ACR_OS_START_CANONERR + 88)
+/** Identifier removed */
+#define ACR_EIDRM               (ACR_OS_START_CANONERR + 89)
+/** No message of desired type */
+#define ACR_ENOMSG              (ACR_OS_START_CANONERR + 90)
+
+#else
+/* Posix ACR CANONICAL ERROR VALUES */
 /** Operation not permitted */
 #ifndef EPERM
 #define ACR_EPERM               (ACR_OS_START_CANONERR +  1)
@@ -1324,8 +1510,9 @@
 #define ACR_ENOMSG ENOMSG
 #endif
 
-#define ACR_OS_LAST_CANONERR    (ACR_OS_START_CANONERR + 91)
+#endif
 
+#define ACR_OS_LAST_CANONERR    (ACR_OS_START_CANONERR + 91)
 /** @} */
 
 #if defined(WIN32) && !defined(DOXYGEN)

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysrw.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysrw.c?rev=898763&r1=898762&r2=898763&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysrw.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/fsysrw.c Wed Jan 13 14:18:39 2010
@@ -33,12 +33,11 @@
 
 static DWORD overlapped_wait(acr_file_t *f, DWORD *nbytes)
 {
-    DWORD ws;
     DWORD rc = 0;
 
     do {
-        switch (ws = ACR_WaitForObjectOrSignal(f->overlap.hEvent,
-                                               f->timeout)) {
+        switch (ACR_WaitForObjectOrSignal(f->overlap.hEvent,
+                                          f->timeout)) {
             case WAIT_IO_COMPLETION:
             case WAIT_ABANDONED_0:
             case WAIT_ABANDONED_1:
@@ -87,11 +86,10 @@
 
 static DWORD overlapped_wait_all(acr_file_t *f, DWORD *nbytes)
 {
-    DWORD ws;
     DWORD rc = 0;
 
     do {
-        switch (ws = ACR_WaitForObjectOrSignal(f->overlap.hEvent, INFINITE)) {
+        switch (ACR_WaitForObjectOrSignal(f->overlap.hEvent, INFINITE)) {
             case WAIT_IO_COMPLETION:
             case WAIT_ABANDONED_0:
             case WAIT_ABANDONED_1:
@@ -2806,7 +2804,7 @@
             }
         }
         else {
-            switch (rc = GetLastError()) {
+            switch ((rc = GetLastError())) {
                 case ERROR_IO_PENDING:
                     if ((rc = overlapped_wait_all(f, &wr)) == 0) {
                         if (wr) {

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=898763&r1=898762&r2=898763&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Wed Jan 13 14:18:39 2010
@@ -543,17 +543,13 @@
 }
 
 
-static char *acr_os_strerror(char *buf, acr_size_t bufsize, int errcode)
-{
-    snprintf(buf, bufsize, "Unrecognized Win32 error code %d", errcode);
-    return buf;
-}
+#define acr_os_strerror native_strerror
 
 #else
 /* On Unix, apr_os_strerror() handles error codes from the resolver
  * (h_errno).
  */
-static char *acr_os_strerror(char* buf, acr_size_t bufsize, int err)
+static char *acr_os_strerror(char *buf, acr_size_t bufsize, int err)
 {
 #if !defined(HPUX11)
     return stuffbuffer(buf, bufsize, hstrerror(err));
@@ -585,8 +581,7 @@
 #endif
 
 #if defined (WIN32)
-static char *native_strerror(int statcode, char *buf,
-                             acr_size_t bufsize)
+static char *native_strerror(char *buf, acr_size_t bufsize, int statcode)
 {
     DWORD len = 0;
     int i;
@@ -630,8 +625,7 @@
 }
 #elif HAVE_STRERROR_R
 /* glibc style */
-static char *native_strerror(int statcode, char *buf,
-                             acr_size_t bufsize)
+static char *native_strerror(char *buf, acr_size_t bufsize, int statcode)
 {
 #ifdef _GNU_SOURCE
     const char *msg;
@@ -654,8 +648,7 @@
 /* plain old strerror();
  * thread-safe on some platforms (e.g., Solaris, OS/390)
  */
-static char *native_strerror(int statcode, char *buf,
-                             acr_size_t bufsize)
+static char *native_strerror(char *buf, acr_size_t bufsize, int statcode)
 {
     const char *err = strerror(statcode);
     if (err) {
@@ -674,7 +667,7 @@
         return buf;
     }
     else if (statcode < ACR_OS_START_ERROR) {
-        return native_strerror(statcode, buf, bufsize);
+        return native_strerror(buf, bufsize, statcode);
     }
     else if (statcode < ACR_OS_START_USERERR) {
         return stuffbuffer(buf, bufsize, acr_error_string(statcode));
@@ -906,7 +899,7 @@
 
 ACR_JNI_EXPORT_DECLARE(jstring, io_Status, describe)(ACR_JNISTDARGS, jint err)
 {
-    char buf[512];
-    return ACR_NewJavaStringA(_E, acr_os_strerror(buf, sizeof(buf), err));
+    char buf[1024];
+    return ACR_NewJavaStringA(_E, ACR_GetErrorString(err, buf, sizeof(buf)));
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=898763&r1=898762&r2=898763&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Wed Jan 13 14:18:39 2010
@@ -75,6 +75,26 @@
     {NULL,                                 0,   NULL,     0, NULL }
 };
 
+static int test_errors(int argc, const char *const argv[])
+{
+    char buf[512];
+
+#define PRINT_ERROR(E)  \
+    printf("%-25s%8d %s\n", #E, E, ACR_GetErrorString(E, buf, sizeof(buf)))
+
+    printf("ACR_OS_START_USERERR       %d\n", ACR_OS_START_USERERR);
+    printf("ACR_OS_START_EAIERR        %d\n", ACR_OS_START_EAIERR);
+    PRINT_ERROR(ACR_EINVAL);
+    PRINT_ERROR(ACR_EFAULT);
+    PRINT_ERROR(ACR_EINTR);
+    PRINT_ERROR(ACR_EAGAIN);
+    PRINT_ERROR(ACR_EWOULDBLOCK);
+    PRINT_ERROR(ACR_EINPROGRESS);
+    PRINT_ERROR(ACR_EALREADY);
+
+    return 0;
+}
+
 static int test_getenv(int argc, const char *const argv[])
 {
     int failed = 0;
@@ -674,7 +694,7 @@
     }
     ap = args;
     while(*ap) {
-        fprintf(stdout, "ARG : %S.\n", *ap);    
+        fprintf(stdout, "ARG : %S.\n", *ap);
         ap++;
     }
     ACR_Afree(INVALID_HANDLE_VALUE, THROW_FMARK, args);
@@ -746,6 +766,9 @@
         if (!strcasecmp(run_test, "all")) {
 
         }
+        else if (!strcasecmp(run_test, "errors")) {
+            rv = test_errors(argc, argv);
+        }
         else if (!strcasecmp(run_test, "getenv")) {
             rv = test_getenv(argc, argv);
         }
@@ -799,7 +822,7 @@
             rv = test_registry(argc, argv);
         }
 
-#endif        
+#endif
     }
 
 cleanup:



Mime
View raw message