]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Application/Shell/ShellEnvVar.h
udk2010.up2.shell initial release.
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellEnvVar.h
CommitLineData
a405b86d 1/** @file\r
2 function definitions for shell environment functions.\r
3\r
4 the following includes are required:\r
5//#include <Guid/ShellVariableGuid.h>\r
6//#include <Library/UefiRuntimeServicesTableLib.h>\r
7\r
8\r
9 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
10 This program and the accompanying materials\r
11 are licensed and made available under the terms and conditions of the BSD License\r
12 which accompanies this distribution. The full text of the license may be found at\r
13 http://opensource.org/licenses/bsd-license.php\r
14\r
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
17\r
18**/\r
19\r
20#ifndef _SHELL_ENVIRONMENT_VARIABLE_HEADER_\r
21#define _SHELL_ENVIRONMENT_VARIABLE_HEADER_\r
22\r
23typedef struct {\r
24 LIST_ENTRY Link;\r
25 CHAR16 *Key;\r
26 CHAR16 *Val;\r
27 UINT32 Atts;\r
28} ENV_VAR_LIST;\r
29\r
30/**\r
31 Reports whether an environment variable is Volatile or Non-Volatile\r
32\r
33 This will use the Runtime Services call GetVariable to to search for the variable.\r
34\r
35 @param EnvVarName The name of the environment variable in question\r
36\r
37 @retval TRUE This environment variable is Volatile\r
38 @retval FALSE This environment variable is NON-Volatile\r
39**/\r
40BOOLEAN\r
41EFIAPI\r
42IsVolatileEnv (\r
43 IN CONST CHAR16 *EnvVarName\r
44 );\r
45\r
46/**\r
47 Delete a Non-Violatile environment variable.\r
48\r
49 This will use the Runtime Services call SetVariable to remove a non-violatile variable.\r
50\r
51 @param EnvVarName The name of the environment variable in question\r
52\r
53 @retval EFI_SUCCESS The variable was deleted sucessfully\r
54 @retval other An error ocurred\r
55 @sa SetVariable\r
56**/\r
57#define SHELL_DELETE_ENVIRONMENT_VARIABLE(EnvVarName) \\r
58 (gRT->SetVariable((CHAR16*)EnvVarName, \\r
59 &gShellVariableGuid, \\r
60 0, \\r
61 0, \\r
62 NULL))\r
63\r
64/**\r
65 Set a Non-Violatile environment variable.\r
66\r
67 This will use the Runtime Services call SetVariable to set a non-violatile variable.\r
68\r
69 @param EnvVarName The name of the environment variable in question\r
70 @param BufferSize UINTN size of Buffer\r
71 @param Buffer Pointer to value to set variable to\r
72\r
73 @retval EFI_SUCCESS The variable was changed sucessfully\r
74 @retval other An error ocurred\r
75 @sa SetVariable\r
76**/\r
77#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer) \\r
78 (gRT->SetVariable((CHAR16*)EnvVarName, \\r
79 &gShellVariableGuid, \\r
80 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \\r
81 BufferSize, \\r
82 (VOID*)Buffer))\r
83\r
84/**\r
85 Get an environment variable.\r
86\r
87 This will use the Runtime Services call GetVariable to get a variable.\r
88\r
89 @param EnvVarName The name of the environment variable in question\r
90 @param BufferSize Pointer to the UINTN size of Buffer\r
91 @param Buffer Pointer buffer to get variable value into\r
92\r
93 @retval EFI_SUCCESS The variable's value was retrieved sucessfully\r
94 @retval other An error ocurred\r
95 @sa SetVariable\r
96**/\r
97#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer) \\r
98 (gRT->GetVariable((CHAR16*)EnvVarName, \\r
99 &gShellVariableGuid, \\r
100 0, \\r
101 BufferSize, \\r
102 Buffer))\r
103\r
104/**\r
105 Get an environment variable.\r
106\r
107 This will use the Runtime Services call GetVariable to get a variable.\r
108\r
109 @param EnvVarName The name of the environment variable in question\r
110 @param Atts Pointer to the UINT32 for attributes (or NULL)\r
111 @param BufferSize Pointer to the UINTN size of Buffer\r
112 @param Buffer Pointer buffer to get variable value into\r
113\r
114 @retval EFI_SUCCESS The variable's value was retrieved sucessfully\r
115 @retval other An error ocurred\r
116 @sa SetVariable\r
117**/\r
118#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName,Atts,BufferSize,Buffer) \\r
119 (gRT->GetVariable((CHAR16*)EnvVarName, \\r
120 &gShellVariableGuid, \\r
121 Atts, \\r
122 BufferSize, \\r
123 Buffer))\r
124\r
125/**\r
126 Set a Violatile environment variable.\r
127\r
128 This will use the Runtime Services call SetVariable to set a violatile variable.\r
129\r
130 @param EnvVarName The name of the environment variable in question\r
131 @param BufferSize UINTN size of Buffer\r
132 @param Buffer Pointer to value to set variable to\r
133\r
134 @retval EFI_SUCCESS The variable was changed sucessfully\r
135 @retval other An error ocurred\r
136 @sa SetVariable\r
137**/\r
138#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \\r
139 (gRT->SetVariable((CHAR16*)EnvVarName, \\r
140 &gShellVariableGuid, \\r
141 EFI_VARIABLE_BOOTSERVICE_ACCESS, \\r
142 BufferSize, \\r
143 (VOID*)Buffer))\r
144\r
145/**\r
146 Creates a list of all Shell-Guid-based environment variables.\r
147\r
148 @param[in,out] List The pointer to pointer to LIST_ENTRY object for\r
149 storing this list.\r
150\r
151 @retval EFI_SUCCESS the list was created sucessfully.\r
152**/\r
153EFI_STATUS\r
154EFIAPI\r
155GetEnvironmentVariableList(\r
156 IN OUT LIST_ENTRY *List\r
157 );\r
158\r
159/**\r
160 Sets a list of all Shell-Guid-based environment variables. this will\r
161 also eliminate all pre-existing shell environment variables (even if they\r
162 are not on the list).\r
163\r
164 This function will also deallocate the memory from List.\r
165\r
166 @param[in] List The pointer to LIST_ENTRY from\r
167 GetShellEnvVarList().\r
168\r
169 @retval EFI_SUCCESS The list was Set sucessfully.\r
170**/\r
171EFI_STATUS\r
172EFIAPI\r
173SetEnvironmentVariableList(\r
174 IN LIST_ENTRY *List\r
175 );\r
176\r
177/**\r
178 sets all Shell-Guid-based environment variables. this will\r
179 also eliminate all pre-existing shell environment variables (even if they\r
180 are not on the list).\r
181\r
182 @param[in] Environment Points to a NULL-terminated array of environment\r
183 variables with the format 'x=y', where x is the\r
184 environment variable name and y is the value.\r
185\r
186 @retval EFI_SUCCESS The command executed successfully.\r
187 @retval EFI_INVALID_PARAMETER The parameter is invalid.\r
188 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
189\r
190 @sa SetEnvironmentVariableList\r
191**/\r
192EFI_STATUS\r
193EFIAPI\r
194SetEnvironmentVariables(\r
195 IN CONST CHAR16 **Environment\r
196 );\r
197\r
198/**\r
199 free function for ENV_VAR_LIST objects.\r
200\r
201 @param[in] List The pointer to pointer to list.\r
202**/\r
203VOID\r
204EFIAPI\r
205FreeEnvironmentVariableList(\r
206 IN LIST_ENTRY *List\r
207 );\r
208\r
209#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_\r
210\r