]> granicus.if.org Git - apache/commitdiff
Introduce ap_xlate_proto_{to|from}_ascii() to clean up some of
authorJeff Trawick <trawick@apache.org>
Thu, 26 Oct 2000 10:48:28 +0000 (10:48 +0000)
committerJeff Trawick <trawick@apache.org>
Thu, 26 Oct 2000 10:48:28 +0000 (10:48 +0000)
the EBCDIC support.  They are noops on ASCII machines, so this
type of translation doesn't have to be surrounded by #ifdef
CHARSET_EBCDIC.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86751 13f79535-47bb-0310-9956-ffa450edef68

include/util_ebcdic.h
modules/http/http_core.c
server/rfc1413.c
server/util_ebcdic.c

index 8b6c645da51f1d9b48c49e8dec5ae4854ed2d23a..97998237906065bd9942c23f398b8b3d71abe6c7 100644 (file)
@@ -79,10 +79,31 @@ extern "C" {
  */
 apr_status_t ap_init_ebcdic(apr_pool_t *pool);
 
+/**
+ * Convert protocol data from the implementation character
+ * set to ASCII.
+ * @param buffer buffer to translate
+ * @param len number of bytes to translate
+ */
+void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len);
+
+/**
+ * Convert protocol data to the implementation character
+ * set from ASCII.
+ * @param buffer buffer to translate
+ * @param len number of bytes to translate
+ */
+void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len);
+
 #ifdef __cplusplus
 }
 #endif
 
+#else   /* CHARSET_EBCDIC */
+
+#define ap_xlate_proto_to_ascii(x,y)          /* NOOP */
+#define ap_xlate_proto_from_ascii(x,y)        /* NOOP */
+
 #endif  /* CHARSET_EBCDIC */
     
 #endif  /* !APACHE_UTIL_EBCDIC_H */
index 350bad4ee94f85300e32edf5cc2656069c23329b..5d21198ad5c81aef570419e7ba80869559441bf4 100644 (file)
@@ -3279,15 +3279,7 @@ static apr_status_t chunk_filter(ap_filter_t *f, ap_bucket_brigade *b)
             /* XXX might be nice to have APR_OFF_T_FMT_HEX */
             hdr_len = apr_snprintf(chunk_hdr, sizeof(chunk_hdr),
                                    "%qx" CRLF, (apr_uint64_t)bytes);
-#ifdef CHARSET_EBCDIC
-            {
-                apr_size_t inbytes_left = hdr_len, outbytes_left = hdr_len;
-
-                apr_xlate_conv_buffer(ap_hdrs_to_ascii,
-                                      chunk_hdr, &inbytes_left,
-                                      chunk_hdr, &outbytes_left);
-            }
-#endif
+            ap_xlate_proto_to_ascii(chunk_hdr, hdr_len);
             e = ap_bucket_create_transient(chunk_hdr, hdr_len);
             AP_BRIGADE_INSERT_HEAD(b, e);
 
index 7a8cc102f688eff438db1e76337b6edac99a71c1..500553334c3114dd3fdf17ce0483f43e1dcdbfc5 100644 (file)
@@ -119,9 +119,6 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip,
     char *cp;
     char buffer[RFC1413_MAXDATA + 1];
     int buflen;
-#ifdef CHARSET_EBCDIC
-    apr_size_t inbytes_left, outbytes_left;
-#endif
 
     /*
      * Bind the local and remote ends of the query socket to the same
@@ -156,11 +153,7 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip,
 /* send the data */
     buflen = apr_snprintf(buffer, sizeof(buffer), "%u,%u\r\n", sav_rmt_port,
                sav_our_port);
-#ifdef CHARSET_EBCDIC
-    inbytes_left = outbytes_left = buflen;
-    apr_xlate_conv_buffer(ap_hdrs_to_ascii, buffer, &inbytes_left,
-                          buffer, &outbytes_left);
-#endif
+    ap_xlate_proto_to_ascii(buffer, buflen);
 
     /* send query to server. Handle short write. */
     i = 0;
@@ -180,7 +173,7 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip,
 
     /*
      * Read response from server. - the response should be newline 
-     * terminated according to rfc - make sure it doesn't stomp it's
+     * terminated according to rfc - make sure it doesn't stomp its
      * way out of the buffer.
      */
 
@@ -209,11 +202,7 @@ static int get_rfc1413(apr_socket_t *sock, const char *local_ip,
     }
 
 /* RFC1413_USERLEN = 512 */
-#ifdef CHARSET_EBCDIC
-    inbytes_left = outbytes_left = i;
-    apr_xlate_conv_buffer(ap_hdrs_from_ascii, buffer, &inbytes_left,
-                          buffer, &outbytes_left);
-#endif
+    ap_xlate_proto_from_ascii(buffer, i);
     if (sscanf(buffer, "%u , %u : USERID :%*[^:]:%512s", &rmt_port, &our_port,
               user) != 3 || sav_rmt_port != rmt_port
        || sav_our_port != our_port)
index 525ea170ba444f9f4d8805b44a24427da7859352..51830d77c2e1939b10d24363e5fd9fa0582e6fa9 100644 (file)
@@ -123,4 +123,22 @@ apr_status_t ap_init_ebcdic(apr_pool_t *pool)
     return APR_SUCCESS;
 }
 
+void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len)
+{
+    apr_size_t inbytes_left, outbytes_left;
+
+    inbytes_left = outbytes_left = len;
+    apr_xlate_conv_buffer(ap_hdrs_to_ascii, buffer, &inbytes_left,
+                          buffer, &outbytes_left);
+}
+
+void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len)
+{
+    apr_size_t inbytes_left, outbytes_left;
+
+    inbytes_left = outbytes_left = len;
+    apr_xlate_conv_buffer(ap_hdrs_from_ascii, buffer, &inbytes_left,
+                          buffer, &outbytes_left);
+}
+
 #endif /* CHARSET_EBCDIC */