VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/nsprpub/pr/include/prenv.h@ 11551

Last change on this file since 11551 was 11551, checked in by vboxsync, 16 years ago

API/xpcom: prefix any C symbols in VBoxXPCOM.so, to avoid namespace pollution. Enabled only on Linux at the moment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Netscape Portable Runtime (NSPR).
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
38#ifndef prenv_h___
39#define prenv_h___
40
41#include "prtypes.h"
42
43#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
44#define PR_GetEnv VBoxNsprPR_GetEnv
45#define PR_SetEnv VBoxNsprPR_SetEnv
46#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
47
48/*******************************************************************************/
49/*******************************************************************************/
50/****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/
51/*******************************************************************************/
52/*******************************************************************************/
53
54PR_BEGIN_EXTERN_C
55
56/*
57** PR_GetEnv() -- Retrieve value of environment variable
58**
59** Description:
60** PR_GetEnv() is modeled on Unix getenv().
61**
62**
63** Inputs:
64** var -- The name of the environment variable
65**
66** Returns:
67** The value of the environment variable 'var' or NULL if
68** the variable is undefined.
69**
70** Restrictions:
71** You'd think that a POSIX getenv(), putenv() would be
72** consistently implemented everywhere. Surprise! It is not. On
73** some platforms, a putenv() where the argument is of
74** the form "name" causes the named environment variable to
75** be un-set; that is: a subsequent getenv() returns NULL. On
76** other platforms, the putenv() fails, on others, it is a
77** no-op. Similarly, a putenv() where the argument is of the
78** form "name=" causes the named environment variable to be
79** un-set; a subsequent call to getenv() returns NULL. On
80** other platforms, a subsequent call to getenv() returns a
81** pointer to a null-string (a byte of zero).
82**
83** PR_GetEnv(), PR_SetEnv() provide a consistent behavior
84** across all supported platforms. There are, however, some
85** restrictions and some practices you must use to achieve
86** consistent results everywhere.
87**
88** When manipulating the environment there is no way to un-set
89** an environment variable across all platforms. We suggest
90** you interpret the return of a pointer to null-string to
91** mean the same as a return of NULL from PR_GetEnv().
92**
93** A call to PR_SetEnv() where the parameter is of the form
94** "name" will return PR_FAILURE; the environment remains
95** unchanged. A call to PR_SetEnv() where the parameter is
96** of the form "name=" may un-set the envrionment variable on
97** some platforms; on others it may set the value of the
98** environment variable to the null-string.
99**
100** For example, to test for NULL return or return of the
101** null-string from PR_GetEnv(), use the following code
102** fragment:
103**
104** char *val = PR_GetEnv("foo");
105** if ((NULL == val) || ('\0' == *val)) {
106** ... interpret this as un-set ...
107** }
108**
109** The caller must ensure that the string passed
110** to PR_SetEnv() is persistent. That is: The string should
111** not be on the stack, where it can be overwritten
112** on return from the function calling PR_SetEnv().
113** Similarly, the string passed to PR_SetEnv() must not be
114** overwritten by other actions of the process. ... Some
115** platforms use the string by reference rather than copying
116** it into the environment space. ... You have been warned!
117**
118** Use of platform-native functions that manipulate the
119** environment (getenv(), putenv(),
120** SetEnvironmentVariable(), etc.) must not be used with
121** NSPR's similar functions. The platform-native functions
122** may not be thread safe and/or may operate on different
123** conceptual environment space than that operated upon by
124** NSPR's functions or other environment manipulating
125** functions on the same platform. (!)
126**
127*/
128NSPR_API(char*) PR_GetEnv(const char *var);
129
130/*
131** PR_SetEnv() -- set, unset or change an environment variable
132**
133** Description:
134** PR_SetEnv() is modeled on the Unix putenv() function.
135**
136** Inputs:
137** string -- pointer to a caller supplied
138** constant, persistent string of the form name=value. Where
139** name is the name of the environment variable to be set or
140** changed; value is the value assigned to the variable.
141**
142** Returns:
143** PRStatus.
144**
145** Restrictions:
146** See the Restrictions documented in the description of
147** PR_GetEnv() in this header file.
148**
149**
150*/
151NSPR_API(PRStatus) PR_SetEnv(const char *string);
152
153/*
154** DEPRECATED. Use PR_SetEnv() instead.
155*/
156#ifdef XP_MAC
157NSPR_API(PRIntn) PR_PutEnv(const char *string);
158#endif
159
160PR_END_EXTERN_C
161
162#endif /* prenv_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette