tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hgo...@apache.org
Subject svn commit: r531392 - in /tomcat/connectors/trunk/jk/native/common: jk_util.c jk_util.h
Date Mon, 23 Apr 2007 09:20:33 GMT
Author: hgomez
Date: Mon Apr 23 02:20:32 2007
New Revision: 531392

URL: http://svn.apache.org/viewvc?view=rev&rev=531392
Log:
in i5/OS V5R4 all APR/Apache APIs are in UTF8 but the runtime apis like inet_addr() still
need EBCDIC.
Add basic ASCII<->EBCDIC conversion

Modified:
    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_util.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=531392&r1=531391&r2=531392
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Mon Apr 23 02:20:32 2007
@@ -1672,3 +1672,103 @@
 #endif /* AS400 */
 }
 #endif
+
+/***
+ * ASCII <-> EBCDIC conversions
+ *
+ * For now usefull only in i5/OS V5R4 where UTF and EBCDIC mode are mixed
+ */
+
+#if defined(AS400) && !defined(AS400_UTF8)
+
+/* EBCDIC to ASCII translation table */
+static u_char ebcdic_to_ascii[256] =
+{
+  0x00,0x01,0x02,0x03,0x20,0x09,0x20,0x7f, /* 00-07 */
+  0x20,0x20,0x20,0x0b,0x0c,0x0d,0x0e,0x0f, /* 08-0f */
+  0x10,0x11,0x12,0x13,0x20,0x0a,0x08,0x20, /* 10-17 */
+  0x18,0x19,0x20,0x20,0x20,0x1d,0x1e,0x1f, /* 18-1f */
+  0x20,0x20,0x1c,0x20,0x20,0x0a,0x17,0x1b, /* 20-27 */
+  0x20,0x20,0x20,0x20,0x20,0x05,0x06,0x07, /* 28-2f */
+  0x20,0x20,0x16,0x20,0x20,0x20,0x20,0x04, /* 30-37 */
+  0x20,0x20,0x20,0x20,0x14,0x15,0x20,0x1a, /* 38-3f */
+  0x20,0x20,0x83,0x84,0x85,0xa0,0xc6,0x86, /* 40-47 */
+  0x87,0xa4,0xbd,0x2e,0x3c,0x28,0x2b,0x7c, /* 48-4f */
+  0x26,0x82,0x88,0x89,0x8a,0xa1,0x8c,0x8b, /* 50-57 */
+  0x8d,0xe1,0x21,0x24,0x2a,0x29,0x3b,0xaa, /* 58-5f */
+  0x2d,0x2f,0xb6,0x8e,0xb7,0xb5,0xc7,0x8f, /* 60-67 */
+  0x80,0xa5,0xdd,0x2c,0x25,0x5f,0x3e,0x3f, /* 68-6f */
+  0x9b,0x90,0xd2,0xd3,0xd4,0xd6,0xd7,0xd8, /* 70-77 */
+  0xde,0x60,0x3a,0x23,0x40,0x27,0x3d,0x22, /* 78-7f */
+  0x9d,0x61,0x62,0x63,0x64,0x65,0x66,0x67, /* 80-87 */
+  0x68,0x69,0xae,0xaf,0xd0,0xec,0xe7,0xf1, /* 88-8f */
+  0xf8,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70, /* 90-97 */
+  0x71,0x72,0xa6,0xa7,0x91,0xf7,0x92,0xcf, /* 98-9f */
+  0xe6,0x7e,0x73,0x74,0x75,0x76,0x77,0x78, /* a8-a7 */
+  0x79,0x7a,0xad,0xa8,0xd1,0xed,0xe8,0xa9, /* a8-af */
+  0x5e,0x9c,0xbe,0xfa,0xb8,0x15,0x14,0xac, /* b0-b7 */
+  0xab,0xf3,0x5b,0x5d,0xee,0xf9,0xef,0x9e, /* b8-bf */
+  0x7b,0x41,0x42,0x43,0x44,0x45,0x46,0x47, /* c0-c7 */
+  0x48,0x49,0xf0,0x93,0x94,0x95,0xa2,0xe4, /* c8-cf */
+  0x7d,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50, /* d0-d7 */
+  0x51,0x52,0xfb,0x96,0x81,0x97,0xa3,0x98, /* d8-df */
+  0x5c,0xf6,0x53,0x54,0x55,0x56,0x57,0x58, /* e0-e7 */
+  0x59,0x5a,0xfc,0xe2,0x99,0xe3,0xe0,0xe5, /* e8-ef */
+  0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, /* f0-f7 */
+  0x38,0x39,0xfd,0xea,0x9a,0xeb,0xe9,0xff  /* f8-ff */
+};
+
+/* ASCII to EBCDIC translation table */
+static u_char ascii_to_ebcdic[256] =
+{
+  0x00,0x01,0x02,0x03,0x37,0x2d,0x2e,0x2f, /* 00-07 */
+  0x16,0x05,0x25,0x0b,0x0c,0x0d,0x0e,0x0f, /* 08-0f */
+  0x10,0x11,0x12,0x13,0x3c,0x3d,0x32,0x26, /* 10-17 */
+  0x18,0x19,0x3f,0x27,0x22,0x1d,0x1e,0x1f, /* 18-1f */
+  0x40,0x5a,0x7f,0x7b,0x5b,0x6c,0x50,0x7d, /* 20-27 */
+  0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x4b,0x61, /* 28-2f */
+  0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7, /* 30-37 */
+  0xf8,0xf9,0x7a,0x5e,0x4c,0x7e,0x6e,0x6f, /* 38-3f */
+  0x7c,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7, /* 40-47 */
+  0xc8,0xc9,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6, /* 48-4f */
+  0xd7,0xd8,0xd9,0xe2,0xe3,0xe4,0xe5,0xe6, /* 50-57 */
+  0xe7,0xe8,0xe9,0xba,0xe0,0xbb,0xb0,0x6d, /* 58-5f */
+  0x79,0x81,0x82,0x83,0x84,0x85,0x86,0x87, /* 60-67 */
+  0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96, /* 68-6f */
+  0x97,0x98,0x99,0xa2,0xa3,0xa4,0xa5,0xa6, /* 70-77 */
+  0xa7,0xa8,0xa9,0xc0,0x4f,0xd0,0xa1,0x07, /* 78-7f */
+  0x68,0xdc,0x51,0x42,0x43,0x44,0x47,0x48, /* 80-87 */
+  0x52,0x53,0x54,0x57,0x56,0x58,0x63,0x67, /* 88-8f */
+  0x71,0x9c,0x9e,0xcb,0xcc,0xcd,0xdb,0xdd, /* 90-97 */
+  0xdf,0xec,0xfc,0x70,0xb1,0x80,0xbf,0x40, /* 98-9f */
+  0x45,0x55,0xee,0xde,0x49,0x69,0x9a,0x9b, /* a8-a7 */
+  0xab,0xaf,0x5f,0xb8,0xb7,0xaa,0x8a,0x8b, /* a8-af */
+  0x40,0x40,0x40,0x40,0x40,0x65,0x62,0x64, /* b0-b7 */
+  0xb4,0x40,0x40,0x40,0x40,0x4a,0xb2,0x40, /* b8-bf */
+  0x40,0x40,0x40,0x40,0x40,0x40,0x46,0x66, /* c0-c7 */
+  0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x9f, /* c8-cf */
+  0x8c,0xac,0x72,0x73,0x74,0x89,0x75,0x76, /* d0-d7 */
+  0x77,0x40,0x40,0x40,0x40,0x6a,0x78,0x40, /* d8-df */
+  0xee,0x59,0xeb,0xed,0xcf,0xef,0xa0,0x8e, /* e0-e7 */
+  0xae,0xfe,0xfb,0xfd,0x8d,0xad,0xbc,0xbe, /* e8-ef */
+  0xca,0x8f,0x40,0xb9,0xb6,0xb5,0xe1,0x9d, /* f0-f7 */
+  0x90,0xbd,0xb3,0xda,0xea,0xfa,0x40,0x40  /* f8-ff */
+};
+
+void jk_ascii2ebcdic(char *ptr) {
+    char c;
+
+    while ((c = *ptr) != 0) {
+        *ptr++ = ascii_to_ebcdic[(unsigned int)c];
+    }
+}
+
+void jk_ebcdic2ascii(char *ptr) {
+    char c;
+
+    while ((c = *ptr) != 0) {
+        *ptr++ = ebcdic_to_ascii[(unsigned int)c];
+    }
+}
+#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=531392&r1=531391&r2=531392
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Mon Apr 23 02:20:32 2007
@@ -211,6 +211,11 @@
 #define TC41_BRIDGE_TYPE    41
 #define TC50_BRIDGE_TYPE    50
 
+#if defined(AS400) && !defined(AS400_UTF8)
+void jk_ascii2ebcdic(char *ptr);
+void jk_ebcdic2ascii(char *ptr);
+#endif
+
 #ifdef __cplusplus
 extern "C"
 {



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


Mime
View raw message