GME
13
|
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. 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 INHERIT_H 00018 #define INHERIT_H 00019 00020 #include "apr_inherit.h" 00021 00022 #define APR_INHERIT (1 << 24) /* Must not conflict with other bits */ 00023 00024 #if APR_HAS_UNICODE_FS && APR_HAS_ANSI_FS 00025 /* !defined(_WIN32_WCE) is implicit here */ 00026 00027 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ 00028 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ 00029 { \ 00030 IF_WIN_OS_IS_UNICODE \ 00031 { \ 00032 /* if (!SetHandleInformation(the##name->filehand, \ 00033 * HANDLE_FLAG_INHERIT, \ 00034 * HANDLE_FLAG_INHERIT)) \ 00035 * return apr_get_os_error(); \ 00036 */ } \ 00037 ELSE_WIN_OS_IS_ANSI \ 00038 { \ 00039 HANDLE temp, hproc = GetCurrentProcess(); \ 00040 if (!DuplicateHandle(hproc, the##name->filehand, \ 00041 hproc, &temp, 0, TRUE, \ 00042 DUPLICATE_SAME_ACCESS)) \ 00043 return apr_get_os_error(); \ 00044 CloseHandle(the##name->filehand); \ 00045 the##name->filehand = temp; \ 00046 } \ 00047 return APR_SUCCESS; \ 00048 } 00049 00050 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ 00051 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ 00052 { \ 00053 IF_WIN_OS_IS_UNICODE \ 00054 { \ 00055 /* if (!SetHandleInformation(the##name->filehand, \ 00056 * HANDLE_FLAG_INHERIT, 0)) \ 00057 * return apr_get_os_error(); \ 00058 */ } \ 00059 ELSE_WIN_OS_IS_ANSI \ 00060 { \ 00061 HANDLE temp, hproc = GetCurrentProcess(); \ 00062 if (!DuplicateHandle(hproc, the##name->filehand, \ 00063 hproc, &temp, 0, FALSE, \ 00064 DUPLICATE_SAME_ACCESS)) \ 00065 return apr_get_os_error(); \ 00066 CloseHandle(the##name->filehand); \ 00067 the##name->filehand = temp; \ 00068 } \ 00069 return APR_SUCCESS; \ 00070 } 00071 00072 #elif APR_HAS_ANSI_FS || defined(_WIN32_WCE) 00073 00074 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ 00075 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ 00076 { \ 00077 HANDLE temp, hproc = GetCurrentProcess(); \ 00078 if (!DuplicateHandle(hproc, the##name->filehand, \ 00079 hproc, &temp, 0, TRUE, \ 00080 DUPLICATE_SAME_ACCESS)) \ 00081 return apr_get_os_error(); \ 00082 CloseHandle(the##name->filehand); \ 00083 the##name->filehand = temp; \ 00084 return APR_SUCCESS; \ 00085 } 00086 00087 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ 00088 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ 00089 { \ 00090 HANDLE temp, hproc = GetCurrentProcess(); \ 00091 if (!DuplicateHandle(hproc, the##name->filehand, \ 00092 hproc, &temp, 0, FALSE, \ 00093 DUPLICATE_SAME_ACCESS)) \ 00094 return apr_get_os_error(); \ 00095 CloseHandle(the##name->filehand); \ 00096 the##name->filehand = temp; \ 00097 return APR_SUCCESS; \ 00098 } 00099 00100 #else /* APR_HAS_UNICODE_FS && !APR_HAS_ANSI_FS && !defined(_WIN32_WCE) */ 00101 00102 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup) \ 00103 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \ 00104 { \ 00105 /* if (!SetHandleInformation(the##name->filehand, \ 00106 * HANDLE_FLAG_INHERIT, \ 00107 * HANDLE_FLAG_INHERIT)) \ 00108 * return apr_get_os_error(); \ 00109 */ return APR_SUCCESS; \ 00110 } 00111 00112 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup) \ 00113 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\ 00114 { \ 00115 /* if (!SetHandleInformation(the##name->filehand, \ 00116 * HANDLE_FLAG_INHERIT, 0)) \ 00117 * return apr_get_os_error(); \ 00118 */ return APR_SUCCESS; \ 00119 } 00120 00121 #endif /* defined(APR_HAS_UNICODE_FS) */ 00122 00123 #endif /* ! INHERIT_H */