summaryrefslogtreecommitdiff
path: root/misc/win32
diff options
context:
space:
mode:
authorrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-05-17 22:31:14 +0000
committerrbb <rbb@13f79535-47bb-0310-9956-ffa450edef68>2000-05-17 22:31:14 +0000
commitbe0a34adea54787d124eb6342e9f122625e7b70e (patch)
tree4af64d71eb95203d34c222f7c9bd2f7f9e464261 /misc/win32
parent5b87e234adb0a5559d21c2dfce4fe9f30dda0b3d (diff)
downloadlibapr-be0a34adea54787d124eb6342e9f122625e7b70e.tar.gz
Merging windows and Unix common misc files.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@60059 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc/win32')
-rw-r--r--misc/win32/common.c (renamed from misc/win32/canonerr.c)22
-rw-r--r--misc/win32/errorcodes.c198
-rw-r--r--misc/win32/getopt.c127
-rw-r--r--misc/win32/misc.h144
-rw-r--r--misc/win32/start.c180
5 files changed, 6 insertions, 665 deletions
diff --git a/misc/win32/canonerr.c b/misc/win32/common.c
index aff1e0fc4..fbf2f755c 100644
--- a/misc/win32/canonerr.c
+++ b/misc/win32/common.c
@@ -52,20 +52,10 @@
* <http://www.apache.org/>.
*/
-#include "misc.h"
+#include "../unix/canonerr.c"
-/*
- * Map Windows system errors to APR specific error codes.
- * This routine should only be called when it is necessary to
- * selectively react to errors returned by APR functions.
- *
- * hack alert:
- * Certain Windows APR routines already canonicalize their
- * return codes in most (and maybe all) cases that are
- * interesting to Apache. For now, canonicalization
- * on Windows is a no-op.
- */
-int ap_canonical_error(ap_status_t code)
-{
- return code;
-}
+#include "../unix/getopt.c"
+
+#include "../unix/errorcodes.c"
+
+#include "../unix/start.c"
diff --git a/misc/win32/errorcodes.c b/misc/win32/errorcodes.c
deleted file mode 100644
index 8a3e96a87..000000000
--- a/misc/win32/errorcodes.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation. 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. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" 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 name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``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 SOFTWARE FOUNDATION 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 Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "apr_lib.h"
-#include "misc.h"
-
-/* Todo: Merge this code with the code in the misc/unix directory.
- * Most of it is common
- */
-
-/*
- * stuffbuffer - like ap_cpystrn() but returns the address of the
- * dest buffer instead of the address of the terminating '\0'
- */
-static char *stuffbuffer(char *buf, ap_size_t bufsize, const char *s)
-{
- ap_cpystrn(buf,s,bufsize);
- return buf;
-}
-
-static char *apr_error_string(ap_status_t statcode)
-{
- switch (statcode) {
- case APR_ENOPOOL:
- return "A new pool could not be created.";
- case APR_ENOFILE:
- return "No file was provided and one was required.";
- case APR_EBADDATE:
- return "An invalid date has been provided";
- case APR_EINVALSOCK:
- return "An invalid socket was returned";
- case APR_ENOPROC:
- return "No process was provided and one was required.";
- case APR_ENOTIME:
- return "No time was provided and one was required.";
- case APR_ENODIR:
- return "No directory was provided and one was required.";
- case APR_ENOLOCK:
- return "No lock was provided and one was required.";
- case APR_ENOPOLL:
- return "No poll structure was provided and one was required.";
- case APR_ENOSOCKET:
- return "No socket was provided and one was required.";
- case APR_ENOTHREAD:
- return "No thread was provided and one was required.";
- case APR_ENOTHDKEY:
- return "No thread key structure was provided and one was required.";
- case APR_ENOSHMAVAIL:
- return "No shared memory is currently available";
- case APR_EDSOOPEN:
- return "Could not open the dso.";
- case APR_INCHILD:
- return
- "Your code just forked, and you are currently executing in the "
- "child process";
- case APR_INPARENT:
- return
- "Your code just forked, and you are currently executing in the "
- "parent process";
- case APR_DETACH:
- return "The specified thread is detached";
- case APR_NOTDETACH:
- return "The specified thread is not detached";
- case APR_CHILD_DONE:
- return "The specified child process is done executing";
- case APR_CHILD_NOTDONE:
- return "The specified child process is not done executing";
- case APR_TIMEUP:
- return "The timeout specified has expired";
- case APR_BADCH:
- return "Bad character specified on command line";
- case APR_BADARG:
- return "Missing parameter for the specified command line option";
- case APR_EOF:
- return "End of file found";
- case APR_NOTFOUND:
- return "Could not find specified socket in poll list.";
- case APR_ANONYMOUS:
- return "Shared memory is implemented anonymously";
- case APR_FILEBASED:
- return "Shared memory is implemented using files";
- case APR_KEYBASED:
- return "Shared memory is implemented using a key system";
- case APR_EINIT:
- return "There is no error, this value signifies an initialized "
- "error code";
- case APR_ENOTIMPL:
- return "This function has not been implemented on this platform";
- case APR_EMISMATCH:
- return "passwords do not match";
- default:
- return "Error string not specified yet";
- }
-}
-
-static char *apr_os_strerror(char *buf, ap_size_t bufsize, ap_status_t errcode)
-{
- DWORD len;
- DWORD i;
-
- len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
- NULL,
- errcode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
- (LPTSTR) buf,
- bufsize,
- NULL);
-
- if (len) {
- /* FormatMessage put the message in the buffer, but it may
- * have embedded a newline (\r\n), and possible more than one.
- * Remove the newlines replacing them with a space. This is not
- * as visually perfect as moving all the remaining message over,
- * but more efficient.
- */
- i = len;
- while (i) {
- i--;
- if ((buf[i] == '\r') || (buf[i] == '\n'))
- buf[i] = ' ';
- }
- }
- else {
- /* Windows didn't provide us with a message. Even stuff like
- * WSAECONNREFUSED won't get a message.
- */
- ap_cpystrn(buf, "Unrecognized error code", bufsize);
- }
-
- return buf;
-}
-
-char *ap_strerror(ap_status_t statcode, char* buf, ap_size_t bufsize)
-{
- if (statcode < APR_OS_START_ERROR) {
- return apr_os_strerror(buf, bufsize, statcode);
- }
- else if (statcode < APR_OS_START_USEERR) {
- return stuffbuffer(buf, bufsize, apr_error_string(statcode));
- }
- else if (statcode < APR_OS_START_SYSERR) {
- return stuffbuffer(buf, bufsize, "APR does not understand this error code");
- }
- else {
- return apr_os_strerror(buf, bufsize, statcode - APR_OS_START_SYSERR);
- }
-}
diff --git a/misc/win32/getopt.c b/misc/win32/getopt.c
deleted file mode 100644
index 7a5b369e9..000000000
--- a/misc/win32/getopt.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * 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"
-
-API_VAR_EXPORT int
- ap_opterr = 1, /* if error message should be printed */
- ap_optind = 1, /* index into parent argv vector */
- ap_optopt, /* character checked for validity */
- ap_optreset; /* reset getopt */
-API_VAR_EXPORT char *
- ap_optarg = ""; /* argument associated with option */
-
-#define EMSG ""
-
-ap_status_t ap_getopt(ap_int32_t nargc, char *const *nargv, const char *ostr, ap_int32_t *rv, ap_pool_t *cont)
-{
- char *p;
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
-
- if (ap_optreset || !*place) { /* update scanning pointer */
- ap_optreset = 0;
- if (ap_optind >= nargc || *(place = nargv[ap_optind]) != '-') {
- place = EMSG;
- *rv = ap_optopt;
- return (APR_EOF);
- }
- if (place[1] && *++place == '-') { /* found "--" */
- ++ap_optind;
- place = EMSG;
- *rv = ap_optopt;
- return (APR_EOF);
- }
- } /* option letter okay? */
- if ((ap_optopt = (int) *place++) == (int) ':' ||
- !(oli = strchr(ostr, ap_optopt))) {
- /*
- * if the user didn't specify '-' as an option,
- * assume it means -1.
- */
- if (ap_optopt == (int) '-') {
- *rv = ap_optopt;
- return (APR_EOF);
- }
- if (!*place)
- ++ap_optind;
- if (ap_opterr && *ostr != ':') {
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- (void) fprintf(stderr,
- "%s: illegal option -- %c\n", p, ap_optopt);
- }
- *rv = ap_optopt;
- return APR_BADCH;
- }
- if (*++oli != ':') { /* don't need argument */
- ap_optarg = NULL;
- if (!*place)
- ++ap_optind;
- }
- else { /* need an argument */
- if (*place) /* no white space */
- ap_optarg = place;
- else if (nargc <= ++ap_optind) { /* no arg */
- place = EMSG;
- if (*ostr == ':') {
- *rv = ap_optopt;
- return (APR_BADARG);
- }
- if (ap_opterr) {
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- (void) fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- p, ap_optopt);
- }
- *rv = ap_optopt;
- return (APR_BADCH);
- }
- else /* white space */
- ap_optarg = nargv[ap_optind];
- place = EMSG;
- ++ap_optind;
- }
- *rv = ap_optopt;
- return APR_SUCCESS;
-}
-
-
diff --git a/misc/win32/misc.h b/misc/win32/misc.h
deleted file mode 100644
index 5ddb2d2ff..000000000
--- a/misc/win32/misc.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation. 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. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" 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 name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``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 SOFTWARE FOUNDATION 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 Software Foundation. For more
- * information on the Apache Software Foundation, 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"
-#include "apr_getopt.h"
-
-typedef struct datastruct {
- void *data;
- char *key;
- struct datastruct *next;
- struct datastruct *prev;
-} datastruct;
-
-#define WSAHighByte 2
-#define WSALowByte 0
-/* Platform specific designation of run time os version.
- * Gaps allow for specific service pack levels that
- * export new kernel or winsock functions or behavior.
- */
-typedef enum {
- APR_WIN_95 = 0,
- APR_WIN_98 = 4,
- APR_WIN_NT = 8,
- APR_WIN_NT_4 = 12,
- APR_WIN_NT_4_SP2 = 14,
- APR_WIN_NT_4_SP3 = 15,
- APR_WIN_NT_4_SP4 = 16,
- APR_WIN_NT_4_SP6 = 18,
- APR_WIN_2000 = 24
-} ap_oslevel_e;
-
-
-typedef enum {
- DLL_WINBASEAPI = 0, // kernel32 From WinBase.h
- DLL_WINADVAPI = 1, // advapi32 From WinBase.h
- DLL_WINSOCKAPI = 2, // mswsock From WinSock.h
- DLL_WINSOCK2API = 3, // ws2_32 From WinSock2.h
- DLL_defined = 4 // must define as last idx_ + 1
-} ap_dlltoken_e;
-
-FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char *fnName, int ordinal);
-
-/* The ap_load_dll_func call WILL fault if the function cannot be loaded */
-
-#define AP_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
- typedef rettype (calltype *ap_winapi_fpt_##fn) args; \
- static ap_winapi_fpt_##fn ap_winapi_pfn_##fn = NULL; \
- __inline rettype ap_winapi_##fn args \
- { if (!ap_winapi_pfn_##fn) \
- ap_winapi_pfn_##fn = (ap_winapi_fpt_##fn) ap_load_dll_func(lib, #fn, ord); \
- return (*(ap_winapi_pfn_##fn)) names; }; \
-
-/* Provide late bound declarations of every API function missing from
- * one or more supported releases of the Win32 API
- *
- * lib is the enumerated token from ap_dlltoken_e, and must correspond
- * to the string table entry in start.c used by the ap_load_dll_func().
- * Token names (attempt to) follow Windows.h declarations prefixed by DLL_
- * in order to facilitate comparison. Use the exact declaration syntax
- * and names from Windows.h to prevent ambigutity and bugs.
- *
- * rettype and calltype follow the original declaration in Windows.h
- * fn is the true function name - beware Ansi/Unicode #defined macros
- * ord is the ordinal within the library, use 0 if it varies between versions
- * args is the parameter list following the original declaration, in parens
- * names is the parameter list sans data types, enclosed in parens
- *
- * #undef/re#define the Ansi/Unicode generic name to abate confusion
- * In the case of non-text functions, simply #define the original name
- */
-
-AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExA, 0, (
- IN LPCSTR lpFileName,
- IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
- OUT LPVOID lpFileInformation),
- (lpFileName, fInfoLevelId, lpFileInformation));
-#undef GetFileAttributesEx
-#define GetFileAttributesEx ap_winapi_GetFileAttributesExA
-
-AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, (
- IN HANDLE hFile),
- (hFile));
-#define CancelIo ap_winapi_CancelIo
-
-ap_status_t ap_get_oslevel(struct ap_pool_t *, ap_oslevel_e *);
-
-#endif /* ! MISC_H */
-
diff --git a/misc/win32/start.c b/misc/win32/start.c
deleted file mode 100644
index fa35f8f26..000000000
--- a/misc/win32/start.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2000 The Apache Software Foundation. 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. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" 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 name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``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 SOFTWARE FOUNDATION 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 Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-#include "apr_private.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>
-#include <stdlib.h>
-
-ap_status_t clean_cont(void *data)
-{
- return APR_SUCCESS;
-}
-
-
-ap_status_t ap_create_pool(ap_pool_t **newcont, ap_pool_t *cont)
-{
- ap_pool_t *new;
-
- if (cont) {
- new = ap_make_sub_pool(cont, cont->apr_abort);
- }
- else {
- new = ap_make_sub_pool(NULL, NULL);
- }
-
- if (new == NULL) {
- return APR_ENOPOOL;
- }
-
- new->prog_data = NULL;
- new->apr_abort = NULL;
-
- *newcont = new;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_destroy_context(ap_pool_t *cont)
-{
- ap_destroy_pool(cont);
- return APR_SUCCESS;
-}
-
-ap_status_t ap_set_userdata(void *data, char *key,
- ap_status_t (*cleanup) (void *),
- ap_pool_t *cont)
-{
- datastruct *dptr = NULL, *dptr2 = NULL;
- if (cont) {
- dptr = cont->prog_data;
- while (dptr) {
- if (!strcmp(dptr->key, key))
- break;
- dptr2 = dptr;
- dptr = dptr->next;
- }
- if (dptr == NULL) {
- dptr = ap_palloc(cont, sizeof(datastruct));
- dptr->next = dptr->prev = NULL;
- dptr->key = ap_pstrdup(cont, key);
- if (dptr2) {
- dptr2->next = dptr;
- dptr->prev = dptr2;
- }
- else {
- cont->prog_data = dptr;
- }
- }
- dptr->data = data;
- ap_register_cleanup(cont, dptr->data, cleanup, cleanup);
- return APR_SUCCESS;
- }
- return APR_ENOPOOL;
-}
-
-ap_status_t ap_get_userdata(void **data, char *key, ap_pool_t *cont)
-{
- datastruct *dptr = NULL;
- if (cont) {
- dptr = cont->prog_data;
- while (dptr) {
- if (!strcmp(dptr->key, key)) {
- break;
- }
- dptr = dptr->next;
- }
- if (dptr) {
- (*data) = dptr->data;
- }
- else {
- (*data) = NULL;
- }
- return APR_SUCCESS;
- }
- return APR_ENOPOOL;
-}
-
-/* This puts one thread in a Listen for signals mode */
-ap_status_t ap_initialize(void)
-{
- ap_status_t status;
- int iVersionRequested;
- WSADATA wsaData;
- int err;
-
- iVersionRequested = MAKEWORD(WSAHighByte, WSALowByte);
- err = WSAStartup((WORD) iVersionRequested, &wsaData);
- if (err) {
- return err;
- }
- if (LOBYTE(wsaData.wVersion) != WSAHighByte ||
- HIBYTE(wsaData.wVersion) != WSALowByte) {
- WSACleanup();
- return APR_EEXIST;
- }
-
- status = ap_init_alloc();
- return status;
-}
-
-void ap_terminate(void)
-{
- WSACleanup();
- ap_term_alloc();
-}