OLD | NEW |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ | 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 | 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 | 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/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 #ifndef prenv_h___ | 6 #ifndef prenv_h___ |
7 #define prenv_h___ | 7 #define prenv_h___ |
8 | 8 |
9 #include "prtypes.h" | 9 #include "prtypes.h" |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 ** PRStatus. | 106 ** PRStatus. |
107 ** | 107 ** |
108 ** Restrictions: | 108 ** Restrictions: |
109 ** See the Restrictions documented in the description of | 109 ** See the Restrictions documented in the description of |
110 ** PR_GetEnv() in this header file. | 110 ** PR_GetEnv() in this header file. |
111 ** | 111 ** |
112 ** | 112 ** |
113 */ | 113 */ |
114 NSPR_API(PRStatus) PR_SetEnv(const char *string); | 114 NSPR_API(PRStatus) PR_SetEnv(const char *string); |
115 | 115 |
| 116 /* |
| 117 ** PR_DuplicateEnvironment() -- Obtain a copy of the environment. |
| 118 ** |
| 119 ** Description: |
| 120 ** PR_DuplicateEnvironment() copies the environment so that it can be |
| 121 ** modified without changing the current process's environment, and |
| 122 ** then passed to interfaces such as POSIX execve(). In particular, |
| 123 ** this avoids needing to allocate memory or take locks in the child |
| 124 ** after a fork(); neither of these is allowed by POSIX after a |
| 125 ** multithreaded process calls fork(), and PR_SetEnv does both. |
| 126 ** |
| 127 ** Inputs: |
| 128 ** none |
| 129 ** |
| 130 ** Returns: |
| 131 ** A pointer to a null-terminated array of null-terminated strings, |
| 132 ** like the traditional global variable "environ". The array and |
| 133 ** the strings are allocated with PR_Malloc(), and it is the |
| 134 ** caller's responsibility to free them. |
| 135 ** |
| 136 ** In case of memory allocation failure, or if the operating system |
| 137 ** doesn't support reading the entire environment through the global |
| 138 ** variable "environ" or similar, returns NULL instead. |
| 139 ** |
| 140 ** Restrictions: |
| 141 ** Similarly to PR_GetEnv(), this function may not interoperate as |
| 142 ** expected with the operating system's native environment accessors. |
| 143 */ |
| 144 NSPR_API(char **) PR_DuplicateEnvironment(void); |
| 145 |
116 PR_END_EXTERN_C | 146 PR_END_EXTERN_C |
117 | 147 |
118 #endif /* prenv_h___ */ | 148 #endif /* prenv_h___ */ |
OLD | NEW |