Apache HTTPD
env.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define APR_WANT_STRFUNC
18#include "apr_want.h"
19#include "apr.h"
20#include "apr_arch_misc.h"
21#include "apr_arch_utf8.h"
22#include "apr_env.h"
23#include "apr_errno.h"
24#include "apr_pools.h"
25#include "apr_strings.h"
26
27#if APR_HAS_UNICODE_FS && !defined(_WIN32_WCE)
30 const char *envvar)
31{
34
35 inchars = strlen(envvar) + 1;
39
40 return status;
41}
42#endif
43
44
46 const char *envvar,
48{
49#if defined(_WIN32_WCE)
50 return APR_ENOTIMPL;
51#else
52 char *val = NULL;
53 DWORD size;
54
55#if APR_HAS_UNICODE_FS
57 {
62
64 if (status)
65 return status;
66
67 SetLastError(0);
70 /* The environment variable doesn't exist. */
71 return APR_ENOENT;
72
73 if (size == 0) {
74 /* The environment value exists, but is zero-length. */
75 *value = apr_pstrdup(pool, "");
76 return APR_SUCCESS;
77 }
78
79 wvalue = apr_palloc(pool, size * sizeof(*wvalue));
81
82 inchars = wcslen(wvalue) + 1;
83 outchars = 3 * inchars; /* Enough for any UTF-8 representation */
86 if (status)
87 return status;
88 }
89#endif
90#if APR_HAS_ANSI_FS
92 {
93 char dummy;
94
95 SetLastError(0);
98 /* The environment variable doesn't exist. */
99 return APR_ENOENT;
100
101 if (size == 0) {
102 /* The environment value exists, but is zero-length. */
103 *value = apr_pstrdup(pool, "");
104 return APR_SUCCESS;
105 }
106
109 if (size == 0)
110 /* Mid-air collision?. Somebody must've changed the env. var. */
111 return APR_INCOMPLETE;
112 }
113#endif
114
115 *value = val;
116 return APR_SUCCESS;
117#endif
118}
119
120
122 const char *value,
124{
125#if defined(_WIN32_WCE)
126 return APR_ENOTIMPL;
127#else
128#if APR_HAS_UNICODE_FS
130 {
135
137 if (status)
138 return status;
139
140 outchars = inchars = strlen(value) + 1;
141 wvalue = apr_palloc(pool, outchars * sizeof(*wvalue));
143 if (status)
144 return status;
145
147 return apr_get_os_error();
148 }
149#endif
150#if APR_HAS_ANSI_FS
152 {
154 return apr_get_os_error();
155 }
156#endif
157
158 return APR_SUCCESS;
159#endif
160}
161
162
164{
165#if defined(_WIN32_WCE)
166 return APR_ENOTIMPL;
167#else
168#if APR_HAS_UNICODE_FS
170 {
173
175 if (status)
176 return status;
177
179 return apr_get_os_error();
180 }
181#endif
182#if APR_HAS_ANSI_FS
184 {
186 return apr_get_os_error();
187 }
188#endif
189
190 return APR_SUCCESS;
191#endif
192}
apr_uint16_t apr_wchar_t
APR Environment functions.
APR Error Codes.
APR memory allocation.
APR Strings library.
APR Standard Headers Support.
void * dummy
Definition http_vhost.h:62
#define APR_ENAMETOOLONG
Definition apr_errno.h:655
#define APR_INCOMPLETE
Definition apr_errno.h:452
#define APR_ENOTIMPL
Definition apr_errno.h:476
#define APR_ENOENT
Definition apr_errno.h:662
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
apr_uint32_t val
Definition apr_atomic.h:66
const char int apr_pool_t * pool
Definition apr_cstr.h:84
const char * value
Definition apr_env.h:51
const char * envvar
Definition apr_env.h:42
#define APR_SUCCESS
Definition apr_errno.h:225
#define apr_get_os_error()
Definition apr_errno.h:1217
int apr_status_t
Definition apr_errno.h:44
char * buffer
int int status
return NULL
Definition mod_so.c:359
#define ELSE_WIN_OS_IS_ANSI
#define IF_WIN_OS_IS_UNICODE
typedef DWORD(WINAPI *apr_winapi_fpt_GetCompressedFileSizeA)(IN LPCSTR lpFileName