Main Page | Modules | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

ap_regkey.h

Go to the documentation of this file.
00001 /* Copyright 2002-2005 The Apache Software Foundation or its licensors, as
00002  * applicable.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * 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 AP_REGKEY_H
00018 #define AP_REGKEY_H
00019 
00020 #if defined(WIN32) || defined(DOXYGEN)
00021 
00022 #include "apr.h"
00023 #include "apr_pools.h"
00024 #include "ap_config.h"      /* Just for AP_DECLARE */
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029 
00030 typedef struct ap_regkey_t ap_regkey_t;
00031 
00032 /* Used to recover AP_REGKEY_* constants 
00033  */
00034 AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i);
00035 
00036 /**
00037  * @file ap_regkey.h
00038  * @brief APR-style Win32 Registry Manipulation
00039  */
00040 
00041 /**
00042  * Win32 Only: Constants for ap_regkey_open()
00043  */
00044 #define AP_REGKEY_CLASSES_ROOT         ap_regkey_const(0)
00045 #define AP_REGKEY_CURRENT_CONFIG       ap_regkey_const(1)
00046 #define AP_REGKEY_CURRENT_USER         ap_regkey_const(2)
00047 #define AP_REGKEY_LOCAL_MACHINE        ap_regkey_const(3)
00048 #define AP_REGKEY_USERS                ap_regkey_const(4)
00049 #define AP_REGKEY_PERFORMANCE_DATA     ap_regkey_const(5)
00050 #define AP_REGKEY_DYN_DATA             ap_regkey_const(6)
00051 
00052 /**
00053  * Win32 Only: Flags for ap_regkey_value_set()
00054  */
00055 #define AP_REGKEY_EXPAND               0x0001
00056 
00057 /**
00058  * Win32 Only: Open the specified registry key.
00059  * @param newkey The opened registry key
00060  * @param parentkey The open registry key of the parent, or one of
00061  * <PRE>
00062  *           AP_REGKEY_CLASSES_ROOT
00063  *           AP_REGKEY_CURRENT_CONFIG
00064  *           AP_REGKEY_CURRENT_USER
00065  *           AP_REGKEY_LOCAL_MACHINE
00066  *           AP_REGKEY_USERS
00067  *           AP_REGKEY_PERFORMANCE_DATA 
00068  *           AP_REGKEY_DYN_DATA 
00069  * </PRE>
00070  * @param keyname The path of the key relative to the parent key
00071  * @param flags Or'ed value of:
00072  * <PRE>
00073  *           APR_READ             open key for reading
00074  *           APR_WRITE            open key for writing
00075  *           APR_CREATE           create the key if it doesn't exist
00076  *           APR_EXCL             return error if APR_CREATE and key exists
00077  * </PRE>
00078  * @param pool The pool in which newkey is allocated
00079  */
00080 AP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey, 
00081                                         const ap_regkey_t *parentkey,
00082                                         const char *keyname,
00083                                         apr_int32_t flags, 
00084                                         apr_pool_t *pool);
00085 
00086 /**
00087  * Win32 Only: Close the registry key opened or created by ap_regkey_open().
00088  * @param key The registry key to close
00089  */
00090 AP_DECLARE(apr_status_t) ap_regkey_close(ap_regkey_t *key);
00091 
00092 /**
00093  * Win32 Only: Remove the given registry key.
00094  * @param parentkey The open registry key of the parent, or one of
00095  * <PRE>
00096  *           AP_REGKEY_CLASSES_ROOT
00097  *           AP_REGKEY_CURRENT_CONFIG
00098  *           AP_REGKEY_CURRENT_USER
00099  *           AP_REGKEY_LOCAL_MACHINE
00100  *           AP_REGKEY_USERS
00101  *           AP_REGKEY_PERFORMANCE_DATA 
00102  *           AP_REGKEY_DYN_DATA 
00103  * </PRE>
00104  * @param keyname The path of the key relative to the parent key
00105  * @param pool The pool used for temp allocations
00106  * @remark ap_regkey_remove() is not recursive, although it removes
00107  * all values within the given keyname, it will not remove a key 
00108  * containing subkeys.
00109  */
00110 AP_DECLARE(apr_status_t) ap_regkey_remove(const ap_regkey_t *parent, 
00111                                           const char *keyname,
00112                                           apr_pool_t *pool);
00113 
00114 /**
00115  * Win32 Only: Retrieve a registry value string from an open key.
00116  * @param result The string value retrieved 
00117  * @param key The registry key to retrieve the value from
00118  * @param valuename The named value to retrieve (pass "" for the default)
00119  * @param pool The pool used to store the result
00120  * @remark There is no toggle to prevent environment variable expansion
00121  * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such
00122  * expansions are always performed.
00123  */
00124 AP_DECLARE(apr_status_t) ap_regkey_value_get(char **result, 
00125                                              ap_regkey_t *key, 
00126                                              const char *valuename, 
00127                                              apr_pool_t *pool);
00128 
00129 /**
00130  * Win32 Only: Store a registry value string into an open key.
00131  * @param key The registry key to store the value into
00132  * @param valuename The named value to store (pass "" for the default)
00133  * @param value The string to store for the named value
00134  * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND
00135  * values will find all %foo% variables expanded from the environment.
00136  * @param pool The pool used for temp allocations
00137  */
00138 AP_DECLARE(apr_status_t) ap_regkey_value_set(ap_regkey_t *key, 
00139                                              const char *valuename, 
00140                                              const char *value, 
00141                                              apr_int32_t flags,
00142                                              apr_pool_t *pool);
00143 
00144 /**
00145  * Win32 Only: Retrieve a raw byte value from an open key.
00146  * @param result The raw bytes value retrieved 
00147  * @param resultsize Pointer to a variable to store the number raw bytes retrieved 
00148  * @param key The registry key to retrieve the value from
00149  * @param valuename The named value to retrieve (pass "" for the default)
00150  * @param pool The pool used to store the result
00151  */
00152 AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result, 
00153                                                  apr_size_t *resultsize,
00154                                                  apr_int32_t *resulttype,
00155                                                  ap_regkey_t *key, 
00156                                                  const char *valuename, 
00157                                                  apr_pool_t *pool);
00158 
00159 /**
00160  * Win32 Only: Store a raw bytes value into an open key.
00161  * @param key The registry key to store the value into
00162  * @param valuename The named value to store (pass "" for the default)
00163  * @param value The bytes to store for the named value
00164  * @param valuesize The number of bytes for value
00165  * @param valuetype The 
00166  * values will find all %foo% variables expanded from the environment.
00167  * @param pool The pool used for temp allocations
00168  */
00169 AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key, 
00170                                                  const char *valuename, 
00171                                                  const void *value, 
00172                                                  apr_size_t  valuesize,
00173                                                  apr_int32_t valuetype,
00174                                                  apr_pool_t *pool);
00175 
00176 /**
00177  * Win32 Only: Retrieve a registry value string from an open key.
00178  * @param result The string elements retrieved from a REG_MULTI_SZ string array
00179  * @param key The registry key to retrieve the value from
00180  * @param valuename The named value to retrieve (pass "" for the default)
00181  * @param pool The pool used to store the result
00182  */
00183 AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result, 
00184                                                    ap_regkey_t *key,
00185                                                    const char *valuename, 
00186                                                    apr_pool_t *pool);
00187 
00188 /**
00189  * Win32 Only: Store a registry value string array into an open key.
00190  * @param key The registry key to store the value into
00191  * @param valuename The named value to store (pass "" for the default)
00192  * @param nelts The string elements to store in a REG_MULTI_SZ string array
00193  * @param elts The number of elements in the elts string array
00194  * @param pool The pool used for temp allocations
00195  */
00196 AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key, 
00197                                                    const char *valuename, 
00198                                                    int nelts, 
00199                                                    const char * const * elts,
00200                                                    apr_pool_t *pool);
00201 
00202 /**
00203  * Win32 Only: Remove a registry value from an open key.
00204  * @param key The registry key to remove the value from
00205  * @param valuename The named value to remove (pass "" for the default)
00206  * @param pool The pool used for temp allocations
00207  */
00208 AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key, 
00209                                                 const char *valuename,
00210                                                 apr_pool_t *pool);
00211 
00212 #ifdef __cplusplus
00213 }
00214 #endif
00215 
00216 #endif /* def WIN32 || def DOXYGEN */
00217 
00218 #endif /* AP_REGKEY_H */