/usr/src/redhat/BUILD/httpd-2.2.3/srclib/apr/include/arch/win32/apr_arch_misc.h

00001 /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 /* ### create APR_HAVE_* macros for these? */
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 /* start.c and apr_app.c helpers and communication within misc.c
00062  *
00063  * They are not for public consumption, although apr_app_init_complete
00064  * must be an exported symbol to avoid reinitialization.
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 /* Platform specific designation of run time os version.
00072  * Gaps allow for specific service pack levels that
00073  * export new kernel or winsock functions or behavior.
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, /* Prior versions support only narrow chars */
00086 
00087         APR_WIN_CE_3 =     23, /* CE is an odd beast, not supporting */
00088                                /* some pre-NT features, such as the    */
00089         APR_WIN_NT =       30, /* narrow charset APIs (fooA fns), while  */
00090         APR_WIN_NT_3_5 =   35, /* not supporting some NT-family features.  */
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 /* The APR_HAS_ANSI_FS symbol is PRIVATE, and internal to APR.
00114  * APR only supports char data for filenames.  Like most applications,
00115  * characters >127 are essentially undefined.  APR_HAS_UNICODE_FS lets
00116  * the application know that utf-8 is the encoding method of APR, and
00117  * only incidently hints that we have Wide OS calls.
00118  *
00119  * APR_HAS_ANSI_FS is simply an OS flag to tell us all calls must be
00120  * the unicode eqivilant.
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 /* IF_WIN_OS_IS_UNICODE / ELSE_WIN_OS_IS_ANSI help us keep the code trivial
00130  * where have runtime tests for unicode-ness, that aren't needed in any
00131  * build which supports only WINNT or WCE.
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 /* APR_HAS_UNICODE_FS */
00137 #define IF_WIN_OS_IS_UNICODE
00138 #define ELSE_WIN_OS_IS_ANSI
00139 #endif /* WINNT */
00140 
00141 typedef enum {
00142     DLL_WINBASEAPI = 0,    // kernel32 From WinBase.h
00143     DLL_WINADVAPI = 1,     // advapi32 From WinBase.h
00144     DLL_WINSOCKAPI = 2,    // mswsock  From WinSock.h
00145     DLL_WINSOCK2API = 3,   // ws2_32   From WinSock2.h
00146     DLL_SHSTDAPI = 4,      // shell32  From ShellAPI.h
00147     DLL_NTDLL = 5,         // shell32  From our real kernel
00148     DLL_defined = 6        // must define as last idx_ + 1
00149 } apr_dlltoken_e;
00150 
00151 FARPROC apr_load_dll_func(apr_dlltoken_e fnLib, char *fnName, int ordinal);
00152 
00153 /* The apr_load_dll_func call WILL fault if the function cannot be loaded */
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 /* Provide late bound declarations of every API function missing from
00165  * one or more supported releases of the Win32 API
00166  *
00167  * lib is the enumerated token from apr_dlltoken_e, and must correspond
00168  * to the string table entry in start.c used by the apr_load_dll_func().
00169  * Token names (attempt to) follow Windows.h declarations prefixed by DLL_
00170  * in order to facilitate comparison.  Use the exact declaration syntax
00171  * and names from Windows.h to prevent ambigutity and bugs.
00172  *
00173  * rettype and calltype follow the original declaration in Windows.h
00174  * fn is the true function name - beware Ansi/Unicode #defined macros
00175  * ord is the ordinal within the library, use 0 if it varies between versions
00176  * args is the parameter list following the original declaration, in parens
00177  * names is the parameter list sans data types, enclosed in parens
00178  *
00179  * #undef/re#define the Ansi/Unicode generic name to abate confusion
00180  * In the case of non-text functions, simply #define the original name
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 /* !defined(_WIN32_WCE) && !defined(WINNT) */
00277 
00278 #if !defined(_WIN32_WCE)
00279 
00280 APR_DECLARE_LATE_DLL_FUNC(DLL_NTDLL, DWORD, WINAPI, NtQueryTimerResolution, 0, (
00281     ULONG *pMaxRes,  /* Minimum NS Resolution */
00282     ULONG *pMinRes,  /* Maximum NS Resolution */
00283     ULONG *pCurRes), /* Current NS Resolution */
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,    /* Requested NS Clock Resolution */
00289     BOOL  Acquire,   /* Aquire (1) or Release (0) our interest */
00290     ULONG *pNewRes), /* The NS Clock Resolution granted */
00291     (ReqRes, Acquire, pNewRes));
00292 #define SetTimerResolution apr_winapi_NtSetTimerResolution
00293 
00294 /* ### These are ULONG_PTR values, but that's int32 for all we care
00295  * until the Win64 port is prepared.
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,  /* Obvious */
00308     INT   info,       /* Use 0 for PBI documented above */
00309     PVOID pPI,        /* The PIB buffer */
00310     ULONG LenPI,      /* Use sizeof(PBI) */
00311     ULONG *pSizePI),  /* returns pPI buffer used (may pass NULL) */
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,   /* Obvious */
00317     INT   info,       /* Use 0 for PBI documented above */
00318     PVOID pOI,        /* The PIB buffer */
00319     ULONG LenOI,      /* Use sizeof(PBI) */
00320     ULONG *pSizeOI),  /* returns pPI buffer used (may pass NULL) */
00321     (hObject, info, pOI, LenOI, pSizeOI));
00322 #define QueryObject apr_winapi_NtQueryObject
00323 
00324 #endif /* !defined(_WIN32_WCE) */
00325 
00326 #endif  /* ! MISC_H */
00327 

Apacheに対してSun Jul 19 22:05:24 2009に生成されました。  doxygen 1.4.7