diff options
Diffstat (limited to 'APACHE_1_3_42/src/os/os2')
-rw-r--r-- | APACHE_1_3_42/src/os/os2/Makefile.tmpl | 57 | ||||
-rw-r--r-- | APACHE_1_3_42/src/os/os2/os-inline.c | 50 | ||||
-rw-r--r-- | APACHE_1_3_42/src/os/os2/os.c | 79 | ||||
-rw-r--r-- | APACHE_1_3_42/src/os/os2/os.h | 77 | ||||
-rw-r--r-- | APACHE_1_3_42/src/os/os2/util_os2.c | 170 |
5 files changed, 433 insertions, 0 deletions
diff --git a/APACHE_1_3_42/src/os/os2/Makefile.tmpl b/APACHE_1_3_42/src/os/os2/Makefile.tmpl new file mode 100644 index 0000000000..9e21b9c69e --- /dev/null +++ b/APACHE_1_3_42/src/os/os2/Makefile.tmpl @@ -0,0 +1,57 @@ +CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) +LIBS=$(EXTRA_LIBS) $(LIBS1) +INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES) +LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS) + +OBJS= os.o os-inline.o util_os2.o +COPY= os.h os-inline.c + +LIB= libos.a + +all: $(LIB) + +$(LIB): $(OBJS) + rm -f $@ + ar cr $@ $(OBJS) + $(RANLIB) $@ + +.c.o: + $(CC) -c $(INCLUDES) $(CFLAGS) $< + +clean: + for i in $(COPY); do rm -f $(INCDIR)/$$i ; done + rm -f $(OBJS) $(LIB) + +distclean: clean + -rm -f Makefile + +$(OBJS): Makefile + +$(INCDIR)/os.h: os.h + cp $< $@ + +$(INCDIR)/os-inline.c: os-inline.c + cp $< $@ + +# 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 + +# DO NOT REMOVE +os-inline.o: os-inline.c $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \ + $(INCDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h +os.o: os.c os.h os-inline.c +util_os2.o: util_os2.c $(INCDIR)/httpd.h $(INCDIR)/ap_config.h \ + $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \ + $(INCDIR)/os.h $(INCDIR)/os-inline.c $(INCDIR)/ap_ctype.h \ + $(INCDIR)/hsregex.h $(INCDIR)/ap_alloc.h $(INCDIR)/buff.h \ + $(INCDIR)/ap.h $(INCDIR)/util_uri.h $(INCDIR)/http_log.h diff --git a/APACHE_1_3_42/src/os/os2/os-inline.c b/APACHE_1_3_42/src/os/os2/os-inline.c new file mode 100644 index 0000000000..b9b838391f --- /dev/null +++ b/APACHE_1_3_42/src/os/os2/os-inline.c @@ -0,0 +1,50 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * 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) +{ + /* For now, just do the same check that http_request.c and mod_alias.c + * do. + */ + return file && (file[0] == '/' || (file[1] == ':' && file[2] == '/')); +} diff --git a/APACHE_1_3_42/src/os/os2/os.c b/APACHE_1_3_42/src/os/os2/os.c new file mode 100644 index 0000000000..cb0927b87d --- /dev/null +++ b/APACHE_1_3_42/src/os/os2/os.c @@ -0,0 +1,79 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * This file will include OS specific functions which are not inlineable. + * Any inlineable functions should be defined in os-inline.c instead. + */ + +#include "os.h" +#define INCL_DOS +#include <os2.h> +#include <stdio.h> +#include <string.h> + +static int rc=0; +static char errorstr[20]; + +void ap_os_dso_init(void) +{ +} + + + +ap_os_dso_handle_t ap_os_dso_load(const char *module_name) +{ + HMODULE handle; + + rc = DosLoadModule(errorstr, sizeof(errorstr), module_name, &handle); + + if (rc == 0) + return handle; + + return 0; +} + + + +void ap_os_dso_unload(ap_os_dso_handle_t handle) +{ + DosFreeModule(handle); +} + + + +void *ap_os_dso_sym(ap_os_dso_handle_t handle, const char *funcname) +{ + PFN func; + + rc = DosQueryProcAddr( handle, 0, funcname, &func ); + + if (rc == 0) + return func; + + return NULL; +} + + + +const char *ap_os_dso_error(void) +{ + static char message[200]; + strcpy(message, ap_os_error_message(rc)); + strcat(message, " for module "); + strcat(message, errorstr); + return message; +} diff --git a/APACHE_1_3_42/src/os/os2/os.h b/APACHE_1_3_42/src/os/os2/os.h new file mode 100644 index 0000000000..fa1f3fb8e7 --- /dev/null +++ b/APACHE_1_3_42/src/os/os2/os.h @@ -0,0 +1,77 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef APACHE_OS_H +#define APACHE_OS_H + +#define PLATFORM "OS/2" +#define HAVE_CANONICAL_FILENAME +#define HAVE_DRIVE_LETTERS +#define HAVE_UNC_PATHS + +/* + * 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(__GNUC__) && !defined(INLINE) +/* Compiler supports inline, so include the inlineable functions as + * part of the header + */ +#define INLINE extern __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 + +/* FIXME: the following should be implemented on this platform */ +#define ap_os_is_filename_valid(f) (1) + +/* Use a specialized kill() function */ +int ap_os_kill(int pid, int sig); + +/* Maps an OS error code to an error message */ +char *ap_os_error_message(int err); + +/* OS/2 doesn't have symlinks so S_ISLNK is always false */ +#define S_ISLNK(m) 0 +#define lstat(x, y) stat(x, y) + +#define isinf(n) (!isfinite(n)) +#define HAVE_ISINF +#define HAVE_ISNAN + +/* strtol() correctly returns ERANGE on overflow, use it */ +#define ap_strtol strtol + +/* Dynamic loading functions */ +#define ap_os_dso_handle_t unsigned long +void ap_os_dso_init(void); +ap_os_dso_handle_t ap_os_dso_load(const char *); +void ap_os_dso_unload(ap_os_dso_handle_t); +void * ap_os_dso_sym(ap_os_dso_handle_t, const char *); +const char *ap_os_dso_error(void); + +#endif /* ! APACHE_OS_H */ diff --git a/APACHE_1_3_42/src/os/os2/util_os2.c b/APACHE_1_3_42/src/os/os2/util_os2.c new file mode 100644 index 0000000000..5b518f8581 --- /dev/null +++ b/APACHE_1_3_42/src/os/os2/util_os2.c @@ -0,0 +1,170 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define INCL_DOS +#define INCL_DOSERRORS +#include <os2.h> +#include "httpd.h" +#include "http_log.h" + + +API_EXPORT(char *)ap_os_case_canonical_filename(pool *pPool, const char *szFile) +{ + char *buf; + char buf2[CCHMAXPATH]; + int rc, len; + char *pos; + +/* Remove trailing slash unless it's a root directory */ + len = strlen(szFile); + buf = ap_pstrndup(pPool, szFile, len); + + if (len > 3 && buf[len-1] == '/') + buf[--len] = 0; + + if (buf[0] == '/' && buf[1] == '/') { + /* A UNC path */ + if (strchr(buf+2, '/') == NULL) { /* Allow // or //server */ + return ap_pstrdup(pPool, buf); + } + } + + rc = DosQueryPathInfo(buf, FIL_QUERYFULLNAME, buf2, sizeof(buf2)); + + if (rc) { + if ( rc != ERROR_INVALID_NAME ) { + ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, NULL, "OS/2 error %d for file %s", rc, szFile); + } + + return ap_pstrdup(pPool, szFile); + } + +/* Switch backslashes to forward */ + for (pos=buf2; *pos; pos++) + if (*pos == '\\') + *pos = '/'; + + return ap_pstrdup(pPool, buf2); +} + + + +static void fix_component(char *path, char *lastcomp) +{ + FILEFINDBUF3 fb3; + HDIR hDir = HDIR_CREATE; + ULONG numNames = 1; + ULONG rc = DosFindFirst( (UCHAR *)path, &hDir, FILE_NORMAL|FILE_DIRECTORY, &fb3, sizeof(fb3), &numNames, FIL_STANDARD ); + + if (rc == 0) + strcpy(lastcomp, fb3.achName); + + DosFindClose(hDir); +} + + + +char *ap_os_systemcase_canonical_filename(pool *pPool, const char *szFile) +{ + char *szCanonicalFile = ap_os_case_canonical_filename(pPool, szFile); + int startslash = 2, slashnum=0; + char *pos, *prevslash = NULL; + + if (szCanonicalFile[0] == '/' && szCanonicalFile[1] == '/') /* a UNC name */ + startslash = 5; + + for (pos = szCanonicalFile; *pos; pos++) { + if (*pos == '/') { + slashnum++; + if (slashnum >= startslash) { + *pos = 0; + fix_component(szCanonicalFile, prevslash+1); + *pos = '/'; + } + prevslash = pos; + } + } + + if (slashnum >= startslash) { + fix_component(szCanonicalFile, prevslash+1); + } + + return szCanonicalFile; +} + + + +API_EXPORT(char *)ap_os_canonical_filename(pool *pPool, const char *szFile) +{ + char *szCanonicalFile = ap_os_systemcase_canonical_filename(pPool, szFile); + strlwr(szCanonicalFile); + return szCanonicalFile; +} + + + +int ap_os_kill(pid_t pid, int sig) +{ +/* SIGTERM's don't work too well in OS/2 (only affects other EMX programs). + CGIs may not be, esp. REXX scripts, so use a native call instead */ + + int rc; + + if ( sig == SIGTERM ) { + rc = DosSendSignalException( pid, XCPT_SIGNAL_BREAK ); + + if ( rc ) { + errno = ESRCH; + rc = -1; + } + } else { + rc = kill(pid, sig); + } + + return rc; +} + + + +char *ap_os_error_message(int err) +{ + static char result[200]; + char message[HUGE_STRING_LEN]; + ULONG len; + char *pos; + int c; + + if (DosGetMessage(NULL, 0, message, HUGE_STRING_LEN, err, "OSO001.MSG", &len) == 0) { + len--; + message[len] = 0; + pos = result; + + if (len >= sizeof(result)) + len = sizeof(result-1); + + for (c=0; c<len; c++) { + while (ap_isspace(message[c]) && ap_isspace(message[c+1])) /* skip multiple whitespace */ + c++; + *(pos++) = ap_isspace(message[c]) ? ' ' : message[c]; + } + + *pos = 0; + } else { + sprintf(result, "OS/2 error %d", err); + } + + return result; +} |