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 | * If you received this file as part of a commercial VirtualBox
|
---|
17 | * distribution, then only the terms of your commercial VirtualBox
|
---|
18 | * license agreement apply instead of the previous paragraph.
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef ___iprt_env_h
|
---|
22 | #define ___iprt_env_h
|
---|
23 |
|
---|
24 | #include <iprt/cdefs.h>
|
---|
25 | #include <iprt/types.h>
|
---|
26 |
|
---|
27 | __BEGIN_DECLS
|
---|
28 |
|
---|
29 | /** @defgroup grp_rt_env RTProc - Process Environment Strings
|
---|
30 | * @ingroup grp_rt
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 |
|
---|
34 | #ifdef IN_RING3
|
---|
35 |
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Checks if an environment variable exists.
|
---|
39 | *
|
---|
40 | * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
|
---|
41 | *
|
---|
42 | * @param pszVar The environment variable name.
|
---|
43 | */
|
---|
44 | RTDECL(bool) RTEnvExist(const char *pszVar);
|
---|
45 |
|
---|
46 | /**
|
---|
47 | * Gets an environment variable (getenv).
|
---|
48 | *
|
---|
49 | * The caller is responsible for ensuring that nobody changes the environment
|
---|
50 | * while it's using the returned string pointer!
|
---|
51 | *
|
---|
52 | * @returns Pointer to read only string on success, NULL if the variable wasn't found.
|
---|
53 | *
|
---|
54 | * @param pszVar The environment variable name.
|
---|
55 | */
|
---|
56 | RTDECL(const char *) RTEnvGet(const char *pszVar);
|
---|
57 |
|
---|
58 | /**
|
---|
59 | * Puts an variable=value string into the environment (putenv).
|
---|
60 | *
|
---|
61 | * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
|
---|
62 | *
|
---|
63 | * @param pszVarEqualValue The variable '=' value string. If the value and '=' is
|
---|
64 | * omitted, the variable is removed from the environment.
|
---|
65 | */
|
---|
66 | RTDECL(int) RTEnvPut(const char *pszVarEqualValue);
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Sets an environment variable (setenv(,,1)).
|
---|
70 | *
|
---|
71 | * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
|
---|
72 | *
|
---|
73 | * @param pszVar The environment variable name.
|
---|
74 | * @param pszValue The environment variable value.
|
---|
75 | */
|
---|
76 | RTDECL(int) RTEnvSet(const char *pszVar, const char *pszValue);
|
---|
77 |
|
---|
78 | /** @todo Add the missing environment APIs: safe, printf like, and various modifications. */
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Creates an empty environment block.
|
---|
82 | *
|
---|
83 | * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
|
---|
84 | *
|
---|
85 | * @param pEnv Where to store the handle of the environment block.
|
---|
86 | */
|
---|
87 | RTDECL(int) RTEnvCreate(PRTENV pEnv);
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Destroys an environment block.
|
---|
91 | *
|
---|
92 | * @returns IPRT status code.
|
---|
93 | *
|
---|
94 | * @param Env Handle of the environment block.
|
---|
95 | */
|
---|
96 | RTDECL(int) RTEnvDestroy(RTENV Env);
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Creates an environment block and fill it with variables from the given
|
---|
100 | * environment array.
|
---|
101 | *
|
---|
102 | * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
|
---|
103 | *
|
---|
104 | * @param pEnv Where to store the handle of the environment block.
|
---|
105 | * @param apszEnv Pointer to the NULL-terminated array of environment
|
---|
106 | * variables. If NULL, the current process' environment
|
---|
107 | * will be cloned.
|
---|
108 | */
|
---|
109 | RTDECL(int) RTEnvClone(PRTENV pEnv, char const *const *apszEnv);
|
---|
110 |
|
---|
111 | /** @todo later */
|
---|
112 | /*
|
---|
113 | RTDECL(int) RTEnvCloneEx(PRTENV pEnv, const RTENV Env);
|
---|
114 |
|
---|
115 | RTDECL(int) RTEnvExistEx(RTENV Env, const char *pszVar);
|
---|
116 | RTDECL(int) RTEnvSetEx(RTENV Env, const char *pszVar, const char *pszValue);
|
---|
117 | RTDECL(int) RTEnvGetEx(RTENV Env, const char *pszVar, const char **ppszValue);
|
---|
118 | RTDECL(int) RTEnvCountEx(RTENV Env, size_t *cbCount);
|
---|
119 | */
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * Puts a 'variable=value' string into the environment.
|
---|
123 | *
|
---|
124 | * The supplied string must be in the current process' codepage.
|
---|
125 | * This function makes a copy of the supplied string.
|
---|
126 | *
|
---|
127 | * @returns IPRT status code. Typical error is VERR_NO_MEMORY.
|
---|
128 | *
|
---|
129 | * @param Env Handle of the environment block.
|
---|
130 | * @param pszVarEqualValue The variable '=' value string. If the value and '=' is
|
---|
131 | * omitted, the variable is removed from the environment.
|
---|
132 | */
|
---|
133 | RTDECL(int) RTEnvPutEx(RTENV Env, const char *pszVarEqualValue);
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Returns a raw pointer to the array of environment variables of the given
|
---|
137 | * environment block where every variable is a string in format
|
---|
138 | * 'variable=value'.
|
---|
139 | *
|
---|
140 | * All returned strings are in the current process' codepage.
|
---|
141 | *
|
---|
142 | * @returns Pointer to the raw array of environment variables.
|
---|
143 | * @returns NULL if Env is NULL or invalid.
|
---|
144 | *
|
---|
145 | * @param Env Handle of the environment block.
|
---|
146 | */
|
---|
147 | RTDECL(char const *const *) RTEnvGetArray(RTENV Env);
|
---|
148 |
|
---|
149 | #endif /* IN_RING3 */
|
---|
150 |
|
---|
151 | /** @} */
|
---|
152 |
|
---|
153 | __END_DECLS
|
---|
154 |
|
---|
155 | #endif
|
---|
156 |
|
---|