PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/gecko_api/include/prenv.h

http://firefox-mac-pdf.googlecode.com/
C++ Header | 157 lines | 11 code | 9 blank | 137 comment | 0 complexity | 5b11ac6e21f4de8a527b41d6c49b03f2 MD5 | raw file
  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/*******************************************************************************/
 44/*******************************************************************************/
 45/****************** THESE FUNCTIONS MAY NOT BE THREAD SAFE *********************/
 46/*******************************************************************************/
 47/*******************************************************************************/
 48
 49PR_BEGIN_EXTERN_C
 50
 51/*
 52** PR_GetEnv() -- Retrieve value of environment variable
 53** 
 54** Description:
 55** PR_GetEnv() is modeled on Unix getenv().
 56** 
 57** 
 58** Inputs: 
 59**   var -- The name of the environment variable
 60** 
 61** Returns:
 62**   The value of the environment variable 'var' or NULL if
 63** the variable is undefined.
 64** 
 65** Restrictions:
 66**   You'd think that a POSIX getenv(), putenv() would be
 67**   consistently implemented everywhere. Surprise! It is not. On
 68**   some platforms, a putenv() where the argument is of
 69**   the form "name"  causes the named environment variable to
 70**   be un-set; that is: a subsequent getenv() returns NULL. On
 71**   other platforms, the putenv() fails, on others, it is a
 72**   no-op. Similarly, a putenv() where the argument is of the
 73**   form "name=" causes the named environment variable to be
 74**   un-set; a subsequent call to getenv() returns NULL. On
 75**   other platforms, a subsequent call to getenv() returns a
 76**   pointer to a null-string (a byte of zero).
 77** 
 78**   PR_GetEnv(), PR_SetEnv() provide a consistent behavior 
 79**   across all supported platforms. There are, however, some
 80**   restrictions and some practices you must use to achieve
 81**   consistent results everywhere.
 82** 
 83**   When manipulating the environment there is no way to un-set
 84**   an environment variable across all platforms. We suggest
 85**   you interpret the return of a pointer to null-string to
 86**   mean the same as a return of NULL from PR_GetEnv().
 87** 
 88**   A call to PR_SetEnv() where the parameter is of the form
 89**   "name" will return PR_FAILURE; the environment remains
 90**   unchanged. A call to PR_SetEnv() where the parameter is
 91**   of the form "name=" may un-set the envrionment variable on
 92**   some platforms; on others it may set the value of the
 93**   environment variable to the null-string.
 94** 
 95**   For example, to test for NULL return or return of the
 96**   null-string from PR_GetEnv(), use the following code
 97**   fragment:
 98** 
 99**      char *val = PR_GetEnv("foo");
100**      if ((NULL == val) || ('\0' == *val)) { 
101**          ... interpret this as un-set ... 
102**      }
103** 
104**   The caller must ensure that the string passed
105**   to PR_SetEnv() is persistent. That is: The string should
106**   not be on the stack, where it can be overwritten
107**   on return from the function calling PR_SetEnv().
108**   Similarly, the string passed to PR_SetEnv() must not be
109**   overwritten by other actions of the process. ... Some
110**   platforms use the string by reference rather than copying
111**   it into the environment space. ... You have been warned!
112** 
113**   Use of platform-native functions that manipulate the
114**   environment (getenv(), putenv(), 
115**   SetEnvironmentVariable(), etc.) must not be used with
116**   NSPR's similar functions. The platform-native functions
117**   may not be thread safe and/or may operate on different
118**   conceptual environment space than that operated upon by
119**   NSPR's functions or other environment manipulating
120**   functions on the same platform. (!)
121** 
122*/
123NSPR_API(char*) PR_GetEnv(const char *var);
124
125/*
126** PR_SetEnv() -- set, unset or change an environment variable
127** 
128** Description:
129** PR_SetEnv() is modeled on the Unix putenv() function.
130** 
131** Inputs: 
132**   string -- pointer to a caller supplied
133**   constant, persistent string of the form name=value. Where
134**   name is the name of the environment variable to be set or
135**   changed; value is the value assigned to the variable.
136**
137** Returns: 
138**   PRStatus.
139** 
140** Restrictions: 
141**   See the Restrictions documented in the description of
142**   PR_GetEnv() in this header file.
143** 
144** 
145*/
146NSPR_API(PRStatus) PR_SetEnv(const char *string);
147
148/*
149** DEPRECATED.  Use PR_SetEnv() instead.
150*/
151#ifdef XP_MAC
152NSPR_API(PRIntn) PR_PutEnv(const char *string);
153#endif
154
155PR_END_EXTERN_C
156
157#endif /* prenv_h___ */