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 parent 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 resulttype Pointer to a variable to store the registry type of the value retrieved
149 * @param key The registry key to retrieve the value from
150 * @param valuename The named value to retrieve (pass "" for the default)
151 * @param pool The pool used to store the result
153 AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
154 apr_size_t *resultsize,
155 apr_int32_t *resulttype,
157 const char *valuename,
161 * Win32 Only: Store a raw bytes value into an open key.
162 * @param key The registry key to store the value into
163 * @param valuename The named value to store (pass "" for the default)
164 * @param value The bytes to store for the named value
165 * @param valuesize The number of bytes for value
166 * @param valuetype The
167 * values will find all %foo% variables expanded from the environment.
168 * @param pool The pool used for temp allocations
170 AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key,
171 const char *valuename,
173 apr_size_t valuesize,
174 apr_int32_t valuetype,
178 * Win32 Only: Retrieve a registry value string from an open key.
179 * @param result The string elements retrieved from a REG_MULTI_SZ string array
180 * @param key The registry key to retrieve the value from
181 * @param valuename The named value to retrieve (pass "" for the default)
182 * @param pool The pool used to store the result
184 AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result,
186 const char *valuename,
190 * Win32 Only: Store a registry value string array into an open key.
191 * @param key The registry key to store the value into
192 * @param valuename The named value to store (pass "" for the default)
193 * @param nelts The string elements to store in a REG_MULTI_SZ string array
194 * @param elts The number of elements in the elts string array
195 * @param pool The pool used for temp allocations
197 AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key,
198 const char *valuename,
200 const char * const * elts,
204 * Win32 Only: Remove a registry value from an open key.
205 * @param key The registry key to remove the value from
206 * @param valuename The named value to remove (pass "" for the default)
207 * @param pool The pool used for temp allocations
209 AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key,
210 const char *valuename,
217 #endif /* def WIN32 || def DOXYGEN */
219 #endif /* AP_REGKEY_H */