]> granicus.if.org Git - apache/blob - server/mpm/winnt/mpm_winnt.h
Renamed all MODULE_EXPORT symbols to AP_MODULE_DECLARE and all symbols
[apache] / server / mpm / winnt / mpm_winnt.h
1 /* ====================================================================
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2000 The Apache Software Foundation.  All rights
5  * reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  *
19  * 3. The end-user documentation included with the redistribution,
20  *    if any, must include the following acknowledgment:
21  *       "This product includes software developed by the
22  *        Apache Software Foundation (http://www.apache.org/)."
23  *    Alternately, this acknowledgment may appear in the software itself,
24  *    if and wherever such third-party acknowledgments normally appear.
25  *
26  * 4. The names "Apache" and "Apache Software Foundation" must
27  *    not be used to endorse or promote products derived from this
28  *    software without prior written permission. For written
29  *    permission, please contact apache@apache.org.
30  *
31  * 5. Products derived from this software may not be called "Apache",
32  *    nor may "Apache" appear in their name, without prior written
33  *    permission of the Apache Software Foundation.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46  * SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Apache Software Foundation.  For more
51  * information on the Apache Software Foundation, please see
52  * <http://www.apache.org/>.
53  *
54  * Portions of this software are based upon public domain software
55  * originally written at the National Center for Supercomputing Applications,
56  * University of Illinois, Urbana-Champaign.
57  */
58
59 #ifndef APACHE_MPM_WINNT_H
60 #define APACHE_MPM_WINNT_H
61
62 #include "ap_listen.h"
63
64 /* From registry.c: */
65
66 apr_status_t ap_registry_create_key(const char *key);
67 apr_status_t ap_registry_delete_key(const char *key);
68
69 apr_status_t ap_registry_store_value(const char *key, const char *name, 
70                                     const char *value);
71 apr_status_t ap_registry_get_value(apr_pool_t *p, const char *key, 
72                                   const char *name, char **ppValue);
73 apr_status_t ap_registry_store_array(apr_pool_t *p, const char *key, 
74                                     const char *name, int nelts, 
75                                     char const* const* elts);
76 apr_status_t ap_registry_get_array(apr_pool_t *p, const char *key, 
77                                   const char *name, 
78                                   apr_array_header_t **parray);
79 apr_status_t ap_registry_delete_value(const char *key, const char *name);
80
81
82 /* From service.c: */
83
84 #define SERVICE_APACHE_RESTART 128
85
86 #define DEFAULT_SERVICE_NAME AP_SERVER_BASEPRODUCT
87 #define SERVICECONFIG9X "Software\\Microsoft\\Windows\\CurrentVersion\\RunServices"
88 #define SERVICECONFIG "System\\CurrentControlSet\\Services\\%s"
89 #define SERVICEPARAMS "System\\CurrentControlSet\\Services\\%s\\Parameters"
90
91 extern char const* service_name;
92 extern char const* display_name;
93
94 apr_status_t mpm_service_set_name(apr_pool_t *p, const char *name);
95 apr_status_t mpm_merge_service_args(apr_pool_t *p, apr_array_header_t *args, 
96                                    int fixed_args);
97
98 apr_status_t mpm_service_to_start(void);
99 apr_status_t mpm_service_started(void);
100 apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, 
101                                 char const* const* argv);
102 apr_status_t mpm_service_uninstall(void);
103
104 apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc, 
105                               char const* const* argv);
106
107 void mpm_signal_service(apr_pool_t *ptemp, int signal);
108
109 void mpm_service_stopping(void);
110
111 void mpm_start_console_handler(void);
112 void mpm_start_child_console_handler(void);
113
114 /* From winnt.c: */
115
116 extern OSVERSIONINFO osver;
117 extern int ap_threads_per_child;
118 extern int ap_max_requests_per_child;
119 extern int ap_extended_status;
120 extern void clean_child_exit(int);
121
122 AP_DECLARE(void) ap_start_shutdown(void);
123 AP_DECLARE(void) ap_start_restart(int gracefully);
124
125 void setup_signal_names(char *prefix);
126 void signal_parent(int type);
127
128 typedef struct CompContext {
129     OVERLAPPED Overlapped;
130     SOCKET accept_socket;
131     apr_socket_t *sock;
132     ap_listen_rec *lr;
133     BUFF *conn_io;
134     char *recv_buf;
135     int  recv_buf_size;
136     apr_pool_t *ptrans;
137     struct sockaddr *sa_server;
138     int sa_server_len;
139     struct sockaddr *sa_client;
140     int sa_client_len;
141 } COMP_CONTEXT, *PCOMP_CONTEXT;
142
143 /* This code is stolen from the apr_private.h and misc/win32/misc.c
144  * Please see those sources for detailed documentation.
145  */
146 typedef enum {
147     DLL_WINBASEAPI = 0,    // kernel32 From WinBase.h
148     DLL_WINADVAPI = 1,     // advapi32 From WinBase.h
149     DLL_WINSOCKAPI = 2,    // mswsock  From WinSock.h
150     DLL_WINSOCK2API = 3,   // ws2_32   From WinSock2.h
151     DLL_defined = 4        // must define as last idx_ + 1
152 } ap_dlltoken_e;
153
154 FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char *fnName, int ordinal);
155
156 #define AP_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
157     typedef rettype (calltype *ap_winapi_fpt_##fn) args; \
158     static ap_winapi_fpt_##fn ap_winapi_pfn_##fn = NULL; \
159     __inline rettype ap_winapi_##fn args \
160     {   if (!ap_winapi_pfn_##fn) \
161             ap_winapi_pfn_##fn = (ap_winapi_fpt_##fn) ap_load_dll_func(lib, #fn, ord); \
162         return (*(ap_winapi_pfn_##fn)) names; }; \
163
164 /* WinNT kernel only */
165 AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, (
166     IN HANDLE hFile),
167     (hFile));
168 #define CancelIo ap_winapi_CancelIo
169
170 /* Win9x kernel only */
171 AP_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, DWORD, WINAPI, RegisterServiceProcess, 0, (
172     DWORD dwProcessId,
173     DWORD dwType),
174     (dwProcessId, dwType));
175 #define RegisterServiceProcess ap_winapi_RegisterServiceProcess
176
177 #endif /* APACHE_MPM_WINNT_H */