1 /* Copyright 2002-2004 The Apache Software Foundation
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
19 #if defined(WIN32) || defined(DOXYGEN)
22 #include "apr_pools.h"
23 #include "ap_config.h" /* Just for AP_DECLARE */
29 typedef struct ap_regkey_t ap_regkey_t;
31 /* Used to recover AP_REGKEY_* constants
33 AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i);
37 * @brief APR-style Win32 Registry Manipulation
41 * Win32 Only: Constants for ap_regkey_open()
43 #define AP_REGKEY_CLASSES_ROOT ap_regkey_const(0)
44 #define AP_REGKEY_CURRENT_CONFIG ap_regkey_const(1)
45 #define AP_REGKEY_CURRENT_USER ap_regkey_const(2)
46 #define AP_REGKEY_LOCAL_MACHINE ap_regkey_const(3)
47 #define AP_REGKEY_USERS ap_regkey_const(4)
48 #define AP_REGKEY_PERFORMANCE_DATA ap_regkey_const(5)
49 #define AP_REGKEY_DYN_DATA ap_regkey_const(6)
52 * Win32 Only: Flags for ap_regkey_value_set()
54 #define AP_REGKEY_EXPAND 0x0001
57 * Win32 Only: Open the specified registry key.
58 * @param newkey The opened registry key
59 * @param parentkey The open registry key of the parent, or one of
61 * AP_REGKEY_CLASSES_ROOT
62 * AP_REGKEY_CURRENT_CONFIG
63 * AP_REGKEY_CURRENT_USER
64 * AP_REGKEY_LOCAL_MACHINE
66 * AP_REGKEY_PERFORMANCE_DATA
69 * @param keyname The path of the key relative to the parent key
70 * @param flags Or'ed value of:
72 * APR_READ open key for reading
73 * APR_WRITE open key for writing
74 * APR_CREATE create the key if it doesn't exist
75 * APR_EXCL return error if APR_CREATE and key exists
77 * @param pool The pool in which newkey is allocated
79 AP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey,
80 const ap_regkey_t *parentkey,
86 * Win32 Only: Close the registry key opened or created by ap_regkey_open().
87 * @param key The registry key to close
89 AP_DECLARE(apr_status_t) ap_regkey_close(ap_regkey_t *key);
92 * Win32 Only: Remove the given registry key.
93 * @param parentkey The open registry key of the parent, or one of
95 * AP_REGKEY_CLASSES_ROOT
96 * AP_REGKEY_CURRENT_CONFIG
97 * AP_REGKEY_CURRENT_USER
98 * AP_REGKEY_LOCAL_MACHINE
100 * AP_REGKEY_PERFORMANCE_DATA
103 * @param keyname The path of the key relative to the parent key
104 * @param pool The pool used for temp allocations
105 * @remark ap_regkey_remove() is not recursive, although it removes
106 * all values within the given keyname, it will not remove a key
107 * containing subkeys.
109 AP_DECLARE(apr_status_t) ap_regkey_remove(const ap_regkey_t *parent,
114 * Win32 Only: Retrieve a registry value string from an open key.
115 * @param result The string value retrieved
116 * @param key The registry key to retrieve the value from
117 * @param valuename The named value to retrieve (pass "" for the default)
118 * @param pool The pool used to store the result
119 * @remark There is no toggle to prevent environment variable expansion
120 * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such
121 * expansions are always performed.
123 AP_DECLARE(apr_status_t) ap_regkey_value_get(char **result,
125 const char *valuename,
129 * Win32 Only: Store a registry value string into an open key.
130 * @param key The registry key to store the value into
131 * @param valuename The named value to store (pass "" for the default)
132 * @param value The string to store for the named value
133 * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND
134 * values will find all %foo% variables expanded from the environment.
135 * @param pool The pool used for temp allocations
137 AP_DECLARE(apr_status_t) ap_regkey_value_set(ap_regkey_t *key,
138 const char *valuename,
144 * Win32 Only: Retrieve a raw byte value from an open key.
145 * @param result The raw bytes value retrieved
146 * @param resultsize Pointer to a variable to store the number raw bytes retrieved
147 * @param key The registry key to retrieve the value from
148 * @param valuename The named value to retrieve (pass "" for the default)
149 * @param pool The pool used to store the result
151 AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
152 apr_size_t *resultsize,
153 apr_int32_t *resulttype,
155 const char *valuename,
159 * Win32 Only: Store a raw bytes value into an open key.
160 * @param key The registry key to store the value into
161 * @param valuename The named value to store (pass "" for the default)
162 * @param value The bytes to store for the named value
163 * @param valuesize The number of bytes for value
164 * @param valuetype The
165 * values will find all %foo% variables expanded from the environment.
166 * @param pool The pool used for temp allocations
168 AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key,
169 const char *valuename,
171 apr_size_t valuesize,
172 apr_int32_t valuetype,
176 * Win32 Only: Retrieve a registry value string from an open key.
177 * @param result The string elements retrieved from a REG_MULTI_SZ string array
178 * @param key The registry key to retrieve the value from
179 * @param valuename The named value to retrieve (pass "" for the default)
180 * @param pool The pool used to store the result
182 AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result,
184 const char *valuename,
188 * Win32 Only: Store a registry value string array into an open key.
189 * @param key The registry key to store the value into
190 * @param valuename The named value to store (pass "" for the default)
191 * @param nelts The string elements to store in a REG_MULTI_SZ string array
192 * @param elts The number of elements in the elts string array
193 * @param pool The pool used for temp allocations
195 AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key,
196 const char *valuename,
198 const char * const * elts,
202 * Win32 Only: Remove a registry value from an open key.
203 * @param key The registry key to remove the value from
204 * @param valuename The named value to remove (pass "" for the default)
205 * @param pool The pool used for temp allocations
207 AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key,
208 const char *valuename,
215 #endif /* def WIN32 || def DOXYGEN */
217 #endif /* AP_REGKEY_H */