ap_regkey.c revision 9e12bb8a48225fc58bc56166b1104158e0d17ed4
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
#ifdef WIN32
#include "apr.h"
#include "ap_regkey.h"
struct ap_regkey_t {
};
{
{
{NULL, HKEY_USERS},
};
return ap_regkey_consts + i;
}
{
}
return APR_SUCCESS;
}
const ap_regkey_t *parentkey,
const char *keyname,
{
{
if (rv != APR_SUCCESS)
return rv;
else if (keylen)
return APR_ENAMETOOLONG;
if (flags & APR_CREATE)
else
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
if (flags & APR_CREATE)
else
}
#endif
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
return APR_EEXIST;
}
return APR_SUCCESS;
}
{
}
return stat;
}
const char *keyname,
{
{
if (rv != APR_SUCCESS)
return rv;
else if (keylen)
return APR_ENAMETOOLONG;
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
/* We need to determine if subkeys exist on Win9x, to provide
* consistent behavior with NT, which returns access denied
* if subkeys exist when attempting to delete a key.
*/
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
else if (subkeys)
return APR_FROM_OS_ERROR(ERROR_ACCESS_DENIED);
}
#endif
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
return APR_SUCCESS;
}
const char *valuename,
{
/* Retrieve a registry string value, and explode any envvars
* that the system has configured (e.g. %SystemRoot%/someapp.exe)
*/
{
if (rv != APR_SUCCESS)
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
/* Read to NULL buffer to determine value size */
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
return APR_FROM_OS_ERROR(ERROR_INVALID_PARAMETER);
}
/* Read value based on size query above */
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
if (type == REG_EXPAND_SZ) {
if (size) {
/* The size returned by ExpandEnvironmentStringsW is wchars */
}
}
else {
/* count wchars from RegQueryValueExW, rather than bytes */
size /= 2;
}
/* ###: deliberately overallocate all but the trailing null.
* We could precalculate the exact buffer here instead, the question
* is a matter of storage v.s. cpu cycles.
*/
if (rv != APR_SUCCESS)
return rv;
else if (size)
return APR_ENAMETOOLONG;
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
/* Read to NULL buffer to determine value size */
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
return APR_FROM_OS_ERROR(ERROR_INVALID_PARAMETER);
}
/* Read value based on size query above */
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
if (type == REG_EXPAND_SZ) {
/* Advise ExpandEnvironmentStrings that we have a zero char
* buffer to force computation of the required length.
*/
char zbuf[1];
if (size) {
}
}
}
#endif
return APR_SUCCESS;
}
const char *valuename,
const char *value,
{
/* Retrieve a registry string value, and explode any envvars
* that the system has configured (e.g. %SystemRoot%/someapp.exe)
*/
{
if (rv != APR_SUCCESS)
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
if (rv != APR_SUCCESS)
return rv;
else if (size)
return APR_ENAMETOOLONG;
/* The size is the number of wchars consumed by apr_conv_utf8_to_ucs2
* converted to bytes; the trailing L'\0' continues to be counted.
*/
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
}
#endif
return APR_SUCCESS;
}
const char *valuename,
{
/* Retrieve a registry string value, and explode any envvars
* that the system has configured (e.g. %SystemRoot%/someapp.exe)
*/
{
if (rv != APR_SUCCESS)
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
/* Read to NULL buffer to determine value size */
NULL, resultsize);
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
/* Read value based on size query above */
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
/* Read to NULL buffer to determine value size */
NULL, resultsize);
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
/* Read value based on size query above */
if (rc != ERROR_SUCCESS)
return APR_FROM_OS_ERROR(rc);
}
#endif
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
return APR_SUCCESS;
}
const char *valuename,
const void *value,
{
{
if (rv != APR_SUCCESS)
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
}
#endif
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
return APR_SUCCESS;
}
const char *valuename,
{
/* Retrieve a registry string value, and explode any envvars
* that the system has configured (e.g. %SystemRoot%/someapp.exe)
*/
void *value;
char *buf;
char *tmp;
if (rv != APR_SUCCESS) {
return rv;
}
else if (type != REG_MULTI_SZ) {
return APR_EINVAL;
}
{
/* ###: deliberately overallocate plus two extra nulls.
* We could precalculate the exact buffer here instead, the question
* is a matter of storage v.s. cpu cycles.
*/
size /= 2;
if (rv != APR_SUCCESS)
return rv;
else if (size)
return APR_ENAMETOOLONG;
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
/* Small possiblity the array is either unterminated
* or single NULL terminated. Avert.
*/
}
}
#endif
size = 0; /* Element Count */
++size;
while (*tmp) {
++tmp;
}
}
while (*tmp) {
++tmp;
}
}
return APR_SUCCESS;
}
const char *valuename,
int nelts,
const char * const * elts,
{
/* Retrieve a registry string value, and explode any envvars
* that the system has configured (e.g. %SystemRoot%/someapp.exe)
*/
int i;
const void *value;
{
for (i = 0; i < nelts; ++i) {
}
if (!nelts) {
++bufsize;
}
for (i = 0; i < nelts; ++i) {
if (rv != APR_SUCCESS)
return rv;
else if (size)
return APR_ENAMETOOLONG;
}
if (!nelts) {
--bufrem;
(*tmp++) = L'\0';
}
--bufrem;
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
char *buf;
char *tmp;
for (i = 0; i < nelts; ++i) {
}
if (!nelts) {
++bufsize;
}
for (i = 0; i < nelts; ++i) {
}
if (!nelts) {
(*tmp++) = '\0';
}
}
#endif
}
const char *valuename,
{
{
if (rv != APR_SUCCESS)
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
}
#endif /* APR_HAS_UNICODE_FS */
#if APR_HAS_ANSI_FS
{
}
#endif
if (rc != ERROR_SUCCESS) {
return APR_FROM_OS_ERROR(rc);
}
return APR_SUCCESS;
}
#endif /* defined WIN32 */