X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FApplication%2FShell%2FShell.h;h=e6eb150f57a525fbf75974c2752ac0f67f3b17db;hb=6a5033ca3e8868a176a9671d55ad297bac385b1b;hp=51ec4f3a4bd275699d9e0afd55767202cfbccd82;hpb=a49f6a2f7e0d0141519c136905ce70038573ce40;p=mirror_edk2.git
diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h
index 51ec4f3a4b..e6eb150f57 100644
--- a/ShellPkg/Application/Shell/Shell.h
+++ b/ShellPkg/Application/Shell/Shell.h
@@ -1,14 +1,9 @@
/** @file
function definitions for internal to shell functions.
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
- This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+ (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -16,17 +11,18 @@
#define _SHELL_INTERNAL_HEADER_
#include
-#include
#include
+#include
#include
#include
-#include
+#include
#include
#include
-#include
+#include
#include
+#include
#include
#include
@@ -44,6 +40,8 @@
#include
#include
#include
+#include
+#include
#include "ShellParametersProtocol.h"
#include "ShellProtocol.h"
@@ -51,11 +49,16 @@
#include "ConsoleLogger.h"
#include "ShellManParser.h"
#include "ConsoleWrappers.h"
+#include "FileHandleWrappers.h"
+
+extern CONST CHAR16 mNoNestingEnvVarName[];
+extern CONST CHAR16 mNoNestingTrue[];
+extern CONST CHAR16 mNoNestingFalse[];
typedef struct {
LIST_ENTRY Link; ///< Standard linked list handler.
- SHELL_FILE_HANDLE *SplitStdOut; ///< ConsoleOut for use in the split.
- SHELL_FILE_HANDLE *SplitStdIn; ///< ConsoleIn for use in the split.
+ SHELL_FILE_HANDLE SplitStdOut; ///< ConsoleOut for use in the split.
+ SHELL_FILE_HANDLE SplitStdIn; ///< ConsoleIn for use in the split.
} SPLIT_LIST;
typedef struct {
@@ -67,7 +70,9 @@ typedef struct {
UINT32 NoMap:1; ///< Was "-nomap" found on command line.
UINT32 NoVersion:1; ///< Was "-noversion" found on command line.
UINT32 Delay:1; ///< Was "-delay[:n] found on command line
- UINT32 Reserved:8; ///< Extra bits
+ UINT32 Exit:1; ///< Was "-_exit" found on command line
+ UINT32 NoNest:1; ///< Was "-nonest" found on command line
+ UINT32 Reserved:7; ///< Extra bits
} SHELL_BITS;
typedef union {
@@ -106,26 +111,59 @@ typedef struct {
EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting.
SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing.
SPLIT_LIST SplitList; ///< List of Splits in FILO stack.
- EFI_HANDLE CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
- EFI_HANDLE CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
+ VOID *CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.
BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt.
} SHELL_INFO;
+#pragma pack(1)
+///
+/// HII specific Vendor Device Path definition.
+///
+typedef struct {
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} SHELL_MAN_HII_VENDOR_DEVICE_PATH;
+#pragma pack()
+
extern SHELL_INFO ShellInfoObject;
+/**
+ Converts the command line to its post-processed form. this replaces variables and alias' per UEFI Shell spec.
+
+ @param[in,out] CmdLine pointer to the command line to update
+
+ @retval EFI_SUCCESS The operation was successful
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
+ @return some other error occurred
+**/
+EFI_STATUS
+ProcessCommandLineToFinal(
+ IN OUT CHAR16 **CmdLine
+ );
+
+/**
+ Function to update the shell variable "lasterror".
+
+ @param[in] ErrorCode the error code to put into lasterror
+**/
+EFI_STATUS
+SetLastError(
+ IN CONST SHELL_STATUS ErrorCode
+ );
+
/**
Sets all the alias' that were registered with the ShellCommandLib library.
- @retval EFI_SUCCESS all init commands were run sucessfully.
+ @retval EFI_SUCCESS all init commands were run successfully.
**/
EFI_STATUS
-EFIAPI
SetBuiltInAlias(
VOID
);
@@ -136,16 +174,15 @@ SetBuiltInAlias(
loaded image protocol installed on it. the FilePath will point to the device path
for the file that was loaded.
- @param[in,out] DevPath on a sucessful return the device path to the loaded image
- @param[in,out] FilePath on a sucessful return the device path to the file
+ @param[in, out] DevPath on a successful return the device path to the loaded image
+ @param[in, out] FilePath on a successful return the device path to the file
- @retval EFI_SUCCESS the 2 device paths were sucessfully returned.
+ @retval EFI_SUCCESS the 2 device paths were successfully returned.
@return other a error from gBS->HandleProtocol
@sa HandleProtocol
**/
EFI_STATUS
-EFIAPI
GetDevicePathsForImageAndFile (
IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,
IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath
@@ -179,7 +216,6 @@ GetDevicePathsForImageAndFile (
@retval EFI_SUCCESS the variable is initialized.
**/
EFI_STATUS
-EFIAPI
ProcessCommandLine(
VOID
);
@@ -195,7 +231,6 @@ ProcessCommandLine(
@retval EFI_SUCCESS The variable is initialized.
**/
EFI_STATUS
-EFIAPI
DoStartupScript(
IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,
IN EFI_DEVICE_PATH_PROTOCOL *FilePath
@@ -210,7 +245,6 @@ DoStartupScript(
@retval RETURN_ABORTED
**/
EFI_STATUS
-EFIAPI
DoShellPrompt (
VOID
);
@@ -222,7 +256,6 @@ DoShellPrompt (
@param Buffer Something to pass to FreePool when the shell is exiting.
**/
VOID*
-EFIAPI
AddBufferToFreeList(
VOID *Buffer
);
@@ -233,7 +266,6 @@ AddBufferToFreeList(
@param Buffer[in] The line buffer to add.
**/
VOID
-EFIAPI
AddLineToCommandHistory(
IN CONST CHAR16 *Buffer
);
@@ -249,36 +281,38 @@ AddLineToCommandHistory(
@retval EFI_ABORTED the command's operation was aborted
**/
EFI_STATUS
-EFIAPI
RunCommand(
IN CONST CHAR16 *CmdLine
);
/**
- Function determins if the CommandName COULD be a valid command. It does not determine whether
- this is a valid command. It only checks for invalid characters.
+ Function will process and run a command line.
- @param[in] CommandName The name to check
+ This will determine if the command line represents an internal shell
+ command or dispatch an external application.
- @retval TRUE CommandName could be a command name
- @retval FALSE CommandName could not be a valid command name
+ @param[in] CmdLine The command line to parse.
+ @param[out] CommandStatus The status from the command line.
+
+ @retval EFI_SUCCESS The command was completed.
+ @retval EFI_ABORTED The command's operation was aborted.
**/
-BOOLEAN
-EFIAPI
-IsValidCommandName(
- IN CONST CHAR16 *CommandName
+EFI_STATUS
+RunShellCommand(
+ IN CONST CHAR16 *CmdLine,
+ OUT EFI_STATUS *CommandStatus
);
+
/**
Function to process a NSH script file via SHELL_FILE_HANDLE.
@param[in] Handle The handle to the already opened file.
@param[in] Name The name of the script file.
- @retval EFI_SUCCESS the script completed sucessfully
+ @retval EFI_SUCCESS the script completed successfully
**/
EFI_STATUS
-EFIAPI
RunScriptFileHandle (
IN SHELL_FILE_HANDLE Handle,
IN CONST CHAR16 *Name
@@ -288,15 +322,69 @@ RunScriptFileHandle (
Function to process a NSH script file.
@param[in] ScriptPath Pointer to the script file name (including file system path).
+ @param[in] Handle the handle of the script file already opened.
+ @param[in] CmdLine the command line to run.
+ @param[in] ParamProtocol the shell parameters protocol pointer
- @retval EFI_SUCCESS the script completed sucessfully
+ @retval EFI_SUCCESS the script completed successfully
**/
EFI_STATUS
-EFIAPI
RunScriptFile (
- IN CONST CHAR16 *ScriptPath
+ IN CONST CHAR16 *ScriptPath,
+ IN SHELL_FILE_HANDLE Handle OPTIONAL,
+ IN CONST CHAR16 *CmdLine,
+ IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol
);
+/**
+ Return the pointer to the first occurrence of any character from a list of characters.
+
+ @param[in] String the string to parse
+ @param[in] CharacterList the list of character to look for
+ @param[in] EscapeCharacter An escape character to skip
+
+ @return the location of the first character in the string
+ @retval CHAR_NULL no instance of any character in CharacterList was found in String
+**/
+CONST CHAR16*
+FindFirstCharacter(
+ IN CONST CHAR16 *String,
+ IN CONST CHAR16 *CharacterList,
+ IN CONST CHAR16 EscapeCharacter
+ );
+
+/**
+ Cleans off leading and trailing spaces and tabs.
+
+ @param[in] String pointer to the string to trim them off.
+**/
+EFI_STATUS
+TrimSpaces(
+ IN CHAR16 **String
+ );
+
+/**
+
+ Create a new buffer list and stores the old one to OldBufferList
+
+ @param OldBufferList The temporary list head used to store the nodes in BufferToFreeList.
+**/
+VOID
+SaveBufferList (
+ OUT LIST_ENTRY *OldBufferList
+ );
+
+/**
+ Restore previous nodes into BufferToFreeList .
+
+ @param OldBufferList The temporary list head used to store the nodes in BufferToFreeList.
+**/
+VOID
+RestoreBufferList (
+ IN OUT LIST_ENTRY *OldBufferList
+ );
+
+
#endif //_SHELL_INTERNAL_HEADER_