]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/Shell.h
ShellPkg: Fix command-line parsing to start with Argv[0] when comparing passed-in...
[mirror_edk2.git] / ShellPkg / Application / Shell / Shell.h
index da98fc1a56d0e4efb48c93235f4c163165efb876..72dde69645b7dcc787db023851ac82a49831c8c9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   function definitions for internal to shell functions.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2014, 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
@@ -71,7 +71,8 @@ typedef struct {
   UINT32  NoMap:1;        ///< Was "-nomap"         found on command line.\r
   UINT32  NoVersion:1;    ///< Was "-noversion"     found on command line.\r
   UINT32  Delay:1;        ///< Was "-delay[:n]      found on command line\r
-  UINT32  Reserved:8;     ///< Extra bits\r
+  UINT32  Exit:1;         ///< Was "-_exit"          found on command line\r
+  UINT32  Reserved:7;     ///< Extra bits\r
 } SHELL_BITS;\r
 \r
 typedef union {\r
@@ -123,6 +124,40 @@ typedef struct {
 \r
 extern SHELL_INFO ShellInfoObject;\r
 \r
+typedef enum {\r
+  Internal_Command,\r
+  Script_File_Name,\r
+  Efi_Application,\r
+  File_Sys_Change,\r
+  Unknown_Invalid\r
+} SHELL_OPERATION_TYPES;\r
+\r
+/**\r
+  Converts the command line to it's post-processed form.  this replaces variables and alias' per UEFI Shell spec.\r
+\r
+  @param[in,out] CmdLine        pointer to the command line to update\r
+\r
+  @retval EFI_SUCCESS           The operation was successful\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+  @return                       some other error occured\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessCommandLineToFinal(\r
+  IN OUT CHAR16 **CmdLine\r
+  );\r
+\r
+/**\r
+  Function to update the shell variable "lasterror".\r
+\r
+  @param[in] ErrorCode      the error code to put into lasterror\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SetLastError(\r
+  IN CONST SHELL_STATUS   ErrorCode\r
+  );\r
+\r
 /**\r
   Sets all the alias' that were registered with the ShellCommandLib library.\r
 \r
@@ -195,14 +230,17 @@ ProcessCommandLine(
 \r
   @param[in] ImagePath          The path to the image for shell.  The first place to look for the startup script.\r
   @param[in] FilePath           The path to the file for shell.  The second place to look for the startup script.\r
+  @param[out] ExitStatus        The exit code of the script. Ignored if NULL.\r
+                                Invalid when this function returns an error.\r
 \r
   @retval EFI_SUCCESS           The variable is initialized.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 DoStartupScript(\r
-  IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,\r
-  IN EFI_DEVICE_PATH_PROTOCOL *FilePath\r
+  IN  EFI_DEVICE_PATH_PROTOCOL *ImagePath,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
+  OUT SHELL_STATUS             *ExitStatus\r
   );\r
 \r
 /**\r
@@ -247,7 +285,8 @@ AddLineToCommandHistory(
 \r
   This will determine if the command line represents an internal shell command or dispatch an external application.\r
 \r
-  @param[in] CmdLine  the command line to parse\r
+  @param[in]  CmdLine     the command line to parse\r
+  @param[out] ExitStatus  The exit status of the command. Ignored if NULL.\r
 \r
   @retval EFI_SUCCESS     the command was completed\r
   @retval EFI_ABORTED     the command's operation was aborted\r
@@ -255,7 +294,8 @@ AddLineToCommandHistory(
 EFI_STATUS\r
 EFIAPI\r
 RunCommand(\r
-  IN CONST CHAR16   *CmdLine\r
+  IN  CONST CHAR16         *CmdLine,\r
+  OUT       SHELL_STATUS   *ExitStatus\r
   );\r
 \r
 /**\r
@@ -279,28 +319,41 @@ IsValidCommandName(
   @param[in] Handle             The handle to the already opened file.\r
   @param[in] Name               The name of the script file.\r
 \r
+  @param[out] ExitStatus      The exit code of the script. Ignored if NULL.\r
+                              Invalid when this function returns an error.\r
+\r
   @retval EFI_SUCCESS           the script completed sucessfully\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RunScriptFileHandle (\r
-  IN SHELL_FILE_HANDLE  Handle,\r
-  IN CONST CHAR16       *Name\r
+  IN  SHELL_FILE_HANDLE  Handle,\r
+  IN  CONST CHAR16       *Name,\r
+  OUT SHELL_STATUS       *ExitStatus\r
   );\r
 \r
 /**\r
   Function to process a NSH script file.\r
 \r
   @param[in] ScriptPath         Pointer to the script file name (including file system path).\r
+  @param[in] Handle             the handle of the script file already opened.\r
+  @param[in] CmdLine            the command line to run.\r
+  @param[in] ParamProtocol      the shell parameters protocol pointer\r
+\r
+  @param[out] ExitStatus      The exit code of the script. Ignored if NULL.\r
+                              Invalid when this function returns an error.\r
 \r
   @retval EFI_SUCCESS           the script completed sucessfully\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RunScriptFile (\r
-  IN CONST CHAR16 *ScriptPath\r
+  IN  CONST CHAR16                   *ScriptPath,\r
+  IN  SHELL_FILE_HANDLE              Handle OPTIONAL,\r
+  IN  CONST CHAR16                   *CmdLine,\r
+  IN  EFI_SHELL_PARAMETERS_PROTOCOL  *ParamProtocol,\r
+  OUT SHELL_STATUS                   *ExitStatus\r
   );\r
 \r
-\r
 #endif //_SHELL_INTERNAL_HEADER_\r
 \r