summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>1999-08-17 15:59:33 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>1999-08-17 15:59:33 +0000
commit6577c978ebc28f950f43591579674e045f3d2a67 (patch)
treea54b0555bf7862582241f3bc69c81ebf035948f8 /misc
parent3171d4b484045e81ea8289845830823008b48ece (diff)
downloadlibapr-6577c978ebc28f950f43591579674e045f3d2a67.tar.gz
Initial revision
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@59151 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r--misc/beos/Makefile.in56
-rw-r--r--misc/beos/misc.h71
-rw-r--r--misc/beos/start.c131
-rw-r--r--misc/os2/Makefile.in56
-rw-r--r--misc/os2/misc.h71
-rw-r--r--misc/os2/start.c129
-rw-r--r--misc/unix/.cvsignore1
-rw-r--r--misc/unix/Makefile.in61
-rw-r--r--misc/unix/getopt.c143
-rw-r--r--misc/unix/misc.h71
-rw-r--r--misc/unix/start.c210
-rw-r--r--misc/win32/getopt.c143
-rw-r--r--misc/win32/misc.def24
-rw-r--r--misc/win32/misc.dsp113
-rw-r--r--misc/win32/misc.h74
-rw-r--r--misc/win32/names.c318
-rw-r--r--misc/win32/start.c212
-rw-r--r--misc/win32/timetest.c75
18 files changed, 1959 insertions, 0 deletions
diff --git a/misc/beos/Makefile.in b/misc/beos/Makefile.in
new file mode 100644
index 000000000..a502388fe
--- /dev/null
+++ b/misc/beos/Makefile.in
@@ -0,0 +1,56 @@
+#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
+#LIBS=$(EXTRA_LIBS) $(LIBS1)
+#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
+#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
+
+CC=@CC@
+RANLIB=@RANLIB@
+CFLAGS=@CFLAGS@ @OPTIM@
+LIBS=@LIBS@
+LDFLAGS=@LDFLAGS@ $(LIBS)
+INCDIR=../../inc
+INCDIR1=../../include
+INCDIR2=../../file_io/unix
+INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I.
+
+LIB=../libmisc.a
+
+OBJS=start.o \
+
+.c.o:
+ $(CC) $(CFLAGS) -c $(INCLUDES) $<
+
+all: $(LIB)
+
+clean:
+ $(RM) -f *.o *.a *.so
+
+distclean: clean
+ -$(RM) -f Makefile
+
+$(OBJS): Makefile
+
+$(LIB): $(OBJS)
+ $(RM) -f $@
+ $(AR) cr $@ $(OBJS)
+ $(RANLIB) $@
+
+#
+# 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.in Makefile.in.bak \
+ && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > 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.in \
+ && rm Makefile.new
+
+# DO NOT REMOVE
+start.o: start.c $(INCDIR)/apr_config.h \
+ ../../include/apr_general.h ../../include/apr_errno.h \
+ $(INCDIR)/apr_pools.h $(INCDIR)/apr_lib.h \
+ $(INCDIR)/hsregex.h
diff --git a/misc/beos/misc.h b/misc/beos/misc.h
new file mode 100644
index 000000000..a496c372e
--- /dev/null
+++ b/misc/beos/misc.h
@@ -0,0 +1,71 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#ifndef MISC_H
+#define MISC_H
+
+#include "apr_general.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+
+struct context_t {
+ struct ap_pool_t *pool;
+ ap_int16_t signal_safe;
+ ap_int16_t cancel_safe;
+ void *prog_data;
+};
+
+#endif /* ! MISC_H */
+
diff --git a/misc/beos/start.c b/misc/beos/start.c
new file mode 100644
index 000000000..eb5231ceb
--- /dev/null
+++ b/misc/beos/start.c
@@ -0,0 +1,131 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#include <stdio.h>
+#include <dirent.h>
+#include "apr_config.h"
+#include "apr_general.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#include "misc.h"
+#include <errno.h>
+#include <string.h>
+
+ap_status_t ap_create_context(ap_context_t *cont, void *data, ap_context_t **newcont)
+{
+ ap_context_t *new;
+ ap_pool_t *pool;
+
+ if (cont) {
+ pool = ap_make_sub_pool(cont->pool);
+ }
+ else {
+ pool = ap_init_alloc();;
+ }
+
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+
+ if (cont) {
+ new = (struct context_t *)ap_palloc(cont, sizeof(struct context_t));
+ }
+ else {
+ new = (struct context_t *)malloc(sizeof(struct context_t));
+ }
+
+ new->pool = pool;
+ if (data == NULL && cont) {
+ new->prog_data = cont->prog_data;
+ }
+ else {
+ new->prog_data = data;
+ }
+ if (cont) {
+ new->signal_safe = cont->signal_safe;
+ new->cancel_safe = cont->cancel_safe;
+ }
+ else {
+ new->signal_safe = 0;
+ new->cancel_safe = 0;
+ }
+
+ *newcont = new;
+ return APR_SUCCESS;
+}
+
+ap_status_t ap_set_signal_safe(ap_context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->signal_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_set_cancel_safe(ap_context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->cancel_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_destroy_context(ap_context_t *cont)
+{
+ ap_destroy_pool(cont->pool);
+ return APR_SUCCESS;
+}
diff --git a/misc/os2/Makefile.in b/misc/os2/Makefile.in
new file mode 100644
index 000000000..a042e3f39
--- /dev/null
+++ b/misc/os2/Makefile.in
@@ -0,0 +1,56 @@
+#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
+#LIBS=$(EXTRA_LIBS) $(LIBS1)
+#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
+#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
+
+CC=@CC@
+RANLIB=@RANLIB@
+CFLAGS=@CFLAGS@ @OPTIM@
+LIBS=@LIBS@
+LDFLAGS=@LDFLAGS@ $(LIBS)
+INCDIR=../../inc
+INCDIR1=../../include
+INCDIR2=../../file_io/os2
+INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I.
+
+LIB=../misc.a
+
+OBJS=start.o \
+
+.c.o:
+ $(CC) $(CFLAGS) -c $(INCLUDES) $<
+
+all: $(LIB)
+
+clean:
+ $(RM) -f *.o *.a *.so
+
+distclean: clean
+ -$(RM) -f Makefile
+
+$(OBJS): Makefile
+
+$(LIB): $(OBJS)
+ $(RM) -f $@
+ $(AR) cr $@ $(OBJS)
+ $(RANLIB) $@
+
+#
+# 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.in Makefile.in.bak \
+ && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > 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.in \
+ && rm Makefile.new
+
+# DO NOT REMOVE
+start.o: start.c ../../include/apr_general.h \
+ ../../include/apr_errno.h ../include/apr_pools.h \
+ ../include/apr_lib.h ../include/apr_config.h \
+ ../include/hsregex.h
diff --git a/misc/os2/misc.h b/misc/os2/misc.h
new file mode 100644
index 000000000..a496c372e
--- /dev/null
+++ b/misc/os2/misc.h
@@ -0,0 +1,71 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#ifndef MISC_H
+#define MISC_H
+
+#include "apr_general.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+
+struct context_t {
+ struct ap_pool_t *pool;
+ ap_int16_t signal_safe;
+ ap_int16_t cancel_safe;
+ void *prog_data;
+};
+
+#endif /* ! MISC_H */
+
diff --git a/misc/os2/start.c b/misc/os2/start.c
new file mode 100644
index 000000000..ade80f619
--- /dev/null
+++ b/misc/os2/start.c
@@ -0,0 +1,129 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#include "apr_general.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#include "misc.h"
+#include <errno.h>
+#include <string.h>
+
+ap_status_t ap_create_context(struct context_t *cont, void *data, ap_context_t **newcont)
+{
+ struct context_t *new;
+ ap_pool_t *pool;
+
+ if (cont) {
+ pool = ap_make_sub_pool(cont->pool);
+ }
+ else {
+ pool = ap_init_alloc();;
+ }
+
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+
+ if (cont) {
+ new = (struct context_t *)ap_palloc(cont, sizeof(struct context_t));
+ }
+ else {
+ new = (struct context_t *)malloc(sizeof(struct context_t));
+ }
+
+ new->pool = pool;
+ if (data == NULL && cont) {
+ new->prog_data = cont->prog_data;
+ }
+ else {
+ new->prog_data = data;
+ }
+ if (cont) {
+ new->signal_safe = cont->signal_safe;
+ new->cancel_safe = cont->cancel_safe;
+ }
+ else {
+ new->signal_safe = 0;
+ new->cancel_safe = 0;
+ }
+
+ *newcont = new;
+ return APR_SUCCESS;
+}
+
+ap_status_t ap_set_signal_safe(struct context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->signal_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_set_cancel_safe(struct context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->cancel_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_destroy_context(struct context_t *cont)
+{
+ ap_destroy_pool(cont->pool);
+ return APR_SUCCESS;
+}
+
diff --git a/misc/unix/.cvsignore b/misc/unix/.cvsignore
new file mode 100644
index 000000000..f3c7a7c5d
--- /dev/null
+++ b/misc/unix/.cvsignore
@@ -0,0 +1 @@
+Makefile
diff --git a/misc/unix/Makefile.in b/misc/unix/Makefile.in
new file mode 100644
index 000000000..68fbbc05d
--- /dev/null
+++ b/misc/unix/Makefile.in
@@ -0,0 +1,61 @@
+#CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
+#LIBS=$(EXTRA_LIBS) $(LIBS1)
+#INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
+#LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
+
+RM=@RM@
+CC=@CC@
+RANLIB=@RANLIB@
+CFLAGS=@CFLAGS@ @OPTIM@
+LIBS=@LIBS@
+LDFLAGS=@LDFLAGS@ $(LIBS)
+INCDIR=../../inc
+INCDIR1=../../include
+INCDIR2=../../file_io/unix
+INCLUDES=-I$(INCDIR) -I$(INCDIR1) -I$(INCDIR2) -I.
+
+LIB=../libmisc.a
+
+OBJS=start.o getopt.o
+
+.c.o:
+ $(CC) $(CFLAGS) -c $(INCLUDES) $<
+
+all: $(LIB)
+
+clean:
+ $(RM) -f *.o *.a *.so
+
+distclean: clean
+ -$(RM) -f Makefile
+
+$(OBJS): Makefile
+
+$(LIB): $(OBJS)
+ $(RM) -f $@
+ $(AR) cr $@ $(OBJS)
+ $(RANLIB) $@
+
+#
+# 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.in Makefile.in.bak \
+ && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.in > 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.in \
+ && rm Makefile.new
+
+# DO NOT REMOVE
+getopt.o: getopt.c misc.h ../../include/apr_general.h \
+ ../../include/apr_config.h ../../include/apr_errno.h \
+ ../../include/apr_file_io.h
+start.o: start.c ../../include/apr_general.h \
+ ../../include/apr_config.h ../../include/apr_errno.h \
+ ../../include/apr_pools.h $(INCDIR)/apr_lib.h \
+ ../../include/apr_file_io.h $(INCDIR)/apr_config.h \
+ $(INCDIR)/hsregex.h misc.h
diff --git a/misc/unix/getopt.c b/misc/unix/getopt.c
new file mode 100644
index 000000000..55fb69b10
--- /dev/null
+++ b/misc/unix/getopt.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. 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 acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS 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 REGENTS OR 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "misc.h"
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+#define EMSG ""
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_getopt(ap_context_t *, ap_int32_t, char *const *,
+ * const char *, ap_int32_t)
+ * Parse the command line options passed to the program.
+ * arg 1) The context to operate on.
+ * arg 2) The number of arguments passed to ap_getopt to parse
+ * arg 3) The array of command line options to parse
+ * arg 4) A string of characters that are acceptable options to the program.
+ * characters followed by ":" are required to have an option
+ * associated
+ * arg 5) The next option found. There are four potential values for
+ * this variable on exit. They are:
+ * APR_EOF -- No more options to parse
+ * APR_BADCH -- Found a bad option character
+ * APR_BADARG -- Missing parameter for the found option
+ * Other -- The next option found.
+ * NOTE: Arguments 2 and 3 are most commonly argc and argv from
+ * main(argc, argv)
+ */
+ap_status_t ap_getopt(struct context_t *cont, ap_int32_t nargc,
+ char *const *nargv, const char *ostr, ap_int32_t *rv)
+{
+ char *p;
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ *rv = optopt;
+ return (APR_EOF);
+ }
+ if (place[1] && *++place == '-') { /* found "--" */
+ ++optind;
+ place = EMSG;
+ *rv = optopt;
+ return (APR_EOF);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int) *place++) == (int) ':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int) '-')
+ *rv = optopt;
+ return (APR_EOF);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':') {
+ if (!(p = strrchr(*nargv, '/')))
+ p = *nargv;
+ else
+ ++p;
+ (void) fprintf(stderr,
+ "%s: illegal option -- %c\n", p, optopt);
+ }
+ *rv = optopt;
+ return APR_BADCH;
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (*ostr == ':')
+ *rv = optopt;
+ return (APR_BADARG);
+ if (opterr) {
+ if (!(p = strrchr(*nargv, '/')))
+ p = *nargv;
+ else
+ ++p;
+ (void) fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ p, optopt);
+ }
+ *rv = optopt;
+ return (APR_BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ *rv = optopt;
+ return APR_SUCCESS;
+}
+
+
diff --git a/misc/unix/misc.h b/misc/unix/misc.h
new file mode 100644
index 000000000..a496c372e
--- /dev/null
+++ b/misc/unix/misc.h
@@ -0,0 +1,71 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#ifndef MISC_H
+#define MISC_H
+
+#include "apr_general.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+
+struct context_t {
+ struct ap_pool_t *pool;
+ ap_int16_t signal_safe;
+ ap_int16_t cancel_safe;
+ void *prog_data;
+};
+
+#endif /* ! MISC_H */
+
diff --git a/misc/unix/start.c b/misc/unix/start.c
new file mode 100644
index 000000000..8b4bf00a3
--- /dev/null
+++ b/misc/unix/start.c
@@ -0,0 +1,210 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#include "apr_general.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#include "misc.h"
+#include <pthread.h>
+#include <signal.h>
+#include <errno.h>
+#include <string.h>
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_create_context(ap_context_t *, void *, ap_context_t **)
+ * Create a new context.
+ * arg 1) The parent context. If this is NULL, the new context is a root
+ * context. If it is non-NULL, the new context will inherit all
+ * of it's parent context's attributes, except the pool will be a
+ * sub-pool.
+ * arg 2) Any data to be assocaited with the context. If this is a
+ * sub-context, and this value is NULL, the new context will
+ * inherit the data from it's parent.
+ * arg 3) The context we have just created.
+ */
+ap_status_t ap_create_context(struct context_t *cont, void *data,
+ struct context_t **newcont)
+{
+ struct context_t *new;
+ ap_pool_t *pool;
+
+ if (cont) {
+ pool = ap_make_sub_pool(cont->pool);
+ }
+ else {
+ pool = ap_init_alloc();;
+ }
+
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+
+ if (cont) {
+ new = (struct context_t *)ap_palloc(cont, sizeof(struct context_t));
+ }
+ else {
+ new = (struct context_t *)malloc(sizeof(struct context_t));
+ }
+
+ new->pool = pool;
+ if (data == NULL && cont) {
+ new->prog_data = cont->prog_data;
+ }
+ else {
+ new->prog_data = data;
+ }
+ if (cont) {
+ new->signal_safe = cont->signal_safe;
+ new->cancel_safe = cont->cancel_safe;
+ }
+ else {
+ new->signal_safe = 0;
+ new->cancel_safe = 0;
+ }
+
+ *newcont = new;
+ return APR_SUCCESS;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_set_signal_safe(ap_context_t *, ap_int16_t)
+ * Set the signal safe attribute of the program. If this bit-is on, then
+ * any apr function which uses this context IS signal safe.
+ * arg 1) The context to modify.
+ * arg 2) Should functions be signal safe or not?
+ */
+ap_status_t ap_set_signal_safe(struct context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->signal_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_set_cancel_safe(ap_context_t *, ap_int16_t)
+ * Set the cancel safe attribute of the program. If this bit-is off, then
+ * any thread which is in a function using this context IS NOT allowed
+ * to be cancelled.
+ * arg 1) The context to modify.
+ * arg 2) Should functions be cancellable or not?
+ */
+ap_status_t ap_set_cancel_safe(struct context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->cancel_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_destroy_context(ap_context_t *)
+ * Free the context and all of it's child contexts'.
+ * arg 1) The context to free.
+ */
+ap_status_t ap_destroy_context(struct context_t *cont)
+{
+ ap_destroy_pool(cont);
+ return APR_SUCCESS;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_set_userdata(ap_context_t *, void *)
+ * Set the data associated with the current context.
+ * arg 1) The current context.
+ * arg 2) The user data associated with the context.
+ */
+ap_status_t ap_set_userdata(struct context_t *cont, void *data)
+{
+ if (cont) {
+ cont->prog_data = data;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_get_userdata(ap_context_t *, void **)
+ * Return the data associated with the current context.
+ * arg 1) The current context.
+ * arg 2) The user data associated with the context.
+ */
+ap_status_t ap_get_userdata(struct context_t *cont, void **data)
+{
+ if (cont) {
+ (*data) = cont->prog_data;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_initialize()
+ * Setup any APR internal data structures. This MUST be the first
+ * function called for any APR program.
+ */
+ap_status_t ap_initialize(void)
+{
+#ifdef HAVE_PTHREAD_H
+ sigset_t sigset;
+
+ sigfillset(&sigset);
+ pthread_sigmask(SIG_BLOCK, &sigset, NULL);
+#endif
+ return APR_SUCCESS;
+}
+
diff --git a/misc/win32/getopt.c b/misc/win32/getopt.c
new file mode 100644
index 000000000..6941ef451
--- /dev/null
+++ b/misc/win32/getopt.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 1987, 1993, 1994
+ * The Regents of the University of California. 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 acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS 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 REGENTS OR 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "misc.h"
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg = ""; /* argument associated with option */
+
+#define EMSG ""
+
+/* ***APRDOC********************************************************
+ * ap_status_t ap_getopt(ap_context_t *, ap_int32_t, char *const *,
+ * const char *, ap_int32_t)
+ * Parse the command line options passed to the program.
+ * arg 1) The context to operate on.
+ * arg 2) The number of arguments passed to ap_getopt to parse
+ * arg 3) The array of command line options to parse
+ * arg 4) A string of characters that are acceptable options to the program.
+ * characters followed by ":" are required to have an option
+ * associated
+ * arg 5) The next option found. There are four potential values for
+ * this variable on exit. They are:
+ * APR_EOF -- No more options to parse
+ * APR_BADCH -- Found a bad option character
+ * APR_BADARG -- Missing parameter for the found option
+ * Other -- The next option found.
+ * NOTE: Arguments 2 and 3 are most commonly argc and argv from
+ * main(argc, argv)
+ */
+ap_status_t ap_getopt(struct context_t *cont, ap_int32_t nargc,
+ char *const *nargv, const char *ostr, ap_int32_t *rv)
+{
+ char *p;
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ *rv = optopt;
+ return (APR_EOF);
+ }
+ if (place[1] && *++place == '-') { /* found "--" */
+ ++optind;
+ place = EMSG;
+ *rv = optopt;
+ return (APR_EOF);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int) *place++) == (int) ':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int) '-')
+ *rv = optopt;
+ return (APR_EOF);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':') {
+ if (!(p = strrchr(*nargv, '/')))
+ p = *nargv;
+ else
+ ++p;
+ (void) fprintf(stderr,
+ "%s: illegal option -- %c\n", p, optopt);
+ }
+ *rv = optopt;
+ return APR_BADCH;
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (*ostr == ':')
+ *rv = optopt;
+ return (APR_BADARG);
+ if (opterr) {
+ if (!(p = strrchr(*nargv, '/')))
+ p = *nargv;
+ else
+ ++p;
+ (void) fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ p, optopt);
+ }
+ *rv = optopt;
+ return (APR_BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ *rv = optopt;
+ return APR_SUCCESS;
+}
+
+
diff --git a/misc/win32/misc.def b/misc/win32/misc.def
new file mode 100644
index 000000000..e1e650194
--- /dev/null
+++ b/misc/win32/misc.def
@@ -0,0 +1,24 @@
+; misc.def :
+
+LIBRARY misc
+DESCRIPTION ''
+
+EXPORTS
+ ; Add new API calls to the end of this list.
+ ap_os_systemcase_filename @1
+ canonical_filename @2
+ ap_create_context @3
+ ap_set_signal_safe @4
+ ap_set_cancel_safe @5
+ ap_destroy_context @6
+ WinTimeToUnixTime @7
+ ap_get_oslevel @8
+ ap_get_userdata @9
+ ap_set_userdata @10
+ ap_initialize @11
+ ap_getopt @12
+ opterr @13 DATA
+ optind @14 DATA
+ optopt @15 DATA
+ optreset @16 DATA
+ optarg @17 DATA
diff --git a/misc/win32/misc.dsp b/misc/win32/misc.dsp
new file mode 100644
index 000000000..844eb182d
--- /dev/null
+++ b/misc/win32/misc.dsp
@@ -0,0 +1,113 @@
+# Microsoft Developer Studio Project File - Name="misc" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=misc - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "misc.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "misc.mak" CFG="misc - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "misc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "misc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "misc - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+
+!ELSEIF "$(CFG)" == "misc - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib ..\..\lib\Debug\lib.lib ..\..\signal\win32\Debug\signal.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "misc - Win32 Release"
+# Name "misc - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\getopt.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\misc.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\misc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\names.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\start.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\timetest.c
+# End Source File
+# End Target
+# End Project
diff --git a/misc/win32/misc.h b/misc/win32/misc.h
new file mode 100644
index 000000000..716d16cd4
--- /dev/null
+++ b/misc/win32/misc.h
@@ -0,0 +1,74 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#ifndef MISC_H
+#define MISC_H
+
+#include "apr_general.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+
+struct context_t {
+ struct ap_pool_t *pool;
+ ap_int16_t signal_safe;
+ ap_int16_t cancel_safe;
+ void *prog_data;
+};
+
+#define WSAHighByte 2
+#define WSALowByte 0
+
+#endif /* ! MISC_H */
+
diff --git a/misc/win32/names.c b/misc/win32/names.c
new file mode 100644
index 000000000..9ce9a49aa
--- /dev/null
+++ b/misc/win32/names.c
@@ -0,0 +1,318 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+#ifdef WIN32
+#include "apr_win.h"
+#endif
+#include "apr_file_io.h"
+#include "apr_general.h"
+#include "apr_lib.h"
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+/* Returns TRUE if the input string is a string
+ * of one or more '.' characters.
+ */
+static BOOL OnlyDots(char *pString)
+{
+ char *c;
+
+ if (*pString == '\0')
+ return FALSE;
+
+ for (c = pString;*c;c++)
+ if (*c != '.')
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Accepts as input a pathname, and tries to match it to an
+ * existing path and return the pathname in the case that
+ * is present on the existing path. This routine also
+ * converts alias names to long names.
+ */
+API_EXPORT(char *) ap_os_systemcase_filename(struct context_t *pCont,
+ const char *szFile)
+{
+ char buf[HUGE_STRING_LEN];
+ char *pInputName;
+ char *p, *q;
+ BOOL bDone = FALSE;
+ BOOL bFileExists = TRUE;
+ HANDLE hFind;
+ WIN32_FIND_DATA wfd;
+
+ if (!szFile || strlen(szFile) == 0 || strlen(szFile) >= sizeof(buf))
+ return ap_pstrdup(pCont, "");
+
+ buf[0] = '\0';
+ pInputName = ap_pstrdup(pCont, szFile);
+
+ /* First convert all slashes to \ so Win32 calls work OK */
+ for (p = pInputName; *p; p++) {
+ if (*p == '/')
+ *p = '\\';
+ }
+
+ p = pInputName;
+ /* If there is drive information, copy it over. */
+ if (pInputName[1] == ':') {
+ buf[0] = tolower(*p++);
+ buf[1] = *p++;
+ buf[2] = '\0';
+
+ /* If all we have is a drive letter, then we are done */
+ if (strlen(pInputName) == 2)
+ bDone = TRUE;
+ }
+
+ q = p;
+ if (*p == '\\') {
+ p++;
+ if (*p == '\\') /* Possible UNC name */
+ {
+ p++;
+ /* Get past the machine name. FindFirstFile */
+ /* will not find a machine name only */
+ p = strchr(p, '\\');
+ if (p)
+ {
+ p++;
+ /* Get past the share name. FindFirstFile */
+ /* will not find a \\machine\share name only */
+ p = strchr(p, '\\');
+ if (p) {
+ strncat(buf,q,p-q);
+ q = p;
+ p++;
+ }
+ }
+
+ if (!p)
+ p = q;
+ }
+ }
+
+ p = strchr(p, '\\');
+
+ while (!bDone) {
+ if (p)
+ *p = '\0';
+
+ if (strchr(q, '*') || strchr(q, '?'))
+ bFileExists = FALSE;
+
+ /* If the path exists so far, call FindFirstFile
+ * again. However, if this portion of the path contains
+ * only '.' charaters, skip the call to FindFirstFile
+ * since it will convert '.' and '..' to actual names.
+ * Note: in the call to OnlyDots, we may have to skip
+ * a leading slash.
+ */
+ if (bFileExists && !OnlyDots((*q == '.' ? q : q+1))) {
+ hFind = FindFirstFile(pInputName, &wfd);
+
+ if (hFind == INVALID_HANDLE_VALUE) {
+ bFileExists = FALSE;
+ }
+ else {
+ FindClose(hFind);
+
+ if (*q == '\\')
+ strcat(buf,"\\");
+ strcat(buf, wfd.cFileName);
+ }
+ }
+
+ if (!bFileExists || OnlyDots((*q == '.' ? q : q+1))) {
+ strcat(buf, q);
+ }
+
+ if (p) {
+ q = p;
+ *p++ = '\\';
+ p = strchr(p, '\\');
+ }
+ else {
+ bDone = TRUE;
+ }
+ }
+
+ /* First convert all slashes to / so server code handles it ok */
+ for (p = buf; *p; p++) {
+ if (*p == '\\')
+ *p = '/';
+ }
+
+ return ap_pstrdup(pCont, buf);
+}
+
+/* Perform canonicalization with the exception that the
+ * input case is preserved.
+ */
+char * canonical_filename(struct context_t *pCont, const char *szFile)
+{
+ char *pNewStr;
+ char *s;
+ char *p;
+ char *q;
+
+ if (szFile == NULL || strlen(szFile) == 0)
+ return ap_pstrdup(pCont, "");
+
+ pNewStr = ap_pstrdup(pCont, szFile);
+
+ /* Change all '\' characters to '/' characters.
+ * While doing this, remove any trailing '.'.
+ * Also, blow away any directories with 3 or
+ * more '.'
+ */
+ for (p = pNewStr,s = pNewStr; *s; s++,p++) {
+ if (*s == '\\' || *s == '/') {
+
+ q = p;
+ while (p > pNewStr && *(p-1) == '.')
+ p--;
+
+ if (p == pNewStr && q-p <= 2 && *p == '.')
+ p = q;
+ else if (p > pNewStr && p < q && *(p-1) == '/') {
+ if (q-p > 2)
+ p--;
+ else
+ p = q;
+ }
+
+ *p = '/';
+ }
+ else {
+ *p = *s;
+ }
+ }
+ *p = '\0';
+
+ /* Blow away any final trailing '.' since on Win32
+ * foo.bat == foo.bat. == foo.bat... etc.
+ * Also blow away any trailing spaces since
+ * "filename" == "filename "
+ */
+ q = p;
+ while (p > pNewStr && (*(p-1) == '.' || *(p-1) == ' '))
+ p--;
+ if ((p > pNewStr) ||
+ (p == pNewStr && q-p > 2))
+ *p = '\0';
+
+
+ /* One more security issue to deal with. Win32 allows
+ * you to create long filenames. However, alias filenames
+ * are always created so that the filename will
+ * conform to 8.3 rules. According to the Microsoft
+ * Developer's network CD (1/98)
+ * "Automatically generated aliases are composed of the
+ * first six characters of the filename plus ~n
+ * (where n is a number) and the first three characters
+ * after the last period."
+ * Here, we attempt to detect and decode these names.
+ */
+ p = strchr(pNewStr, '~');
+ if (p != NULL) {
+ char *pConvertedName, *pQstr, *pPstr;
+ char buf[HUGE_STRING_LEN];
+ /* We potentially have a short name. Call
+ * ap_os_systemcase_filename to examine the filesystem
+ * and possibly extract the long name.
+ */
+ pConvertedName = ap_os_systemcase_filename(pCont, pNewStr);
+
+ /* Since we want to preserve the incoming case as much
+ * as we can, compare for differences in the string and
+ * only substitute in the path names that changed.
+ */
+ if (stricmp(pNewStr, pConvertedName)) {
+ buf[0] = '\0';
+
+ q = pQstr = pConvertedName;
+ p = pPstr = pNewStr;
+ do {
+ q = strchr(q,'/');
+ p = strchr(p,'/');
+
+ if (p != NULL) {
+ *q = '\0';
+ *p = '\0';
+ }
+
+ if (stricmp(pQstr, pPstr))
+ strcat(buf, pQstr); /* Converted name */
+ else
+ strcat(buf, pPstr); /* Original name */
+
+
+ if (p != NULL) {
+ pQstr = q;
+ pPstr = p;
+ *q++ = '/';
+ *p++ = '/';
+ }
+
+ } while (p != NULL);
+
+ pNewStr = ap_pstrdup(pCont, buf);
+ }
+ }
+ return pNewStr;
+}
diff --git a/misc/win32/start.c b/misc/win32/start.c
new file mode 100644
index 000000000..99a64d985
--- /dev/null
+++ b/misc/win32/start.c
@@ -0,0 +1,212 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+
+#include "apr_win.h"
+#include "misc.h"
+#include "apr_general.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#include "apr_lib.h"
+#include <string.h>
+#include <process.h>
+
+ap_status_t clean_cont(void *data)
+{
+ WSACleanup();
+ return APR_SUCCESS;
+}
+
+
+ap_status_t ap_create_context(ap_context_t *cont, void *data, ap_context_t **newcont)
+{
+ int iVersionRequested;
+ WSADATA wsaData;
+ int err;
+ ap_context_t *new;
+ ap_pool_t *pool;
+
+ if (cont) {
+ pool = ap_make_sub_pool(cont->pool);
+ }
+ else {
+ pool = ap_init_alloc();;
+ }
+
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+
+ if (cont) {
+ new = (ap_context_t *)ap_palloc(cont, sizeof(ap_context_t));
+ }
+ else {
+ new = (ap_context_t *)malloc(sizeof(ap_context_t));
+ }
+ new->pool = pool;
+ if (data == NULL && cont) {
+ new->prog_data = cont->prog_data;
+ }
+ else {
+ new->prog_data = data;
+ }
+ if (cont) {
+ new->signal_safe = cont->signal_safe;
+ new->cancel_safe = cont->cancel_safe;
+ }
+ else {
+ new->signal_safe = 0;
+ new->cancel_safe = 0;
+ }
+
+ iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte);
+ err = WSAStartup((WORD) iVersionRequested, &wsaData);
+ if (err) {
+ return APR_EEXIST;
+ }
+ if (LOBYTE(wsaData.wVersion) != WSAHighByte ||
+ HIBYTE(wsaData.wVersion) != WSALowByte) {
+ WSACleanup();
+ return APR_EEXIST;
+ }
+
+ ap_register_cleanup(new, NULL, clean_cont, NULL);
+
+ *newcont = new;
+ return APR_SUCCESS;
+}
+
+ap_status_t ap_set_signal_safe(ap_context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->signal_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_set_cancel_safe(ap_context_t *cont, ap_int16_t safe)
+{
+ if (cont) {
+ cont->cancel_safe = safe;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_destroy_context(ap_context_t *cont)
+{
+ ap_destroy_pool(cont);
+ return APR_SUCCESS;
+}
+
+ap_status_t ap_get_oslevel(ap_context_t *cont, ap_oslevel_e *level)
+{
+ static OSVERSIONINFO oslev;
+ static BOOL first = TRUE;
+
+ if (first) {
+ first = FALSE;
+ GetVersionEx(&oslev);
+ }
+ if (oslev.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+ (*level) = APR_WIN_NT;
+ return APR_SUCCESS;
+ }
+ else if (oslev.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ if (oslev.dwMinorVersion == 0) {
+ (*level) = APR_WIN_95;
+ return APR_SUCCESS;
+ }
+ else if (oslev.dwMinorVersion > 0) {
+ (*level) = APR_WIN_98;
+ return APR_SUCCESS;
+ }
+ }
+ return APR_EEXIST;
+}
+
+ap_status_t ap_set_userdata(struct context_t *cont, void *data)
+{
+ if (cont) {
+ cont->prog_data = data;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+ap_status_t ap_get_userdata(struct context_t *cont, void **data)
+{
+ if (cont) {
+ (*data) = cont->prog_data;
+ return APR_SUCCESS;
+ }
+ return APR_ENOCONT;
+}
+
+/* This puts one thread in a Listen for signals mode */
+ap_status_t ap_initialize(void)
+{
+ unsigned tid;
+
+ if (_beginthreadex(NULL, 0, SignalHandling, NULL, 0, &tid) == 0) {
+ return APR_EEXIST;
+ }
+
+ while (thread_ready() != 1) {
+ sleep(1);
+ }
+
+ return APR_SUCCESS;
+}
diff --git a/misc/win32/timetest.c b/misc/win32/timetest.c
new file mode 100644
index 000000000..bb7d3313e
--- /dev/null
+++ b/misc/win32/timetest.c
@@ -0,0 +1,75 @@
+/* ====================================================================
+ * Copyright (c) 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.
+ * For more information on the Apache Group and the Apache HTTP server
+ * project, please see <http://www.apache.org/>.
+ *
+ */
+#include <windows.h>
+#include <time.h>
+#include <stdio.h>
+
+time_t WinTimeToUnixTime(FILETIME *time)
+{
+ LONGLONG temp = 0;
+ /* Convert to one 64 bit number so we can work with it. */
+ temp = time->dwHighDateTime;
+ temp = temp << 32;
+ temp |= time->dwLowDateTime;
+
+ /* Convert from Windows epoch (Jan 1, 1600) to Unix
+ * epoch (Jan 1, 1970)
+ */
+ temp -= 116444736000000000;
+ /* Convert from 100 nano-sec blocks to seconds. */
+ temp /= 10000000;
+
+ return (time_t) temp;
+}