00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef INHERIT_H
00018 #define INHERIT_H
00019
00020 #include "apr_inherit.h"
00021
00022 #define APR_INHERIT (1 << 24)
00023
00024 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \
00025 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
00026 { \
00027 IF_WIN_OS_IS_UNICODE \
00028 { \
00029 if (!SetHandleInformation(the##name->filehand, \
00030 HANDLE_FLAG_INHERIT, \
00031 HANDLE_FLAG_INHERIT)) \
00032 return apr_get_os_error(); \
00033 } \
00034 ELSE_WIN_OS_IS_ANSI \
00035 { \
00036 HANDLE temp, hproc = GetCurrentProcess(); \
00037 if (!DuplicateHandle(hproc, the##name->filehand, \
00038 hproc, &temp, 0, TRUE, \
00039 DUPLICATE_SAME_ACCESS)) \
00040 return apr_get_os_error(); \
00041 CloseHandle(the##name->filehand); \
00042 the##name->filehand = temp; \
00043 } \
00044 return APR_SUCCESS; \
00045 }
00046
00047 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \
00048 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
00049 { \
00050 IF_WIN_OS_IS_UNICODE \
00051 { \
00052 if (!SetHandleInformation(the##name->filehand, \
00053 HANDLE_FLAG_INHERIT, 0)) \
00054 return apr_get_os_error(); \
00055 } \
00056 ELSE_WIN_OS_IS_ANSI \
00057 { \
00058 HANDLE temp, hproc = GetCurrentProcess(); \
00059 if (!DuplicateHandle(hproc, the##name->filehand, \
00060 hproc, &temp, 0, FALSE, \
00061 DUPLICATE_SAME_ACCESS)) \
00062 return apr_get_os_error(); \
00063 CloseHandle(the##name->filehand); \
00064 the##name->filehand = temp; \
00065 } \
00066 return APR_SUCCESS; \
00067 }
00068
00069 #endif