ebcdic.html revision 091caae3b2ebdb760c98575d0d5e349cd686f913
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<HTML>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<HEAD>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<TITLE>The Apache EBCDIC Port</TITLE>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik</HEAD>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<BODY
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik BGCOLOR="#FFFFFF"
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik TEXT="#000000"
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik LINK="#0000FF"
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik VLINK="#000080"
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik ALINK="#FF0000"
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<!--#include virtual="header.html" -->
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik<H1 ALIGN="CENTER">Overview of the Apache EBCDIC Port</H1>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik Version 1.3 of the Apache HTTP Server is the first version which
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik includes a port to a (non-ASCII) mainframe machine which uses
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik the EBCDIC character set as its native codeset.<BR>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik (It is the SIEMENS NIXDORF family of mainframes running the
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <A HREF="http://www.sni.de/servers/bs2osd/osdbc_us.htm">BS2000/OSD
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik operating system</A>. This mainframe OS nowadays features a
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik SVR4-derived POSIX subsystem).
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik </P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik The port was started initially to
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <UL>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <LI> prove the feasibility of porting
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <A HREF="http://dev.apache.org/">the Apache HTTP server</A>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik to this platform
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <LI> find a "worthy and capable" successor for the venerable
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <A HREF="http://www.w3.org/Daemon/">CERN-3.0</A> daemon
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik (which was ported a couple of years ago), and to
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <LI> prove that Apache's preforking process model can on this platform
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik easily outperform the accept-fork-serve model used by CERN by a
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik factor of 5 or more.
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik </UL>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik </P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik This document serves as a rationale to describe some of the design
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik decisions of the port to this machine.
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik </P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <H2 ALIGN=CENTER>Design Goals</H2>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik One objective of the EBCDIC port was to maintain enough backwards
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik compatibility with the (EBCDIC) CERN server to make the transition to
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik the new server attractive and easy. This required the addition of
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik a configurable method to define whether a HTML document was stored
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik in ASCII (the only format accepted by the old server) or in EBCDIC
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik (the native document format in the POSIX subsystem, and therefore
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik the only realistic format in which the other POSIX tools like grep
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik or sed could operate on the documents). The current solution to
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik this is a "pseudo-MIME-format" which is intercepted and
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik interpreted by the Apache server (see below). Future versions
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik might solve the problem by defining an "ebcdic-handler" for all
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik documents which must be converted.
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik </P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <H2 ALIGN=CENTER>Technical Solution</H2>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <P>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik Since all Apache input and output is based upon the BUFF data type
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik and its methods, the easiest solution was to add the conversion to
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik the BUFF handling routines. The conversion must be settable at any
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik time, so a BUFF flag was added which defines whether a BUFF object
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik has currently enabled conversion or not. This flag is modified at
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik several points in the HTTP protocol:
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <UL>
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <LI><STRONG>set</STRONG> before a request is received (because the
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik request and the request header lines are always in ASCII
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik format)
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik <LI><STRONG>set/unset</STRONG> when the request body is
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik received - depending on the content type of the request body
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik (because the request body may contain ASCII text or a binary file)
8d22687fbdc540bd0b4d05fd90d87fb6037f4b9fJorgen Austvik
<LI><STRONG>set</STRONG> before a reply header is sent (because the
response header lines are always in ASCII format)
<LI><STRONG>set/unset</STRONG> when the response body is
sent - depending on the content type of the response body
(because the response body may contain text or a binary file)
</UL>
</P>
<H2 ALIGN=CENTER>Porting Notes</H2>
<P>
<OL>
<LI>
The relevant changes in the source are #ifdef'ed into two
categories:
<DL>
<DT><CODE><STRONG>#ifdef CHARSET_EBCDIC</STRONG></CODE>
<DD>Code which is needed for any EBCDIC based machine. This
includes character translations, differences in
contiguity of the two character sets, flags which
indicate which part of the HTTP protocol has to be
converted and which part doesn't etc.
<DT><CODE><STRONG>#ifdef _OSD_POSIX</STRONG></CODE>
<DD>Code which is needed for the BS2000 SIEMENS NIXDORF
mainframe platform only. This deals with include file
differences and socket implementations topics which are
only required on the BS2000/OSD platform.
</DL>
</LI><BR>
<LI>
The possibility to translate between ASCII and EBCDIC at the
socket level (on BS2000 POSIX, there is a socket option which
supports this) was intentionally <EM>not</EM> chosen, because
the byte stream at the HTTP protocol level consists of a
mixture of protocol related strings and non-protocol related
raw file data. HTTP protocol strings are always encoded in
ASCII (the GET request, any Header: lines, the chunking
information etc.) whereas the file transfer parts (i.e., GIF
images, CGI output etc.) should usually be just "passed through"
by the server. This separation between "protocol string" and
"raw data" is reflected in the server code by functions like
bgets() or rvputs() for strings, and functions like bwrite()
for binary data. A global translation of everything would
therefore be inadequate.<BR>
(In the case of text files of course, provisions must be made so
that EBCDIC documents are always served in ASCII)
</LI><BR>
<LI>
This port therefore features a built-in protocol level conversion
for the server-internal strings (which the compiler translated to
EBCDIC strings) and thus for all server-generated documents.
The hard coded ASCII escapes \012 and \015 which are
ubiquitous in the server code are an exception: they are
already the binary encoding of the ASCII \n and \r and must
not be converted to ASCII a second time. This exception is
only relevant for server-generated strings; and <EM>external</EM>
EBCDIC documents are not expected to contain ASCII newline characters.
</LI><BR>
<LI>
By examining the call hierarchy for the BUFF management
routines, I added an "ebcdic/ascii conversion layer" which
would be crossed on every puts/write/get/gets, and a
conversion flag which allowed enabling/disabling the
conversions on-the-fly. Usually, a document crosses this
layer twice from its origin source (a file or CGI output) to
its destination (the requesting client): <SAMP>file -&gt;
Apache</SAMP>, and <SAMP>Apache -&gt; client</SAMP>.<BR>
The server can now read the header
lines of a CGI-script output in EBCDIC format, and then find
out that the remainder of the script's output is in ASCII
(like in the case of the output of a WWW Counter program: the
document body contains a GIF image). All header processing is
done in the native EBCDIC format; the server then determines,
based on the type of document being served, whether the
document body (except for the chunking information, of
course) is in ASCII already or must be converted from EBCDIC.
</LI><BR>
<LI>
For Text documents (MIME types text/plain, text/html etc.),
an implicit translation to ASCII can be used, or (if the
users prefer to store some documents in raw ASCII form for
faster serving, or because the files reside on a NFS-mounted
directory tree) can be served without conversion.
<BR>
<STRONG>Example:</STRONG><BLOCKQUOTE>
to serve files with the suffix .ahtml as a raw ASCII text/html
document without implicit conversion (and suffix .ascii
as ASCII text/plain), use the directives:<PRE>
AddType text/x-ascii-html .ahtml
AddType text/x-ascii-plain .ascii
</PRE></BLOCKQUOTE>
Similarly, any text/XXXX MIME type can be served as "raw ASCII" by
configuring a MIME type "text/x-ascii-XXXX" for it using AddType.
</LI><BR>
<LI>
Non-text documents are always served "binary" without conversion.
This seems to be the most sensible choice for, .e.g., GIF/ZIP/AU
file types. This of course requires the user to copy them to the
mainframe host using the "rcp -b" binary switch.
</LI><BR>
<LI>
Server parsed files are always assumed to be in native (i.e.,
EBCDIC) format as used on the machine, and are converted after
processing.
</LI><BR>
<LI>
For CGI output, the CGI script determines whether a conversion is
needed or not: by setting the appropriate Content-Type, text files
can be converted, or GIF output can be passed through unmodified.
An example for the latter case is the wwwcount program which we ported
as well.
</LI><BR>
</OL>
</P>
<H2 ALIGN=CENTER>Document Storage Notes</H2>
<H3 ALIGN=CENTER>Binary Files</H3>
<P>
All files with a <SAMP>Content-Type:</SAMP> which does not
start with <SAMP>text/</SAMP> are regarded as <EM>binary files</EM>
by the server and are not subject to any conversion.
Examples for binary files are GIF images, gzip-compressed
files and the like.
</P>
<P>
When exchanging binary files between the mainframe host and a
Unix machine or Windows PC, be sure to use the ftp "binary"
(<SAMP>TYPE I</SAMP>) command, or use the
<SAMP>rcp&nbsp;-b</SAMP> command from the mainframe host
(the -b switch is not supported in unix rcp's).
</P>
<H3 ALIGN=CENTER>Text Documents</H3>
<P>
The default assumption of the server is that Text Files
(i.e., all files whose <SAMP>Content-Type:</SAMP> starts with
<SAMP>text/</SAMP>) are stored in the native character
set of the host, EBCDIC.
</P>
<H3 ALIGN=CENTER>Server Side Included Documents</H3>
<P>
SSI documents must currently be stored in EBCDIC only. No
provision is made to convert it from ASCII before processing.
</P>
<H2 ALIGN=CENTER>Apache Modules' Status</H2>
<TABLE BORDER ALIGN=middle>
<TR>
<TH>Module
<TH>Status
<TH>Notes
</TR>
<TR>
<TD ALIGN=LEFT>http_core
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_access
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_actions
<TD ALIGN=CENTER>?
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_alias
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_asis
<TD ALIGN=CENTER>?
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_auth
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_auth_anon
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_auth_db
<TD ALIGN=CENTER>?
<TD>with own libdb.a
</TR>
<TR>
<TD ALIGN=LEFT>mod_auth_dbm
<TD ALIGN=CENTER>?
<TD>with own libdb.a
</TR>
<TR>
<TD ALIGN=LEFT>mod_autoindex
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_cern_meta
<TD ALIGN=CENTER>?
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_cgi
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_digest
<TD ALIGN=CENTER>-
<TD>MD5 not ported yet
</TR>
<TR>
<TD ALIGN=LEFT>mod_dir
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_dld
<TD ALIGN=CENTER>-
<TD>no shared libs
</TR>
<TR>
<TD ALIGN=LEFT>mod_env
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_example
<TD ALIGN=CENTER>-
<TD>not tried yet
</TR>
<TR>
<TD ALIGN=LEFT>mod_expires
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_headers
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_imap
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_include
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_info
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_log_agent
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_log_config
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_log_referer
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_mime
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_mime_magic
<TD ALIGN=CENTER>-
<TD>not tried yet
</TR>
<TR>
<TD ALIGN=LEFT>mod_negotiation
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_proxy
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_rewrite
<TD ALIGN=CENTER>?
<TD>untested
</TR>
<TR>
<TD ALIGN=LEFT>mod_setenvif
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_speling
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_status
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_unique_id
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_userdir
<TD ALIGN=CENTER>+
<TD>
</TR>
<TR>
<TD ALIGN=LEFT>mod_usertrack
<TD ALIGN=CENTER>?
<TD>untested
</TR>
</TABLE>
<H2 ALIGN=CENTER>Third Party Modules' Status</H2>
<TABLE BORDER ALIGN=middle>
<TR>
<TH>Module
<TH>Status
<TH>Notes
</TR>
<TR>
<TD ALIGN=LEFT><A HREF="http://java.apache.org/">mod_jserv</A>
<TD ALIGN=CENTER>-
<TD>JAVA still being ported.
</TR>
<TR>
<TD ALIGN=LEFT><A HREF="http://www.php.net/">mod_php</A>
<TD ALIGN=CENTER>-
<TD>not ported yet
</TR>
<TR>
<TD ALIGN=LEFT
><A HREF="http://hpwww.ec-lyon.fr/~vincent/apache/mod_put.html">mod_put</A>
<TD ALIGN=CENTER>?
<TD>untested
</TR>
<TR>
<TD ALIGN=LEFT
><A HREF="ftp://hachiman.vidya.com/pub/apache/">mod_session</A>
<TD ALIGN=CENTER>-
<TD>untested
</TR>
</TABLE>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>