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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @brief APR-style Win32 Registry Manipulation
25 #if defined(WIN32) || defined(DOXYGEN)
28 #include "apr_pools.h"
29 #include "ap_config.h" /* Just for AP_DECLARE */
35 typedef struct ap_regkey_t ap_regkey_t
;
37 /* Used to recover AP_REGKEY_* constants
39 AP_DECLARE(const ap_regkey_t
*) ap_regkey_const(int i
);
42 * Win32 Only: Constants for ap_regkey_open()
44 #define AP_REGKEY_CLASSES_ROOT ap_regkey_const(0)
45 #define AP_REGKEY_CURRENT_CONFIG ap_regkey_const(1)
46 #define AP_REGKEY_CURRENT_USER ap_regkey_const(2)
47 #define AP_REGKEY_LOCAL_MACHINE ap_regkey_const(3)
48 #define AP_REGKEY_USERS ap_regkey_const(4)
49 #define AP_REGKEY_PERFORMANCE_DATA ap_regkey_const(5)
50 #define AP_REGKEY_DYN_DATA ap_regkey_const(6)
53 * Win32 Only: Flags for ap_regkey_value_set()
55 #define AP_REGKEY_EXPAND 0x0001
58 * Win32 Only: Open the specified registry key.
59 * @param newkey The opened registry key
60 * @param parentkey The open registry key of the parent, or one of
62 * AP_REGKEY_CLASSES_ROOT
63 * AP_REGKEY_CURRENT_CONFIG
64 * AP_REGKEY_CURRENT_USER
65 * AP_REGKEY_LOCAL_MACHINE
67 * AP_REGKEY_PERFORMANCE_DATA
70 * @param keyname The path of the key relative to the parent key
71 * @param flags Or'ed value of:
73 * APR_READ open key for reading
74 * APR_WRITE open key for writing
75 * APR_CREATE create the key if it doesn't exist
76 * APR_EXCL return error if APR_CREATE and key exists
78 * @param pool The pool in which newkey is allocated
80 AP_DECLARE(apr_status_t
) ap_regkey_open(ap_regkey_t
**newkey
,
81 const ap_regkey_t
*parentkey
,
87 * Win32 Only: Close the registry key opened or created by ap_regkey_open().
88 * @param key The registry key to close
90 AP_DECLARE(apr_status_t
) ap_regkey_close(ap_regkey_t
*key
);
93 * Win32 Only: Remove the given registry key.
94 * @param parentkey The open registry key of the parent, or one of
96 * AP_REGKEY_CLASSES_ROOT
97 * AP_REGKEY_CURRENT_CONFIG
98 * AP_REGKEY_CURRENT_USER
99 * AP_REGKEY_LOCAL_MACHINE
101 * AP_REGKEY_PERFORMANCE_DATA
104 * @param keyname The path of the key relative to the parent key
105 * @param pool The pool used for temp allocations
106 * @remark ap_regkey_remove() is not recursive, although it removes
107 * all values within the given keyname, it will not remove a key
108 * containing subkeys.
110 AP_DECLARE(apr_status_t
) ap_regkey_remove(const ap_regkey_t
*parent
,
115 * Win32 Only: Retrieve a registry value string from an open key.
116 * @param result The string value retrieved
117 * @param key The registry key to retrieve the value from
118 * @param valuename The named value to retrieve (pass "" for the default)
119 * @param pool The pool used to store the result
120 * @remark There is no toggle to prevent environment variable expansion
121 * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such
122 * expansions are always performed.
124 AP_DECLARE(apr_status_t
) ap_regkey_value_get(char **result
,
126 const char *valuename
,
130 * Win32 Only: Store a registry value string into an open key.
131 * @param key The registry key to store the value into
132 * @param valuename The named value to store (pass "" for the default)
133 * @param value The string to store for the named value
134 * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND
135 * values will find all %foo% variables expanded from the environment.
136 * @param pool The pool used for temp allocations
138 AP_DECLARE(apr_status_t
) ap_regkey_value_set(ap_regkey_t
*key
,
139 const char *valuename
,
145 * Win32 Only: Retrieve a raw byte value from an open key.
146 * @param result The raw bytes value retrieved
147 * @param resultsize Pointer to a variable to store the number raw bytes retrieved
148 * @param key The registry key to retrieve the value from
149 * @param valuename The named value to retrieve (pass "" for the default)
150 * @param pool The pool used to store the result
152 AP_DECLARE(apr_status_t
) ap_regkey_value_raw_get(void **result
,
153 apr_size_t
*resultsize
,
154 apr_int32_t
*resulttype
,
156 const char *valuename
,
160 * Win32 Only: Store a raw bytes value into an open key.
161 * @param key The registry key to store the value into
162 * @param valuename The named value to store (pass "" for the default)
163 * @param value The bytes to store for the named value
164 * @param valuesize The number of bytes for value
165 * @param valuetype The
166 * values will find all %foo% variables expanded from the environment.
167 * @param pool The pool used for temp allocations
169 AP_DECLARE(apr_status_t
) ap_regkey_value_raw_set(ap_regkey_t
*key
,
170 const char *valuename
,
172 apr_size_t valuesize
,
173 apr_int32_t valuetype
,
177 * Win32 Only: Retrieve a registry value string from an open key.
178 * @param result The string elements retrieved from a REG_MULTI_SZ string array
179 * @param key The registry key to retrieve the value from
180 * @param valuename The named value to retrieve (pass "" for the default)
181 * @param pool The pool used to store the result
183 AP_DECLARE(apr_status_t
) ap_regkey_value_array_get(apr_array_header_t
**result
,
185 const char *valuename
,
189 * Win32 Only: Store a registry value string array into an open key.
190 * @param key The registry key to store the value into
191 * @param valuename The named value to store (pass "" for the default)
192 * @param nelts The string elements to store in a REG_MULTI_SZ string array
193 * @param elts The number of elements in the elts string array
194 * @param pool The pool used for temp allocations
196 AP_DECLARE(apr_status_t
) ap_regkey_value_array_set(ap_regkey_t
*key
,
197 const char *valuename
,
199 const char * const * elts
,
203 * Win32 Only: Remove a registry value from an open key.
204 * @param key The registry key to remove the value from
205 * @param valuename The named value to remove (pass "" for the default)
206 * @param pool The pool used for temp allocations
208 AP_DECLARE(apr_status_t
) ap_regkey_value_remove(const ap_regkey_t
*key
,
209 const char *valuename
,
216 #endif /* def WIN32 || def DOXYGEN */
218 #endif /* AP_REGKEY_H */