VirtualBox

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

Last change on this file since 5605 was 4475, checked in by vboxsync, 17 years ago

Some adjustments to RTEnv and RTProcCreate. Should work on darwin now.

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