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_private.h"
21#include "apr_env.h"
22#include "apr_strings.h"
23
24#if APR_HAVE_UNISTD_H
25#include <unistd.h>
26#endif
27#if APR_HAVE_STDLIB_H
28#include <stdlib.h>
29#endif
30
32 const char *envvar,
34{
35#ifdef HAVE_GETENV
36
37 char *val = getenv(envvar);
38 if (!val)
39 return APR_ENOENT;
40 *value = val;
41 return APR_SUCCESS;
42
43#else
44 return APR_ENOTIMPL;
45#endif
46}
47
48
50 const char *value,
52{
53#if defined(HAVE_SETENV)
54
55 if (0 > setenv(envvar, value, 1))
56 return APR_ENOMEM;
57 return APR_SUCCESS;
58
59#elif defined(HAVE_PUTENV)
60
61 if (0 > putenv(apr_pstrcat(pool, envvar, "=", value, NULL)))
62 return APR_ENOMEM;
63 return APR_SUCCESS;
64
65#else
66 return APR_ENOTIMPL;
67#endif
68}
69
70
72{
73#ifdef HAVE_UNSETENV
74
75 unsetenv(envvar);
76 return APR_SUCCESS;
77
78#else
79 /* hint: some platforms allow envvars to be unset via
80 * putenv("varname")... that isn't Single Unix spec,
81 * but if your platform doesn't have unsetenv() it is
82 * worth investigating and potentially adding a
83 * configure check to decide when to use that form of
84 * putenv() here
85 */
86 return APR_ENOTIMPL;
87#endif
88}
APR Environment functions.
APR Strings library.
APR Standard Headers Support.
#define APR_ENOMEM
Definition apr_errno.h:683
#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
int apr_status_t
Definition apr_errno.h:44
return NULL
Definition mod_so.c:359