Apache HTTPD
framework
httpd-2.4.62
srclib
apr
misc
unix
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
31
APR_DECLARE
(
apr_status_t
)
apr_env_get
(
char
**
value
,
32
const
char
*
envvar
,
33
apr_pool_t
*
pool
)
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
49
APR_DECLARE
(
apr_status_t
)
apr_env_set
(
const
char
*
envvar
,
50
const
char
*
value
,
51
apr_pool_t
*
pool
)
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
71
APR_DECLARE
(
apr_status_t
)
apr_env_delete
(
const
char
*
envvar
,
apr_pool_t
*
pool
)
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_env.h
APR Environment functions.
apr_strings.h
APR Strings library.
apr_want.h
APR Standard Headers Support.
APR_ENOMEM
#define APR_ENOMEM
Definition
apr_errno.h:683
APR_ENOTIMPL
#define APR_ENOTIMPL
Definition
apr_errno.h:476
APR_ENOENT
#define APR_ENOENT
Definition
apr_errno.h:662
APR_DECLARE
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
size
apr_size_t size
Definition
apr_allocator.h:115
val
apr_uint32_t val
Definition
apr_atomic.h:66
pool
const char int apr_pool_t * pool
Definition
apr_cstr.h:84
value
const char * value
Definition
apr_env.h:51
envvar
const char * envvar
Definition
apr_env.h:42
APR_SUCCESS
#define APR_SUCCESS
Definition
apr_errno.h:225
apr_status_t
int apr_status_t
Definition
apr_errno.h:44
NULL
return NULL
Definition
mod_so.c:359
apr_pool_t
Definition
apr_pools.c:562
Generated by
1.9.8