ap_regkey.c revision 76f36a1e6f8c0fb0bbd106a4e04ac62782e10a5f
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek/* ====================================================================
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * The Apache Software License, Version 1.1
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * Copyright (c) 2002 The Apache Software Foundation. All rights
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * Redistribution and use in source and binary forms, with or without
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * modification, are permitted provided that the following conditions
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * 1. Redistributions of source code must retain the above copyright
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * notice, this list of conditions and the following disclaimer.
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * 2. Redistributions in binary form must reproduce the above copyright
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * notice, this list of conditions and the following disclaimer in
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * the documentation and/or other materials provided with the
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * 3. The end-user documentation included with the redistribution,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * if any, must include the following acknowledgment:
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * "This product includes software developed by the
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * Apache Software Foundation (http://www.apache.org/)."
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * Alternately, this acknowledgment may appear in the software itself,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * if and wherever such third-party acknowledgments normally appear.
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * 4. The names "Apache" and "Apache Software Foundation" must
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * not be used to endorse or promote products derived from this
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * software without prior written permission. For written
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * permission, please contact apache@apache.org.
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * 5. Products derived from this software may not be called "Apache",
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * nor may "Apache" appear in their name, without prior written
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * permission of the Apache Software Foundation.
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * ====================================================================
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * This software consists of voluntary contributions made by many
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * individuals on behalf of the Apache Software Foundation. For more
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * information on the Apache Software Foundation, please see
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * Portions of this software are based upon public domain software
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * originally written at the National Center for Supercomputing Applications,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek * University of Illinois, Urbana-Champaign.
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-SzmekAP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i)
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek static struct ap_regkey_t ap_regkey_consts[7] =
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmekapr_status_t regkey_cleanup(void *key)
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek if (regkey->hkey && regkey->hkey != INVALID_HANDLE_VALUE) {
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek regkey->hkey = INVALID_HANDLE_VALUE;
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-SzmekAP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek apr_status_t rv = apr_conv_utf8_to_ucs2(keyname, &keylen, wkeyname, &wkeylen);
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek rc = RegCreateKeyExW(parentkey->hkey, wkeyname, 0, NULL, 0,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek rc = RegOpenKeyExW(parentkey->hkey, wkeyname, 0, access, &hkey);
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek#endif /* APR_HAS_UNICODE_FS */
5aded369782f28255bc6b494ca905d7acaea7a56Zbigniew Jędrzejewski-Szmek rc = RegCreateKeyEx(parentkey->hkey, keyname, 0, NULL, 0,
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek rc = RegOpenKeyEx(parentkey->hkey, keyname, 0, access, &hkey);
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek if ((flags & APR_EXCL) && (exists == REG_OPENED_EXISTING_KEY)) {
effbc8e4f70fc70e4a4a8a1dc77228dd187f9c22Zbigniew Jędrzejewski-Szmek *newkey = apr_palloc(pool, sizeof(**newkey));
return APR_SUCCESS;
return stat;
const char *keyname,
return rv;
else if (keylen)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
else if (subkeys)
return APR_SUCCESS;
const char *valuename,
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
if (size) {
* is a matter of storage v.s. cpu cycles.
return rv;
else if (size)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
if (size) {
return APR_SUCCESS;
const char *valuename,
const char *value,
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
return rv;
else if (size)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
return APR_SUCCESS;
const char *valuename,
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
return APR_SUCCESS;
const char *valuename,
void *value,
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
return APR_SUCCESS;
const char *valuename,
void *value;
char *buf;
char *tmp;
return rv;
return APR_EINVAL;
* is a matter of storage v.s. cpu cycles.
return rv;
else if (size)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
++size;
while (*tmp) {
++tmp;
while (*tmp) {
++tmp;
return APR_SUCCESS;
const char *valuename,
int nelts,
const char * const * elts,
const void *value;
for (i = 0; i < nelts; ++i) {
if (!nelts) {
++bufsize;
for (i = 0; i < nelts; ++i) {
return rv;
else if (size)
return APR_ENAMETOOLONG;
if (!nelts) {
--bufrem;
--bufrem;
#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) {
const char *valuename,
return rv;
else if (valuelen)
return APR_ENAMETOOLONG;
#if APR_HAS_ANSI_FS
return APR_SUCCESS;