upload http
[bottlenecks.git] / rubbos / app / httpd-2.0.64 / srclib / apr / include / arch / win32 / apr_arch_inherit.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 #ifndef INHERIT_H
18 #define INHERIT_H
19
20 #include "apr_inherit.h"
21
22 #define APR_INHERIT (1 << 24)    /* Must not conflict with other bits */
23
24 #if APR_HAS_UNICODE_FS && APR_HAS_ANSI_FS
25 /* !defined(_WIN32_WCE) is implicit here */
26
27 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup)        \
28 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
29 {                                                                   \
30     IF_WIN_OS_IS_UNICODE                                            \
31     {                                                               \
32 /*     if (!SetHandleInformation(the##name->filehand,              \
33  *                                HANDLE_FLAG_INHERIT,              \
34  *                                HANDLE_FLAG_INHERIT))             \
35  *          return apr_get_os_error();                              \
36  */  }                                                               \
37     ELSE_WIN_OS_IS_ANSI                                             \
38     {                                                               \
39         HANDLE temp, hproc = GetCurrentProcess();                   \
40         if (!DuplicateHandle(hproc, the##name->filehand,            \
41                              hproc, &temp, 0, TRUE,                 \
42                              DUPLICATE_SAME_ACCESS))                \
43             return apr_get_os_error();                              \
44         CloseHandle(the##name->filehand);                           \
45         the##name->filehand = temp;                                 \
46     }                                                               \
47     return APR_SUCCESS;                                             \
48 }                                                                   \
49 /* Deprecated */                                                    \
50 APR_DECLARE(void) apr_##name##_set_inherit(apr_##name##_t *the##name) \
51 {                                                                   \
52     apr_##name##_inherit_set(the##name);                            \
53 }
54
55 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup)      \
56 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
57 {                                                                   \
58     IF_WIN_OS_IS_UNICODE                                            \
59     {                                                               \
60 /*      if (!SetHandleInformation(the##name->filehand,              \
61  *                                HANDLE_FLAG_INHERIT, 0))          \
62  *          return apr_get_os_error();                              \
63  */ }                                                               \
64     ELSE_WIN_OS_IS_ANSI                                             \
65     {                                                               \
66         HANDLE temp, hproc = GetCurrentProcess();                   \
67         if (!DuplicateHandle(hproc, the##name->filehand,            \
68                              hproc, &temp, 0, FALSE,                \
69                              DUPLICATE_SAME_ACCESS))                \
70             return apr_get_os_error();                              \
71         CloseHandle(the##name->filehand);                           \
72         the##name->filehand = temp;                                 \
73     }                                                               \
74     return APR_SUCCESS;                                             \
75 }                                                                   \
76 /* Deprecated */                                                    \
77 APR_DECLARE(void) apr_##name##_unset_inherit(apr_##name##_t *the##name) \
78 {                                                                   \
79     apr_##name##_inherit_unset(the##name);                          \
80 }
81
82 #elif APR_HAS_ANSI_FS || defined(_WIN32_WCE)
83
84 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup)        \
85 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
86 {                                                                   \
87     HANDLE temp, hproc = GetCurrentProcess();                       \
88     if (!DuplicateHandle(hproc, the##name->filehand,                \
89                          hproc, &temp, 0, TRUE,                     \
90                          DUPLICATE_SAME_ACCESS))                    \
91         return apr_get_os_error();                                  \
92     CloseHandle(the##name->filehand);                               \
93     the##name->filehand = temp;                                     \
94     return APR_SUCCESS;                                             \
95 }
96
97 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup)      \
98 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
99 {                                                                   \
100     HANDLE temp, hproc = GetCurrentProcess();                       \
101     if (!DuplicateHandle(hproc, the##name->filehand,                \
102                          hproc, &temp, 0, FALSE,                    \
103                          DUPLICATE_SAME_ACCESS))                    \
104         return apr_get_os_error();                                  \
105     CloseHandle(the##name->filehand);                               \
106     the##name->filehand = temp;                                     \
107     return APR_SUCCESS;                                             \
108 }
109
110 #else /* APR_HAS_UNICODE_FS && !APR_HAS_ANSI_FS && !defined(_WIN32_WCE) */
111
112 #define APR_IMPLEMENT_INHERIT_SET(name, flag, pool, cleanup)        \
113 APR_DECLARE(apr_status_t) apr_##name##_inherit_set(apr_##name##_t *the##name) \
114 {                                                                   \
115 /*  if (!SetHandleInformation(the##name->filehand,                  \
116  *                            HANDLE_FLAG_INHERIT,                  \
117  *                            HANDLE_FLAG_INHERIT))                 \
118  *      return apr_get_os_error();                                  \
119  */ return APR_SUCCESS;                                             \
120 }
121
122 #define APR_IMPLEMENT_INHERIT_UNSET(name, flag, pool, cleanup)      \
123 APR_DECLARE(apr_status_t) apr_##name##_inherit_unset(apr_##name##_t *the##name)\
124 {                                                                   \
125 /*  if (!SetHandleInformation(the##name->filehand,                  \
126  *                            HANDLE_FLAG_INHERIT, 0))              \
127  *      return apr_get_os_error();                                  \
128  */ return APR_SUCCESS;                                             \
129 }
130
131 #endif /* defined(APR_HAS_UNICODE_FS) */
132
133 #endif  /* ! INHERIT_H */