]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/ShellEnvVar.h
ShellPkg/Application: Fix various typos
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellEnvVar.h
index 277895994aa500c9d63c3b429f4aa2dc8e367e1e..6c8552ee6437385212b6693418c533efc7020c48 100644 (file)
@@ -6,14 +6,8 @@
 //#include <Library/UefiRuntimeServicesTableLib.h>\r
 \r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -27,31 +21,36 @@ typedef struct {
   UINT32      Atts;\r
 } ENV_VAR_LIST;\r
 \r
-/**\r
-  Reports whether an environment variable is Volatile or Non-Volatile\r
+//\r
+// The list is used to cache the environment variables.\r
+//\r
+extern ENV_VAR_LIST    gShellEnvVarList;\r
+\r
 \r
-  This will use the Runtime Services call GetVariable to to search for the variable.\r
+/**\r
+  Reports whether an environment variable is Volatile or Non-Volatile.\r
 \r
   @param EnvVarName             The name of the environment variable in question\r
+  @param Volatile               Return TRUE if the environment variable is volatile\r
 \r
-  @retval TRUE                  This environment variable is Volatile\r
-  @retval FALSE                 This environment variable is NON-Volatile\r
+  @retval EFI_SUCCESS           The volatile attribute is returned successfully\r
+  @retval others                Some errors happened.\r
 **/\r
-BOOLEAN\r
-EFIAPI\r
+EFI_STATUS\r
 IsVolatileEnv (\r
-  IN CONST CHAR16 *EnvVarName\r
+  IN CONST CHAR16 *EnvVarName,\r
+  OUT BOOLEAN     *Volatile\r
   );\r
 \r
 /**\r
-  Delete a Non-Violatile environment variable.\r
+  Delete a Non-Volatile environment variable.\r
 \r
-  This will use the Runtime Services call SetVariable to remove a non-violatile variable.\r
+  This will use the Runtime Services call SetVariable to remove a non-volatile variable.\r
 \r
   @param EnvVarName             The name of the environment variable in question\r
 \r
-  @retval EFI_SUCCESS           The variable was deleted sucessfully\r
-  @retval other                 An error ocurred\r
+  @retval EFI_SUCCESS           The variable was deleted successfully\r
+  @retval other                 An error occurred\r
   @sa SetVariable\r
 **/\r
 #define SHELL_DELETE_ENVIRONMENT_VARIABLE(EnvVarName) \\r
@@ -62,16 +61,16 @@ IsVolatileEnv (
   NULL))\r
 \r
 /**\r
-  Set a Non-Violatile environment variable.\r
+  Set a Non-Volatile environment variable.\r
 \r
-  This will use the Runtime Services call SetVariable to set a non-violatile variable.\r
+  This will use the Runtime Services call SetVariable to set a non-volatile variable.\r
 \r
   @param EnvVarName             The name of the environment variable in question\r
   @param BufferSize             UINTN size of Buffer\r
   @param Buffer                 Pointer to value to set variable to\r
 \r
-  @retval EFI_SUCCESS           The variable was changed sucessfully\r
-  @retval other                 An error ocurred\r
+  @retval EFI_SUCCESS           The variable was changed successfully\r
+  @retval other                 An error occurred\r
   @sa SetVariable\r
 **/\r
 #define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer)  \\r
@@ -90,8 +89,8 @@ IsVolatileEnv (
   @param BufferSize             Pointer to the UINTN size of Buffer\r
   @param Buffer                 Pointer buffer to get variable value into\r
 \r
-  @retval EFI_SUCCESS           The variable's value was retrieved sucessfully\r
-  @retval other                 An error ocurred\r
+  @retval EFI_SUCCESS           The variable's value was retrieved successfully\r
+  @retval other                 An error occurred\r
   @sa SetVariable\r
 **/\r
 #define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer)    \\r
@@ -111,8 +110,8 @@ IsVolatileEnv (
   @param BufferSize             Pointer to the UINTN size of Buffer\r
   @param Buffer                 Pointer buffer to get variable value into\r
 \r
-  @retval EFI_SUCCESS           The variable's value was retrieved sucessfully\r
-  @retval other                 An error ocurred\r
+  @retval EFI_SUCCESS           The variable's value was retrieved successfully\r
+  @retval other                 An error occurred\r
   @sa SetVariable\r
 **/\r
 #define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName,Atts,BufferSize,Buffer)    \\r
@@ -123,16 +122,16 @@ IsVolatileEnv (
   Buffer))\r
 \r
 /**\r
-  Set a Violatile environment variable.\r
+  Set a Volatile environment variable.\r
 \r
-  This will use the Runtime Services call SetVariable to set a violatile variable.\r
+  This will use the Runtime Services call SetVariable to set a volatile variable.\r
 \r
   @param EnvVarName             The name of the environment variable in question\r
   @param BufferSize             UINTN size of Buffer\r
   @param Buffer                 Pointer to value to set variable to\r
 \r
-  @retval EFI_SUCCESS           The variable was changed sucessfully\r
-  @retval other                 An error ocurred\r
+  @retval EFI_SUCCESS           The variable was changed successfully\r
+  @retval other                 An error occurred\r
   @sa SetVariable\r
 **/\r
 #define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \\r
@@ -145,13 +144,12 @@ IsVolatileEnv (
 /**\r
   Creates a list of all Shell-Guid-based environment variables.\r
 \r
-  @param[in,out] List           The pointer to pointer to LIST_ENTRY object for\r
-                                storing this list.\r
+  @param[in, out] List           The pointer to pointer to LIST_ENTRY object for\r
+                                 storing this list.\r
 \r
-  @retval EFI_SUCCESS           the list was created sucessfully.\r
+  @retval EFI_SUCCESS           the list was created successfully.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 GetEnvironmentVariableList(\r
   IN OUT LIST_ENTRY *List\r
   );\r
@@ -166,10 +164,9 @@ GetEnvironmentVariableList(
   @param[in] List               The pointer to LIST_ENTRY from\r
                                 GetShellEnvVarList().\r
 \r
-  @retval EFI_SUCCESS           The list was Set sucessfully.\r
+  @retval EFI_SUCCESS           The list was Set successfully.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 SetEnvironmentVariableList(\r
   IN LIST_ENTRY *List\r
   );\r
@@ -190,7 +187,6 @@ SetEnvironmentVariableList(
   @sa SetEnvironmentVariableList\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 SetEnvironmentVariables(\r
   IN CONST CHAR16 **Environment\r
   );\r
@@ -201,10 +197,86 @@ SetEnvironmentVariables(
   @param[in] List               The pointer to pointer to list.\r
 **/\r
 VOID\r
-EFIAPI\r
 FreeEnvironmentVariableList(\r
   IN LIST_ENTRY *List\r
   );\r
 \r
+/**\r
+  Find an environment variable in the gShellEnvVarList.\r
+\r
+  @param Key        The name of the environment variable.\r
+  @param Value      The value of the environment variable, the buffer\r
+                    shoule be freed by the caller.\r
+  @param ValueSize  The size in bytes of the environment variable\r
+                    including the tailing CHAR_NULL.\r
+  @param Atts       The attributes of the variable.\r
+\r
+  @retval EFI_SUCCESS       The command executed successfully.\r
+  @retval EFI_NOT_FOUND     The environment variable is not found in\r
+                            gShellEnvVarList.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellFindEnvVarInList (\r
+  IN  CONST CHAR16    *Key,\r
+  OUT CHAR16          **Value,\r
+  OUT UINTN           *ValueSize,\r
+  OUT UINT32          *Atts OPTIONAL\r
+  );\r
+\r
+/**\r
+  Add an environment variable into gShellEnvVarList.\r
+\r
+  @param Key        The name of the environment variable.\r
+  @param Value      The value of environment variable.\r
+  @param ValueSize  The size in bytes of the environment variable\r
+                    including the tailing CHAR_NULL\r
+  @param Atts       The attributes of the variable.\r
+\r
+  @retval EFI_SUCCESS  The environment variable was added to list successfully.\r
+  @retval others       Some errors happened.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellAddEnvVarToList (\r
+  IN CONST CHAR16     *Key,\r
+  IN CONST CHAR16     *Value,\r
+  IN UINTN            ValueSize,\r
+  IN UINT32           Atts\r
+  );\r
+\r
+/**\r
+  Remove a specified environment variable in gShellEnvVarList.\r
+\r
+  @param Key        The name of the environment variable.\r
+\r
+  @retval EFI_SUCCESS       The command executed successfully.\r
+  @retval EFI_NOT_FOUND     The environment variable is not found in\r
+                            gShellEnvVarList.\r
+**/\r
+EFI_STATUS\r
+ShellRemvoeEnvVarFromList (\r
+  IN CONST CHAR16           *Key\r
+  );\r
+\r
+/**\r
+  Initialize the gShellEnvVarList and cache all Shell-Guid-based environment\r
+  variables.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellInitEnvVarList (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Destructe the gShellEnvVarList.\r
+\r
+**/\r
+VOID\r
+ShellFreeEnvVarList (\r
+  VOID\r
+  );\r
+\r
 #endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_\r
 \r