]> granicus.if.org Git - apache/blob - os/win32/os.h
update after backport
[apache] / os / win32 / os.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  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 /**
18  * @file win32/os.h
19  * @brief This file in included in all Apache source code. It contains definitions
20  * of facilities available on _this_ operating system (HAVE_* macros),
21  * and prototypes of OS specific functions defined in os.c or os-inline.c
22  *
23  * @defgroup APACHE_OS_WIN32 win32
24  * @ingroup  APACHE_OS
25  * @{
26  */
27
28 #ifdef WIN32
29
30 #ifndef AP_OS_H
31 #define AP_OS_H
32 /* Delegate windows include to the apr.h header, if USER or GDI declarations
33  * are required (for a window rather than console application), include
34  * windows.h prior to any other Apache header files.
35  */
36 #include "apr_pools.h"
37
38 #include <io.h>
39 #include <fcntl.h>
40
41 #ifdef _WIN64
42 #define PLATFORM "Win64"
43 #else
44 #define PLATFORM "Win32"
45 #endif
46
47 /* Define command-line rewriting for this platform, handled by core.
48  * For Windows, this is currently handled inside the WinNT MPM.
49  * XXX To support a choice of MPMs, extract common platform behavior
50  * into a function specified here.
51  */
52 #define AP_PLATFORM_REWRITE_ARGS_HOOK NULL
53
54 /* going away shortly... */
55 #define HAVE_DRIVE_LETTERS
56 #define HAVE_UNC_PATHS
57 #define CASE_BLIND_FILESYSTEM
58
59 #include <stddef.h>
60 #include <stdlib.h> /* for exit() */
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 /* BIG RED WARNING: exit() is mapped to allow us to capture the exit
67  * status.  This header must only be included from modules linked into
68  * the ApacheCore.dll - since it's a horrible behavior to exit() from
69  * any module outside the main() block, and we -will- assume it's a
70  * fatal error.
71  */
72
73 AP_DECLARE_DATA extern int ap_real_exit_code;
74
75 #define exit(status) ((exit)((ap_real_exit_code==2) \
76                                 ? (ap_real_exit_code = (status)) \
77                                 : ((ap_real_exit_code = 0), (status))))
78
79 #ifdef AP_DECLARE_EXPORT
80
81 /* Defined in util_win32.c and available only to the core module for
82  * win32 MPM design.
83  */
84
85 AP_DECLARE(apr_status_t) ap_os_proc_filepath(char **binpath, apr_pool_t *p);
86
87 typedef enum {
88     AP_DLL_WINBASEAPI = 0,    /* kernel32 From WinBase.h      */
89     AP_DLL_WINADVAPI = 1,     /* advapi32 From WinBase.h      */
90     AP_DLL_WINSOCKAPI = 2,    /* mswsock  From WinSock.h      */
91     AP_DLL_WINSOCK2API = 3,   /* ws2_32   From WinSock2.h     */
92     AP_DLL_defined = 4        /* must define as last idx_ + 1 */
93 } ap_dlltoken_e;
94
95 FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char* fnName, int ordinal);
96
97 PSECURITY_ATTRIBUTES GetNullACL(void);
98 void CleanNullACL(void *sa);
99
100 #define AP_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
101     typedef rettype (calltype *ap_winapi_fpt_##fn) args; \
102     static ap_winapi_fpt_##fn ap_winapi_pfn_##fn = NULL; \
103     static APR_INLINE rettype ap_winapi_##fn args \
104     {   if (!ap_winapi_pfn_##fn) \
105             ap_winapi_pfn_##fn = (ap_winapi_fpt_##fn) ap_load_dll_func(lib, #fn, ord); \
106         return (*(ap_winapi_pfn_##fn)) names; }; \
107
108 #endif /* def AP_DECLARE_EXPORT */
109
110 #ifdef __cplusplus
111 }
112 #endif
113
114 #endif  /* ndef AP_OS_H */
115 #endif  /* def WIN32 */
116 /** @} */