#! /bin/ksh # ===== self-applying patch file ===== # Documentation and patch file are inline at bottom of script. set -x unset _BPX_SHAREAS ANAME=apache_1.3.9 ARCHIVE="$ANAME.tar.gz" PATCHFILE="`whence $0`" || PATCHFILE="`type -path $0`" # The "-o to=$charmap" is needed to convert the ASCII archive # to EBCDIC. You must not download as a text file; the conversion # must be performed after the uncompress. unset PAXOPT if eval "export `locale -ck charmap`"; then # "locale" is broken on OS/390 v1r2. Circumvent. case "$charmap" in "") ;; \\x*) export charmap=IBM-1047 PAXOPT="-o to=$charmap";; *) PAXOPT="-o to=$charmap";; esac; fi # depending on mount options, may need to convert ARCHIVE # from EBCDIC to ASCII, or even from ASCII to EBCDIC. # try several ways and hope one works. inflate() { gunzip <"$ARCHIVE" || iconv -f "$charmap" -t ISO8859-1 "$ARCHIVE" | gunzip || /pub/ccmdbs/NCS_20/bin/cl_iconv -t IBM-1047 "$ARCHIVE" | gunzip || exit $?; } inflate | pax -rv $PAXOPT # Undo ASCII to EBCDIC conversion for binary files. inflate | pax -rv \ $ANAME/htdocs/apache_pb.gif \ $ANAME/htdocs/manual/images \ $ANAME/icons \ # Copy EBCDIC support files into os/unix source directory. ( cd $ANAME/src/os/unix ( cd ../tpf && tar -cf - ebcdic.* ) | tar -xvf - ) # "export UPDATE_APACHE=false" to generate unpatched reference tree. ${UPDATE_APACHE} && ( cd apache_1.3.9 patch -l -p1 ) <"$PATCHFILE" exit $? ======================================================================== This document suggests steps to install Apache on OS/390 systems. ======================================================================== o Download the archive file apache_1.3.9.tar.gz in BINARY from http://www.apache.org/dist/apache_1.3.9.tar.gz o Unpack and update by running this file as a shell script. ======================================================================== o Configure with: /bin/time ./configure \ --prefix=/pub/unsup/test/.arch/$MTYPES \ --shadow & o Build and test: ( gmake -k --jobs 5 & gmake install gmake install-programs ) /pub/unsup/test/.arch/$MTYPES/bin/apachectl start ======================================================================== o Generate patch file with: mkdir orig cd orig ln -s ../$ARCHIVE . export UPDATE_APACHE=false # re-extract ( cd .. && diff -brc orig/apache_1.3.9 apache_1.3.9 ) | grep -v ^Only >apache.patch ======================================================================== diff -brc orig/apache_1.3.9/configure apache_1.3.9/configure *** orig/apache_1.3.9/configure Sat Aug 14 02:29:05 1999 --- apache_1.3.9/configure Tue Nov 23 07:47:09 1999 *************** *** 549,555 **** # Makefile is for platform bootstrapping, so don't hardcode paths) gnutriple=`$aux/GuessOS | sed -e 's:/:-:g' | awk '{ printf("%s",$1); }'` # create Makefile wrapper (the first time only) ! if [ "x`ls $top/src.* 2>/dev/null`" = "x" ]; then if [ "x$quiet" = "xno" ]; then echo " + creating Makefile (shadow wrapper)" fi --- 549,555 ---- # Makefile is for platform bootstrapping, so don't hardcode paths) gnutriple=`$aux/GuessOS | sed -e 's:/:-:g' | awk '{ printf("%s",$1); }'` # create Makefile wrapper (the first time only) ! if ls $top/src.* Makefile 2>/dev/null 1>&2; then :; else if [ "x$quiet" = "xno" ]; then echo " + creating Makefile (shadow wrapper)" fi *************** *** 562,570 **** else echo "SHADOW=." >> Makefile fi ! echo "GNUTRIPLE=\`$aux/GuessOS | sed -e 's:/:-:g' | $AWK '{ printf(\"%s\",\$\$1); }'\`" >> Makefile echo "" >> Makefile ! echo "all build install install-quiet clean distclean:" >> Makefile echo " @cd \$(SHADOW); \$(MAKE) -f Makefile.\$(GNUTRIPLE) \$(MFLAGS) \$@" >> Makefile echo "" >> Makefile fi --- 562,570 ---- else echo "SHADOW=." >> Makefile fi ! echo "GNUTRIPLE=\`$aux/GuessOS | sed -e 's:/:-:g' | awk '{ printf(\"%s\",\$\$1); }'\`" >> Makefile echo "" >> Makefile ! echo "all build install install-quiet install-programs clean distclean:" >> Makefile echo " @cd \$(SHADOW); \$(MAKE) -f Makefile.\$(GNUTRIPLE) \$(MFLAGS) \$@" >> Makefile echo "" >> Makefile fi diff -brc orig/apache_1.3.9/src/Configure apache_1.3.9/src/Configure *** orig/apache_1.3.9/src/Configure Sun Aug 15 18:49:08 1999 --- apache_1.3.9/src/Configure Mon Nov 22 15:22:20 1999 *************** *** 616,621 **** --- 616,632 ---- LIBS="$LIBS" SUBTARGET="target_compile_only" ;; + *-*-os390*) + OS='OS390' + OSDIR='os/unix' + CC="_C89_CCMODE=1 c89" + CFLAGS="$CFLAGS -DCHARSET_EBCDIC -DOS390" + CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE" + CFLAGS="$CFLAGS -DNO_DLOPEN" + ##### CFLAGS="$CFLAGS -D_OE_SOCKETS" + DEF_WANTHSREGEX=yes + DBM_LIB="" + ;; BS2000*-siemens-sysv4*) OS='BS2000' OSDIR='os/bs2000' *************** *** 848,854 **** # # If $TCC is null, then no such line exists in Configuration # ! TCC=`egrep '^CC=' Makefile.config | tail -1 | awk -F= '{print $2}'` if [ "x$TCC" = "x" ]; then if [ "x$CC" = "x" ]; then # At this point, CC is not set in Configuration or above, so we --- 859,865 ---- # # If $TCC is null, then no such line exists in Configuration # ! TCC=`egrep '^CC=' Makefile.config | tail -1 | sed -e 's!^[^=]*=!!'` if [ "x$TCC" = "x" ]; then if [ "x$CC" = "x" ]; then # At this point, CC is not set in Configuration or above, so we *************** *** 870,877 **** fi CC=$COMPILER fi - echo " + setting C compiler to $CC" - fi #################################################################### ## Write the value of $CC to Makefile.config... We only do this --- 881,886 ---- *************** *** 879,885 **** ## If there was an entry for it, then set $CC for our own internal ## use. ## ! if [ "x$TCC" = "x" ]; then echo "CC=$CC" >> Makefile.config else CC=$TCC --- 888,894 ---- ## If there was an entry for it, then set $CC for our own internal ## use. ## ! echo " + setting C compiler to $CC" echo "CC=$CC" >> Makefile.config else CC=$TCC *************** *** 888,898 **** #################################################################### ## Now check how we can _directly_ run the C pre-processor ## ! TCPP=`egrep '^CPP=' Makefile.config | tail -1 | awk -F= '{print $2}'` if [ "x$TCPP" != "x" ]; then ! CPP=`CC=$CC CPP=$TCPP ./helpers/findcpp.sh` else ! CPP=`CC=$CC ./helpers/findcpp.sh` fi if [ "x$TCPP" = "x" ]; then echo "CPP=$CPP" >> Makefile.config --- 897,907 ---- #################################################################### ## Now check how we can _directly_ run the C pre-processor ## ! TCPP=`egrep '^CPP=' Makefile.config | tail -1 | sed -e 's!^[^=]*=!!'` if [ "x$TCPP" != "x" ]; then ! CPP=`CC="$CC" CPP="$TCPP" export CC CPP; ./helpers/findcpp.sh` else ! CPP=`CC="$CC" export CC; ./helpers/findcpp.sh` fi if [ "x$TCPP" = "x" ]; then echo "CPP=$CPP" >> Makefile.config diff -brc orig/apache_1.3.9/src/ap/ap_execve.c apache_1.3.9/src/ap/ap_execve.c *** orig/apache_1.3.9/src/ap/ap_execve.c Sun Mar 7 06:51:19 1999 --- apache_1.3.9/src/ap/ap_execve.c Thu Nov 25 00:30:05 1999 *************** *** 99,105 **** #undef execle #undef execve ! static const char **hashbang(const char *filename, char **argv); /* Historically, a list of arguments on the stack was often treated as --- 99,105 ---- #undef execle #undef execve ! static const char **hashbang(const char *filename, char * const *argv); /* Historically, a list of arguments on the stack was often treated as *************** *** 133,139 **** /* Pass two --- copy the argument strings into the result space */ va_start(adummy, argv0); ! argv[0] = argv0; for (argc = 1; (argv[argc] = va_arg(adummy, char *)) != NULL; ++argc) { continue; } --- 133,139 ---- /* Pass two --- copy the argument strings into the result space */ va_start(adummy, argv0); ! ((const char **)argv)[0] = argv0; for (argc = 1; (argv[argc] = va_arg(adummy, char *)) != NULL; ++argc) { continue; } *************** *** 149,155 **** /* Count number of entries in vector "args", including the trailing NULL entry */ static int ! count_args(const char **args) { int i; for (i = 0; args[i] != NULL; ++i) { --- 149,155 ---- /* Count number of entries in vector "args", including the trailing NULL entry */ static int ! count_args(char * const *args) { int i; for (i = 0; args[i] != NULL; ++i) { *************** *** 163,176 **** * We have to fiddle with the argv array to make it work on platforms * which don't support the "hashbang" interpreter line by default. */ ! int ap_execve(const char *filename, const char *argv[], ! const char *envp[]) { const char **script_argv; extern char **environ; if (envp == NULL) { ! envp = (const char **) environ; } /* Try to execute the file directly first: */ --- 163,176 ---- * We have to fiddle with the argv array to make it work on platforms * which don't support the "hashbang" interpreter line by default. */ ! int ap_execve(const char *filename, char * const argv[], ! char * const envp[]) { const char **script_argv; extern char **environ; if (envp == NULL) { ! envp = (char * const *)environ; } /* Try to execute the file directly first: */ *************** *** 211,217 **** script_argv[0] = argv[0]; } ! execve(filename, script_argv, envp); free(script_argv); } --- 211,217 ---- script_argv[0] = argv[0]; } ! execve(filename, (char * const *)script_argv, envp); free(script_argv); } *************** *** 236,242 **** --i; } ! execve(SHELL_PATH, script_argv, envp); free(script_argv); } --- 236,242 ---- --i; } ! execve(SHELL_PATH, (char * const *)script_argv, envp); free(script_argv); } *************** *** 257,263 **** */ #define HACKBUFSZ 1024 /* Max chars in #! vector */ #define HACKVECSZ 128 /* Max words in #! vector */ ! static const char **hashbang(const char *filename, char **argv) { char lbuf[HACKBUFSZ]; char *sargv[HACKVECSZ]; --- 257,263 ---- */ #define HACKBUFSZ 1024 /* Max chars in #! vector */ #define HACKVECSZ 128 /* Max words in #! vector */ ! static const char **hashbang(const char *filename, char * const *argv) { char lbuf[HACKBUFSZ]; char *sargv[HACKVECSZ]; *************** *** 347,353 **** } ++i; ! newargv = (char **) malloc((p - lbuf + 1) + (i + sargc + 1) * sizeof(*newargv)); if (newargv == NULL) { fprintf(stderr, "Ouch! Out of memory in hashbang()!\n"); --- 347,353 ---- } ++i; ! newargv = (const char **) malloc((p - lbuf + 1) + (i + sargc + 1) * sizeof(*newargv)); if (newargv == NULL) { fprintf(stderr, "Ouch! Out of memory in hashbang()!\n"); diff -brc orig/apache_1.3.9/src/helpers/GuessOS apache_1.3.9/src/helpers/GuessOS *** orig/apache_1.3.9/src/helpers/GuessOS Mon Aug 9 01:38:44 1999 --- apache_1.3.9/src/helpers/GuessOS Mon Nov 22 15:22:20 1999 *************** *** 154,159 **** --- 154,163 ---- echo "${MACHINE}-tandem-oss"; exit 0; ;; + OS/390:*:*:*) + echo "i370-ibm-os390v${VERSION}r${RELEASE}"; exit 0 + ;; + QNX:*) if [ "$VERSION" -gt 422 ]; then echo "${MACHINE}-qssl-qnx32" *************** *** 326,330 **** # At this point we gone through all the one's # we know of: Punt ! echo "${MACHINE}-whatever-${SYSTEM}|${RELEASE}|${VERSION}" exit 0 --- 330,334 ---- # At this point we gone through all the one's # we know of: Punt ! echo "${MACHINE}-whatever-${SYSTEM}-${RELEASE}-${VERSION}" exit 0 diff -brc orig/apache_1.3.9/src/include/ap.h apache_1.3.9/src/include/ap.h *** orig/apache_1.3.9/src/include/ap.h Thu Aug 12 12:06:20 1999 --- apache_1.3.9/src/include/ap.h Wed Nov 24 16:02:51 1999 *************** *** 68,74 **** API_EXPORT(char *) ap_cpystrn(char *, const char *, size_t); int ap_slack(int, int); int ap_execle(const char *, const char *, ...); - int ap_execve(const char *, const char *argv[], const char *envp[]); API_EXPORT(int) ap_getpass(const char *prompt, char *pwbuf, size_t bufsiz); /* small utility macros to make things easier to read */ --- 68,73 ---- diff -brc orig/apache_1.3.9/src/include/ap_config.h apache_1.3.9/src/include/ap_config.h *** orig/apache_1.3.9/src/include/ap_config.h Mon Aug 9 01:38:45 1999 --- apache_1.3.9/src/include/ap_config.h Wed Nov 24 18:26:12 1999 *************** *** 115,121 **** #include "os.h" #endif ! #if !defined(QNX) && !defined(MPE) && !defined(WIN32) && !defined(TPF) #include #endif --- 115,122 ---- #include "os.h" #endif ! #if !defined(QNX) && !defined(MPE) && !defined(WIN32) && !defined(TPF) \ ! && !defined(OS390) #include #endif *************** *** 905,910 **** --- 906,915 ---- /* All windows stuff is now in os/win32/os.h */ + #elif defined(OS390) /* IBM OS/390 Unix Services */ + #include + #define NEED_HASHBANG_EMUL + #elif defined(TPF) /* IBM Transaction Processing Facility operating system */ #include *************** *** 1050,1055 **** --- 1055,1063 ---- #include #endif /* TPF */ #include + #if defined(OS390) && !defined(NO_ADDRESS) + #define NO_ADDRESS NO_DATA /* Not defined properly by OS/390 v1r2 */ + #endif #include #if !defined(MPE) && !defined(BEOS) && !defined(TPF) #include /* for inet_ntoa */ *************** *** 1227,1234 **** */ #ifdef NEED_HASHBANG_EMUL extern int ap_execle(const char *filename, const char *arg,...); ! extern int ap_execve(const char *filename, const char *argv[], ! const char *envp[]); /* ap_execle() is a wrapper function around ap_execve(). */ #define execle ap_execle #define execve(path,argv,envp) ap_execve(path,argv,envp) --- 1235,1242 ---- */ #ifdef NEED_HASHBANG_EMUL extern int ap_execle(const char *filename, const char *arg,...); ! extern int ap_execve(const char *filename, char * const argv[], ! char * const envp[]); /* ap_execle() is a wrapper function around ap_execve(). */ #define execle ap_execle #define execve(path,argv,envp) ap_execve(path,argv,envp) diff -brc orig/apache_1.3.9/src/main/http_main.c apache_1.3.9/src/main/http_main.c *** orig/apache_1.3.9/src/main/http_main.c Tue Aug 10 07:54:48 1999 --- apache_1.3.9/src/main/http_main.c Mon Nov 22 23:29:14 1999 *************** *** 116,122 **** #endif #ifdef WIN32 #include "../os/win32/getopt.h" ! #elif !defined(BEOS) && !defined(TPF) #include #endif --- 116,122 ---- #endif #ifdef WIN32 #include "../os/win32/getopt.h" ! #elif !defined(BEOS) && !defined(TPF) && !defined(OS390) #include #endif *************** *** 3817,3823 **** usr1_just_die = 0; for (;;) { clen = sizeof(sa_client); ! csd = ap_accept(sd, &sa_client, &clen); if (csd >= 0 || errno != EINTR) break; if (deferred_die) { --- 3817,3823 ---- usr1_just_die = 0; for (;;) { clen = sizeof(sa_client); ! csd = ap_accept(sd, &sa_client, (unsigned int *)&clen); if (csd >= 0 || errno != EINTR) break; if (deferred_die) { *************** *** 3967,3973 **** */ clen = sizeof(sa_server); ! if (getsockname(csd, &sa_server, &clen) < 0) { ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "getsockname"); continue; } --- 3967,3973 ---- */ clen = sizeof(sa_server); ! if (getsockname(csd, &sa_server, (unsigned int *)&clen) < 0) { ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "getsockname"); continue; } *************** *** 4690,4695 **** --- 4690,4700 ---- int sock_out; char *s; + #ifdef OS390 + /* Dummy call to initialize translation tables. */ + ebcdic2ascii(NULL, NULL, 0); + #endif + #ifdef SecureWare if (set_auth_parameters(argc, argv) < 0) perror("set_auth_parameters"); *************** *** 4916,4929 **** #endif l = sizeof(sa_client); ! if ((getpeername(sock_in, &sa_client, &l)) < 0) { /* get peername will fail if the input isn't a socket */ perror("getpeername"); memset(&sa_client, '\0', sizeof(sa_client)); } l = sizeof(sa_server); ! if (getsockname(sock_in, &sa_server, &l) < 0) { perror("getsockname"); fprintf(stderr, "Error getting local address\n"); exit(1); --- 4921,4934 ---- #endif l = sizeof(sa_client); ! if ((getpeername(sock_in, &sa_client, (unsigned int *)&l)) < 0) { /* get peername will fail if the input isn't a socket */ perror("getpeername"); memset(&sa_client, '\0', sizeof(sa_client)); } l = sizeof(sa_server); ! if (getsockname(sock_in, &sa_server, (unsigned int *)&l) < 0) { perror("getsockname"); fprintf(stderr, "Error getting local address\n"); exit(1); diff -brc orig/apache_1.3.9/src/main/rfc1413.c apache_1.3.9/src/main/rfc1413.c *** orig/apache_1.3.9/src/main/rfc1413.c Fri Jul 30 08:06:56 1999 --- apache_1.3.9/src/main/rfc1413.c Mon Nov 22 15:22:22 1999 *************** *** 148,154 **** /* send query to server. Handle short write. */ #ifdef CHARSET_EBCDIC ! ebcdic2ascii(&buffer, &buffer, buflen); #endif i = 0; while(i < strlen(buffer)) { --- 148,154 ---- /* send query to server. Handle short write. */ #ifdef CHARSET_EBCDIC ! ebcdic2ascii(buffer, buffer, buflen); #endif i = 0; while(i < strlen(buffer)) { *************** *** 191,197 **** /* RFC1413_USERLEN = 512 */ #ifdef CHARSET_EBCDIC ! ascii2ebcdic(&buffer, &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 --- 191,197 ---- /* RFC1413_USERLEN = 512 */ #ifdef CHARSET_EBCDIC ! ascii2ebcdic(buffer, 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 diff -brc orig/apache_1.3.9/src/main/util_script.c apache_1.3.9/src/main/util_script.c *** orig/apache_1.3.9/src/main/util_script.c Thu Aug 12 12:34:15 1999 --- apache_1.3.9/src/main/util_script.c Wed Nov 24 22:52:47 1999 *************** *** 155,160 **** --- 155,169 ---- return res; } + #ifdef OS390 + /* ANSI C 4.10.4.4 states "The string pointed to ... may be modified + * by a subsequent call to getenv. OS/390 does this. Sigh. + */ + #define ap_getenv(p, s) (ap_pstrdup(p, getenv(s))) + #else /*OS390*/ + #define ap_getenv(p, s) getenv((s)) + #endif /*OS390*/ + API_EXPORT(char **) ap_create_environment(pool *p, table *t) { array_header *env_arr = ap_table_elts(t); *************** *** 250,256 **** } } ! if (!(env_path = getenv("PATH"))) { env_path = DEFAULT_PATH; } --- 259,265 ---- } } ! if (!(env_path = ap_getenv(r->pool, "PATH"))) { env_path = DEFAULT_PATH; } diff -brc orig/apache_1.3.9/src/os/unix/Makefile.tmpl apache_1.3.9/src/os/unix/Makefile.tmpl *** orig/apache_1.3.9/src/os/unix/Makefile.tmpl Mon Sep 7 00:59:35 1998 --- apache_1.3.9/src/os/unix/Makefile.tmpl Mon Nov 22 16:05:58 1999 *************** *** 43,47 **** --- 43,48 ---- $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \ $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h os.o: os.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \ + os-aix-dso.c ebcdic.c \ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \ $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h os.h diff -brc orig/apache_1.3.9/src/os/unix/ebcdic.c apache_1.3.9/src/os/unix/ebcdic.c *** orig/apache_1.3.9/src/os/unix/ebcdic.c Fri Jan 1 12:05:29 1999 --- apache_1.3.9/src/os/unix/ebcdic.c Tue Nov 23 07:50:30 1999 *************** *** 57,64 **** #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 's code for --- 57,94 ---- #ifdef CHARSET_EBCDIC + #include "httpd.h" + #include "http_core.h" #include "ap_config.h" ! ! #ifdef OS390 ! static unsigned char os_toascii_strictly[256]; ! unsigned char os_toascii[256]; ! unsigned char os_toebcdic[256]; ! static int Initted = 0; ! #define INITTAB { if (!Initted) InitTables(); } ! ! /* Use OS/390's built-in translation function to initialize tables. ! */ ! static void InitTables() ! { ! register int i, j; ! ! for (i = 0; i<256; i++) os_toebcdic[i] = i; ! ! __atoe_l((char *) os_toebcdic, 256); ! for (i = 0; i<256; i++) { ! j = os_toebcdic[i]; ! os_toascii_strictly[j] = os_toascii[j] = i; ! } ! os_toascii[012] = 012; ! os_toascii[015] = 015; ! ! Initted = 1; ! } ! ! #else /*OS390*/ ! #define INITTAB { } /* This code does basic character mapping for IBM's TPF operating system. It is a modified version of 's code for *************** *** 186,191 **** --- 216,222 ---- 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */ 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */ }; + #endif /*OS390*/ /* Translate a memory block from EBCDIC (host charset) to ASCII (net charset) * dest and srce may be identical, or separate memory blocks, but *************** *** 196,201 **** --- 227,233 ---- { unsigned char *udest = dest; const unsigned char *usrce = srce; + INITTAB; while (count-- != 0) { *udest++ = os_toascii[*usrce++]; } *************** *** 217,221 **** *udest++ = os_toebcdic[*usrce++]; } } ! #endif /*CHARSET_EBCDIC*/ --- 249,290 ---- *udest++ = os_toebcdic[*usrce++]; } } ! #include "http_core.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; + } + #endif /*CHARSET_EBCDIC*/ diff -brc orig/apache_1.3.9/src/os/unix/ebcdic.h apache_1.3.9/src/os/unix/ebcdic.h *** orig/apache_1.3.9/src/os/unix/ebcdic.h Tue Nov 3 15:06:31 1998 --- apache_1.3.9/src/os/unix/ebcdic.h Mon Nov 22 23:17:28 1999 *************** *** 1,8 **** --- 1,17 ---- + #ifndef APACHE_EBCDIC_H + #define APACHE_EBCDIC_H #include + #ifdef OS390 + extern unsigned char os_toascii[256]; + extern unsigned char os_toebcdic[256]; + #else extern const unsigned char os_toascii[256]; extern const unsigned char os_toebcdic[256]; + #endif + void ebcdic2ascii(void *dest, const void *srce, size_t count); void ebcdic2ascii_strictly(unsigned char *dest, const unsigned char *srce, size_t count); void ascii2ebcdic(void *dest, const void *srce, size_t count); + #endif /*APACHE_EBCDIC_H*/ diff -brc orig/apache_1.3.9/src/os/unix/os.c apache_1.3.9/src/os/unix/os.c *** orig/apache_1.3.9/src/os/unix/os.c Mon Aug 9 01:38:48 1999 --- apache_1.3.9/src/os/unix/os.c Mon Nov 22 15:22:23 1999 *************** *** 21,26 **** --- 21,33 ---- #endif /* + * Insert the EBCDIC support code for OS/390 + */ + #ifdef CHARSET_EBCDIC + #include "ebcdic.c" + #endif /*CHARSET_EBCDIC*/ + + /* * Abstraction layer for loading * Apache modules under run-time via * dynamic shared object (DSO) mechanism *************** *** 113,120 **** (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) return dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); ! #else return dlopen(path, RTLD_NOW | RTLD_GLOBAL); #endif } --- 120,130 ---- (defined(__FreeBSD_version) && (__FreeBSD_version >= 220000)) return dlopen((char *)path, RTLD_NOW | RTLD_GLOBAL); ! #elif !defined(NO_DLOPEN) return dlopen(path, RTLD_NOW | RTLD_GLOBAL); + + #else + return NULL; #endif } *************** *** 126,132 **** #elif defined(HAVE_DYLD) NSUnLinkModule(handle,FALSE); ! #else dlclose(handle); #endif --- 136,142 ---- #elif defined(HAVE_DYLD) NSUnLinkModule(handle,FALSE); ! #elif !defined(NO_DLOPEN) dlclose(handle); #endif *************** *** 164,171 **** #elif defined(SEQUENT) return dlsym(handle, (char *)symname); ! #else return dlsym(handle, symname); #endif } --- 174,184 ---- #elif defined(SEQUENT) return dlsym(handle, (char *)symname); ! #elif !defined(NO_DLOPEN) return dlsym(handle, symname); + + #else + return NULL; #endif } *************** *** 175,181 **** return strerror(errno); #elif defined(HAVE_DYLD) return NULL; ! #else return dlerror(); #endif } --- 188,196 ---- return strerror(errno); #elif defined(HAVE_DYLD) return NULL; ! #elif !defined(NO_DLOPEN) return dlerror(); + #else + return strerror(errno); #endif } diff -brc orig/apache_1.3.9/src/os/unix/os.h apache_1.3.9/src/os/unix/os.h *** orig/apache_1.3.9/src/os/unix/os.h Mon May 3 20:57:14 1999 --- apache_1.3.9/src/os/unix/os.h Mon Nov 22 15:22:23 1999 *************** *** 144,147 **** --- 144,160 ---- void * ap_os_dso_sym(void *, const char *); const char *ap_os_dso_error(void); + #ifdef CHARSET_EBCDIC + + /* 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); + + #ifndef APACHE_EBCDIC_H + #include "ebcdic.h" + #endif /*APACHE_EBCDIC_H*/ + + #endif /*CHARSET_EBCDIC*/ + #endif /* !APACHE_OS_H */ diff -brc orig/apache_1.3.9/src/support/htdigest.c apache_1.3.9/src/support/htdigest.c *** orig/apache_1.3.9/src/support/htdigest.c Mon Aug 2 04:45:36 1999 --- apache_1.3.9/src/support/htdigest.c Mon Nov 22 15:22:23 1999 *************** *** 72,78 **** #include "ap_md5.h" #if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM) #include ! #else #include #endif --- 72,78 ---- #include "ap_md5.h" #if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM) #include ! #elif !defined(OS390) #include #endif