]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
I added configurable EBCDIC configuration functionality to http_core.c;
authorMartin Kraemer <martin@apache.org>
Fri, 9 Mar 2001 10:10:55 +0000 (10:10 +0000)
committerMartin Kraemer <martin@apache.org>
Fri, 9 Mar 2001 10:10:55 +0000 (10:10 +0000)
because conversion is a base feature, this looked like the only sensible
place to me. Other basic features like Resource limits live there too.

* make EBCDIC conversion truly configurable. Up to know, there was a
  hardwired assumption that only files of MIME type text/* (and a few
  exceptions) could be EBCDIC files; and everything else HAD TO BE
  binary. This assumption breaks (again and again) for MIME types like
  application/postscript, model/vrml, application/x-javascript and
  others, which can never be stored as EBCDIC text files.
  I now implemented two new directives for defining the conversion
  based on MIME type or file extension. The conversion can be set for
  upload and download independently, on or off, for any file.

* make EBCDIC conversion symmetric. Up to now, there was no clean way
  to deal with uploaded content (POST with Content-Type:, PUT with
  Content-Type:) because a) there was no MIME checker attached to the
  header-reader, and b) you could not actually define a conversion
  based on MIME type. Both deficiencies have now been addressed (the
  ap_checkconv_in() routine is called upon parsing of an uploaded
  Content-Type: line, and it can set a flag which is different from
  the download conversion flag. Also, its change is triggered at a
  different phase in the request handling: the upload conversion
  is set as soon as a Content-Type: for an uploaded document is
  detected, but the download conversion is only set when the
  response is about to be returned). All this was impossible in the
  past.

* unify the EBCDIC tables to be in a single common file
  src/ap/ap_ebcdic.c (and src/include/ap_ebcdic.h) instead
  of having redundant copies under src/os/{tpf,bs2000,os390}/ebcdic.{c,h}
  The common file will have the correct translation table
  conditionally compiled based on #ifdef TPF/OS390/_OSD_POSIX.
  Up to now, each EBCDIC had its own copy, cloned and slightly
  adapted.

* Also, put the conversion checker ap_checkconv() to http_core,
  because is is an essential central cog in the whole conversion
  clockwork. Until now, three almost incompatible copies were
  spread throughout the EBCDIC platforms' os.c files.

Reviewed by: "David McCreedy" <mccreedy@us.ibm.com>

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@88479 13f79535-47bb-0310-9956-ffa450edef68

38 files changed:
conf/httpd.conf-dist
src/CHANGES
src/ap/Makefile.tmpl
src/ap/ap_base64.c
src/ap/ap_ebcdic.c [new file with mode: 0644]
src/ap/ap_md5c.c
src/ap/ap_sha1.c
src/include/ap_ebcdic.h [new file with mode: 0644]
src/include/http_core.h
src/include/httpd.h
src/main/http_core.c
src/main/http_protocol.c
src/main/http_request.c
src/modules/example/mod_example.c
src/modules/proxy/proxy_ftp.c
src/modules/standard/mod_autoindex.c
src/modules/standard/mod_cgi.c
src/modules/standard/mod_imap.c
src/modules/standard/mod_info.c
src/modules/standard/mod_status.c
src/modules/test/mod_rndchunk.c
src/modules/test/mod_test_util_uri.c
src/os/bs2000/Makefile.tmpl
src/os/bs2000/ebcdic.c
src/os/bs2000/ebcdic.h
src/os/bs2000/os.c
src/os/bs2000/os.h
src/os/os390/Makefile.tmpl
src/os/os390/ebcdic.c
src/os/os390/ebcdic.h
src/os/os390/os.c
src/os/os390/os.h
src/os/tpf/Makefile.tmpl
src/os/tpf/ebcdic.c
src/os/tpf/ebcdic.h
src/os/tpf/os.c
src/os/tpf/os.h
src/support/ab.c

index 4c98d4a50cb4422850f9c203da0569af0f7d4b47..8bfe50452d6f0cd45cbd13a702c4c56eb14f4554 100644 (file)
@@ -499,6 +499,29 @@ CustomLog logs/access_log common
 #
 ServerSignature On
 
+# EBCDIC configuration:
+# (only for mainframes using the EBCDIC codeset, currently one of:
+# Fujitsu-Siemens' BS2000/OSD, IBM's OS/390 and IBM's TPF)!!
+# The following default configuration assumes that "text files"
+# are stored in EBCDIC (so that you can operate on them using the
+# normal POSIX tools like grep and sort) while "binary files" are
+# stored with identical octets as on an ASCII machine.
+#
+# The directives are evaluated in configuration file order, with
+# the EBCDICConvert directives applied before EBCDICConvertByType.
+#
+# If you want to have ASCII HTML documents and EBCDIC HTML documents
+# at the same time, you can use the file extension to force
+# conversion off for the ASCII documents:
+# > AddType       text/html .ahtml
+# > EBCDICConvert Off=InOut .ahtml
+#
+# EBCDICConvertByType  On=InOut text/* message/* multipart/*
+# EBCDICConvertByType  On=In    application/x-www-form-urlencoded
+# EBCDICConvertByType  On=InOut application/postscript model/vrml
+# EBCDICConvertByType Off=InOut */*
+
+
 #
 # Aliases: Add here as many aliases as you need (with no limit). The format is 
 # Alias fakename realname
index 99bcc3808372900c5e86ce65c64bab8484e9ea1d..9899ae1e65689c0657b9dc460c00861232ffc4ec 100644 (file)
@@ -1,5 +1,12 @@
 Changes with Apache 1.3.20
 
+  *) Make EBCDIC conversion fully configurable. Until now, apache relied
+     on some (incomplete) heuristics, and would fail to correctly serve
+     text files when they had a MIME type of application/anything, like
+     application/x-javascript. The new conversion directives allow
+     defining the conversion based on MIME type or file suffix.
+     [Martin Kraemer]
+
   *) Add a -V flag to suexec, which causes it to display the
      compile-time settings with which it was built.  (Only
      usable by root or the HTTPD_USER username.)  [Ken Coar]
index fcb167bfad6cee9ea8c57e405939f63fe820f7e5..9606f2d33059e43a03d8b36363d509ac44929f66 100644 (file)
@@ -6,7 +6,7 @@ LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
 LIB=libap.a
 
 OBJS=ap_cpystrn.o ap_execve.o ap_fnmatch.o ap_getpass.o ap_md5c.o ap_signal.o \
-     ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o
+     ap_slack.o ap_snprintf.o ap_sha1.o ap_checkpass.o ap_base64.o ap_ebcdic.o
 
 .c.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $<
index 1066e524ea6dd6a8a2f31845b4830ff39256000d..2f5a597d048da648e16119a1c4a791d62261c034 100644 (file)
@@ -68,7 +68,7 @@
 #include "ap.h"
 
 #ifdef CHARSET_EBCDIC
-#include "ebcdic.h"
+#include "ap_ebcdic.h"
 #endif                         /* CHARSET_EBCDIC */
 
 /* aaaack but it's fast and const should make it shared text page. */
diff --git a/src/ap/ap_ebcdic.c b/src/ap/ap_ebcdic.c
new file mode 100644 (file)
index 0000000..5834f4c
--- /dev/null
@@ -0,0 +1,261 @@
+/* ====================================================================
+ * Copyright (c) 1995-2000 The Apache Group.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgment:
+ *    "This product includes software developed by the Apache Group
+ *    for use in the Apache HTTP server project (http://www.apache.org/)."
+ *
+ * 4. The names "Apache Server" and "Apache Group" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please contact
+ *    apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ *    nor may "Apache" appear in their names without prior written
+ *    permission of the Apache Group.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by the Apache Group
+ *    for use in the Apache HTTP server project (http://www.apache.org/)."
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Group and was originally based
+ * on public domain software written at the National Center for
+ * Supercomputing Applications, University of Illinois, Urbana-Champaign.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#include "httpd.h"
+#include "http_core.h"
+#include "http_config.h"
+#include "ap_config.h"
+
+#ifdef CHARSET_EBCDIC
+#include "ap_ebcdic.h"
+
+
+/* ====================================================================== */
+/*     Global functions for dealing with EBCDIC <-> ASCII conversion:     */
+/* ====================================================================== */
+
+/* EBCDIC-to-ASCII tables:
+  These tables are bijective - there are no ambigous or duplicate characters.
+ */
+const unsigned char os_toascii[256] = {
+#ifdef _OSD_POSIX /* Fujitsu-Siemens' EDF04 character set on BS2000: */
+/*00*/  0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
+        0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
+/*10*/  0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
+        0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
+/*20*/  0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
+        0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
+/*30*/  0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
+        0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
+/*40*/  0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
+        0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
+/*50*/  0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
+        0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
+/*60*/  0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
+        0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
+/*70*/  0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
+        0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
+/*80*/  0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+        0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
+/*90*/  0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
+        0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
+/*a0*/  0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
+        0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
+/*b0*/  0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
+        0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
+/*c0*/  0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+        0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
+/*d0*/  0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+        0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
+/*e0*/  0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+        0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
+/*f0*/  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+        0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e  /*0123456789.{.}.~*/
+
+#elif defined(OS390) || defined(TPF)  /* IBM's OS/390 and TPF systems: */
+/*
+Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
+*/
+    0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
+    0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
+    0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
+    0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
+    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
+    0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
+    0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
+    0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
+    0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
+    0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
+    0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
+    0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
+    0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
+    0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
+    0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
+    0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
+    0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
+    0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
+    0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
+    0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
+    0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
+    0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
+    0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
+    0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
+    0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
+    0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
+    0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
+    0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
+    0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
+    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
+    0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
+#else
+#error Unimplemented EBCDIC platform. Please send information about your system to <martin@apache.org>!
+#endif
+};
+
+
+/* Bijective ascii-to-ebcdic table: */
+const unsigned char os_toebcdic[256] = {
+#ifdef _OSD_POSIX /* Fujitsu-Siemens' EDF04 character set on BS2000: */
+/*00*/  0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
+        0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,  /*................*/
+/*10*/  0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
+        0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,  /*................*/
+/*20*/  0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
+        0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,  /* !"#$%&'()*+,-./ */
+/*30*/  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+        0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,  /*0123456789:;<=>?*/
+/*40*/  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+        0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,  /*@ABCDEFGHIJKLMNO*/
+/*50*/  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
+        0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d,  /*PQRSTUVWXYZ[\]^_*/
+/*60*/  0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+        0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,  /*`abcdefghijklmno*/
+/*70*/  0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
+        0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07,  /*pqrstuvwxyz{|}~.*/
+/*80*/  0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
+        0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14,  /*................*/
+/*90*/  0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
+        0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f,  /*................*/
+/*a0*/  0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
+        0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1,  /*................*/
+/*b0*/  0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
+        0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,  /*................*/
+/*c0*/  0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
+        0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,  /*................*/
+/*d0*/  0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
+        0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59,  /*................*/
+/*e0*/  0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
+        0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,  /*................*/
+/*f0*/  0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
+        0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf   /*................*/
+#elif defined(OS390) || defined(TPF)  /* IBM's OS/390 and TPF systems: */
+/*
+The US-ASCII to EBCDIC (character set IBM-1047) table:
+This table is bijective (no ambiguous or duplicate characters)
+*/
+    0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
+    0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
+    0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
+    0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
+    0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
+    0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
+    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
+    0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
+    0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
+    0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
+    0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
+    0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
+    0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
+    0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
+    0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
+    0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
+    0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
+    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
+    0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
+    0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
+    0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
+    0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
+    0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
+    0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
+    0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
+    0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
+    0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
+    0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
+    0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
+    0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
+    0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
+    0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
+#else
+#error Unimplemented EBCDIC platform. Please send information about your system to <martin@apache.org>!
+#endif
+};
+
+
+/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
+ * dest and srce may be identical, or separate memory blocks, but
+ * should not overlap. These functions intentionally have an interface
+ * compatible to memcpy(3).
+ */
+
+
+API_EXPORT(void *)
+ebcdic2ascii(void *dest, const void *srce, size_t count)
+{
+    unsigned char *udest = dest;
+    const unsigned char *usrce = srce;
+
+    while (count-- != 0) {
+        *udest++ = os_toascii[*usrce++];
+    }
+
+    return dest;
+}
+
+API_EXPORT(void *)
+ascii2ebcdic(void *dest, const void *srce, size_t count)
+{
+    unsigned char *udest = dest;
+    const unsigned char *usrce = srce;
+
+    while (count-- != 0) {
+        *udest++ = os_toebcdic[*usrce++];
+    }
+
+    return dest;
+}
+#endif /*CHARSET_EBCDIC*/
index ae09e417a74327f541574e731a7abe7d53ff8ffe..9f6c8c7b645b21fe68c6f0d6ffc81ff670291f6a 100644 (file)
 #include "ap_md5.h"
 #include "ap.h"
 #ifdef CHARSET_EBCDIC
-#include "ebcdic.h"
+#include "ap_ebcdic.h"
 #endif /*CHARSET_EBCDIC*/
 #if HAVE_CRYPT_H
 #include <crypt.h>
index c664e9f785940abf60bbb7defd0437bddf7543df..64811bbb6bf9a73e7e724d686c86534ef6b17541 100644 (file)
@@ -93,7 +93,7 @@
 #include "ap_sha1.h"
 #include "ap.h"
 #ifdef CHARSET_EBCDIC
-#include "ebcdic.h"
+#include "ap_ebcdic.h"
 #endif /*CHARSET_EBCDIC*/
 
 /* a bit faster & bigger, if defined */
diff --git a/src/include/ap_ebcdic.h b/src/include/ap_ebcdic.h
new file mode 100644 (file)
index 0000000..119da99
--- /dev/null
@@ -0,0 +1,68 @@
+/* ====================================================================
+ * Copyright (c) 1998-1999 The Apache Group.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer. 
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgment:
+ *    "This product includes software developed by the Apache Group
+ *    for use in the Apache HTTP server project (http://www.apache.org/)."
+ *
+ * 4. The names "Apache Server" and "Apache Group" must not be used to
+ *    endorse or promote products derived from this software without
+ *    prior written permission. For written permission, please contact
+ *    apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ *    nor may "Apache" appear in their names without prior written
+ *    permission of the Apache Group.
+ *
+ * 6. Redistributions of any form whatsoever must retain the following
+ *    acknowledgment:
+ *    "This product includes software developed by the Apache Group
+ *    for use in the Apache HTTP server project (http://www.apache.org/)."
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Group and was originally based
+ * on public domain software written at the National Center for
+ * Supercomputing Applications, University of Illinois, Urbana-Champaign.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#ifndef AP_EBCDIC_H
+#define AP_EBCDIC_H  "$Id: ap_ebcdic.h,v 1.1 2001/03/09 10:10:19 martin Exp $"
+
+#include <sys/types.h>
+
+extern const unsigned char os_toascii[256];
+extern const unsigned char os_toebcdic[256];
+API_EXPORT(void *) ebcdic2ascii(void *dest, const void *srce, size_t count);
+API_EXPORT(void *) ascii2ebcdic(void *dest, const void *srce, size_t count);
+
+#endif /*AP_EBCDIC_H*/
index c6789fdb3b74b4ae1f992fcbf8eedfbf3917bdd1..32bdb524266ee9767b3753076442961d1801f802 100644 (file)
@@ -279,6 +279,36 @@ typedef struct {
     interpreter_source_e script_interpreter_source;
 #endif    
     
+#ifdef CHARSET_EBCDIC
+    /* Configurable EBCDIC Conversion stuff */
+    /* Direction specific conversion: */
+#define dir_Out 0               /* 0utput (returned contents in a GET or POST) */
+#define dir_In  1               /* 1nput  (uploaded contents in a PUT / POST) */
+
+    /* Conversion Enabled/Disabled: */
+#define conv_Unset '?'          /* Conversion unconfigured */
+#define conv_Off   '0'          /* BINARY or ASCII file (no conversion) */
+#define conv_On    '1'          /* TEXT file (EBCDIC->ASCII for dir_Out; ASCII->EBCDIC for dir_In) */
+
+    /* The configuration args {On|Off}[={In|Out|InOut}] are currently stored
+     * as character strings ("0" = conv_Off, "1" = conv_On)
+     */
+    table *ebcdicconversion_by_ext_in;
+    table *ebcdicconversion_by_ext_out;
+    table *ebcdicconversion_by_type_in;
+    table *ebcdicconversion_by_type_out;
+
+#define LEGACY_KLUDGE 1 /* After a couple of versions this legacy kludge should be set to 0 */
+#ifndef ASCIITEXT_MAGIC_TYPE_PREFIX
+#define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-"     /* Text files whose content-type starts with this are passed thru unconverted */
+#endif
+    int x_ascii_magic_kludge;   /* whether to handle the text/x-ascii- kludge */
+
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+    int ebcdicconversion_debug_header; /* whether to add an X-EBCDIC-Debug-{In,Out} header to the response */
+#endif
+#endif /* CHARSET_EBCDIC */
+
 } core_dir_config;
 
 /* Per-server core configuration */
index 12552728fffd1b52b41e23674fa4de730d31a79a..411de5bc3c3302f5e447620cbb0545ca515e512d 100644 (file)
@@ -616,7 +616,7 @@ API_EXPORT(const char *) ap_get_server_built(void);
 #define CRLF "\015\012"
 #define OS_ASC(c) (c)
 #else /* CHARSET_EBCDIC */
-#include "ebcdic.h"
+#include "ap_ebcdic.h"
 /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
  * the buff package (bread/bputs/bwrite), so everywhere else, we use
  * "native EBCDIC" CR and NL characters. These are therefore defined as
@@ -833,6 +833,17 @@ struct request_rec {
      */
     char *case_preserved_filename;
 
+#ifdef CHARSET_EBCDIC
+    /* We don't want subrequests to modify our current conversion flags.
+     * These flags save the state of the conversion flags when subrequests
+     * are run.
+     */
+    struct {
+        unsigned conv_in:1;    /* convert ASCII->EBCDIC when read()ing? */
+        unsigned conv_out:1;   /* convert EBCDIC->ASCII when write()ing? */
+    } ebcdic;
+#endif
+
 /* Things placed at the end of the record to avoid breaking binary
  * compatibility.  It would be nice to remember to reorder the entire
  * record to improve 64bit alignment the next time we need to break
@@ -1117,10 +1128,10 @@ API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
 #endif
 #endif
 
-#ifdef _OSD_POSIX
-extern const char *os_set_account(pool *p, const char *account);
-extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
-#endif /* _OSD_POSIX */
+#ifdef CHARSET_EBCDIC
+API_EXPORT(int)    ap_checkconv(struct request_rec *r);    /* for downloads */
+API_EXPORT(int)    ap_checkconv_in(struct request_rec *r); /* for uploads */
+#endif /*#ifdef CHARSET_EBCDIC*/
 
 char *ap_get_local_host(pool *);
 unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port);
index 5b7519cb3cc47ef31e5601f784642b375e1072b4..86fe6e03ddfadba4656c274e95e849ca894e2a7a 100644 (file)
@@ -57,6 +57,7 @@
  */
 
 #define CORE_PRIVATE
+#define ADD_EBCDICCONVERT_DEBUG_HEADER 0
 #include "httpd.h"
 #include "http_config.h"
 #include "http_core.h"
@@ -158,6 +159,17 @@ static void *create_core_dir_config(pool *a, char *dir)
     conf->add_default_charset = ADD_DEFAULT_CHARSET_UNSET;
     conf->add_default_charset_name = DEFAULT_ADD_DEFAULT_CHARSET_NAME;
 
+#ifdef CHARSET_EBCDIC
+    conf->ebcdicconversion_by_ext_in = ap_make_table(a, 4);
+    conf->ebcdicconversion_by_ext_out = ap_make_table(a, 4);
+    conf->ebcdicconversion_by_type_in = ap_make_table(a, 4);
+    conf->ebcdicconversion_by_type_out = ap_make_table(a, 4);
+    conf->x_ascii_magic_kludge = 0;
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+    conf->ebcdicconversion_debug_header = 0;
+#endif
+#endif /* CHARSET_EBCDIC */
+
     return (void *)conf;
 }
 
@@ -292,6 +304,21 @@ static void *merge_core_dir_configs(pool *a, void *basev, void *newv)
        }
     }
 
+#ifdef CHARSET_EBCDIC
+    conf->ebcdicconversion_by_ext_in = ap_overlay_tables(a, new->ebcdicconversion_by_ext_in,
+                                               base->ebcdicconversion_by_ext_in);
+    conf->ebcdicconversion_by_ext_out = ap_overlay_tables(a, new->ebcdicconversion_by_ext_out,
+                                               base->ebcdicconversion_by_ext_out);
+    conf->ebcdicconversion_by_type_in = ap_overlay_tables(a, new->ebcdicconversion_by_type_in,
+                                                base->ebcdicconversion_by_type_in);
+    conf->ebcdicconversion_by_type_out = ap_overlay_tables(a, new->ebcdicconversion_by_type_out,
+                                                base->ebcdicconversion_by_type_out);
+    conf->x_ascii_magic_kludge = new->x_ascii_magic_kludge ? new->x_ascii_magic_kludge : base->x_ascii_magic_kludge;
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+    conf->ebcdicconversion_debug_header = new->ebcdicconversion_debug_header ? new->ebcdicconversion_debug_header : base->ebcdicconversion_debug_header;
+#endif
+#endif /* CHARSET_EBCDIC */
+
     return (void*)conf;
 }
 
@@ -2813,6 +2840,123 @@ static const char *set_interpreter_source(cmd_parms *cmd, core_dir_config *d,
 }
 #endif
 
+
+#ifdef CHARSET_EBCDIC
+
+typedef struct {
+  char conv_out[2];
+  char conv_in[2];
+} parsed_conf_t;
+
+/* Check for conversion syntax:  { On | Off } [ = { In | Out | InOut } ] */
+static parsed_conf_t *
+parse_on_off_in_out(pool *p, char *arg)
+{
+    static parsed_conf_t ret = { { conv_Unset, '\0' }, { conv_Unset, '\0' } };
+    char *onoff = ap_getword_nc(p, &arg, '=');
+    int in = 0, out = 0, inout = 0;
+    char conv_val;
+
+    /* Check for valid syntax:  { On | Off } [ = { In | Out | InOut } ] */
+    if (strcasecmp(onoff, "On") == 0)
+        conv_val = conv_On;
+    else if (strcasecmp(onoff, "Off") == 0)
+        conv_val = conv_Off;
+    else
+        return NULL;
+
+    /* Check the syntax, and at the same time assign the test results */
+    if (!(inout = (*arg == '\0')) &&
+        !(in = (strcasecmp(arg, "In") == 0)) &&
+        !(out = (strcasecmp(arg, "Out") == 0)) &&
+        !(inout = (strcasecmp(arg, "InOut") == 0))) {
+        /* Invalid string, not conforming to syntax! */
+        return NULL;
+    }
+
+    ret.conv_in[0]  = (in || inout)  ? conv_val : conv_Unset;
+    ret.conv_out[0] = (out || inout) ? conv_val : conv_Unset;
+
+    return &ret;
+}
+
+
+/* Handle the EBCDICConvert directive:
+ *   EBCDICConvert {On|Off}[={In|Out|InOut}] ext ...
+ */
+static const char *
+add_conversion_by_ext(cmd_parms *cmd, core_dir_config *m,
+                     char *onoff, char *ext)
+{
+    parsed_conf_t *onoff_code = parse_on_off_in_out(cmd->pool, onoff);
+
+    if (onoff_code == NULL)
+        return "Invalid syntax: use EBCDICConvert {On|Off}[={In|Out|InOut}] ext [...]";
+
+    if (*ext == '.')
+        ++ext;
+
+    if (*onoff_code->conv_in != conv_Unset)
+       ap_table_addn(m->ebcdicconversion_by_ext_in, ext,
+                     ap_pstrndup(cmd->pool, onoff_code->conv_in, 1));
+    if (*onoff_code->conv_out != conv_Unset)
+       ap_table_addn(m->ebcdicconversion_by_ext_out, ext,
+                     ap_pstrndup(cmd->pool, onoff_code->conv_out, 1));
+
+    return NULL;
+}
+
+
+/* Handle the EBCDICConvertByType directive:
+ *   EBCDICConvertByType {On|Off}[={In|Out|InOut}] mimetype ...
+ */
+static const char *
+add_conversion_by_type(cmd_parms *cmd, core_dir_config *m,
+                      char *onoff, char *type)
+{
+    parsed_conf_t *onoff_code = parse_on_off_in_out(cmd->pool, onoff);
+
+    if (onoff_code == NULL)
+        return "Invalid syntax: use EBCDICConvertByType {On|Off}[={In|Out|InOut}] mimetype [...]";
+
+    if (*onoff_code->conv_in != conv_Unset)
+       ap_table_addn(m->ebcdicconversion_by_type_in, type,
+                     ap_pstrndup(cmd->pool, onoff_code->conv_in, 1));
+    if (*onoff_code->conv_out != conv_Unset)
+       ap_table_addn(m->ebcdicconversion_by_type_out, type,
+                     ap_pstrndup(cmd->pool, onoff_code->conv_out, 1));
+
+    return NULL;
+}
+
+
+/* Handle the EBCDICKludge directive:
+ *   EBCDICKludge {On|Off}
+ */
+#ifdef LEGACY_KLUDGE
+static const char *
+set_x_ascii_kludge(cmd_parms *cmd, core_dir_config *m, int arg)
+{
+    m->x_ascii_magic_kludge = arg;
+
+    return NULL;
+}
+#endif
+
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+/* Handle the EBCDICDebugHeader directive:
+ *   EBCDICDebugHeader {On|Off}
+ */
+static const char *
+set_debug_header(cmd_parms *cmd, core_dir_config *m, int arg)
+{
+    m->ebcdicconversion_debug_header = arg;
+
+    return NULL;
+}
+#endif
+#endif /* CHARSET_EBCDIC */
+
 /* Note --- ErrorDocument will now work from .htaccess files.  
  * The AllowOverride of Fileinfo allows webmasters to turn it off
  */
@@ -3043,6 +3187,23 @@ static const command_rec core_cmds[] = {
   (void*)XtOffsetOf(core_dir_config, limit_req_body),
   OR_ALL, TAKE1,
   "Limit (in bytes) on maximum size of request message body" },
+
+/* EBCDIC Conversion directives: */
+#ifdef CHARSET_EBCDIC
+{ "EBCDICConvert", add_conversion_by_ext, NULL, OR_FILEINFO, ITERATE2,
+    "{On|Off}[={In|Out|InOut}] followed by one or more file extensions" },
+{ "EBCDICConvertByType", add_conversion_by_type, NULL, OR_FILEINFO, ITERATE2,
+    "{On|Off}[={In|Out|InOut}] followed by one or more MIME types" },
+#ifdef LEGACY_KLUDGE
+{ "EBCDICKludge", set_x_ascii_kludge, NULL, OR_FILEINFO, FLAG,
+    "'On': enable or default='Off': disable the old text/x-ascii-mimetype kludge" },
+#endif
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+{ "EBCDICDebugHeader", set_debug_header, NULL, OR_FILEINFO, FLAG,
+    "'On': enable or default='Off': disable the EBCDIC Debugging MIME Header" },
+#endif
+#endif /* CHARSET_EBCDIC */
+
 { NULL }
 };
 
@@ -3095,6 +3256,259 @@ static int core_translate(request_rec *r)
 
 static int do_nothing(request_rec *r) { return OK; }
 
+#ifdef CHARSET_EBCDIC
+struct do_mime_match_parms {
+    request_rec *request;     /* [In] current request_rec */
+    int direction;            /* [In] determine conversion for: dir_In|dir_Out */
+    const char *content_type; /* [In] Content-Type (dir_In: from MIME Header, else r->content_type) */
+    int match_found;          /* [Out] nonzero if a match was found */
+    int conv;                 /* [Out] conversion setting if match was found */
+};
+
+
+/* This routine is called for each mime type configured by the
+ * EBCDICConvertByType directive.
+ */
+static int
+do_mime_match(void *rec, const char *key, const char *val)
+{
+    int conv = (val[0] == conv_On);
+    const char *content_type;
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+    request_rec *r = ((struct do_mime_match_parms *) rec)->request;
+#endif
+
+    ((struct do_mime_match_parms *) rec)->match_found = 0;
+    ((struct do_mime_match_parms *) rec)->conv = conv_Unset;
+
+    content_type = ((struct do_mime_match_parms *) rec)->content_type;
+
+    /* If no type set: no need to continue */
+    if (content_type == NULL)
+        return 0;
+
+    /* If the MIME type matches, set the conversion flag appropriately */
+    if ((ap_is_matchexp(key) && ap_strcasecmp_match(content_type, key) == 0)
+        || (strcasecmp(key, content_type) == 0)) {
+
+        ((struct do_mime_match_parms *) rec)->match_found = 1;
+        ((struct do_mime_match_parms *) rec)->conv = conv;
+
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+       ap_table_setn(r->headers_out,
+               ((((struct do_mime_match_parms *) rec)->direction) == dir_In)
+                     ? "X-EBCDIC-Debug-In" : "X-EBCDIC-Debug-Out",
+                       ap_psprintf(r->pool, "EBCDICConversionByType %s %s",
+                                   conv ? "On" : "Off",
+                                   key));
+#endif
+
+        /* the mime type scan stops at the first  match. */
+        return 0;
+    }
+
+    return 1;
+}
+
+static void
+ap_checkconv_dir(request_rec *r, const char **pType, int dir)
+{
+    core_dir_config *conf =
+    (core_dir_config *) ap_get_module_config(r->per_dir_config, &core_module);
+    table *conv_by_ext, *conv_by_type;
+    const char *type, *conversion;
+    char *ext;
+    int conv_valid = 0, conv;
+
+    conv_by_ext  = (dir == dir_In) ? conf->ebcdicconversion_by_ext_in  : conf->ebcdicconversion_by_ext_out;
+    conv_by_type = (dir == dir_In) ? conf->ebcdicconversion_by_type_in : conf->ebcdicconversion_by_type_out;
+
+    type = (*pType == NULL) ? ap_default_type(r) : *pType;
+
+    /* Pseudo "loop" which is executed once only, with break's at individual steps */
+    do {
+        /* Step 0: directories result in redirections or in directory listings.
+        * Both are EBCDIC text documents.
+        * @@@ Should we check for the handler instead?
+        */
+        if (S_ISDIR(r->finfo.st_mode) && dir == dir_Out) {
+            conv = conv_valid = 1;
+            break;
+        }
+
+        /* 1st step: check the binding on file extension. This allows us to
+         * override the conversion default based on a specific name.
+         * For instance, the following would allow some HTML files
+         * to be converted (.html) and others passed unconverted (.ahtml):
+         *     AddType text/html .html .ahtml
+         *     EBCDICConvert Off .ahtml
+         * For uploads, this assumes that the destination file name
+        * has the correct extension. That may not be true for, e.g.,
+        * Netscape Communicator roaming profile uploads!
+         */
+        if (r->filename && !ap_is_empty_table(conv_by_ext)) {
+            const char *fn = strrchr(r->filename, '/');
+
+            if (fn == NULL)
+                fn = r->filename;
+
+            /* Parse filename extension */
+            if ((ext = strrchr(fn, '.')) != NULL) {
+                ++ext;
+
+                /* Check for Content-Type */
+                if ((conversion = ap_table_get(conv_by_ext, ext)) != NULL) {
+
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+                   if (conf->ebcdicconversion_debug_header)
+                       ap_table_setn(r->headers_out,
+                                     (dir == dir_In) ? "X-EBCDIC-Debug-In" : "X-EBCDIC-Debug-Out",
+                                     ap_psprintf(r->pool, "EBCDICConversion %s .%s",
+                                                 (conversion[0] == conv_On) ? "On" : "Off",
+                                                 ext));
+#endif
+
+                    conv = (conversion[0] == conv_On);
+                    conv_valid = 1;
+                    break;
+                }
+            }
+        }
+
+
+        /* 2nd step: test for the old "legacy kludge", that is, a default
+         * conversion=on for text/?* message/?* multipart/?* and the possibility
+         * to override the text/?* conversion with a definition like
+         *    AddType text/x-ascii-plain .atxt
+         *    AddType text/x-ascii-html  .ahtml
+         * where the "x-ascii-" would be removed and the conversion switched
+         * off.
+         * This step must be performed prior to testing wildcard MIME types
+         * like text/?* by the EBCDICConvertByType directive.
+         */
+#ifdef LEGACY_KLUDGE
+        /* This fallback is only used when enabled (default=off) */
+        if (conf->x_ascii_magic_kludge) {
+            char *magic;
+
+            /* If the mime type of a document is set to
+             * "text/x-ascii-anything", it gets changed to
+             * "text/anything" here and the conversion is forced to off
+             * ("binary" or ASCII documents).
+             */
+            if (*pType != NULL
+                && (magic = strstr(*pType, "/x-ascii-")) != NULL) {
+
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+               if (conf->ebcdicconversion_debug_header)
+                   ap_table_setn(r->headers_out,
+                                 (dir == dir_In) ? "X-EBCDIC-Debug-In" : "X-EBCDIC-Debug-Out",
+                                 ap_psprintf(r->pool, "EBCDICKludge On (and type is: %s, thus no conversion)",
+                                             *pType));
+#endif
+
+                /* the mime type scan stops at the first  match. */
+                magic[1] = '\0';        /* overwrite 'x' */
+
+                /* Fix MIME type: strip out the magic "x-ascii-" substring */
+                *pType = ap_pstrcat(r->pool, *pType, &magic[9], NULL);
+
+                magic[1] = 'x'; /* restore 'x' in old string (just in case) */
+
+                /* Switch conversion to BINARY */
+                conv = 0;       /* do NOT convert this document */
+                conv_valid = 1;
+                break;
+            }
+        }
+#endif /*LEGACY_KLUDGE */
+
+
+        /* 3rd step: check whether a generic conversion was defined for a MIME type,
+         * like in
+         *    EBCDICConvertByType  On  model/vrml application/postscript text/?*
+         */
+        if (!ap_is_empty_table(conv_by_type)) {
+            struct do_mime_match_parms do_par;
+
+            do_par.request = r;
+            do_par.direction = dir;
+           do_par.content_type = type;
+
+            ap_table_do(do_mime_match, (void *) &do_par, conv_by_type, NULL);
+
+            if ((conv_valid = do_par.match_found) != 0) {
+                conv = do_par.conv;
+                break;
+            }
+        }
+        else /* If no conversion by type was configured, use the default: */
+        {
+            /*
+             * As a final step, mime types starting with "text/", "message/" or
+             * "multipart/" imply a conversion, while all the rest is
+             * delivered unconverted (i.e., binary, e.g. application/octet-stream).
+             */
+
+            /* If no content type is set then treat it as text (conversion=on) */
+            conv =
+                (type == NULL) ||
+                (strncasecmp(type, "text/", 5) == 0) ||
+                (strncasecmp(type, "message/", 8) == 0) ||
+                (strncasecmp(type, "multipart/", 10) == 0) ||
+                (strcasecmp(type, "application/x-www-form-urlencoded") == 0);
+
+#if ADD_EBCDICCONVERT_DEBUG_HEADER
+               if (conf->ebcdicconversion_debug_header)
+                   ap_table_setn(r->headers_out,
+                                 (dir == dir_In) ? "X-EBCDIC-Debug-In" : "X-EBCDIC-Debug-Out",
+                                 ap_psprintf(r->pool,
+                                             "No EBCDICConversion configured (and type is: %s, "
+                                             "=> guessed conversion = %s)",
+                                             type, conv ? "On" : "Off"));
+#endif
+            conv_valid = 1;
+            break;
+        }
+    } while (0);
+
+    if (conv_valid) {
+        if (dir == dir_In)
+            r->ebcdic.conv_in = conv;
+        else
+            r->ebcdic.conv_out = conv;
+    }
+}
+
+/* This function determines the conversion for uploads (PUT/POST): */
+API_EXPORT(int)
+ap_checkconv_in(request_rec *r)
+{
+    const char *typep;
+
+    /* If nothing is being sent as input anyway, we don't bother about conversion */
+    /* (see ap_should_client_block())*/
+    if (r->read_length || (!r->read_chunked && (r->remaining <= 0)))
+        return r->ebcdic.conv_in;
+
+    typep = ap_table_get(r->headers_in, "Content-Type");
+    ap_checkconv_dir(r, &typep, dir_In);
+
+    return r->ebcdic.conv_in;
+}
+
+
+/* Backward compatibility function */
+API_EXPORT(int)
+ap_checkconv(request_rec *r)
+{
+    ap_checkconv_dir(r, &r->content_type, dir_Out);
+    return r->ebcdic.conv_out;
+}
+
+#endif /* CHARSET_EBCDIC */
+
+
 #ifdef USE_MMAP_FILES
 struct mmap_rec {
     void *mm;
@@ -3130,9 +3544,6 @@ static int default_handler(request_rec *r)
 #ifdef USE_MMAP_FILES
     caddr_t mm;
 #endif
-#ifdef CHARSET_EBCDIC
-    int convert_flag;
-#endif
 
     /* This handler has no use for a request body (yet), but we still
      * need to read and discard it if the client sent one.
@@ -3188,19 +3599,6 @@ static int default_handler(request_rec *r)
         return errstatus;
     }
 
-#ifdef CHARSET_EBCDIC
-    /* To make serving of "raw ASCII text" files easy (they serve faster
-     * since they don't have to be converted from EBCDIC), a new
-     * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
-     * If we detect one of these content types here, we simply correct
-     * the type to the real text/{plain,html,...} type. Otherwise, we
-     * set a flag that translation is required later on.
-     *
-     * Note: convert_flag is not used in the MMAP path;
-     * ap_checkconv() sets a request_req flag based on content_type
-     */ 
-    convert_flag = ap_checkconv(r);
-#endif
 #ifdef USE_MMAP_FILES
     ap_block_alarms();
     if ((r->finfo.st_size >= MMAP_THRESHOLD)
@@ -3226,7 +3624,7 @@ static int default_handler(request_rec *r)
 #ifdef CHARSET_EBCDIC
        if (d->content_md5 & 1) {
            ap_table_setn(r->headers_out, "Content-MD5",
-                         ap_md5digest(r->pool, f, convert_flag));
+                         ap_md5digest(r->pool, f, r->ebcdic.conv_out));
        }
 #else
        if (d->content_md5 & 1) {
index 1d0253aa4c5ae4ddf08b51f2c80a8b3f26810a52..425f0ed437c6abeab3aaed24d8695547029d6ee4 100644 (file)
 #define POP_EBCDIC_INPUTCONVERSION_STATE(_buff) \
         ap_bsetflag(_buff, B_ASCII2EBCDIC, _convert_in);
 
-#define PUSH_EBCDIC_OUTPUTCONVERSION_STATE(_buff, _onoff) \
-        int _convert_out = ap_bgetflag(_buff, B_EBCDIC2ASCII); \
-        ap_bsetflag(_buff, B_EBCDIC2ASCII, _onoff);
+#define PUSH_EBCDIC_INPUTCONVERSION_STATE_r(_req, _onoff) \
+        ap_bsetflag(_req->connection->client, B_ASCII2EBCDIC, _onoff);
 
-#define POP_EBCDIC_OUTPUTCONVERSION_STATE(_buff) \
-        ap_bsetflag(_buff, B_EBCDIC2ASCII, _convert_out);
+#define POP_EBCDIC_INPUTCONVERSION_STATE_r(_req) \
+        ap_bsetflag(_req->connection->client, B_ASCII2EBCDIC, _req->ebcdic.conv_in);
+
+#define PUSH_EBCDIC_OUTPUTCONVERSION_STATE_r(_req, _onoff) \
+        ap_bsetflag(_req->connection->client, B_EBCDIC2ASCII, _onoff);
+
+#define POP_EBCDIC_OUTPUTCONVERSION_STATE_r(_req) \
+        ap_bsetflag(_req->connection->client, B_EBCDIC2ASCII, _req->ebcdic.conv_out);
 
 #endif /*CHARSET_EBCDIC*/
 
@@ -238,7 +243,7 @@ static int byterange_boundary(request_rec *r, long start, long end, int output)
      * set to ON (protocol strings MUST be converted)
      * and reset to original setting before returning
      */
-    PUSH_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client, 1);
+    PUSH_EBCDIC_OUTPUTCONVERSION_STATE_r(r, 1);
 #endif /*CHARSET_EBCDIC*/
 
     if (start < 0 || end < 0) {
@@ -262,7 +267,7 @@ static int byterange_boundary(request_rec *r, long start, long end, int output)
     }
 
 #ifdef CHARSET_EBCDIC
-    POP_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client);
+    POP_EBCDIC_OUTPUTCONVERSION_STATE_r(r);
 #endif /*CHARSET_EBCDIC*/
 
     return length;
@@ -1106,7 +1111,8 @@ request_rec *ap_read_request(conn_rec *conn)
     r->the_request     = NULL;
 
 #ifdef CHARSET_EBCDIC
-    ap_bsetflag(r->connection->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1);
+    ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->ebcdic.conv_in  = 1);
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
 #endif
 
     /* Get the request... */
@@ -1322,8 +1328,8 @@ API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw)
         return AUTH_REQUIRED;
     }
 
-    /* CHARSET_EBCDIC Issue's here ?!? Compare with 32/9 instead
-     * as we are operating on an octed stream ?
+    /* No CHARSET_EBCDIC Issue here because the line has already
+     * been converted to native text.
      */
     while (*auth_line== ' ' || *auth_line== '\t')
         auth_line++;
@@ -1481,7 +1487,7 @@ API_EXPORT(void) ap_basic_http_header(request_rec *r)
         protocol = SERVER_PROTOCOL;
 
 #ifdef CHARSET_EBCDIC
-    { PUSH_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client, 1);
+    PUSH_EBCDIC_OUTPUTCONVERSION_STATE_r(r, 1);
 #endif /*CHARSET_EBCDIC*/
 
     /* Output the HTTP/1.x Status-Line and the Date and Server fields */
@@ -1494,7 +1500,7 @@ API_EXPORT(void) ap_basic_http_header(request_rec *r)
     ap_table_unset(r->headers_out, "Date");        /* Avoid bogosity */
     ap_table_unset(r->headers_out, "Server");
 #ifdef CHARSET_EBCDIC
-    POP_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client); }
+    POP_EBCDIC_OUTPUTCONVERSION_STATE_r(r);
 #endif /*CHARSET_EBCDIC*/
 }
 
@@ -1565,6 +1571,10 @@ API_EXPORT(int) ap_send_http_trace(request_rec *r)
 
     r->content_type = "message/http";
     ap_send_http_header(r);
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
 
     /* Now we recreate the request, and echo it back */
 
@@ -1702,6 +1712,11 @@ API_EXPORT(void) ap_send_http_header(request_rec *r)
     int i;
     const long int zero = 0L;
 
+#ifdef CHARSET_EBCDIC
+    /* Use previously determined conversion (output): */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, ap_checkconv(r));
+#endif /*CHARSET_EBCDIC*/
+
     if (r->assbackwards) {
         if (!r->main)
             ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
@@ -1737,7 +1752,7 @@ API_EXPORT(void) ap_send_http_header(request_rec *r)
     ap_basic_http_header(r);
 
 #ifdef CHARSET_EBCDIC
-    { PUSH_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client, 1);
+    PUSH_EBCDIC_OUTPUTCONVERSION_STATE_r(r, 1);
 #endif /*CHARSET_EBCDIC*/
 
     ap_set_keepalive(r);
@@ -1790,7 +1805,7 @@ API_EXPORT(void) ap_send_http_header(request_rec *r)
     if (r->chunked)
         ap_bsetflag(r->connection->client, B_CHUNK, 1);
 #ifdef CHARSET_EBCDIC
-    POP_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client); }
+    POP_EBCDIC_OUTPUTCONVERSION_STATE_r(r);
 #endif /*CHARSET_EBCDIC*/
 }
 
@@ -1803,7 +1818,7 @@ API_EXPORT(void) ap_finalize_request_protocol(request_rec *r)
 {
     if (r->chunked && !r->connection->aborted) {
 #ifdef CHARSET_EBCDIC
-       PUSH_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client, 1);
+        PUSH_EBCDIC_OUTPUTCONVERSION_STATE_r(r, 1);
 #endif
         /*
          * Turn off chunked encoding --- we can only do this once.
@@ -1818,7 +1833,7 @@ API_EXPORT(void) ap_finalize_request_protocol(request_rec *r)
         ap_kill_timeout(r);
 
 #ifdef CHARSET_EBCDIC
-       POP_EBCDIC_OUTPUTCONVERSION_STATE(r->connection->client);
+        POP_EBCDIC_OUTPUTCONVERSION_STATE_r(r);
 #endif /*CHARSET_EBCDIC*/
     }
 }
@@ -1917,18 +1932,11 @@ API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy)
 
 #ifdef CHARSET_EBCDIC
     {
-        /* @@@ Temporary kludge for guessing the conversion @@@
-         * from looking at the MIME header. 
+        /* Determine the EBCDIC conversion for the uploaded content
+         * by looking at the Content-Type MIME header. 
          * If no Content-Type header is found, text conversion is assumed.
          */
-        const char *typep = ap_table_get(r->headers_in, "Content-Type");
-        int convert_in = (typep == NULL ||
-                          strncasecmp(typep, "text/", 5) == 0 ||
-                          strncasecmp(typep, "message/", 8) == 0 ||
-                          strncasecmp(typep, "multipart/", 10) == 0 ||
-                          strcasecmp (typep, "application/x-www-form-urlencoded") == 0
-                         );
-        ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, convert_in);
+        ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, ap_checkconv_in(r));
     }
 #endif
 
@@ -1959,6 +1967,7 @@ static long get_chunk_size(char *b)
     while (ap_isxdigit(*b)) {
         int xvalue = 0;
 
+       /* This works even on EBCDIC. */
         if (*b >= '0' && *b <= '9')
             xvalue = *b - '0';
         else if (*b >= 'A' && *b <= 'F')
@@ -2118,7 +2127,7 @@ API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
     if (r->remaining == 0) {    /* End of chunk, get trailing CRLF */
 #ifdef CHARSET_EBCDIC
         /* Chunk end is Protocol stuff! Set conversion = 1 to read CR LF: */
-        PUSH_EBCDIC_INPUTCONVERSION_STATE(r->connection->client, 1);
+        PUSH_EBCDIC_INPUTCONVERSION_STATE_r(r, 1);
 #endif /*CHARSET_EBCDIC*/
 
         if ((c = ap_bgetc(r->connection->client)) == CR) {
@@ -2127,7 +2136,7 @@ API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
 
 #ifdef CHARSET_EBCDIC
         /* restore ASCII->EBCDIC conversion state */
-        POP_EBCDIC_INPUTCONVERSION_STATE(r->connection->client);
+        POP_EBCDIC_INPUTCONVERSION_STATE_r(r);
 #endif /*CHARSET_EBCDIC*/
 
         if (c != LF) {
@@ -2590,6 +2599,10 @@ API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error)
     int idx = ap_index_of_response(status);
     char *custom_response;
     const char *location = ap_table_get(r->headers_out, "Location");
+#ifdef CHARSET_EBCDIC
+    /* Error Responses (builtin / string literal / redirection) are TEXT! */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
 
     /*
      * It's possible that the Location field might be in r->err_headers_out
@@ -2677,6 +2690,11 @@ API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error)
         }
     }
 
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
+
     ap_hard_timeout("send error body", r);
 
     if ((custom_response = ap_response_code_string(r, idx))) {
index 13ce145c293b3c45b5603356fda16bbdc9f78048..0dfb108550c59ae0701302be28456b3cb45f804c 100644 (file)
@@ -782,6 +782,11 @@ static request_rec *make_sub_request(const request_rec *r)
     request_rec *rr = ap_pcalloc(rrp, sizeof(request_rec));
 
     rr->pool = rrp;
+#ifdef CHARSET_EBCDIC
+    /* Assume virgin state (like after reading the request_line): */
+    ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, rr->ebcdic.conv_in  = 1);
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, rr->ebcdic.conv_out = 1);
+#endif   
     return rr;
 }
 
@@ -1007,20 +1012,19 @@ API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file,
 
 API_EXPORT(int) ap_run_sub_req(request_rec *r)
 {
-#ifndef CHARSET_EBCDIC
     int retval = ap_invoke_handler(r);
-#else /*CHARSET_EBCDIC*/
-    /* Save the EBCDIC conversion setting of the caller across subrequests */
-    int convert = ap_bgetflag(r->connection->client, B_EBCDIC2ASCII);
-    int retval  = ap_invoke_handler(r);
-    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert);
-#endif /*CHARSET_EBCDIC*/
     ap_finalize_sub_req_protocol(r);
     return retval;
 }
 
 API_EXPORT(void) ap_destroy_sub_req(request_rec *r)
 {
+#ifdef CHARSET_EBCDIC
+    if (r->main) {
+        ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, r->main->ebcdic.conv_in);
+        ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->main->ebcdic.conv_out);
+    }
+#endif   
     /* Reclaim the space */
     ap_destroy_pool(r->pool);
 }
@@ -1404,6 +1408,10 @@ static request_rec *internal_internal_redirect(const char *new_uri, request_rec
     new->no_local_copy   = r->no_local_copy;
     new->read_length     = r->read_length;     /* We can only read it once */
     new->vlist_validator = r->vlist_validator;
+#ifdef CHARSET_EBCDIC /* @@@ Is this correct? When is it used? */
+    new->ebcdic.conv_out= r->ebcdic.conv_out;
+    new->ebcdic.conv_in = r->ebcdic.conv_in;
+#endif
 
     ap_table_setn(new->subprocess_env, "REDIRECT_STATUS",
        ap_psprintf(r->pool, "%d", r->status));
index b1af0edd066f0b6caf7ed647b9649f12a49e986b..05e694f774c76be78baa24fb8c7b0b057ae9e886 100644 (file)
@@ -513,8 +513,14 @@ static int example_handler(request_rec *r)
      * is broken.
      */
     r->content_type = "text/html";
+
     ap_soft_timeout("send example call trace", r);
     ap_send_http_header(r);
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
+
     /*
      * If we're only supposed to send header information (HEAD request), we're
      * already there.
index e18fea6ebb5350fd822ab1fcb151e125deeb985e..f659d84b9303853af2b948ffb4f5f10b3187e521 100644 (file)
@@ -1137,9 +1137,16 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url)
     ap_table_setn(resp_hdrs, "Date", ap_gm_timestr_822(r->pool, r->request_time));
     ap_table_setn(resp_hdrs, "Server", ap_get_server_version());
 
-    if (parms[0] == 'd')
+    if (parms[0] == 'd') {
        ap_table_setn(resp_hdrs, "Content-Type", "text/html");
+#ifdef CHARSET_EBCDIC
+       r->ebcdic.conv_out = 1; /* server-generated */
+#endif
+    }
     else {
+#ifdef CHARSET_EBCDIC
+       r->ebcdic.conv_out = 0; /* do not convert what we read from the ftp server */
+#endif
        if (r->content_type != NULL) {
            ap_table_setn(resp_hdrs, "Content-Type", r->content_type);
            Explain1("FTP: Content-Type set to %s", r->content_type);
@@ -1232,6 +1239,9 @@ int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url)
 
     ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
     r->sent_bodyct = 1;
+#ifdef CHARSET_EBCDIC
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out);
+#endif
 /* send body */
     if (!r->header_only) {
        if (parms[0] != 'd') {
index 4db0ab4b90afa8028ff8df137b71de1e9166b025..0201d5cf5435d6891d4fa61d56d679243c4986d4 100644 (file)
@@ -1627,6 +1627,11 @@ static int index_directory(request_rec *r,
     }
     ap_send_http_header(r);
 
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
+
     if (r->header_only) {
        ap_pclosedir(r->pool, d);
        return 0;
index 1d6bdd2ce9a8f7aa6ac10c6adbb28e46cdfab79a..dfa791bed8e47a678ad5be802ba218e7dbc94b82 100644 (file)
@@ -445,9 +445,13 @@ static int cgi_handler(request_rec *r)
 #endif   /* TPF */
 
 #ifdef CHARSET_EBCDIC
-    /* XXX:@@@ Is the generated/included output ALWAYS in text/ebcdic format? */
-    /* Or must we check the Content-Type first? */
-    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, 1);
+    /* The included MIME headers must ALWAYS be in text/ebcdic format.
+     * Only after reading the MIME headers, we check the Content-Type
+     * and switch to the necessary conversion mode.
+     * Until then (and in case an nph- script was called), use the
+     * configured default conversion:
+     */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out);
 #endif /*CHARSET_EBCDIC*/
 
     /*
@@ -516,11 +520,6 @@ static int cgi_handler(request_rec *r)
            return log_script(r, conf, ret, dbuf, sbuf, script_in, script_err);
        }
 
-#ifdef CHARSET_EBCDIC
-        /* Now check the Content-Type to decide if conversion is needed */
-        ap_checkconv(r);
-#endif /*CHARSET_EBCDIC*/
-
        location = ap_table_get(r->headers_out, "Location");
 
        if (location && location[0] == '/' && r->status == 200) {
index d79f45f0a5715debefe4397abd7787e123bba3fa..55d1641be5f8b7a69b6c45e2ce4dd75f2471ca39 100644 (file)
@@ -507,6 +507,10 @@ static void menu_header(request_rec *r, char *menu)
 {
     r->content_type = "text/html";
     ap_send_http_header(r);
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
     ap_hard_timeout("send menu", r);       /* killed in menu_footer */
 
     ap_rvputs(r, DOCTYPE_HTML_3_2, "<html><head>\n<title>Menu for ", r->uri,
index 8e3adf22104cd8d5928b1bd5397b5b1a0061cd18..df5b7fee64207353652f7878905c3a8aa3a6a3be 100644 (file)
@@ -443,6 +443,10 @@ static int display_info(request_rec *r)
     if (r->header_only) {
         return 0;
     }
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
     ap_hard_timeout("send server info", r);
 
     ap_rputs(DOCTYPE_HTML_3_2
index 0ccd19fa4f5135515aee376357017098867805a0..79f543586ca596590790b8ff91d13363b3597611 100644 (file)
@@ -299,6 +299,10 @@ static int status_handler(request_rec *r)
     }
 
     ap_send_http_header(r);
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
 
     if (r->header_only)
        return 0;
index d822cea547c86b747864aa51fd0c71d473fc9593..cb4b19f58b3d4cd73f1717dc4a4a649584716203 100644 (file)
@@ -106,6 +106,10 @@ static int send_rndchunk(request_rec *r)
 
     r->content_type = "text/html";             
     ap_send_http_header(r);
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
     if(r->header_only) {
        return 0;
     }
index 52539a7c39f369aefa1c050adb1003268700457a..ead389ab802cbad8c3e1435200cdf2b244d8710e 100644 (file)
@@ -271,6 +271,10 @@ static int test_util_uri(request_rec *r)
 
     r->content_type = "text/html";             
     ap_send_http_header(r);
+#ifdef CHARSET_EBCDIC
+    /* Server-generated response, converted */
+    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, r->ebcdic.conv_out = 1);
+#endif
     if(r->header_only) {
        return 0;
     }
index 92f627f689ff83e9b4404b2ff929c5b31ffa4884..4d6c1ca21d851852f37c5d2962ed6135445a7a48 100644 (file)
@@ -3,7 +3,7 @@ LIBS=$(EXTRA_LIBS) $(LIBS1)
 INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
 LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
 
-OBJS=   os.o os-inline.o ebcdic.o bs2login.o
+OBJS=   os.o os-inline.o bs2login.o
 
 LIB=   libos.a
 
index f5cccf9914209218bd7368d29c79209014bf69de..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,183 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-
-#ifdef CHARSET_EBCDIC
-#include "ap_config.h"
-#include "ebcdic.h"
-/*
-           Initial Port for Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>
-
-"BS2000 OSD/POSIX" is a POSIX subsystem on a main frame. It is made
-by Fujitsu-Siemens Computers GmbH, Germany. The POSIX system has been
-derived from a regular SVR4 source and thus is very "compatible"
-to other unixes. In fact, it received the X/Open branding.
-
-Within the POSIX subsystem, the same character set was chosen as in
-"native BS2000", namely EBCDIC. This requires conversions at various
-stages of the request and response processing.
-
-EBCDIC Table. (In EBCDIC, the letters 'a'..'z' are not contiguous!)
-This table is bijective, i.e. there are no ambigous or duplicate characters
-*/
-
-/* Bijective ebcdic-to-ascii table: */
-const unsigned char os_toascii[256] = {
-/*00*/  0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
-        0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
-/*10*/  0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
-        0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
-/*20*/  0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
-        0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
-/*30*/  0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
-        0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
-/*40*/  0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
-        0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
-/*50*/  0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
-        0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
-/*60*/  0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
-        0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
-/*70*/  0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
-        0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
-/*80*/  0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
-        0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
-/*90*/  0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
-        0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
-/*a0*/  0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
-        0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
-/*b0*/  0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
-        0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
-/*c0*/  0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
-        0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
-/*d0*/  0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
-        0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
-/*e0*/  0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
-        0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
-/*f0*/  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
-        0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e  /*0123456789.{.}.~*/
-};
-
-
-/* Bijective ascii-to-ebcdic table: */
-const unsigned char os_toebcdic[256] = {
-/*00*/  0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
-        0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,  /*................*/
-/*10*/  0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
-        0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f,  /*................*/
-/*20*/  0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
-        0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61,  /* !"#$%&'()*+,-./ */
-/*30*/  0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
-        0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f,  /*0123456789:;<=>?*/
-/*40*/  0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
-        0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,  /*@ABCDEFGHIJKLMNO*/
-/*50*/  0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
-        0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d,  /*PQRSTUVWXYZ[\]^_*/
-/*60*/  0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
-        0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,  /*`abcdefghijklmno*/
-/*70*/  0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
-        0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07,  /*pqrstuvwxyz{|}~.*/
-/*80*/  0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
-        0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14,  /*................*/
-/*90*/  0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
-        0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f,  /*................*/
-/*a0*/  0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
-        0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1,  /*................*/
-/*b0*/  0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
-        0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab,  /*................*/
-/*c0*/  0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
-        0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,  /*................*/
-/*d0*/  0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
-        0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59,  /*................*/
-/*e0*/  0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
-        0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,  /*................*/
-/*f0*/  0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
-        0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf   /*................*/
-};
-
-/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
- * dest and srce may be identical, or separate memory blocks, but
- * should not overlap. These functions intentionally have an interface
- * compatible to memcpy(3).
- */
-
-void *
-ebcdic2ascii(void *dest, const void *srce, size_t count)
-{
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
-
-    while (count-- != 0) {
-        *udest++ = os_toascii[*usrce++];
-    }
-
-    return dest;
-}
-
-void *
-ascii2ebcdic(void *dest, const void *srce, size_t count)
-{
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
-
-    while (count-- != 0) {
-        *udest++ = os_toebcdic[*usrce++];
-    }
-
-    return dest;
-}
-#endif /*CHARSET_EBCDIC*/
index a9370b489b0ebba5b6e7db8411df792989032f6d..18c10949933a52f5ab6364ef9f6166ff78993f89 100644 (file)
@@ -1,11 +1,6 @@
-#ifndef AP_EBCDIC_H
-#define AP_EBCDIC_H  "$Id: ebcdic.h,v 1.8 2000/06/21 14:36:32 martin Exp $"
+#ifndef EBCDIC_H
+#define EBCDIC_H  "$Id: ebcdic.h,v 1.9 2001/03/09 10:10:40 martin Exp $"
 
-#include <sys/types.h>
+#include <ap_ebcdic.h>
 
-extern const unsigned char os_toascii[256];
-extern const unsigned char os_toebcdic[256];
-API_EXPORT(void *) ebcdic2ascii(void *dest, const void *srce, size_t count);
-API_EXPORT(void *) ascii2ebcdic(void *dest, const void *srce, size_t count);
-
-#endif /*AP_EBCDIC_H*/
+#endif /*EBCDIC_H*/
index 40b3e4dc49814fbcde3c5899be2a4e2270006f50..32609181c5e7bc8b76b802e118865215f2312be8 100644 (file)
 #include "http_core.h"
 #include "os.h"
 
-/* Check the Content-Type to decide if conversion is needed */
-int ap_checkconv(struct request_rec *r)
-{
-    int convert_to_ascii;
-    const char *type;
-
-    /* To make serving of "raw ASCII text" files easy (they serve faster 
-     * since they don't have to be converted from EBCDIC), a new
-     * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
-     * If we detect one of these content types here, we simply correct
-     * the type to the real text/{plain,html,...} type. Otherwise, we
-     * set a flag that translation is required later on.
-     */
-
-    type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
-
-    /* If no content type is set then treat it as (ebcdic) text/plain */
-    convert_to_ascii = (type == NULL);
-
-    /* Conversion is applied to text/ files only, if ever. */
-    if (type && (strncasecmp(type, "text/", 5) == 0 ||
-                strncasecmp(type, "message/", 8) == 0 ||
-                strncasecmp(type, "multipart/", 10) == 0)) {
-       if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
-                       sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
-           r->content_type = ap_pstrcat(r->pool, "text/",
-                                        type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
-                                        NULL);
-        else
-           /* translate EBCDIC to ASCII */
-           convert_to_ascii = 1;
-    }
-    /* Enable conversion if it's a text document */
-    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
-
-    return convert_to_ascii;
-}
-
 #ifdef HAVE_DLFCN_H
 #include "../unix/os.c"
 #endif
index 7bda3479b981bc58688cf4132690098fb7b484e0..d3a64281b88607d83f27e41d3e107ff3a7136861 100644 (file)
@@ -42,10 +42,22 @@ typedef struct {
 extern int _rini(_rini_struct *);
 #endif /* !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) */
 
-/* Sorry if this is ugly, but the include order doesn't allow me
- * to use request_rec here... */
-struct request_rec;
-extern int ap_checkconv(struct request_rec *r);
 extern pid_t os_fork(const char *user);
+#ifdef _OSD_POSIX
+struct pool;
+extern const char *os_set_account(struct pool *p, const char *account);
+struct server_rec;
+extern int os_init_job_environment(struct server_rec *s, const char *user_name, int one_process);
+#endif
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#define     ap_os_dso_handle_t  void *
+void        ap_os_dso_init(void);
+void *      ap_os_dso_load(const char *);
+void        ap_os_dso_unload(void *);
+void *      ap_os_dso_sym(void *, const char *);
+const char *ap_os_dso_error(void);
+#endif
 
 #endif /*! APACHE_OS_H*/
index 55488a83b23cf33ff9910d21941de93c476ecbc4..23c509918eff2c869ea8c4ba999ff447c80e8829 100644 (file)
@@ -3,7 +3,7 @@ LIBS=$(EXTRA_LIBS) $(LIBS1)
 INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
 LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
 
-OBJS=   os.o os-inline.o ebcdic.o
+OBJS=   os.o os-inline.o
 
 LIB=   libos.a
 
@@ -39,14 +39,6 @@ $(OBJS): Makefile
 
 # DO NOT REMOVE
 
-ebcdic.o: ebcdic.c
-ebcdic.o: $(INCDIR)/ap_config.h
-ebcdic.o: $(INCDIR)/ap_mmn.h
-ebcdic.o: $(INCDIR)/ap_config_auto.h
-ebcdic.o: os.h
-ebcdic.o: $(INCDIR)/ap_ctype.h
-ebcdic.o: $(INCDIR)/hsregex.h
-ebcdic.o: ebcdic.h
 os-inline.o: os-inline.c
 os-inline.o: $(INCDIR)/ap_config.h
 os-inline.o: $(INCDIR)/ap_mmn.h
index bb0f78860632fba482a0e264e0f8b98d7a016756..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,174 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-
-#ifdef CHARSET_EBCDIC
-#include "ap_config.h"
-#include "ebcdic.h"
-/*
-This code does basic character mapping for IBM's OS/390 Unix
-System Services operating system.  It is a modified version
-of <Martin.Kraemer@Mch.SNI.De>'s code for the BS2000
-(apache/src/os/bs2000/ebcdic.c).
-*/
-
-/*
-Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
-This table is bijective - there are no ambigous or duplicate characters.
-*/
-const unsigned char os_toascii[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
-    0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
-    0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
-    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
-    0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
-    0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
-    0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
-    0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
-    0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
-    0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
-    0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
-    0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
-    0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
-    0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
-    0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
-    0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
-    0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
-    0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
-    0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
-    0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
-    0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
-    0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
-    0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
-    0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
-    0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
-    0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
-    0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
-    0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
-    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
-    0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
-};
-
-
-/*
-The US-ASCII to EBCDIC (character set IBM-1047) table:
-This table is bijective (no ambiguous or duplicate characters)
-*/
-const unsigned char os_toebcdic[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
-    0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
-    0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
-    0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
-    0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
-    0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
-    0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
-    0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
-    0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
-    0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
-    0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
-    0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
-    0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
-    0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
-    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
-    0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
-    0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
-    0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
-    0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
-    0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
-    0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
-    0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
-    0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
-    0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
-    0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
-    0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
-    0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
-    0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
-    0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
-};
-
-/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
- * dest and srce may be identical, or separate memory blocks, but
- * should not overlap.
- */
-void
-ebcdic2ascii(void *dest, const void *srce, size_t count)
-{
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
-    while (count-- != 0) {
-        *udest++ = os_toascii[*usrce++];
-    }
-}
-
-void
-ascii2ebcdic(void *dest, const void *srce, size_t count)
-{
-        unsigned char *udest = dest;
-        const unsigned char *usrce = srce;
-
-        while (count-- != 0) {
-                *udest++ = os_toebcdic[*usrce++];
-    }
-}
-#endif /*CHARSET_EBCDIC*/
-
index 82b6f699be8c0598141bbcdffb2ba003cc0455a2..9243de3f0e541a38bdc60f4bddb8dda8cb72d70c 100644 (file)
@@ -1,6 +1,6 @@
-#include <sys/types.h>
+#ifndef EBCDIC_H
+#define EBCDIC_H  "$Id: ebcdic.h,v 1.4 2001/03/09 10:10:45 martin Exp $"
 
-extern const unsigned char os_toascii[256];
-extern const unsigned char os_toebcdic[256];
-void ebcdic2ascii(void *dest, const void *srce, size_t count);
-void ascii2ebcdic(void *dest, const void *srce, size_t count);
+#include <ap_ebcdic.h>
+
+#endif /*EBCDIC_H*/
index 591d96414c564f9450c088c7515fede93fd45429..65f53af5eed7f08d9f07dbb3c9246fa561dbe88f 100644 (file)
 #include "http_core.h"
 #include "os.h"
 
-/* Check the Content-Type to decide if conversion is needed */
-int ap_checkconv(struct request_rec *r)
-{
-    int convert_to_ascii;
-    const char *type;
-
-    /* To make serving of "raw ASCII text" files easy (they serve faster 
-     * since they don't have to be converted from EBCDIC), a new
-     * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
-     * If we detect one of these content types here, we simply correct
-     * the type to the real text/{plain,html,...} type. Otherwise, we
-     * set a flag that translation is required later on.
-     */
-
-    type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
-
-    /* If no content type is set then treat it as (ebcdic) text/plain */
-    convert_to_ascii = (type == NULL);
-
-    /* Conversion is applied to text/ files only, if ever. */
-    if (type && (strncasecmp(type, "text/", 5) == 0 ||
-                strncasecmp(type, "message/", 8) == 0)) {
-       if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
-                       sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
-           r->content_type = ap_pstrcat(r->pool, "text/",
-                                        type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
-                                        NULL);
-        else
-           /* translate EBCDIC to ASCII */
-           convert_to_ascii = 1;
-    }
-    /* Enable conversion if it's a text document */
-    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
-
-    return convert_to_ascii;
-}
-
index 4aec04aa5f5c76c4369ced063cf06d8b87bfa6d3..f949c965636cc132e135483bb2cbc114fab2ddc7 100644 (file)
@@ -32,9 +32,4 @@ extern int ap_os_is_path_absolute(const char *file);
 #define ap_os_is_filename_valid(f)          (1)
 #define ap_os_kill(pid, sig)                kill(pid, sig)
 
-/* Sorry if this is ugly, but the include order doesn't allow me
- * to use request_rec here... */
-struct request_rec;
-extern int ap_checkconv(struct request_rec *r);
-
 #endif /*! APACHE_OS_H*/
index 14aa0899b1f4b3bd36ff40082fda048a2e1b8af5..719f603bda638bf1b4580aef33035c1bb14c0126 100644 (file)
@@ -3,7 +3,7 @@ LIBS=$(EXTRA_LIBS) $(LIBS1)
 INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
 LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
 
-OBJS=   os.o os-inline.o ebcdic.o cgetop.o
+OBJS=   os.o os-inline.o cgetop.o
 
 LIB=   libos.a
 
@@ -36,7 +36,6 @@ depend:
 
 $(OBJS): Makefile
 os.o:  os.c os-inline.c $(INCDIR)/ap_config.h
-ebcdic.o: ebcdic.c
 cgetop.o: cgetop.c
 # DO NOT REMOVE
 os.o:  os.c
index 5d7b61690539d2c22af4c8895e373ed3c3e18c86..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,171 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation.  All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:
- *       "This product includes software developed by the
- *        Apache Software Foundation (http://www.apache.org/)."
- *    Alternately, this acknowledgment may appear in the software itself,
- *    if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written
- *    permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- *    nor may "Apache" appear in their name, without prior written
- *    permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation.  For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-
-#ifdef CHARSET_EBCDIC
-#include "ap_config.h"
-#include "ebcdic.h"
-/*
-This code does basic character mapping for IBM's TPF operating system.
-It is a modified version of <Martin.Kraemer@Mch.SNI.De>'s code for
-the BS2000 (apache/src/os/bs2000/ebcdic.c).
-*/
-
-/*
-Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
-This table is bijective - there are no ambigous or duplicate characters.
-*/
-const unsigned char os_toascii[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f:           */
-    0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f:           */
-    0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f:           */
-    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
-    0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f:           */
-    0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
-    0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f:           */
-    0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /*  ...........<(+| */
-    0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f:           */
-    0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
-    0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f:           */
-    0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
-    0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f:           */
-    0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
-    0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f:           */
-    0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
-    0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f:           */
-    0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
-    0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af:           */
-    0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
-    0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf:           */
-    0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
-    0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf:           */
-    0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
-    0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df:           */
-    0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
-    0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef:           */
-    0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
-    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff:           */
-    0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f  /* 0123456789...... */
-};
-
-/*
-The US-ASCII to EBCDIC (character set IBM-1047) table:
-This table is bijective (no ambiguous or duplicate characters)
-*/
-const unsigned char os_toebcdic[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f:           */
-    0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
-    0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f:           */
-    0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
-    0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f:           */
-    0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /*  !"#$%&'()*+,-./ */
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f:           */
-    0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
-    0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f:           */
-    0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
-    0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f:           */
-    0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
-    0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f:           */
-    0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
-    0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f:           */
-    0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
-    0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f:           */
-    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
-    0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f:           */
-    0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
-    0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af:           */
-    0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
-    0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf:           */
-    0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
-    0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf:           */
-    0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
-    0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df:           */
-    0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
-    0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef:           */
-    0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
-    0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff:           */
-    0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf  /* ................ */
-};
-
-/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
- * dest and srce may be identical, or separate memory blocks, but
- * should not overlap.
- */
-void
-ebcdic2ascii(void *dest, const void *srce, size_t count)
-{
-    unsigned char *udest = dest;
-    const unsigned char *usrce = srce;
-    while (count-- != 0) {
-        *udest++ = os_toascii[*usrce++];
-    }
-}
-void
-ascii2ebcdic(void *dest, const void *srce, size_t count)
-{
-        unsigned char *udest = dest;
-        const unsigned char *usrce = srce;
-
-        while (count-- != 0) {
-                *udest++ = os_toebcdic[*usrce++];
-    }
-}
-#endif /*CHARSET_EBCDIC*/
index 3f2a63f06d0f6d2793698e2b1c40da0ad8c3b9af..0c41453fbc3b335762888555798cb862a2adb28e 100644 (file)
@@ -1,7 +1,6 @@
-#include <sys/types.h>
+#ifndef EBCDIC_H
+#define EBCDIC_H  "$Id: ebcdic.h,v 1.3 2001/03/09 10:10:50 martin Exp $"
 
-extern const unsigned char os_toascii[256];
-extern const unsigned char os_toebcdic[256];
-void ebcdic2ascii(void *dest, const void *srce, size_t count);
-void ascii2ebcdic(void *dest, const void *srce, size_t count);
+#include <ap_ebcdic.h>
 
+#endif /*EBCDIC_H*/
index 85440b71dc32f83b144d0023e78b84af0b02acfd..ec6662dce094d9475075609b63a0b7042235c981 100644 (file)
@@ -78,51 +78,6 @@ unsigned short zinet_model;
 
 static FILE *sock_fp;
 
-/* Check the Content-Type to decide if conversion is needed */
-int ap_checkconv(struct request_rec *r)
-{
-    int convert_to_ascii;
-    const char *type;
-
-    /* To make serving of "raw ASCII text" files easy (they serve faster 
-     * since they don't have to be converted from EBCDIC), a new
-     * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
-     * If we detect one of these content types here, we simply correct
-     * the type to the real text/{plain,html,...} type. Otherwise, we
-     * set a flag that translation is required later on.
-     */
-
-    type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
-
-    /* If no content type is set then treat it as (ebcdic) text/plain */
-    convert_to_ascii = (type == NULL);
-
-    /* Conversion is applied to text/ files only, if ever. */
-    if (type && (strncasecmp(type, "text/", 5) == 0 ||
-                strncasecmp(type, "message/", 8) == 0)) {
-       if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
-                        sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0){
-           r->content_type = ap_pstrcat(r->pool, "text/",
-                   type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1, NULL);
-            if (r->method_number == M_PUT)
-                   ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0);
-            }
-
-        else
-           /* translate EBCDIC to ASCII */
-           convert_to_ascii = 1;
-    }
-    else{
-           if (r->method_number == M_PUT)
-               ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0);
-               /* don't translate non-text files to EBCDIC */
-    }
-    /* Enable conversion if it's a text document */
-    ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
-
-    return convert_to_ascii;
-}
-
 int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struct timeval *tv)
 {
 /* We're going to force our way through select.  We're only interested reads and TPF allows
index d9a65f4a1059eadba5675bef2293cdb6bd980e23..77d936bce3c94bd16b812c2e12fb3ec78b019254 100644 (file)
@@ -38,11 +38,6 @@ extern int ap_os_is_path_absolute(const char *f);
 #define ap_os_is_filename_valid(f)          (1)
 #define ap_os_kill(pid, sig)                kill(pid, sig)
 
-/* Sorry if this is ugly, but the include order doesn't allow me
- * to use request_rec here... */
-struct request_rec;
-extern int ap_checkconv(struct request_rec *r);
 #include <strings.h>
 #ifndef __strings_h
 
index dd4638744d49d378c1aee53525c10d0276ef0cb8..7603ba88eb7565d384ee8a5d7a9a2956ddb1902b 100644 (file)
 #include "ap_config.h"
 #include "ap.h"
 #ifdef CHARSET_EBCDIC
-#include "ebcdic.h"
+#include "ap_ebcdic.h"
 #endif
 #include <fcntl.h>
 #ifndef MPE
@@ -887,14 +887,14 @@ static void test(void)
 static void copyright(void)
 {
     if (!use_html) {
-       printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.44 $> apache-1.3");
+       printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.45 $> apache-1.3");
        printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
        printf("Copyright (c) 1998-2000 The Apache Group, http://www.apache.org/\n");
        printf("\n");
     }
     else {
        printf("<p>\n");
-       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-1.3<br>\n", VERSION, "$Revision: 1.44 $");
+       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-1.3<br>\n", VERSION, "$Revision: 1.45 $");
        printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
        printf(" Copyright (c) 1998-2000 The Apache Group, http://www.apache.org/<br>\n");
        printf("</p>\n<p>\n");