00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef MISC_H
00018 #define MISC_H
00019
00020 #include "apr.h"
00021 #include "apr_portable.h"
00022 #include "apr_private.h"
00023 #include "apr_general.h"
00024 #include "apr_pools.h"
00025 #include "apr_getopt.h"
00026 #include "apr_thread_proc.h"
00027 #include "apr_file_io.h"
00028 #include "apr_errno.h"
00029 #include "apr_getopt.h"
00030
00031 #if APR_HAVE_STDIO_H
00032 #include <stdio.h>
00033 #endif
00034 #if APR_HAVE_SIGNAL_H
00035 #include <signal.h>
00036 #endif
00037 #if APR_HAVE_PTHREAD_H
00038 #include <pthread.h>
00039 #endif
00040
00041
00042 #if APR_HAVE_STDLIB_H
00043 #include <stdlib.h>
00044 #endif
00045 #if APR_HAVE_STRING_H
00046 #include <string.h>
00047 #endif
00048
00049 struct apr_other_child_rec_t {
00050 apr_pool_t *p;
00051 struct apr_other_child_rec_t *next;
00052 apr_proc_t *proc;
00053 void (*maintenance) (int, void *, int);
00054 void *data;
00055 apr_os_file_t write_fd;
00056 };
00057
00058 #define WSAHighByte 2
00059 #define WSALowByte 0
00060
00061
00062
00063
00064
00065
00066 extern int APR_DECLARE_DATA apr_app_init_complete;
00067
00068 int apr_wastrtoastr(char const * const * *retarr,
00069 wchar_t const * const *arr, int args);
00070
00071
00072
00073
00074
00075 typedef enum {
00076 APR_WIN_UNK = 0,
00077 APR_WIN_UNSUP = 1,
00078 APR_WIN_95 = 10,
00079 APR_WIN_95_B = 11,
00080 APR_WIN_95_OSR2 = 12,
00081 APR_WIN_98 = 14,
00082 APR_WIN_98_SE = 16,
00083 APR_WIN_ME = 18,
00084
00085 APR_WIN_UNICODE = 20,
00086
00087 APR_WIN_CE_3 = 23,
00088
00089 APR_WIN_NT = 30,
00090 APR_WIN_NT_3_5 = 35,
00091 APR_WIN_NT_3_51 = 36,
00092
00093 APR_WIN_NT_4 = 40,
00094 APR_WIN_NT_4_SP2 = 42,
00095 APR_WIN_NT_4_SP3 = 43,
00096 APR_WIN_NT_4_SP4 = 44,
00097 APR_WIN_NT_4_SP5 = 45,
00098 APR_WIN_NT_4_SP6 = 46,
00099
00100 APR_WIN_2000 = 50,
00101 APR_WIN_2000_SP1 = 51,
00102 APR_WIN_2000_SP2 = 52,
00103 APR_WIN_XP = 60,
00104 APR_WIN_XP_SP1 = 61,
00105 APR_WIN_XP_SP2 = 62,
00106 APR_WIN_2003 = 70
00107 } apr_oslevel_e;
00108
00109 extern APR_DECLARE_DATA apr_oslevel_e apr_os_level;
00110
00111 apr_status_t apr_get_oslevel(apr_oslevel_e *);
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 #if defined(_WIN32_WCE) || defined(WINNT)
00124 #define APR_HAS_ANSI_FS 0
00125 #else
00126 #define APR_HAS_ANSI_FS 1
00127 #endif
00128
00129
00130
00131
00132
00133 #if APR_HAS_ANSI_FS && APR_HAS_UNICODE_FS
00134 #define IF_WIN_OS_IS_UNICODE if (apr_os_level >= APR_WIN_UNICODE)
00135 #define ELSE_WIN_OS_IS_ANSI else
00136 #else
00137 #define IF_WIN_OS_IS_UNICODE
00138 #define ELSE_WIN_OS_IS_ANSI
00139 #endif
00140
00141 typedef enum {
00142 DLL_WINBASEAPI = 0,
00143 DLL_WINADVAPI = 1,
00144 DLL_WINSOCKAPI = 2,
00145 DLL_WINSOCK2API = 3,
00146 DLL_SHSTDAPI = 4,
00147 DLL_NTDLL = 5,
00148 DLL_defined = 6
00149 } apr_dlltoken_e;
00150
00151 FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal);
00152
00153
00154
00155 #define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, names) \
00156 typedef rettype (calltype *apr_winapi_fpt_##fn) args; \
00157 static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \
00158 __inline rettype apr_winapi_##fn args \
00159 { if (!apr_winapi_pfn_##fn) \
00160 apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \
00161 apr_load_dll_func(lib, #fn, ord); \
00162 return (*(apr_winapi_pfn_##fn)) names; }; \
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 #if !defined(_WIN32_WCE) && !defined(WINNT)
00184
00185 #ifdef GetFileAttributesExA
00186 #undef GetFileAttributesExA
00187 #endif
00188 APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExA, 0, (
00189 IN LPCSTR lpFileName,
00190 IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
00191 OUT LPVOID lpFileInformation),
00192 (lpFileName, fInfoLevelId, lpFileInformation));
00193 #define GetFileAttributesExA apr_winapi_GetFileAttributesExA
00194 #undef GetFileAttributesEx
00195 #define GetFileAttributesEx apr_winapi_GetFileAttributesExA
00196
00197 #ifdef GetFileAttributesExW
00198 #undef GetFileAttributesExW
00199 #endif
00200 APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, GetFileAttributesExW, 0, (
00201 IN LPCWSTR lpFileName,
00202 IN GET_FILEEX_INFO_LEVELS fInfoLevelId,
00203 OUT LPVOID lpFileInformation),
00204 (lpFileName, fInfoLevelId, lpFileInformation));
00205 #define GetFileAttributesExW apr_winapi_GetFileAttributesExW
00206
00207 APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, CancelIo, 0, (
00208 IN HANDLE hFile),
00209 (hFile));
00210 #define CancelIo apr_winapi_CancelIo
00211
00212 APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, TryEnterCriticalSection, 0, (
00213 LPCRITICAL_SECTION lpCriticalSection),
00214 (lpCriticalSection));
00215 #define TryEnterCriticalSection apr_winapi_TryEnterCriticalSection
00216
00217 APR_DECLARE_LATE_DLL_FUNC(DLL_WINBASEAPI, BOOL, WINAPI, SwitchToThread, 0, (
00218 void),
00219 ());
00220 #define SwitchToThread apr_winapi_SwitchToThread
00221
00222 APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetEffectiveRightsFromAclW, 0, (
00223 IN PACL pacl,
00224 IN PTRUSTEE_W pTrustee,
00225 OUT PACCESS_MASK pAccessRights),
00226 (pacl, pTrustee, pAccessRights));
00227 #define GetEffectiveRightsFromAclW apr_winapi_GetEffectiveRightsFromAclW
00228
00229 APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoW, 0, (
00230 IN LPWSTR pObjectName,
00231 IN SE_OBJECT_TYPE ObjectType,
00232 IN SECURITY_INFORMATION SecurityInfo,
00233 OUT PSID *ppsidOwner,
00234 OUT PSID *ppsidGroup,
00235 OUT PACL *ppDacl,
00236 OUT PACL *ppSacl,
00237 OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor),
00238 (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup,
00239 ppDacl, ppSacl, ppSecurityDescriptor));
00240 #define GetNamedSecurityInfoW apr_winapi_GetNamedSecurityInfoW
00241
00242 APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetNamedSecurityInfoA, 0, (
00243 IN LPSTR pObjectName,
00244 IN SE_OBJECT_TYPE ObjectType,
00245 IN SECURITY_INFORMATION SecurityInfo,
00246 OUT PSID *ppsidOwner,
00247 OUT PSID *ppsidGroup,
00248 OUT PACL *ppDacl,
00249 OUT PACL *ppSacl,
00250 OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor),
00251 (pObjectName, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup,
00252 ppDacl, ppSacl, ppSecurityDescriptor));
00253 #define GetNamedSecurityInfoA apr_winapi_GetNamedSecurityInfoA
00254 #undef GetNamedSecurityInfo
00255 #define GetNamedSecurityInfo apr_winapi_GetNamedSecurityInfoA
00256
00257 APR_DECLARE_LATE_DLL_FUNC(DLL_WINADVAPI, BOOL, WINAPI, GetSecurityInfo, 0, (
00258 IN HANDLE handle,
00259 IN SE_OBJECT_TYPE ObjectType,
00260 IN SECURITY_INFORMATION SecurityInfo,
00261 OUT PSID *ppsidOwner,
00262 OUT PSID *ppsidGroup,
00263 OUT PACL *ppDacl,
00264 OUT PACL *ppSacl,
00265 OUT PSECURITY_DESCRIPTOR *ppSecurityDescriptor),
00266 (handle, ObjectType, SecurityInfo, ppsidOwner, ppsidGroup,
00267 ppDacl, ppSacl, ppSecurityDescriptor));
00268 #define GetSecurityInfo apr_winapi_GetSecurityInfo
00269
00270 APR_DECLARE_LATE_DLL_FUNC(DLL_SHSTDAPI, LPWSTR *, WINAPI, CommandLineToArgvW, 0, (
00271 LPCWSTR lpCmdLine,
00272 int *pNumArgs),
00273 (lpCmdLine, pNumArgs));
00274 #define CommandLineToArgvW apr_winapi_CommandLineToArgvW
00275
00276 #endif
00277
00278 #if !defined(_WIN32_WCE)
00279
00280 APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryTimerResolution, 0, (
00281 ULONG *pMaxRes,
00282 ULONG *pMinRes,
00283 ULONG *pCurRes),
00284 (pMaxRes, pMinRes, pCurRes));
00285 #define QueryTimerResolution apr_winapi_NtQueryTimerResolution
00286
00287 APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtSetTimerResolution, 0, (
00288 ULONG ReqRes,
00289 BOOL Acquire,
00290 ULONG *pNewRes),
00291 (ReqRes, Acquire, pNewRes));
00292 #define SetTimerResolution apr_winapi_NtSetTimerResolution
00293
00294
00295
00296
00297 typedef struct PBI {
00298 DWORD ExitStatus;
00299 PVOID PebBaseAddress;
00300 ULONG AffinityMask;
00301 LONG BasePriority;
00302 ULONG UniqueProcessId;
00303 ULONG InheritedFromUniqueProcessId;
00304 } PBI, *PPBI;
00305
00306 APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryInformationProcess, 0, (
00307 HANDLE hProcess,
00308 INT info,
00309 PVOID pPI,
00310 ULONG LenPI,
00311 ULONG *pSizePI),
00312 (hProcess, info, pPI, LenPI, pSizePI));
00313 #define QueryInformationProcess apr_winapi_NtQueryInformationProcess
00314
00315 APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryObject, 0, (
00316 HANDLE hObject,
00317 INT info,
00318 PVOID pOI,
00319 ULONG LenOI,
00320 ULONG *pSizeOI),
00321 (hObject, info, pOI, LenOI, pSizeOI));
00322 #define QueryObject apr_winapi_NtQueryObject
00323
00324 #endif
00325
00326 #endif
00327