comparison nspr/pr/include/prenv.h @ 0:1e5118fa0cb1

This is NSS with a Cmake Buildsyste To compile a static NSS library for Windows we've used the Chromium-NSS fork and added a Cmake buildsystem to compile it statically for Windows. See README.chromium for chromium changes and README.trustbridge for our modifications.
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 28 Jul 2014 10:47:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e5118fa0cb1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 #ifndef prenv_h___
7 #define prenv_h___
8
9 #include "prtypes.h"
10
11 /*******************************************************************************/
12 /*******************************************************************************/
13 /****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/
14 /*******************************************************************************/
15 /*******************************************************************************/
16
17 PR_BEGIN_EXTERN_C
18
19 /*
20 ** PR_GetEnv() -- Retrieve value of environment variable
21 **
22 ** Description:
23 ** PR_GetEnv() is modeled on Unix getenv().
24 **
25 **
26 ** Inputs:
27 ** var -- The name of the environment variable
28 **
29 ** Returns:
30 ** The value of the environment variable 'var' or NULL if
31 ** the variable is undefined.
32 **
33 ** Restrictions:
34 ** You'd think that a POSIX getenv(), putenv() would be
35 ** consistently implemented everywhere. Surprise! It is not. On
36 ** some platforms, a putenv() where the argument is of
37 ** the form "name" causes the named environment variable to
38 ** be un-set; that is: a subsequent getenv() returns NULL. On
39 ** other platforms, the putenv() fails, on others, it is a
40 ** no-op. Similarly, a putenv() where the argument is of the
41 ** form "name=" causes the named environment variable to be
42 ** un-set; a subsequent call to getenv() returns NULL. On
43 ** other platforms, a subsequent call to getenv() returns a
44 ** pointer to a null-string (a byte of zero).
45 **
46 ** PR_GetEnv(), PR_SetEnv() provide a consistent behavior
47 ** across all supported platforms. There are, however, some
48 ** restrictions and some practices you must use to achieve
49 ** consistent results everywhere.
50 **
51 ** When manipulating the environment there is no way to un-set
52 ** an environment variable across all platforms. We suggest
53 ** you interpret the return of a pointer to null-string to
54 ** mean the same as a return of NULL from PR_GetEnv().
55 **
56 ** A call to PR_SetEnv() where the parameter is of the form
57 ** "name" will return PR_FAILURE; the environment remains
58 ** unchanged. A call to PR_SetEnv() where the parameter is
59 ** of the form "name=" may un-set the envrionment variable on
60 ** some platforms; on others it may set the value of the
61 ** environment variable to the null-string.
62 **
63 ** For example, to test for NULL return or return of the
64 ** null-string from PR_GetEnv(), use the following code
65 ** fragment:
66 **
67 ** char *val = PR_GetEnv("foo");
68 ** if ((NULL == val) || ('\0' == *val)) {
69 ** ... interpret this as un-set ...
70 ** }
71 **
72 ** The caller must ensure that the string passed
73 ** to PR_SetEnv() is persistent. That is: The string should
74 ** not be on the stack, where it can be overwritten
75 ** on return from the function calling PR_SetEnv().
76 ** Similarly, the string passed to PR_SetEnv() must not be
77 ** overwritten by other actions of the process. ... Some
78 ** platforms use the string by reference rather than copying
79 ** it into the environment space. ... You have been warned!
80 **
81 ** Use of platform-native functions that manipulate the
82 ** environment (getenv(), putenv(),
83 ** SetEnvironmentVariable(), etc.) must not be used with
84 ** NSPR's similar functions. The platform-native functions
85 ** may not be thread safe and/or may operate on different
86 ** conceptual environment space than that operated upon by
87 ** NSPR's functions or other environment manipulating
88 ** functions on the same platform. (!)
89 **
90 */
91 NSPR_API(char*) PR_GetEnv(const char *var);
92
93 /*
94 ** PR_SetEnv() -- set, unset or change an environment variable
95 **
96 ** Description:
97 ** PR_SetEnv() is modeled on the Unix putenv() function.
98 **
99 ** Inputs:
100 ** string -- pointer to a caller supplied
101 ** constant, persistent string of the form name=value. Where
102 ** name is the name of the environment variable to be set or
103 ** changed; value is the value assigned to the variable.
104 **
105 ** Returns:
106 ** PRStatus.
107 **
108 ** Restrictions:
109 ** See the Restrictions documented in the description of
110 ** PR_GetEnv() in this header file.
111 **
112 **
113 */
114 NSPR_API(PRStatus) PR_SetEnv(const char *string);
115
116 PR_END_EXTERN_C
117
118 #endif /* prenv_h___ */
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)