httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ovies Brabson <ovi...@us.ibm.com>
Subject [PATCH]Whoops! Apache 1.3.9 Port to OS/390 Unix System Services
Date Tue, 16 Nov 1999 17:54:53 GMT
Whoops!  I had been playing with two different versions of pax on OS/390
and forgot to
replace the pax invocations in xebcdic.sh to pick up what is normally
installed on the system.

---------------------------------------------------------------------------------------------

Here's a patch to port the apache 1.3.9 code base to run on Unix System
Services on OS/390.  We've done some basic testing and things appear
to work for the most part.  We'd like to get it out there for others to
try
and provide feedback.

Besides the unified diff file showing the changes to existing files on
the apache tree, I am including the files in the new src/os/os390
directory.  The files in this directory are basically the same as those
in src/os/bs2000 with some small mods for OS/390.

To facilitate transferring the apache tree from the web to an OS/390
ebcdic system, a new shell script was written.  The shell script is
called xebcdic.sh.  It will de-compress the compressed archive and will
extract the files from the archive while applying ascii to ebcdic
translation.  I would like this new script which I added to the
src/helpers directory to be distributed on the web page where the
compressed archives are distributed along with a README.os390 which
lives in the src/os/os390 directory in the tree.  Would this be
difficult to do?
Would anyone object to doing this?  Both files are included in this note

for review.

----------------------------------------------------------------------------------------------------

? apache-1.3/src/helpers/xebcdic.sh
? apache-1.3/src/os/os390
Index: apache-1.3/INSTALL
===================================================================
RCS file: /home/cvs/apache-1.3/INSTALL,v
retrieving revision 1.60
diff -u -r1.60 INSTALL
--- INSTALL     1999/08/29 10:17:07     1.60
+++ INSTALL     1999/11/16 02:26:30
@@ -160,6 +160,8 @@
                              [--without-support]
[--suexec-gidmin=GID]
                              [--without-confadjust]
[--suexec-safepath=PATH]
                              [--without-execstrip]
+                            [--server-uid=UID]
+                            [--server-gid=GID]

      Use the CC, OPTIM, CFLAGS, INCLUDES, LDFLAGS, LIBS, CFLAGS_SHLIB,
      LD_SHLIB, LDFLAGS_SHLIB, LDFLAGS_SHLIB_EXPORT, RANLIB, DEPS and
TARGET
@@ -413,6 +415,14 @@

      Use the --verbose option to enable additional verbose messages.

+     Use the --server-uid option to specify the user ID you want the
server to run
+     as. If not specified the server will run as user nobody.  If the
user ID
+     specified is different than the ID of the user starting the
server, you need to
+     start the server as root.
+
+     Use the --server-gid option to specify the group ID you want the
server user ID to
+     be a member of.  If not specified, the group ID will be #-1.
+
   4. Building the package
      --------------------

Index: apache-1.3/Makefile.tmpl
===================================================================
RCS file: /home/cvs/apache-1.3/Makefile.tmpl,v
retrieving revision 1.90
diff -u -r1.90 Makefile.tmpl
--- Makefile.tmpl       1999/08/27 11:26:12     1.90
+++ Makefile.tmpl       1999/11/16 02:26:30
@@ -69,6 +69,9 @@
 #   safe environment
 SHELL           = @SHELL@

+#   what platform are we on
+PLATFORM       = @PLATFORM@
+
 #   paths to the source tree parts
 TOP             = .
 SRC             = @SRC@
@@ -176,12 +179,19 @@

 #   build the standard stuff
 build-std:
-       @cd $(TOP)/$(SRC); $(MAKE) $(MFLAGS) SDP=$(SRC)/ all
+       @cd $(TOP)/$(SRC); \
+       if echo "$(PLATFORM)" | grep -q '390'; then \
+               _C89_STEPS="0xffffffff"; export _C89_STEPS; \
+       fi; \
+       $(MAKE) $(MFLAGS) SDP=$(SRC)/ all

 #   build the additional support stuff
 build-support:
        @echo "===> $(SRC)/support"; \
-       cd $(TOP)/$(SRC)/support; $(MAKE) $(MFLAGS) all || exit 1; \
+       if echo "$(PLATFORM)" | grep -q '390'; then \
+               _C89_STEPS="0xffffffff"; export _C89_STEPS; \
+       fi; \
+       cd $(TOP)/$(SRC)/support; $(MAKE) $(MFLAGS) all; \
        if [ ".$(suexec)" = .1 ]; then \
            $(MAKE) $(MFLAGS) \
                EXTRA_CFLAGS='\
Index: apache-1.3/configure
===================================================================
RCS file: /home/cvs/apache-1.3/configure,v
retrieving revision 1.104
diff -u -r1.104 configure
--- configure   1999/10/05 14:46:02     1.104
+++ configure   1999/11/16 02:26:30
@@ -197,6 +197,16 @@
 esac

 ##
+## Request USTAR format for tar files on OS/390
+## Request that prelink step be used for 390
+##
+case $PLATFORM in
+    *-IBM-OS390*)
+       TAROPT="${TAROPT}U"
+       ;;
+esac
+
+##
 ##  determine path to sh, it's not /bin/sh on ALL systems
 ##
 SHELL=/bin/sh
@@ -348,6 +358,12 @@
 esac

 ##
+##  Initialize server user ID and group ID variables
+##
+conf_user=""
+conf_group=""
+
+##
 ##  Iterate over the command line options the first time.
 ##
 ##  This time we pre-process options which need high priority
@@ -417,6 +433,8 @@
             echo " --without-support      disable the build and
installation of support tools"
             echo " --without-confadjust   disable the user/situation
adjustments in config"
             echo " --without-execstrip    disable the stripping of
executables on installation"
+            echo " --server-uid=UID       set the user ID the web
server should run as [nobody]"
+            echo " --server-gid=GID       set the group ID the web
server UID is a memeber of [-1]"
             echo ""
             echo "suEXEC options:"
             echo " --enable-suexec        enable the suEXEC feature"
@@ -939,6 +957,12 @@
             suexec_safepath="$apc_optarg"
             suexec_ok=1
             ;;
+        --server-uid=*)
+            conf_user="$apc_optarg"
+            ;;
+        --server-gid=*)
+            conf_group="$apc_optarg"
+            ;;
         * )
             echo "configure:Error: invalid option '$apc_option'" 1>&2
             exit 1
@@ -1083,25 +1107,27 @@
 ##  on platforms using NIS. But then you propably do not want a
 ##  UID/GID as production oriented as a web server in NIS anyway.
 ##
-conf_user="nobody"
-conf_group="\\\\#-1"
 conf_port="80"
 conf_serveradmin="you@your.address"
 conf_servername="new.host.name"
 if [ "x$confadjust" = "x1" ]; then
     if [ -f /etc/passwd ]; then
-        for uid in nobody www daemon demon http httpd; do
-            if [ "x`egrep \^${uid}: /etc/passwd`" != "x" ]; then
-                conf_user="$uid"
-                break
-            fi
-        done
-        for gid in nobody nogroup www daemon demon http httpd; do
-            if [ "x`egrep \^${gid}: /etc/group`" != "x" ]; then
-                conf_group="$gid"
-                break
-            fi
-        done
+        if [ "x$conf_user" = "x" ]; then
+            for uid in nobody www daemon demon http httpd; do
+                if [ "x`egrep \^${uid}: /etc/passwd`" != "x" ]; then
+                    conf_user="$uid"
+                    break
+                fi
+            done
+        fi
+        if [ "x$conf_group" = "x" ]; then
+            for gid in nobody nogroup www daemon demon http httpd; do
+                if [ "x`egrep \^${gid}: /etc/group`" != "x" ]; then
+                    conf_group="$gid"
+                    break
+                fi
+            done
+        fi
     fi
     if [ "x`$aux/getuid.sh`" != "x0" ]; then
         conf_port="8080"
@@ -1111,6 +1137,17 @@
 fi

 ##
+## Default server user id and group id if not specified on configure
invocation and none
+## of the ids in /etc/passwd or /etc/group worked.
+##
+if [ "x$conf_user" = "x" ]; then
+    conf_user="nobody"
+fi
+if [ "x$conf_group" = "x" ]; then
+    conf_group="#-1"
+fi
+
+##
 ##  determine prefix-relative paths for directories
 ##  because Apache supports them for the -d and -f
 ##  options, the LoadModule directive, etc.
@@ -1182,6 +1219,7 @@
     echo "Creating $mkf"
 fi
 sed <Makefile.tmpl >$mkf \
+-e "s%@PLATFORM@%$PLATFORM%g" \
 -e "s%@PERL@%$PERL%g" \
 -e "s%@TAR@%$TAR%g" \
 -e "s%@TAROPT@%$TAROPT%g" \
Index: apache-1.3/src/Configure
===================================================================
RCS file: /home/cvs/apache-1.3/src/Configure,v
retrieving revision 1.373
diff -u -r1.373 Configure
--- Configure   1999/10/27 09:30:19     1.373
+++ Configure   1999/11/16 02:26:30
@@ -783,6 +783,14 @@
        CFLAGS="-D_TANDEM_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
        CC='c89'
        ;;
+    *-IBM-OS390*)
+       OS='OS390'
+       OSDIR='os/os390'
+       CC='c89'
+       CFLAGS="$CFLAGS -DOS390 -DCHARSET_EBCDIC -D_ALL_SOURCE"
+       DEF_WANTHSREGEX=yes
+       LIBS="$LIBS"
+       ;;
     *) # default: Catch systems we don't know about
        OS='Unknown and unsupported OS'
        echo Sorry, but we cannot grok \"$PLAT\"
@@ -830,6 +838,7 @@
 echo >>Makefile.config "INCDIR=\$(SRCDIR)/include"
 echo >>Makefile.config "INCLUDES0=-I\$(OSDIR) -I\$(INCDIR)"
 echo >>Makefile.config "SHELL=$SHELL"
+echo >>Makefile.config "OS=$OS"

 ####################################################################
 ## And adjust/override WANTHSREGEX as needed
@@ -920,7 +929,7 @@
 echo "#define AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H

 echo " + checking for system header files"
-CHECK_FOR_HEADERS="dlfcn.h dl.h bstring.h crypt.h unistd.h
sys/resource.h sys/select.h sys/processor.h"
+CHECK_FOR_HEADERS="dlfcn.h dl.h bstring.h crypt.h unistd.h
sys/resource.h sys/select.h sys/processor.h sys/param.h"
 for header in $CHECK_FOR_HEADERS; do
     echo "" >>$AP_CONFIG_AUTO_H
     echo "/* check: #include <$header> */" >>$AP_CONFIG_AUTO_H
@@ -2225,7 +2234,11 @@
        @for i in \$(MODULES) ""; do \\
          if [ "x\$\$i" != "x" ]; then \\
            echo "===> \$(SDP)modules/\$\$i"; \\
-               (cd \$\$i && \$(MAKE) \$(MFLAGS_STATIC) SDP='\$(SDP)'
CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1;
\\
+               if [[ "x\$(OS)" != "xOS390" && "x\$(OS)" != "xTPF" ]];
then \\
+                 (cd \$\$i && \$(MAKE) \$(MFLAGS_STATIC) SDP='\$(SDP)'
CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1;
\\
+               else \\
+                 (cd \$\$i && \$(MAKE) SDP='\$(SDP)' \$@) || exit 1; \\

+               fi; \\
                echo "<=== \$(SDP)modules/\$\$i"; \\
          fi; \\
        done
Index: apache-1.3/src/Makefile.tmpl
===================================================================
RCS file: /home/cvs/apache-1.3/src/Makefile.tmpl,v
retrieving revision 1.114
diff -u -r1.114 Makefile.tmpl
--- Makefile.tmpl       1999/08/19 08:54:14     1.114
+++ Makefile.tmpl       1999/11/16 02:26:30
@@ -63,7 +63,11 @@
 subdirs:
        @for i in $(SUBDIRS); do \
                echo "===> $(SDP)$$i"; \
-               ( cd $$i && $(MAKE) $(MFLAGS_STATIC) SDP='$(SDP)'
CC='$(CC)' AUX_CFLAGS='$(CFLAGS)' RANLIB='$(RANLIB)') || exit 1; \
+               if [[ ".$(OS)" != ".OS390" && ".$(OS)" != ".TPF" ]];
then \
+                       ( cd $$i && $(MAKE) $(MFLAGS_STATIC)
SDP='$(SDP)' CC='$(CC)' AUX_CFLAGS='$(CFLAGS)' RANLIB='$(RANLIB)') ||
exit 1; \
+               else \
+                       ( cd $$i && $(MAKE) SDP='$(SDP)' ) || exit 1; \
+               fi; \
                echo "<=== $(SDP)$$i"; \
        done

Index: apache-1.3/src/PORTING
===================================================================
RCS file: /home/cvs/apache-1.3/src/PORTING,v
retrieving revision 1.33
diff -u -r1.33 PORTING
--- PORTING     1998/09/17 21:13:58     1.33
+++ PORTING     1999/11/16 02:26:30
@@ -200,6 +200,12 @@
       functions are available as well. This is set automatically during

the
       Configure process and stored in the src/include/ap_config_auto.h
header
       file.
+
+    HAVE_SYS_PARAM_H:
+      Defined if the OS has the <sys/param.h> header file.  This is set

+      automatically during the Configure process and stored in the
+      src/include/ap_config_auto.h header file.
+
 --

  USE_*:
Index: apache-1.3/src/helpers/GuessOS
===================================================================
RCS file: /home/cvs/apache-1.3/src/helpers/GuessOS,v
retrieving revision 1.63
diff -u -r1.63 GuessOS
--- GuessOS     1999/08/09 07:38:44     1.63
+++ GuessOS     1999/11/16 02:26:31
@@ -279,6 +279,9 @@
     *:*:*:"DRS 6000")
         echo "drs6000-whatever-whatever"; exit 0;
        ;;
+    OS/390:*)
+        echo "${MACHINE}-IBM-OS390-${RELEASE}-${VERSION}"; exit 0;
+        ;;
 esac

 #
Index: apache-1.3/src/helpers/TestCompile
===================================================================
RCS file: /home/cvs/apache-1.3/src/helpers/TestCompile,v
retrieving revision 1.34
diff -u -r1.34 TestCompile
--- TestCompile 1999/07/21 14:32:55     1.34
+++ TestCompile 1999/11/16 02:26:31
@@ -1,6 +1,6 @@
 #!/bin/sh
 exstat=1
-trap 'rm -f Makefile dummy dummy.exe testfunc.c testfunc testfunc.exe;
exit $exstat' 0 1 2 3 15
+trap 'rm -f Makefile dummy ../dummy.o dummy.exe testfunc.c testfunc
../testfunc.o testfunc.exe; exit $exstat' 0 1 2 3 15
 #
 # Yet another Apache Configure helper script.
 # This script tests certain aspects of the compilation
@@ -191,7 +191,18 @@
 #
 # Get makefile settings and build a basic Makefile
 #
-rm -f dummy
+if [ -f dummy ]; then
+   rm -f dummy
+fi
+if [ -f ../dummy.o ]; then
+   rm -f ../dummy.o
+fi
+if [ -f testfunc ]; then
+   rm -f testfunc
+fi
+if [ -f ../testfunc.o ]; then
+   rm -f ../testfunc.o
+fi
 cat ../Makefile.config > Makefile
 cat <<EOF >> Makefile
 CFLAGS=\$(OPTIM) \$(CFLAGS1) \$(EXTRA_CFLAGS)
@@ -200,10 +211,10 @@
 LDFLAGS=\$(LDFLAGS1) \$(EXTRA_LDFLAGS)

 dummy:
-       cd ..; \$(CC) \$(CFLAGS) \$(INCLUDES) \$(LDFLAGS)
helpers/dummy.c -o helpers/dummy $TLIB \$(LIBS)
+       cd ..; \$(CC) \$(CFLAGS) \$(INCLUDES) \$(LDFLAGS) -o
helpers/dummy $TLIB \$(LIBS) helpers/dummy.c

 testfunc:
-       cd ..; \$(CC) \$(CFLAGS) \$(INCLUDES) \$(LDFLAGS)
helpers/testfunc.c -o helpers/testfunc $TLIB \$(LIBS)
+       cd ..; \$(CC) \$(CFLAGS) \$(INCLUDES) \$(LDFLAGS) -o
helpers/testfunc $TLIB \$(LIBS) helpers/testfunc.c
 EOF

 # Now run that Makefile
Index: apache-1.3/src/helpers/binbuild.sh
===================================================================
RCS file: /home/cvs/apache-1.3/src/helpers/binbuild.sh,v
retrieving revision 1.13
diff -u -r1.13 binbuild.sh
--- binbuild.sh 1999/08/13 03:26:29     1.13
+++ binbuild.sh 1999/11/16 02:26:31
@@ -6,12 +6,15 @@
 # This script falls under the Apache License.
 # See http://www.apache.org/docs/LICENSE

-
-CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most
--enable-shared=max"
+OS=`src/helpers/GuessOS`
+if echo "$OS" | grep -q '390'; then
+  CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most
--enable-module=log_agent --enable-module=log_referer
--enable-module=example --enable-module=mmap_static"
+else
+  CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most
--enable-shared=max"
+fi
 APDIR=`pwd`
 APDIR=`basename $APDIR`
 VER=`echo $APDIR |sed s/apache_//`
-OS=`src/helpers/GuessOS`
 TAR="`src/helpers/PrintPath tar`"
 GTAR="`src/helpers/PrintPath gtar`"
 GZIP="`src/helpers/PrintPath gzip`"
@@ -269,7 +272,11 @@
   else
     if [ "x$TAR" != "x" ]
     then
-      $TAR -cf ../apache_$VER-$OS.tar -C .. apache_$VER
+      if echo "$OS" | grep -q '390'; then
+        $TAR -cfU ../apache_$VER-$OS.tar -C .. apache_$VER
+      else
+        $TAR -cf ../apache_$VER-$OS.tar -C .. apache_$VER
+      fi
       if [ "x$GZIP" != "x" ]
       then
         $GZIP ../apache_$VER-$OS.tar
Index: apache-1.3/src/include/ap_config.h
===================================================================
RCS file: /home/cvs/apache-1.3/src/include/ap_config.h,v
retrieving revision 1.272
diff -u -r1.272 ap_config.h
--- ap_config.h 1999/10/28 17:57:28     1.272
+++ ap_config.h 1999/11/16 02:26:31
@@ -116,10 +116,6 @@
 #include "os.h"
 #endif

-#if !defined(QNX) && !defined(MPE) && !defined(WIN32) && !defined(TPF)
&& !defined(NETWARE)
-#include <sys/param.h>
-#endif
-
 /* Define one of these according to your system. */
 #if defined(MINT)
 typedef int rlim_t;
@@ -952,6 +948,28 @@
 #define NO_KILLPG
 #define NEED_INITGROUPS
 #define NO_SLACK
+
+#elif defined(OS390)                /* IBM OS/390 Operating System
*/
+#define HAVE_MMAP
+#define HAVE_SHMGET
+#define USE_SHMGET_SCOREBOARD
+#define USE_MMAP_FILES
+#define USE_FCNTL_SERIALIZED_ACCEPT
+#define _POSIX_SOURCE
+#include <signal.h>
+#define NSIG SIGDUMP+1
+#define JMP_BUF sigjmp_buf
+#define _XOPEN_SOURCE_EXTENDED 1
+#define _OPEN_MSGQ_EXT
+#define _XOPEN_SOURCE
+#define SHM_R S_IRUSR
+#define SHM_W S_IWUSR
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/msg.h>
+#include <sys/socket.h>
+#define NET_SIZE_T size_t
+
 #else
 /* Unknown system - Edit these to match */
 #ifdef BSD
@@ -966,6 +984,10 @@
 /* NEED_STRDUP is set on stupid systems that don't have strdup. */
 #undef NEED_STRDUP
 #endif
+
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */

 /* stuff marked API_EXPORT is part of the API, and intended for use
  * by modules
Index: apache-1.3/src/main/buff.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/buff.c,v
retrieving revision 1.90
diff -u -r1.90 buff.c
--- buff.c      1999/10/22 05:10:06     1.90
+++ buff.c      1999/11/16 02:26:31
@@ -1167,7 +1167,7 @@
                                 nbyte);
 #ifdef CHARSET_EBCDIC
     /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in
ASCII */
-    ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
+    ebcdic2ascii((unsigned char *)chunksize, (unsigned char
*)chunksize, strlen(chunksize));
 #endif /*CHARSET_EBCDIC*/
     vec[1].iov_base = (void *) buf;    /* cast is to avoid const
warning */
     vec[1].iov_len = nbyte;
@@ -1206,7 +1206,7 @@
                                        "%x\015\012", nbyte);
 #ifdef CHARSET_EBCDIC
     /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in
ASCII */
-       ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
+       ebcdic2ascii((unsigned char *)chunksize, (unsigned char
*)chunksize, strlen(chunksize));
 #endif /*CHARSET_EBCDIC*/
        ++nvec;
        vec[nvec].iov_base = (void *) buf;
Index: apache-1.3/src/main/http_main.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/http_main.c,v
retrieving revision 1.481
diff -u -r1.481 http_main.c
--- http_main.c 1999/11/04 19:49:40     1.481
+++ http_main.c 1999/11/16 02:26:31
@@ -116,7 +116,7 @@
 #endif
 #ifdef WIN32
 #include "../os/win32/getopt.h"
-#elif !defined(BEOS) && !defined(TPF) && !defined(NETWARE)
+#elif !defined(BEOS) && !defined(TPF) && !defined(NETWARE) &&
!defined(OS390)
 #include <netinet/tcp.h>
 #endif
 #ifdef HAVE_BSTRING_H
Index: apache-1.3/src/main/rfc1413.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/rfc1413.c,v
retrieving revision 1.30
diff -u -r1.30 rfc1413.c
--- rfc1413.c   1999/09/01 04:21:17     1.30
+++ rfc1413.c   1999/11/16 02:26:31
@@ -154,7 +154,7 @@

     /* send query to server. Handle short write. */
 #ifdef CHARSET_EBCDIC
-    ebcdic2ascii(&buffer, &buffer, buflen);
+    ebcdic2ascii((unsigned char *)buffer, (unsigned char *)buffer,
buflen);
 #endif
     i = 0;
     while(i < strlen(buffer)) {
@@ -212,7 +212,7 @@

 /* RFC1413_USERLEN = 512 */
 #ifdef CHARSET_EBCDIC
-    ascii2ebcdic(&buffer, &buffer, (size_t)i);
+    ascii2ebcdic((unsigned char *)buffer, (unsigned char *)buffer,
(size_t)i);
 #endif
     if (sscanf(buffer, "%u , %u : USERID :%*[^:]:%512s", &rmt_port,
&our_port,
               user) != 3 || ntohs(rmt_sin->sin_port) != rmt_port
Index: apache-1.3/src/main/util_script.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/main/util_script.c,v
retrieving revision 1.146
diff -u -r1.146 util_script.c
--- util_script.c       1999/10/21 20:44:45     1.146
+++ util_script.c       1999/11/16 02:26:31
@@ -529,7 +529,7 @@
            if (maybeASCII > maybeEBCDIC) {
                ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
r->server,
                         "CGI Interface Error: Script headers apparently

ASCII: (CGI = %s)", r->filename);
-               ascii2ebcdic(w, w, cp - w);
+               ascii2ebcdic((unsigned char *)w, (unsigned char *)w, cp
- w);
            }
        }
 #endif
Index: apache-1.3/src/support/Makefile.tmpl
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/Makefile.tmpl,v
retrieving revision 1.30
diff -u -r1.30 Makefile.tmpl
--- Makefile.tmpl       1999/08/10 14:37:18     1.30
+++ Makefile.tmpl       1999/11/16 02:26:31
@@ -14,19 +14,19 @@
 all: $(TARGETS)

 htpasswd: htpasswd.o
-       $(CC) $(CFLAGS) htpasswd.o -o htpasswd $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -o htpasswd $(LDFLAGS) htpasswd.o $(LIBS)

 htdigest: htdigest.o
-       $(CC) $(CFLAGS) htdigest.o -o htdigest $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -o htdigest $(LDFLAGS) htdigest.o $(LIBS)

 rotatelogs: rotatelogs.o
-       $(CC) $(CFLAGS) rotatelogs.o -o rotatelogs $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -o rotatelogs $(LDFLAGS) rotatelogs.o $(LIBS)

 logresolve: logresolve.o
-       $(CC) $(CFLAGS) logresolve.o -o logresolve $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -o logresolve $(LDFLAGS) logresolve.o $(LIBS)

 ab: ab.o
-       $(CC) $(CFLAGS) ab.o -o ab $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -o ab $(LDFLAGS) ab.o $(LIBS)

 apxs: apxs.pl
        sed <apxs.pl >apxs \
@@ -39,7 +39,7 @@
            -e 's%@LIBS_SHLIB@%$(LIBS_SHLIB)%g' && chmod a+x apxs

 suexec: suexec.o
-       $(CC) $(CFLAGS) suexec.o -o suexec $(LDFLAGS) $(LIBS)
+       $(CC) $(CFLAGS) -o suexec $(LDFLAGS) suexec.o $(LIBS)

 clean:
        rm -f $(TARGETS) *.o
Index: apache-1.3/src/support/ab.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/ab.c,v
retrieving revision 1.36
diff -u -r1.36 ab.c
--- ab.c        1999/10/27 22:38:53     1.36
+++ ab.c        1999/11/16 02:26:31
@@ -627,7 +627,7 @@
 #ifndef CHARSET_EBCDIC
        memcpy(c->cbuff + c->cbx, buffer, tocopy);
 #else                          /* CHARSET_EBCDIC */
-       ascii2ebcdic(c->cbuff + c->cbx, buffer, tocopy);
+       ascii2ebcdic((unsigned char *)(c->cbuff + c->cbx), (unsigned
char *)buffer, tocopy);
 #endif                         /* CHARSET_EBCDIC */
        c->cbx += tocopy;
        space -= tocopy;
@@ -823,7 +823,7 @@
     reqlen = strlen(request);

 #ifdef CHARSET_EBCDIC
-    ebcdic2ascii(request, request, reqlen);
+    ebcdic2ascii((unsigned char *)request, (unsigned char *)request,
reqlen);
 #endif                         /* CHARSET_EBCDIC */

     /* ok - lets start */
Index: apache-1.3/src/support/htdigest.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/support/htdigest.c,v
retrieving revision 1.27
diff -u -r1.27 htdigest.c
--- htdigest.c  1999/10/21 20:46:31     1.27
+++ htdigest.c  1999/11/16 02:26:31
@@ -72,7 +72,7 @@
 #endif
 #include "ap.h"
 #include "ap_md5.h"
-#if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM)

+#if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM)

|| defined(OS390)
 #include <signal.h>
 #else
 #include <sys/signal.h>


---------------------------------------------------------------------------------------------------------------

README.os390
==============

This file describes how one extracts the apache source files from a
compressed
archive on one of the apache source code distribution web pages to an
OS/390
system.  OS/390 represents characters with the ebcdic code set.  The
files
in the apache source trees on the web represent characters using the
ascii
code set.  The procedure described here de-compresses the archive file
and
extracts the files from the archive while translating characters in the
files
from ascii to ebcdic.  Once you download the compressed archive to an
OS/390
system and follow this procedure, you will be ready to configure,
compile, and
install apache on your OS/390 system.

This procedure assumes that you will download the apache tree using a
browser
on a workstation and then you will transfer the compressed archive from
your
workstation to an OS/390 system.  You could probably just ftp the
compressed
archive to your OS/390 system ifyou like.  If you download to a
workstation as
described here, it is assumed that the workstation has TCP/IP and FTP
installed
on it.  It is also assumed that you have TCP/IP and FTP access from the
workstation to the OS/390 system you want to put apache on.

Procedure for extracting apache source to an OS/390 system:
-----------------------------------------------------------

- From either www.apache.org/dist or from
dev.apache.org/from-CVS/apache-version
  select one of the source trees with a file type of .tar.gz or .tar.Z
and
  download it to your workstation.  Ensure that the name of the
downloaded
  file remains the same as the name of the file on the web page.

- Also from the same web page download xebcdic.sh.

- From your workstation ftp to the OS/390 system you would like to run
apache
  on.
    - ftp os390-host-name
    - You'll be prompted for user id and password.
    - Once you've logged in successfully you'll get the ftp prompt.

- FTP the .tar.gz file and xebcdic.sh files you downloaded to your
workstation
  to the OS/390 system.  The xebcdic.sh file must be ftp'ed in ascii
mode.  The
  apache compressed archive file must be ftp'ed in binary mode.
    - put xebcdic.sh
    - bin
    - put apache-compressed-archive-file-name

- End your ftp connection.
    - bye or quit

- From your OS/390 system use the xebcdic.sh shell script to de-compress

and
  extract the apache source.  This script will de-compress the apache
source
  tree and will then extract all the files from the archive.  As the
files are
  extracted, they are all translated from ascii to ebcdic.  All the gif
files
  are then re-extracted from the archive without applying the ascii to
ebcdic
  translation so that they won't be corrupted.

  The name of the compressed archive file you specify to xebcdic.sh must

follow
  the following format:

    apache-version_timeStamp.tar.gz or
    apache-version_timeStamp.tar.Z  or
    apache-version.tar.gz           or
    apache-version.tar.Z            or
    apache_version.tar.gz           or
    apache_version.tar.Z

  When you invoke the script, you may specify which file types should be

  re-extracted without applying the ascii to ebcdic translation.  This
can be
  used to save static pages as ascii improving performance when serving
those
  pages by avoiding the ebcdic to ascii translation at the time they are

served.
  Please refer to top-of-source-tree/src/README.ebcdic for information
on how
  to use the AddType and DefaultType directives to serve static pages
without
  trying to translate from ebcdic to ascii.

    - To extract the source tree and have html and txt files
re-extracted
      without translation specify the following:

      ./xebcdic.sh apache-compressed-archive-file-name --f=*.html
--f=*.txt

    - To extract the source tree and have the static text content files
that
      are part of the source tree stored on your OS/390 system in ascii
specify
      the following:

      ./xebcdic.sh apache-compressed-archive-file-name
--all-ascii-content

- The apache source tree is now ready for you to configure, make and
install.
  Refer to top-of-source-tree/INSTALL for directions on how to proceed.


-----------------------
src/os/os390/ebcdic.h
-----------------------

#include <sys/types.h>

extern const unsigned char os_toascii[256];
extern const unsigned char os_toebcdic[256];
void ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t

count);
void ebcdic2ascii_strictly(unsigned char *dest, const unsigned char
*srce, size_t count);
void ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t

count);

-----------------------------
src/os/os390/Makefile.tmpl
-----------------------------

CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
LIBS=$(EXTRA_LIBS) $(LIBS1)
INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)

OBJS=   os.o os-inline.o ebcdic.o

LIB=    libos.a

all:    $(LIB)

$(LIB): $(OBJS)
        rm -f $@
        ar cr $@ $(OBJS)
        $(RANLIB) $@

.c.o:
        $(CC) -c $(INCLUDES) $(CFLAGS) $<

clean:
        rm -f $(OBJS) $(LIB)

distclean: clean
        -rm -f Makefile

# We really don't expect end users to use this rule.  It works only with

# gcc, and rebuilds Makefile.tmpl.  You have to re-run Configure after
# using it.
depend:
        cp Makefile.tmpl Makefile.tmpl.bak \
            && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl >
Makefile.new \
            && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
            && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
                   -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
                > Makefile.tmpl \
            && rm Makefile.new

$(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
os-inline.o: $(INCDIR)/ap_config_auto.h
os-inline.o: os.h
os-inline.o: $(INCDIR)/ap_ctype.h
os-inline.o: $(INCDIR)/hsregex.h
os.o: os.c
os.o: $(INCDIR)/httpd.h
os.o: $(INCDIR)/ap_config.h
os.o: $(INCDIR)/ap_mmn.h
os.o: $(INCDIR)/ap_config_auto.h
os.o: os.h
os.o: $(INCDIR)/ap_ctype.h
os.o: $(INCDIR)/hsregex.h
os.o: $(INCDIR)/alloc.h
os.o: $(INCDIR)/buff.h
os.o: $(INCDIR)/ap.h
os.o: ebcdic.h
os.o: $(INCDIR)/util_uri.h
os.o: $(INCDIR)/http_core.h

----------------------------------------
src/os/os390/os.c
----------------------------------------

/* ====================================================================
 * 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/>.
 *
 */

/*
 * This file will include OS specific functions which are not
inlineable.
 * Any inlineable functions should be defined in os-inline.c instead.
 */

#include "httpd.h"
#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;
}

-----------------------
src/os/os390/os.h
-----------------------

#ifndef APACHE_OS_H
#define APACHE_OS_H

#define PLATFORM "OS390"

/*
 * This file in included in all Apache source code. It contains
definitions
 * of facilities available on _this_ operating system (HAVE_* macros),
 * and prototypes of OS specific functions defined in os.c or
os-inline.c
 */

#if !defined(INLINE) && defined(USE_GNU_INLINE)
/* Compiler supports inline, so include the inlineable functions as
 * part of the header
 */
#define INLINE extern ap_inline

INLINE int ap_os_is_path_absolute(const char *file);

#include "os-inline.c"
#endif

#ifndef INLINE
/* Compiler does not support inline, so prototype the inlineable
functions
 * as normal
 */
extern int ap_os_is_path_absolute(const char *file);
#endif

/* Other ap_os_ routines not used by this platform */

#define ap_os_is_filename_valid(f)          (1)
#define ap_os_kill(pid, sig)                kill(pid, sig)

#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
typedef struct {
    char    *username;
    char    *account;
    char    *processor_name;
}  _rini_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);

#endif /*! APACHE_OS_H*/

-------------------------------------
src/os/os390/os-inline.c
-------------------------------------

/*
 * This file contains functions which can be inlined if the compiler
 * has an "inline" modifier. Because of this, this file is both a
 * header file and a compilable module.
 *
 * Only inlineable functions should be defined in here. They must all
 * include the INLINE modifier.
 *
 * If the compiler supports inline, this file will be #included as a
 * header file from os.h to create all the inline function
 * definitions. INLINE will be defined to whatever is required on
 * function definitions to make them inline declarations.
 *
 * If the compiler does not support inline, this file will be compiled
 * as a normal C file into libos.a (along with os.c). In this case
 * INLINE will _not_ be set so we can use this to test if we are
 * compiling this source file.
 */

#ifndef INLINE
#define INLINE

/* Anything required only when compiling */
#include "ap_config.h"

#endif

INLINE int ap_os_is_path_absolute(const char *file)
{
  return (file && file[0] == '/' ? 1 : 0);
}

------------------------
src/os/os390/ebcdic.c
------------------------

/* ====================================================================
 * 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/>.
 *
 */


#ifdef CHARSET_EBCDIC
#include "ap_config.h"
#include "ebcdic.h"
/*
           Initial Port for  Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>

"BS2000 OSD" is a POSIX on a main frame. It is made by Siemens AG,
Germany.
Within the POSIX subsystem, the same character set was chosen as in
"native BS2000", namely EBCDIC.

EBCDIC Table. (Yes, in EBCDIC, the letters 'a'..'z' are not contiguous!)

This table is bijective, i.e. there are no ambigous or duplicate
characters
00    00 01 02 03 85 09 86 7f  87 8d 8e 0b 0c 0d 0e 1f
*................*
10    10 11 12 13 8f 0a 08 97  18 19 9c 9d 1c 1d 1e 1f
*................*
20    80 81 82 83 84 92 17 1b  88 89 8a 8b 8c 05 06 07
*................*
30    90 91 16 93 94 95 96 04  98 99 9a 9b 14 15 9e 1a
*................*
40    20 a0 e2 e4 e0 e1 e3 e5  e7 f1 60 2e 3c 28 2b 7c  *
...........<(+|*
50    26 e9 ea eb e8 ed ee ef  ec df 21 24 2a 29 3b 5e
*&.........!$*);^*
60    2d 2f c2 c4 c0 c1 c3 c5  c7 d1 5e 2c 25 5f 3e 3f
*-/.........,%_>?*
70    f8 c9 ca cb c8 cd ce cf  cc 60 3a 23 40 27 3d 22
*.........`:#@'="*
80    d8 61 62 63 64 65 66 67  68 69 ab bb f0 fd fe b1
*.abcdefghi......*
90    b0 6a 6b 6c 6d 6e 6f 70  71 72 aa ba e6 b8 c6 a4
*.jklmnopqr......*
a0    b5 7e 73 74 75 76 77 78  79 7a a1 bf d0 5b de ae
*.~stuvwxyz...[..*
b0    a2 a3 a5 b7 a9 a7 b6 bc  bd be ac 5b 5c 5d b4 d7
*.............]..*
c0    7b 41 42 43 44 45 46 47  48 49 ad f4 f6 f2 f3 f5
*{ABCDEFGHI......*
d0    7d 4a 4b 4c 4d 4e 4f 50  51 52 b9 fb fc db fa ff
*}JKLMNOPQR......*
e0    5c f7 53 54 55 56 57 58  59 5a b2 d4 d6 d2 d3 d5
*\.STUVWXYZ......*
f0    30 31 32 33 34 35 36 37  38 39 b3 7b dc 7d da 7e
*0123456789......*
*/

/* The bijective ebcdic-to-ascii table: */
const unsigned char os_toascii_strictly[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, 0x5e,
/*&.........!$*);^*/
/*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, 0x60, 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, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae,
/*.~stuvwxyz...[..*/
/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
       0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7,
/*.............]..*/
/*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
       0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
/*{ABCDEFGHI......*/
/*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff,
/*}JKLMNOPQR......*/
/*e0*/ 0x5c, 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......*/
};

/* This table is (almost) identical to the previous one. The only
difference
 * is the fact that it maps every EBCDIC *except 0x0A* to its ASCII
 * equivalent. The reason for this table is simple: Throughout the
 * server, protocol strings are used in the form
 *  "Content-Type: text/plain\015\012". Now all the characters in the
string
 * are stored as EBCDIC, only the semantics of \012 is completely
 * different from LF (look it up in the table above). \015 happens to be

 * mapped to \015 anyway, so there's no special case for it.
 *
 * In THIS table, EBCDIC-\012 is mapped to ASCII-\012.
 * This table is therefore used wherever an EBCDIC to ASCII conversion
is
 * needed in the server.
 */
/* ebcdic-to-ascii with \012 mapped to ASCII-\n */
const unsigned char os_toascii[256] = {
/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
       0x87, 0x8d, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x1f,
/*................*/
/*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, 0x5e,
/*&.........!$*);^*/
/*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, 0x60, 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, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
       0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae,
/*.~stuvwxyz...[..*/
/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
       0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7,
/*.............]..*/
/*c0*/ 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
       0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5,
/*{ABCDEFGHI......*/
/*d0*/ 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
       0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff,
/*}JKLMNOPQR......*/
/*e0*/ 0x5c, 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......*/
};

/* The ascii-to-ebcdic table:
00    00 01 02 03 37 2d 2e 2f  16 05 15 0b 0c 0d 0e 0f
*................*
10    10 11 12 13 3c 3d 32 26  18 19 3f 27 1c 1d 1e 1f
*................*
20    40 5a 7f 7b 5b 6c 50 7d  4d 5d 5c 4e 6b 60 4b 61  *
!"#$%&'()*+,-./
30    f0 f1 f2 f3 f4 f5 f6 f7  f8 f9 7a 5e 4c 7e 6e 6f
*0123456789:;<=>?*
40    7c c1 c2 c3 c4 c5 c6 c7  c8 c9 d1 d2 d3 d4 d5 d6
*@ABCDEFGHIJKLMNO*
50    d7 d8 d9 e2 e3 e4 e5 e6  e7 e8 e9 bb bc bd 6a 6d
*PQRSTUVWXYZ[\]^_*
60    4a 81 82 83 84 85 86 87  88 89 91 92 93 94 95 96
*`abcdefghijklmno*
70    97 98 99 a2 a3 a4 a5 a6  a7 a8 a9 fb 4f fd ff 07
*pqrstuvwxyz{|}~.*
80    20 21 22 23 24 04 06 08  28 29 2a 2b 2c 09 0a 14
*................*
90    30 31 25 33 34 35 36 17  38 39 3a 3b 1a 1b 3e 5f
*................*
a0    41 aa b0 b1 9f b2 d0 b5  79 b4 9a 8a ba ca af a1
*................*
b0    90 8f ea fa be a0 b6 b3  9d da 9b 8b b7 b8 b9 ab
*................*
c0    64 65 62 66 63 67 9e 68  74 71 72 73 78 75 76 77
*................*
d0    ac 69 ed ee eb ef ec bf  80 e0 fe dd fc ad ae 59
*................*
e0    44 45 42 46 43 47 9c 48  54 51 52 53 58 55 56 57
*................*
f0    8c 49 cd ce cb cf cc e1  70 c0 de db dc 8d 8e df
*................*
*/
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.
 */
void
ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t
count)
{
        while (count-- != 0) {
                *dest++ = os_toascii[*srce++];
        }
}
void
ebcdic2ascii_strictly(unsigned char *dest, const unsigned char *srce,
size_t count)
{
        while (count-- != 0) {
                *dest++ = os_toascii_strictly[*srce++];
        }
}
void
ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t
count)
{
        while (count-- != 0) {
                *dest++ = os_toebcdic[*srce++];
        }
}
#endif /*CHARSET_EBCDIC*/

------------------------------------------
xebcdic.sh
------------------------------------------

#!/bin/sh
#
# xebcdic.sh fileName [--all-ascii-content] [--f=pattern ... ]
#
# This shell script decompresses an archive containing an apache source
tree
# and then extracts the source files from the archive.  The source files

are
# translated from ASCII to EBCDIC as they are extracted from the
archive.
# Once all the files have been extracted and translated, the binary
files are
# re-extracted to undo the ASCII to EBCDIC translation on those files.
Once
# this script is done, the extracted tree can be used on an EBCDIC based

# system.
#
# Input:  fileName -- fileName has one of the following formats:
#                     apache-version_timeStamp.tar.gz or
#                     apache-version_timeStamp.tar.Z  or
#                     apache-version.tar.gz           or
#                     apache-version.tar.Z            or
#                     apache_version.tar.gz           or
#                     apache_version.tar.Z
#
#          --f=pattern -- specifies that all files which match the
pattern
#                         are to be re-extracted without ascii to ebcdic

#                         translation being applied.  pattern is a file
name
#                         specification that may contain path names and
#                         the wildcard character.  All paths are assumed

to
#                         be under the apache source tree top.  Binary
files
#                         are always re-extracted without ascii to
ebcdic
#                         translation regardless of whether any pattern
is
#                         specified or not.  Multiple patterns may be
specified
#                         by repeating this option.
#
#
#          --all-ascii-content -- specifies that all the text content
shipped
#                                 with the apache tree should be stored
in
#                                 ascii on the OS/390 system. This
re-extracts
#                                 all the *.htm* files in the htdocs
directory
#                                 of the apache tree without doing the
ascii
#                                 to ebcdic translation.  In addition to

the
#                                 *.htm* files, file
htdocs/manual/LICENSE and
#                                 file
htdocs/manual/misc/HTTP_Features.tsv
#                                 are also stored in ascii.  If this
option
#                                 is specified, directives AddType and
#                                 DefaultType need to be used to
correctly
#                                 serve the pages without trying to
first
#                                 translate from ebcdic to ascii.  See
#                                 apache-tree-top/src/README.EBCDIC.
#
# Example Invocations:
#
#          ./xebcdic.sh apache_1.3.9.tar.gz:  Runs gunzip, runs pax and
#               extracts everything translating it to ebcdic, and
re-extracts
#               all gif files in the htdocs and icons directories
without
#               applying ascii to ebcdic translation.
#
#          ./xebcdic.sh apache_1.3.9.tar.gz --f=*.htm* --f=htdocs/*.tsv:

#               Runs gunzip, runs pax and extracts everything
translating it to
#               ebcdic, re-extracts all gif files without ascii to
ebcdic
#               translation, and re-extracts all the *.htm* files in the

apache
#               source tree and all *.tsv files in the htdocs directory
of the
#               apache source tree without ascii to ebcdic translation.
#
#          ./xebcdic.sh apache_1.3.9.tar.gz --all-ascii-content:  Runs
gunzip,
#               runs pax and extracts everything translating it to
ebcdic,
#               re-extracts all gif files without ascii to ebcdic
translation,
#               and re-extracts all the *.htm* files in the htdocs
directory
#               as well as htdocs/manual/LICENSE and
#               htdocs/manual/misc/HTTP_Features.tsv without ascii to
ebcdic
#               translation.
#
# Output:  fileName.tar.gz is replaced with fileName.tar and the apache
#          source tree is extracted into a directory named
apache-version or
#          apache_version.  All files except binary files and any files
#          specified through the options are translated from ascii to
#          ebcdic.
#
# Assumptions:  The path to gunzip, uncompress and pax is defined and
#               from where this script is invoked.
#

echo "Input file name is:  $1"

# Verify fileName
if ! echo $1 | grep -q 'apache_.*\.tar\.gz' && \
   ! echo $1 | grep -q 'apache_.*\.tar\.Z'  && \
   ! echo $1 | grep -q 'apache-.*_.*\.tar\.gz' && \
   ! echo $1 | grep -q 'apache-.*_.*\.tar\.Z' && \
   ! echo $1 | grep -q 'apache-.*\.tar\.gz' && \
   ! echo $1 | grep -q 'apache-.*\.tar\.Z'
then
  echo "Filename, $1, does not follow required format."
  echo "Filename should have one of the following formats:"
  echo "apache-version_timeStamp.tar.gz or"
  echo "apache-version_timeStamp.tar.Z  or"
  echo "apache-version.tar.gz           or"
  echo "apache-version.tar.Z            or"
  echo "apache_version.tar.gz           or"
  echo "apache_version.tar.Z"
  exit 1;
fi

if [ ! -f $1 ]; then
  echo "$1 is not a file"
  exit 1;
fi

if [ ! -a $1 ]; then
  echo "$1 file does not exist"
  exit 1;
fi

# Verify fileType option if specified
for option in $@
do
  case "$option" in
                      $1) ;;
     --all-ascii-content) ;;
                   --f=*) ;;
                *) echo "Invalid option specified.  Command syntax is:"
                   echo "xebcdic.sh compressed-archive-file-name
[--all-ascii-content]"
     echo "                                        [--f=pattern ... ]"
                          exit 1;
                         ;;
  esac
done

# Figure out whether to gunzip or uncompress
if echo $1 | grep -q 'apache[-_].*\.tar\.gz'; then
  DECOMPRESS="gunzip"
else
  DECOMPRESS="uncompress"
fi
echo "Decompression utility $DECOMPRESS will be used."

# Set name of tar file after decompressing
if [ "x$DECOMPRESS" = "xgunzip" ]; then
  TARFILE=`echo $1 | sed s/\.tar\.gz/\.tar/`
else
  TARFILE=`echo $1 | sed s/\.tar\.Z/\.tar/`
fi
echo "Archive file name is: $TARFILE"

# Set name of apache source tree directory
if echo $1 | grep -q 'apache-.*_.*\.tar*'; then
  APDIR=`echo $1 | sed s/_.*//`
else
  APDIR=`echo $1 | sed s/\.tar.*//`
fi
echo "Apache source tree top is: $APDIR"

# Decompress input file
echo "Starting decompression of $1"
if [ "x$DECOMPRESS" = "xgunzip" ]; then
  if gunzip $1; then
    echo "Decompression of $1 completed successfully"
  else
    exit 1;
  fi
else
  if uncompress $1; then
    echo "Decompression of $1 completed successfully"
  else
    exit 1;
  fi
fi

# Extract source files and translate them all from ASCII to EBCDIC

# Determine code page for locale

localeCodePage=`locale -ck charmap | sed "s/^.*=//" | sed "s/\"//g"`
echo "Locale code page is $localeCodePage"
echo "Starting extraction of source files from archive $TARFILE."
echo "ASCII being translated to EBCDIC."
echo "ASCII code page assumed to be ISO8859-1."
echo "EBCDIC code page is $localeCodePage."
./pax.r7 -ofrom=ISO8859-1,to=$localeCodePage -rvf $TARFILE
echo "Extraction and translation of source files from archive
completed."

# Re-extract gif files without ASCII to EBCDIC translation
echo "Re-extracting gif files without ASCII to EBCDIC translation"
pax -rvf $TARFILE $(find $APDIR/htdocs -type f -name "*.gif*")
pax -rvf $TARFILE $(find $APDIR/icons -type f -name "*.gif*")

# Re-extract appropriate files as requested by user
for option in $@; do
  case "$option" in
        $1) ;;
     --all-ascii-content) echo "Re-extracting files in $APDIR/htdoc
without ASCII to EBCDIC translation"
                                  pax -rvf $TARFILE $(find $APDIR/htdocs
-type f -name "*.htm*")
                                  pax -rvf $TARFILE $(find $APDIR/htdocs
-type f -name "*.tsv*")
                                  pax -rvf $TARFILE $(find $APDIR/htdocs
-name "manual/LICENSE")
                                  ;;
     --f=*) PATTERN=`echo $option | sed s/--f=//`
                if [ "x$PATTERN" != "x" ]; then
                  echo "Re-extracting files matching $PATTERN without
ASCII to EBCDIC translation"
                  pax -rvf $TARFILE $(find $APDIR -type f -name
"$PATTERN")
                fi
                ;;
         *) ;;
  esac
done







Mime
View raw message