tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hgo...@apache.org
Subject svn commit: r531493 - in /tomcat/connectors/trunk/jk/native/common: jk_connect.c jk_map.c jk_util.c jk_util.h
Date Mon, 23 Apr 2007 15:09:35 GMT
Author: hgomez
Date: Mon Apr 23 08:09:32 2007
New Revision: 531493

URL: http://svn.apache.org/viewvc?view=rev&rev=531493
Log:
More fix for ASCII/EBCDIC fun in i5/OS V5R4

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_connect.c
    tomcat/connectors/trunk/jk/native/common/jk_map.c
    tomcat/connectors/trunk/jk/native/common/jk_util.c
    tomcat/connectors/trunk/jk/native/common/jk_util.h

Modified: tomcat/connectors/trunk/jk/native/common/jk_connect.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_connect.c?view=diff&rev=531493&r1=531492&r2=531493
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_connect.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_connect.c Mon Apr 23 08:09:32 2007
@@ -273,7 +273,7 @@
 
 		/* i5/OS V5R4 need EBCDIC for its runtime calls but APR/APACHE works in UTF */
 #ifdef AS400_UTF8
-        jk_ascii2ebcdic(remote_ipaddr);
+        jk_ascii2ebcdic(remote_ipaddr, remote_ipaddr);
 #endif
         laddr.s_addr = inet_addr(remote_ipaddr);
 
@@ -297,7 +297,7 @@
     else {
 		/* i5/OS V5R4 need EBCDIC for its runtime calls but APR/APACHE works in UTF */
 #ifdef AS400_UTF8
-        jk_ascii2ebcdic((char *)host);
+        jk_ascii2ebcdic((char *)host, (char *)host);
 #endif
         /* If we found only digits we use inet_addr() */
         laddr.s_addr = inet_addr(host);

Modified: tomcat/connectors/trunk/jk/native/common/jk_map.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_map.c?view=diff&rev=531493&r1=531492&r2=531493
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_map.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_map.c Mon Apr 23 08:09:32 2007
@@ -485,7 +485,7 @@
     if (m && f) {
         struct stat statbuf;
         FILE *fp;
-        if ((rc = stat(f, &statbuf)) == -1)
+        if (jk_file_exists(f) != JK_TRUE)
             return JK_FALSE;
 #if defined(AS400) && !defined(AS400_UTF8)
         fp = fopen(f, "r, o_ccsid=0");

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=531493&r1=531492&r2=531493
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Mon Apr 23 08:09:32 2007
@@ -1392,16 +1392,43 @@
 
 int jk_file_exists(const char *f)
 {
+  int   rc;
+  char *ptr;
+
     if (f) {
         struct stat st;
+
 #ifdef AS400
-        if ((0 == stat(f, &st)) && (st.st_mode & _S_IFREG)) {
-#else
-        if ((0 == stat(f, &st)) && (st.st_mode & S_IFREG)) {
-#endif
-            return JK_TRUE;
-        }
+
+/**
+ * i5/OS V5R4 expect filename in ASCII for fopen but required them in EBCDIC for stat()
+ */
+#ifdef AS400_UTF8
+
+		ptr = (char *)malloc(strlen(f) + 1);
+		jk_ascii2ebcdic((char *)f, ptr);
+		rc = stat(ptr, &st);
+		free(ptr);
+
+        if ((0 == rc) && (st.st_mode & _S_IFREG))
+			return JK_TRUE;
+
+#else /* AS400_UTF8 */
+
+        if ((0 == stat(f, &st)) && (st.st_mode & _S_IFREG))
+			return JK_TRUE;
+
+#endif /* AS400_UTF8 */
+
+#else /* AS400 */
+
+        if ((0 == stat(f, &st)) && (st.st_mode & S_IFREG))
+			return JK_TRUE;
+
+#endif /* AS400 */
+
     }
+
     return JK_FALSE;
 }
 
@@ -1755,20 +1782,25 @@
   0x90,0xbd,0xb3,0xda,0xea,0xfa,0x40,0x40  /* f8-ff */
 };
 
-void jk_ascii2ebcdic(char *ptr) {
+void jk_ascii2ebcdic(char *src, char *dst) {
     char c;
 
-    while ((c = *ptr) != 0) {
-        *ptr++ = ascii_to_ebcdic[(unsigned int)c];
+    while ((c = *src++) != 0) {
+        *dst++ = ascii_to_ebcdic[(unsigned int)c];
     }
+
+    *dst = 0;
 }
 
-void jk_ebcdic2ascii(char *ptr) {
+void jk_ebcdic2ascii(char *src, char *dst) {
     char c;
 
-    while ((c = *ptr) != 0) {
-        *ptr++ = ebcdic_to_ascii[(unsigned int)c];
+    while ((c = *src++) != 0) {
+        *dst++ = ebcdic_to_ascii[(unsigned int)c];
     }
+
+    *dst = 0;
 }
+
 #endif
 

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.h?view=diff&rev=531493&r1=531492&r2=531493
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Mon Apr 23 08:09:32 2007
@@ -212,8 +212,8 @@
 #define TC50_BRIDGE_TYPE    50
 
 #ifdef AS400_UTF8
-void jk_ascii2ebcdic(char *ptr);
-void jk_ebcdic2ascii(char *ptr);
+void jk_ascii2ebcdic(char *src, char *dst);
+void jk_ebcdic2ascii(char *src, char *dst);
 #endif
 
 #ifdef __cplusplus



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message