Blame include/ap_regkey.h

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * @file ap_regkey.h
Packit 90a5c9
 * @brief APR-style Win32 Registry Manipulation
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#ifndef AP_REGKEY_H
Packit 90a5c9
#define AP_REGKEY_H
Packit 90a5c9
Packit 90a5c9
#if defined(WIN32) || defined(DOXYGEN)
Packit 90a5c9
Packit 90a5c9
#include "apr.h"
Packit 90a5c9
#include "apr_pools.h"
Packit 90a5c9
#include "ap_config.h"      /* Just for AP_DECLARE */
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
extern "C" {
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
typedef struct ap_regkey_t ap_regkey_t;
Packit 90a5c9
Packit 90a5c9
/* Used to recover AP_REGKEY_* constants
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Constants for ap_regkey_open()
Packit 90a5c9
 */
Packit 90a5c9
#define AP_REGKEY_CLASSES_ROOT         ap_regkey_const(0)
Packit 90a5c9
#define AP_REGKEY_CURRENT_CONFIG       ap_regkey_const(1)
Packit 90a5c9
#define AP_REGKEY_CURRENT_USER         ap_regkey_const(2)
Packit 90a5c9
#define AP_REGKEY_LOCAL_MACHINE        ap_regkey_const(3)
Packit 90a5c9
#define AP_REGKEY_USERS                ap_regkey_const(4)
Packit 90a5c9
#define AP_REGKEY_PERFORMANCE_DATA     ap_regkey_const(5)
Packit 90a5c9
#define AP_REGKEY_DYN_DATA             ap_regkey_const(6)
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Flags for ap_regkey_value_set()
Packit 90a5c9
 */
Packit 90a5c9
#define AP_REGKEY_EXPAND               0x0001
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Open the specified registry key.
Packit 90a5c9
 * @param newkey The opened registry key
Packit 90a5c9
 * @param parentkey The open registry key of the parent, or one of
Packit 90a5c9
 * 
Packit 90a5c9
 *           AP_REGKEY_CLASSES_ROOT
Packit 90a5c9
 *           AP_REGKEY_CURRENT_CONFIG
Packit 90a5c9
 *           AP_REGKEY_CURRENT_USER
Packit 90a5c9
 *           AP_REGKEY_LOCAL_MACHINE
Packit 90a5c9
 *           AP_REGKEY_USERS
Packit 90a5c9
 *           AP_REGKEY_PERFORMANCE_DATA
Packit 90a5c9
 *           AP_REGKEY_DYN_DATA
Packit 90a5c9
 * 
Packit 90a5c9
 * @param keyname The path of the key relative to the parent key
Packit 90a5c9
 * @param flags Or'ed value of:
Packit 90a5c9
 * 
Packit 90a5c9
 *           APR_READ             open key for reading
Packit 90a5c9
 *           APR_WRITE            open key for writing
Packit 90a5c9
 *           APR_CREATE           create the key if it doesn't exist
Packit 90a5c9
 *           APR_EXCL             return error if APR_CREATE and key exists
Packit 90a5c9
 * 
Packit 90a5c9
 * @param pool The pool in which newkey is allocated
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey,
Packit 90a5c9
                                        const ap_regkey_t *parentkey,
Packit 90a5c9
                                        const char *keyname,
Packit 90a5c9
                                        apr_int32_t flags,
Packit 90a5c9
                                        apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Close the registry key opened or created by ap_regkey_open().
Packit 90a5c9
 * @param key The registry key to close
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_close(ap_regkey_t *key);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Remove the given registry key.
Packit 90a5c9
 * @param parent The open registry key of the parent, or one of
Packit 90a5c9
 * 
Packit 90a5c9
 *           AP_REGKEY_CLASSES_ROOT
Packit 90a5c9
 *           AP_REGKEY_CURRENT_CONFIG
Packit 90a5c9
 *           AP_REGKEY_CURRENT_USER
Packit 90a5c9
 *           AP_REGKEY_LOCAL_MACHINE
Packit 90a5c9
 *           AP_REGKEY_USERS
Packit 90a5c9
 *           AP_REGKEY_PERFORMANCE_DATA
Packit 90a5c9
 *           AP_REGKEY_DYN_DATA
Packit 90a5c9
 * 
Packit 90a5c9
 * @param keyname The path of the key relative to the parent key
Packit 90a5c9
 * @param pool The pool used for temp allocations
Packit 90a5c9
 * @remark ap_regkey_remove() is not recursive, although it removes
Packit 90a5c9
 * all values within the given keyname, it will not remove a key
Packit 90a5c9
 * containing subkeys.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_remove(const ap_regkey_t *parent,
Packit 90a5c9
                                          const char *keyname,
Packit 90a5c9
                                          apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Retrieve a registry value string from an open key.
Packit 90a5c9
 * @param result The string value retrieved
Packit 90a5c9
 * @param key The registry key to retrieve the value from
Packit 90a5c9
 * @param valuename The named value to retrieve (pass "" for the default)
Packit 90a5c9
 * @param pool The pool used to store the result
Packit 90a5c9
 * @remark There is no toggle to prevent environment variable expansion
Packit 90a5c9
 * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such
Packit 90a5c9
 * expansions are always performed.
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_get(char **result,
Packit 90a5c9
                                             ap_regkey_t *key,
Packit 90a5c9
                                             const char *valuename,
Packit 90a5c9
                                             apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Store a registry value string into an open key.
Packit 90a5c9
 * @param key The registry key to store the value into
Packit 90a5c9
 * @param valuename The named value to store (pass "" for the default)
Packit 90a5c9
 * @param value The string to store for the named value
Packit 90a5c9
 * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND
Packit 90a5c9
 * values will find all %foo% variables expanded from the environment.
Packit 90a5c9
 * @param pool The pool used for temp allocations
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_set(ap_regkey_t *key,
Packit 90a5c9
                                             const char *valuename,
Packit 90a5c9
                                             const char *value,
Packit 90a5c9
                                             apr_int32_t flags,
Packit 90a5c9
                                             apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Retrieve a raw byte value from an open key.
Packit 90a5c9
 * @param result The raw bytes value retrieved
Packit 90a5c9
 * @param resultsize Pointer to a variable to store the number raw bytes retrieved
Packit 90a5c9
 * @param resulttype Pointer to a variable to store the registry type of the value retrieved
Packit 90a5c9
 * @param key The registry key to retrieve the value from
Packit 90a5c9
 * @param valuename The named value to retrieve (pass "" for the default)
Packit 90a5c9
 * @param pool The pool used to store the result
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result,
Packit 90a5c9
                                                 apr_size_t *resultsize,
Packit 90a5c9
                                                 apr_int32_t *resulttype,
Packit 90a5c9
                                                 ap_regkey_t *key,
Packit 90a5c9
                                                 const char *valuename,
Packit 90a5c9
                                                 apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Store a raw bytes value into an open key.
Packit 90a5c9
 * @param key The registry key to store the value into
Packit 90a5c9
 * @param valuename The named value to store (pass "" for the default)
Packit 90a5c9
 * @param value The bytes to store for the named value
Packit 90a5c9
 * @param valuesize The number of bytes for value
Packit 90a5c9
 * @param valuetype The
Packit 90a5c9
 * values will find all %foo% variables expanded from the environment.
Packit 90a5c9
 * @param pool The pool used for temp allocations
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key,
Packit 90a5c9
                                                 const char *valuename,
Packit 90a5c9
                                                 const void *value,
Packit 90a5c9
                                                 apr_size_t  valuesize,
Packit 90a5c9
                                                 apr_int32_t valuetype,
Packit 90a5c9
                                                 apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Retrieve a registry value string from an open key.
Packit 90a5c9
 * @param result The string elements retrieved from a REG_MULTI_SZ string array
Packit 90a5c9
 * @param key The registry key to retrieve the value from
Packit 90a5c9
 * @param valuename The named value to retrieve (pass "" for the default)
Packit 90a5c9
 * @param pool The pool used to store the result
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result,
Packit 90a5c9
                                                   ap_regkey_t *key,
Packit 90a5c9
                                                   const char *valuename,
Packit 90a5c9
                                                   apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Store a registry value string array into an open key.
Packit 90a5c9
 * @param key The registry key to store the value into
Packit 90a5c9
 * @param valuename The named value to store (pass "" for the default)
Packit 90a5c9
 * @param nelts The string elements to store in a REG_MULTI_SZ string array
Packit 90a5c9
 * @param elts The number of elements in the elts string array
Packit 90a5c9
 * @param pool The pool used for temp allocations
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key,
Packit 90a5c9
                                                   const char *valuename,
Packit 90a5c9
                                                   int nelts,
Packit 90a5c9
                                                   const char * const * elts,
Packit 90a5c9
                                                   apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
/**
Packit 90a5c9
 * Win32 Only: Remove a registry value from an open key.
Packit 90a5c9
 * @param key The registry key to remove the value from
Packit 90a5c9
 * @param valuename The named value to remove (pass "" for the default)
Packit 90a5c9
 * @param pool The pool used for temp allocations
Packit 90a5c9
 */
Packit 90a5c9
AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key,
Packit 90a5c9
                                                const char *valuename,
Packit 90a5c9
                                                apr_pool_t *pool);
Packit 90a5c9
Packit 90a5c9
#ifdef __cplusplus
Packit 90a5c9
}
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#endif /* def WIN32 || def DOXYGEN */
Packit 90a5c9
Packit 90a5c9
#endif /* AP_REGKEY_H */