VirtualBox

source: vbox/trunk/include/iprt/env.h@ 7176

Last change on this file since 7176 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/** @file
2 * innotek Portable Runtime - Process Environment Strings.
3 */
4
5/*
6 * Copyright (C) 2006-2007 innotek GmbH
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___iprt_env_h
27#define ___iprt_env_h
28
29#include <iprt/cdefs.h>
30#include <iprt/types.h>
31
32__BEGIN_DECLS
33
34/** @defgroup grp_rt_env RTProc - Process Environment Strings
35 * @ingroup grp_rt
36 * @{
37 */
38
39#ifdef IN_RING3
40
41/** Special handle that indicates the default process environment. */
42#define RTENV_DEFAULT ((RTENV)~(uintptr_t)0)
43
44/**
45 * Creates an empty environment block.
46 *
47 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
48 *
49 * @param pEnv Where to store the handle of the new environment block.
50 */
51RTDECL(int) RTEnvCreate(PRTENV pEnv);
52
53/**
54 * Creates an environment block and fill it with variables from the given
55 * environment array.
56 *
57 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
58 *
59 * @param pEnv Where to store the handle of the new environment block.
60 * @param EnvToClone The environment to clone.
61 */
62RTDECL(int) RTEnvClone(PRTENV pEnv, RTENV EnvToClone);
63
64/**
65 * Destroys an environment block.
66 *
67 * @returns IPRT status code.
68 *
69 * @param Env Environment block handle.
70 * Both RTENV_DEFAULT and NIL_RTENV are silently ignored.
71 */
72RTDECL(int) RTEnvDestroy(RTENV Env);
73
74/**
75 * Get the execve/spawnve/main envp.
76 *
77 * All returned strings are in the current process' codepage.
78 * This array is only valid until the next RTEnv call.
79 *
80 * @returns Pointer to the raw array of environment variables.
81 * @returns NULL if Env is NULL or invalid.
82 *
83 * @param Env Environment block handle.
84 */
85RTDECL(char const * const *) RTEnvGetExecEnvP(RTENV Env);
86
87
88/**
89 * Checks if an environment variable exists in the default environment block.
90 *
91 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
92 *
93 * @param pszVar The environment variable name.
94 * @remark WARNING! The current implementation does not perform the appropriate
95 * codeset conversion. We'll figure this out when it becomes necessary.
96 */
97RTDECL(bool) RTEnvExist(const char *pszVar);
98
99/**
100 * Checks if an environment variable exists in a specific environment block.
101 *
102 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
103 *
104 * @param Env The environment handle.
105 * @param pszVar The environment variable name.
106 */
107RTDECL(bool) RTEnvExistEx(RTENV Env, const char *pszVar);
108
109/**
110 * Gets an environment variable from the default environment block. (getenv).
111 *
112 * The caller is responsible for ensuring that nobody changes the environment
113 * while it's using the returned string pointer!
114 *
115 * @returns Pointer to read only string on success, NULL if the variable wasn't found.
116 *
117 * @param pszVar The environment variable name.
118 *
119 * @remark WARNING! The current implementation does not perform the appropriate
120 * codeset conversion. We'll figure this out when it becomes necessary.
121 */
122RTDECL(const char *) RTEnvGet(const char *pszVar);
123
124/**
125 * Gets an environment variable in a specific environment block.
126 *
127 * @returns IPRT status code.
128 *
129 * @param Env The environment handle.
130 * @param pszVar The environment variable name.
131 * @param pszValue Where to put the buffer.
132 * @param cbValue The size of the value buffer.
133 * @param pcchActual Returns the actual value string length. Optional.
134 */
135RTDECL(int) RTEnvGetEx(RTENV Env, const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual);
136
137/**
138 * Puts an variable=value string into the environment (putenv).
139 *
140 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
141 *
142 * @param pszVarEqualValue The variable '=' value string. If the value and '=' is
143 * omitted, the variable is removed from the environment.
144 *
145 * @remark Don't assume the value is copied.
146 * @remark WARNING! The current implementation does not perform the appropriate
147 * codeset conversion. We'll figure this out when it becomes necessary.
148 */
149RTDECL(int) RTEnvPut(const char *pszVarEqualValue);
150
151/**
152 * Puts a copy of the passed in 'variable=value' string into the environment block.
153 *
154 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
155 *
156 * @param Env Handle of the environment block.
157 * @param pszVarEqualValue The variable '=' value string. If the value and '=' is
158 * omitted, the variable is removed from the environment.
159 */
160RTDECL(int) RTEnvPutEx(RTENV Env, const char *pszVarEqualValue);
161
162/**
163 * Sets an environment variable (setenv(,,1)).
164 *
165 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
166 *
167 * @param pszVar The environment variable name.
168 * @param pszValue The environment variable value.
169 *
170 * @remark WARNING! The current implementation does not perform the appropriate
171 * codeset conversion. We'll figure this out when it becomes necessary.
172 */
173RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue);
174
175/**
176 * Sets an environment variable (setenv(,,1)).
177 *
178 * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
179 *
180 * @param Env The environment handle.
181 * @param pszVar The environment variable name.
182 * @param pszValue The environment variable value.
183 */
184RTDECL(int) RTEnvSetEx(RTENV Env, const char *pszVar, const char *pszValue);
185
186/**
187 * Removes an environment variable from the default environment block.
188 *
189 * @returns IPRT status code.
190 * @returns VINF_ENV_VAR_NOT_FOUND if the variable was not found.
191 *
192 * @param pszVar The environment variable name.
193 *
194 * @remark WARNING! The current implementation does not perform the appropriate
195 * codeset conversion. We'll figure this out when it becomes necessary.
196 */
197RTDECL(int) RTEnvUnset(const char *pszVar);
198
199/**
200 * Removes an environment variable from the specified environment block.
201 *
202 * @returns IPRT status code.
203 * @returns VINF_ENV_VAR_NOT_FOUND if the variable was not found.
204 *
205 * @param Env The environment handle.
206 * @param pszVar The environment variable name.
207 */
208RTDECL(int) RTEnvUnsetEx(RTENV Env, const char *pszVar);
209
210#endif /* IN_RING3 */
211
212/** @} */
213
214__END_DECLS
215
216#endif
217
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