]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_asn1/lib/prenv.h
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 * The contents of this file are subject to the Mozilla Public
4 * License Version 1.1 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of
6 * the License at http://www.mozilla.org/MPL/
8 * Software distributed under the License is distributed on an "AS
9 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 * implied. See the License for the specific language governing
11 * rights and limitations under the License.
13 * The Original Code is the Netscape Portable Runtime (NSPR).
15 * The Initial Developer of the Original Code is Netscape
16 * Communications Corporation. Portions created by Netscape are
17 * Copyright (C) 1998-2000 Netscape Communications Corporation. All
22 * Alternatively, the contents of this file may be used under the
23 * terms of the GNU General Public License Version 2 or later (the
24 * "GPL"), in which case the provisions of the GPL are applicable
25 * instead of those above. If you wish to allow use of your
26 * version of this file only under the terms of the GPL and not to
27 * allow others to use your version of this file under the MPL,
28 * indicate your decision by deleting the provisions above and
29 * replace them with the notice and other provisions requiored by
30 * the GPL. If you do not delete the provisions above, a recipient
31 * may use your version of this file under either the MPL or the
38 #include <security_asn1/prtypes.h>
40 /*******************************************************************************/
41 /*******************************************************************************/
42 /****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/
43 /*******************************************************************************/
44 /*******************************************************************************/
49 ** PR_GetEnv() -- Retrieve value of environment variable
52 ** PR_GetEnv() is modeled on Unix getenv().
56 ** var -- The name of the environment variable
59 ** The value of the environment variable 'var' or NULL if
60 ** the variable is undefined.
63 ** You'd think that a POSIX getenv(), putenv() would be
64 ** consistently implemented everywhere. Surprise! It is not. On
65 ** some platforms, a putenv() where the argument is of
66 ** the form "name" causes the named environment variable to
67 ** be un-set; that is: a subsequent getenv() returns NULL. On
68 ** other platforms, the putenv() fails, on others, it is a
69 ** no-op. Similarly, a putenv() where the argument is of the
70 ** form "name=" causes the named environment variable to be
71 ** un-set; a subsequent call to getenv() returns NULL. On
72 ** other platforms, a subsequent call to getenv() returns a
73 ** pointer to a null-string (a byte of zero).
75 ** PR_GetEnv(), PR_SetEnv() provide a consistent behavior
76 ** across all supported platforms. There are, however, some
77 ** restrictions and some practices you must use to achieve
78 ** consistent results everywhere.
80 ** When manipulating the environment there is no way to un-set
81 ** an environment variable across all platforms. We suggest
82 ** you interpret the return of a pointer to null-string to
83 ** mean the same as a return of NULL from PR_GetEnv().
85 ** A call to PR_SetEnv() where the parameter is of the form
86 ** "name" will return PR_FAILURE; the environment remains
87 ** unchanged. A call to PR_SetEnv() where the parameter is
88 ** of the form "name=" may un-set the envrionment variable on
89 ** some platforms; on others it may set the value of the
90 ** environment variable to the null-string.
92 ** For example, to test for NULL return or return of the
93 ** null-string from PR_GetEnv(), use the following code
96 ** char *val = PR_GetEnv("foo");
97 ** if ((NULL == val) || ('\0' == *val)) {
98 ** ... interpret this as un-set ...
101 ** The caller must ensure that the string passed
102 ** to PR_SetEnv() is persistent. That is: The string should
103 ** not be on the stack, where it can be overwritten
104 ** on return from the function calling PR_SetEnv().
105 ** Similarly, the string passed to PR_SetEnv() must not be
106 ** overwritten by other actions of the process. ... Some
107 ** platforms use the string by reference rather than copying
108 ** it into the environment space. ... You have been warned!
110 ** Use of platform-native functions that manipulate the
111 ** environment (getenv(), putenv(),
112 ** SetEnvironmentVariable(), etc.) must not be used with
113 ** NSPR's similar functions. The platform-native functions
114 ** may not be thread safe and/or may operate on different
115 ** conceptual environment space than that operated upon by
116 ** NSPR's functions or other environment manipulating
117 ** functions on the same platform. (!)
120 NSPR_API(char*) PR_GetEnv(const char *var
);
123 ** PR_SetEnv() -- set, unset or change an environment variable
126 ** PR_SetEnv() is modeled on the Unix putenv() function.
129 ** string -- pointer to a caller supplied
130 ** constant, persistent string of the form name=value. Where
131 ** name is the name of the environment variable to be set or
132 ** changed; value is the value assigned to the variable.
138 ** See the Restrictions documented in the description of
139 ** PR_GetEnv() in this header file.
143 NSPR_API(PRStatus
) PR_SetEnv(const char *string
);
146 ** DEPRECATED. Use PR_SetEnv() instead.
149 NSPR_API(PRIntn
) PR_PutEnv(const char *string
);
154 #endif /* prenv_h___ */