~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/include/arch/win32/apr_arch_misc.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#ifndef MISC_H
 
18
#define MISC_H
 
19
 
 
20
#include "apr.h"
 
21
#include "apr_portable.h"
 
22
#include "apr_private.h"
 
23
#include "apr_general.h"
 
24
#include "apr_pools.h"
 
25
#include "apr_getopt.h"
 
26
#include "apr_thread_proc.h"
 
27
#include "apr_file_io.h"
 
28
#include "apr_errno.h"
 
29
#include "apr_getopt.h"
 
30
 
 
31
#if APR_HAVE_STDIO_H
 
32
#include <stdio.h>
 
33
#endif
 
34
#if APR_HAVE_SIGNAL_H
 
35
#include <signal.h>
 
36
#endif
 
37
#if APR_HAVE_PTHREAD_H
 
38
#include <pthread.h>
 
39
#endif
 
40
 
 
41
/* ### create APR_HAVE_* macros for these? */
 
42
#if APR_HAVE_STDLIB_H
 
43
#include <stdlib.h>
 
44
#endif
 
45
#if APR_HAVE_STRING_H
 
46
#include <string.h>
 
47
#endif
 
48
 
 
49
struct apr_other_child_rec_t {
 
50
    apr_pool_t *p;
 
51
    struct apr_other_child_rec_t *next;
 
52
    apr_proc_t *proc;
 
53
    void (*maintenance) (int, void *, int);
 
54
    void *data;
 
55
    apr_os_file_t write_fd;
 
56
};
 
57
 
 
58
#define WSAHighByte 2
 
59
#define WSALowByte 0
 
60
 
 
61
/* start.c and apr_app.c helpers and communication within misc.c
 
62
 *
 
63
 * They are not for public consumption, although apr_app_init_complete
 
64
 * must be an exported symbol to avoid reinitialization.
 
65
 */
 
66
extern int APR_DECLARE_DATA apr_app_init_complete;
 
67
 
 
68
int apr_wastrtoastr(char const * const * *retarr, 
 
69
                    wchar_t const * const *arr, int args);
 
70
 
 
71
/* Platform specific designation of run time os version.
 
72
 * Gaps allow for specific service pack levels that
 
73
 * export new kernel or winsock functions or behavior.
 
74
 */
 
75
typedef enum {
 
76
        APR_WIN_UNK =       0,
 
77
        APR_WIN_UNSUP =     1,
 
78
        APR_WIN_95 =       10,
 
79
        APR_WIN_95_B =     11,
 
80
        APR_WIN_95_OSR2 =  12,
 
81
        APR_WIN_98 =       14,
 
82
        APR_WIN_98_SE =    16,
 
83
        APR_WIN_ME =       18,
 
84
 
 
85
        APR_WIN_UNICODE =  20, /* Prior versions support only narrow chars */
 
86
 
 
87
        APR_WIN_CE_3 =     23, /* CE is an odd beast, not supporting */
 
88
                               /* some pre-NT features, such as the    */
 
89
        APR_WIN_NT =       30, /* narrow charset APIs (fooA fns), while  */
 
90
        APR_WIN_NT_3_5 =   35, /* not supporting some NT-family features.  */
 
91
        APR_WIN_NT_3_51 =  36,
 
92
 
 
93
        APR_WIN_NT_4 =     40,
 
94
        APR_WIN_NT_4_SP2 = 42,
 
95
        APR_WIN_NT_4_SP3 = 43,
 
96
        APR_WIN_NT_4_SP4 = 44,
 
97
        APR_WIN_NT_4_SP5 = 45,
 
98
        APR_WIN_NT_4_SP6 = 46,
 
99
 
 
100
        APR_WIN_2000 =     50,
 
101
        APR_WIN_2000_SP1 = 51,
 
102
        APR_WIN_2000_SP2 = 52,
 
103
        APR_WIN_XP =       60,
 
104
        APR_WIN_XP_SP1 =   61,
 
105
        APR_WIN_XP_SP2 =   62,
 
106
        APR_WIN_2003 =     70
 
107
} apr_oslevel_e;
 
108
 
 
109
extern APR_DECLARE_DATA apr_oslevel_e apr_os_level;
 
110
 
 
111
apr_status_t apr_get_oslevel(apr_oslevel_e *);
 
112
 
 
113
/* The APR_HAS_ANSI_FS symbol is PRIVATE, and internal to APR.
 
114
 * APR only supports char data for filenames.  Like most applications,
 
115
 * characters >127 are essentially undefined.  APR_HAS_UNICODE_FS lets
 
116
 * the application know that utf-8 is the encoding method of APR, and
 
117
 * only incidently hints that we have Wide OS calls.
 
118
 *
 
119
 * APR_HAS_ANSI_FS is simply an OS flag to tell us all calls must be
 
120
 * the unicode eqivilant.
 
121
 */
 
122
 
 
123
#if defined(_WIN32_WCE) || defined(WINNT)
 
124
#define APR_HAS_ANSI_FS           0
 
125
#else
 
126
#define APR_HAS_ANSI_FS           1
 
127
#endif
 
128
 
 
129
/* IF_WIN_OS_IS_UNICODE / ELSE_WIN_OS_IS_ANSI help us keep the code trivial
 
130
 * where have runtime tests for unicode-ness, that aren't needed in any
 
131
 * build which supports only WINNT or WCE.
 
132
 */
 
133
#if APR_HAS_ANSI_FS && APR_HAS_UNICODE_FS
 
134
#define IF_WIN_OS_IS_UNICODE if (apr_os_level >= APR_WIN_UNICODE)
 
135
#define ELSE_WIN_OS_IS_ANSI else
 
136
#else /* APR_HAS_UNICODE_FS */
 
137
#define IF_WIN_OS_IS_UNICODE
 
138
#define ELSE_WIN_OS_IS_ANSI
 
139
#endif /* WINNT */
 
140
 
 
141
typedef enum {
 
142
    DLL_WINBASEAPI = 0,    // kernel32 From WinBase.h
 
143
    DLL_WINADVAPI = 1,     // advapi32 From WinBase.h
 
144
    DLL_WINSOCKAPI = 2,    // mswsock  From WinSock.h
 
145
    DLL_WINSOCK2API = 3,   // ws2_32   From WinSock2.h
 
146
    DLL_SHSTDAPI = 4,      // shell32  From ShellAPI.h
 
147
    DLL_NTDLL = 5,         // shell32  From our real kernel
 
148
    DLL_defined = 6        // must define as last idx_ + 1
 
149
} apr_dlltoken_e;
 
150
 
 
151
FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal);
 
152
 
 
153
/* The apr_load_dll_func call WILL fault if the function cannot be loaded */
 
154
 
 
155
#define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
 
156
    typedef rettype (calltype *apr_winapi_fpt_##fn) args; \
 
157
    static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \
 
158
    __inline rettype apr_winapi_##fn args \
 
159
    {   if (!apr_winapi_pfn_##fn) \
 
160
            apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \
 
161
                                      apr_load_dll_func(lib, #fn, ord); \
 
162
        return (*(apr_winapi_pfn_##fn)) names; }; \
 
163
 
 
164
/* Provide late bound declarations of every API function missing from
 
165
 * one or more supported releases of the Win32 API
 
166
 *
 
167
 * lib is the enumerated token from apr_dlltoken_e, and must correspond
 
168
 * to the string table entry in start.c used by the apr_load_dll_func().
 
169
 * Token names (attempt to) follow Windows.h declarations prefixed by DLL_
 
170
 * in order to facilitate comparison.  Use the exact declaration syntax
 
171
 * and names from Windows.h to prevent ambigutity and bugs.
 
172
 *
 
173
 * rettype and calltype follow the original declaration in Windows.h
 
174
 * fn is the true function name - beware Ansi/Unicode #defined macros
 
175
 * ord is the ordinal within the library, use 0 if it varies between versions
 
176
 * args is the parameter list following the original declaration, in parens
 
177
 * names is the parameter list sans data types, enclosed in parens
 
178
 *
 
179
 * #undef/re#define the Ansi/Unicode generic name to abate confusion
 
180
 * In the case of non-text functions, simply #define the original name
 
181
 */
 
182
 
 
183
#if !defined(_WIN32_WCE) && !defined(WINNT)
 
184
 
 
185
#ifdef GetFileAttributesExA
 
186
#undef GetFileAttributesExA
 
187
#endif
 
188
APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExA, 0, (
 
189
    IN LPCSTR lpFileName,
 
190
    IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
 
191
    OUT LPVOID lpFileInformation),
 
192
    (lpFileName, fInfoLevelId, lpFileInformation));
 
193
#define GetFileAttributesExA apr_winapi_GetFileAttributesExA
 
194
#undef GetFileAttributesEx
 
195
#define GetFileAttributesEx apr_winapi_GetFileAttributesExA
 
196
 
 
197
#ifdef GetFileAttributesExW
 
198
#undef GetFileAttributesExW
 
199
#endif
 
200
APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExW, 0, (
 
201
    IN LPCWSTR lpFileName,
 
202
    IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
 
203
    OUT LPVOID lpFileInformation),
 
204
    (lpFileName, fInfoLevelId, lpFileInformation));
 
205
#define GetFileAttributesExW apr_winapi_GetFileAttributesExW
 
206
 
 
207
APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, (
 
208
    IN HANDLE hFile),
 
209
    (hFile));
 
210
#define CancelIo apr_winapi_CancelIo
 
211
 
 
212
APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, TryEnterCriticalSection, 0, (
 
213
    LPCRITICAL_SECTION lpCriticalSection),
 
214
    (lpCriticalSection));
 
215
#define TryEnterCriticalSection apr_winapi_TryEnterCriticalSection
 
216
 
 
217
APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SwitchToThread, 0, (
 
218
    void),
 
219
    ());
 
220
#define SwitchToThread apr_winapi_SwitchToThread
 
221
 
 
222
APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetEffectiveRightsFromAclW, 0, (
 
223
    IN PACL pacl,
 
224
    IN PTRUSTEE_W pTrustee,
 
225
    OUT PACCESS_MASK pAccessRights),
 
226
    (pacl, pTrustee, pAccessRights));
 
227
#define GetEffectiveRightsFromAclW apr_winapi_GetEffectiveRightsFromAclW
 
228
 
 
229
APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoW, 0, (
 
230
    IN LPWSTR pObjectName,
 
231
    IN SE_OBJECT_TYPE ObjectType,
 
232
    IN SECURITY_INFORMATION SecurityInfo,
 
233
    OUT PSID *ppsidOwner,
 
234
    OUT PSID *ppsidGroup,
 
235
    OUT PACL *ppDacl,
 
236
    OUT PACL *ppSacl,
 
237
    OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor),
 
238
    (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, 
 
239
         ppDacl, ppSacl, ppSecurityDescriptor));
 
240
#define GetNamedSecurityInfoW apr_winapi_GetNamedSecurityInfoW
 
241
 
 
242
APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoA, 0, (
 
243
    IN LPSTR pObjectName,
 
244
    IN SE_OBJECT_TYPE ObjectType,
 
245
    IN SECURITY_INFORMATION SecurityInfo,
 
246
    OUT PSID *ppsidOwner,
 
247
    OUT PSID *ppsidGroup,
 
248
    OUT PACL *ppDacl,
 
249
    OUT PACL *ppSacl,
 
250
    OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor),
 
251
    (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, 
 
252
         ppDacl, ppSacl, ppSecurityDescriptor));
 
253
#define GetNamedSecurityInfoA apr_winapi_GetNamedSecurityInfoA
 
254
#undef GetNamedSecurityInfo
 
255
#define GetNamedSecurityInfo apr_winapi_GetNamedSecurityInfoA
 
256
 
 
257
APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetSecurityInfo, 0, (
 
258
    IN HANDLE handle,
 
259
    IN SE_OBJECT_TYPE ObjectType,
 
260
    IN SECURITY_INFORMATION SecurityInfo,
 
261
    OUT PSID *ppsidOwner,
 
262
    OUT PSID *ppsidGroup,
 
263
    OUT PACL *ppDacl,
 
264
    OUT PACL *ppSacl,
 
265
    OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor),
 
266
    (handle, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup, 
 
267
         ppDacl, ppSacl, ppSecurityDescriptor));
 
268
#define GetSecurityInfo apr_winapi_GetSecurityInfo
 
269
 
 
270
APR_DECLARE_LATE_DLL_FUNC(DLL_SHSTDAPI, LPWSTR *, WINAPI, CommandLineToArgvW, 0, (
 
271
    LPCWSTR lpCmdLine, 
 
272
    int *pNumArgs),
 
273
    (lpCmdLine, pNumArgs));
 
274
#define CommandLineToArgvW apr_winapi_CommandLineToArgvW
 
275
 
 
276
#endif /* !defined(_WIN32_WCE) && !defined(WINNT) */
 
277
 
 
278
#if !defined(_WIN32_WCE)
 
279
 
 
280
APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryTimerResolution, 0, (
 
281
    ULONG *pMaxRes,  /* Minimum NS Resolution */
 
282
    ULONG *pMinRes,  /* Maximum NS Resolution */
 
283
    ULONG *pCurRes), /* Current NS Resolution */
 
284
    (pMaxRes, pMinRes, pCurRes));
 
285
#define QueryTimerResolution apr_winapi_NtQueryTimerResolution
 
286
 
 
287
APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtSetTimerResolution, 0, (
 
288
    ULONG ReqRes,    /* Requested NS Clock Resolution */
 
289
    BOOL  Acquire,   /* Aquire (1) or Release (0) our interest */
 
290
    ULONG *pNewRes), /* The NS Clock Resolution granted */
 
291
    (ReqRes, Acquire, pNewRes));
 
292
#define SetTimerResolution apr_winapi_NtSetTimerResolution
 
293
 
 
294
/* ### These are ULONG_PTR values, but that's int32 for all we care
 
295
 * until the Win64 port is prepared.
 
296
 */
 
297
typedef struct PBI {
 
298
    DWORD ExitStatus;
 
299
    PVOID PebBaseAddress;
 
300
    ULONG AffinityMask;
 
301
    LONG  BasePriority;
 
302
    ULONG UniqueProcessId;
 
303
    ULONG InheritedFromUniqueProcessId;
 
304
} PBI, *PPBI;
 
305
 
 
306
APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryInformationProcess, 0, (
 
307
    HANDLE hProcess,  /* Obvious */
 
308
    INT   info,       /* Use 0 for PBI documented above */
 
309
    PVOID pPI,        /* The PIB buffer */
 
310
    ULONG LenPI,      /* Use sizeof(PBI) */
 
311
    ULONG *pSizePI),  /* returns pPI buffer used (may pass NULL) */
 
312
    (hProcess, info, pPI, LenPI, pSizePI));
 
313
#define QueryInformationProcess apr_winapi_NtQueryInformationProcess
 
314
 
 
315
APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryObject, 0, (
 
316
    HANDLE hObject,   /* Obvious */
 
317
    INT   info,       /* Use 0 for PBI documented above */
 
318
    PVOID pOI,        /* The PIB buffer */
 
319
    ULONG LenOI,      /* Use sizeof(PBI) */
 
320
    ULONG *pSizeOI),  /* returns pPI buffer used (may pass NULL) */
 
321
    (hObject, info, pOI, LenOI, pSizeOI));
 
322
#define QueryObject apr_winapi_NtQueryObject
 
323
 
 
324
#endif /* !defined(_WIN32_WCE) */
 
325
 
 
326
#endif  /* ! MISC_H */
 
327