ap_regkey.c revision 489f0cabccbf16a76fe784f08d1c8047cbf99cc1
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifdef WIN32
#include "apr.h"
#include "arch/win32/apr_arch_file_io.h"
#include "arch/win32/apr_arch_misc.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)
*/
apr_size_t size = 0;
{
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 */
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 */
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;
apr_size_t size = 0;
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 */