]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Include/Library/ShellLib.h
ShellPkg: Correct a parameter's name
[mirror_edk2.git] / ShellPkg / Include / Library / ShellLib.h
index a1b534bd3ec360d08de629cf5c8652243399299f..78bdcc8c53116ca65c3cae7651d6601b5d93cbef 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright 2018 Dell Technologies.<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
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/EfiShellInterface.h>\r
 #include <Protocol/EfiShellEnvironment2.h>\r
-#include <Protocol/EfiShell.h>\r
-#include <Protocol/EfiShellParameters.h>\r
+#include <Protocol/Shell.h>\r
+#include <Protocol/ShellParameters.h>\r
 \r
-// (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
-#define MAX_FILE_NAME_LEN 512\r
+#define SHELL_FREE_NON_NULL(Pointer)  \\r
+  do {                                \\r
+    if ((Pointer) != NULL) {          \\r
+      FreePool((Pointer));            \\r
+      (Pointer) = NULL;               \\r
+    }                                 \\r
+  } while(FALSE)\r
 \r
 extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;\r
 extern EFI_SHELL_PROTOCOL            *gEfiShellProtocol;\r
 \r
+/**\r
+  Return a clean, fully-qualified version of an input path.  If the return value\r
+  is non-NULL the caller must free the memory when it is no longer needed.\r
+\r
+  If asserts are disabled, and if the input parameter is NULL, NULL is returned.\r
+\r
+  If there is not enough memory available to create the fully-qualified path or\r
+  a copy of the input path, NULL is returned.\r
+\r
+  If there is no working directory, a clean copy of Path is returned.\r
+\r
+  Otherwise, the current file system or working directory (as appropriate) is\r
+  prepended to Path and the resulting path is cleaned and returned.\r
+\r
+  NOTE: If the input path is an empty string, then the current working directory\r
+  (if it exists) is returned.  In other words, an empty input path is treated\r
+  exactly the same as ".".\r
+\r
+  @param[in] Path  A pointer to some file or directory path.\r
+\r
+  @retval NULL          The input path is NULL or out of memory.\r
+\r
+  @retval non-NULL      A pointer to a clean, fully-qualified version of Path.\r
+                        If there is no working directory, then a pointer to a\r
+                        clean, but not necessarily fully-qualified version of\r
+                        Path.  The caller must free this memory when it is no\r
+                        longer needed.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FullyQualifyPath(\r
+  IN     CONST CHAR16     *Path\r
+  );\r
+\r
 /**\r
   This function will retrieve the information about the file for the handle\r
   specified and store it in allocated pool memory.\r
@@ -84,7 +124,6 @@ ShellSetFileInfo (
 \r
   @param[in, out]  FilePath      On input, the device path to the file.  On output,\r
                                  the remaining device path.\r
-  @param[out]   DeviceHandle     Pointer to the system device handle.\r
   @param[out]   FileHandle       Pointer to the file handle.\r
   @param[in]    OpenMode         The mode to open the file with.\r
   @param[in]    Attributes       The file's file attributes.\r
@@ -110,7 +149,6 @@ EFI_STATUS
 EFIAPI\r
 ShellOpenFileByDevicePath(\r
   IN OUT EFI_DEVICE_PATH_PROTOCOL     **FilePath,\r
-  OUT EFI_HANDLE                      *DeviceHandle,\r
   OUT SHELL_FILE_HANDLE               *FileHandle,\r
   IN UINT64                           OpenMode,\r
   IN UINT64                           Attributes\r
@@ -123,7 +161,7 @@ ShellOpenFileByDevicePath(
   otherwise, the Filehandle is NULL. Attributes is valid only for\r
   EFI_FILE_MODE_CREATE.\r
 \r
-  @param[in] FilePath           The pointer to file name.\r
+  @param[in] FileName           The pointer to file name.\r
   @param[out] FileHandle        The pointer to the file handle.\r
   @param[in] OpenMode           The mode to open the file with.\r
   @param[in] Attributes         The file's file attributes.\r
@@ -148,7 +186,7 @@ ShellOpenFileByDevicePath(
 EFI_STATUS\r
 EFIAPI\r
 ShellOpenFileByName(\r
-  IN CONST CHAR16               *FilePath,\r
+  IN CONST CHAR16               *FileName,\r
   OUT SHELL_FILE_HANDLE         *FileHandle,\r
   IN UINT64                     OpenMode,\r
   IN UINT64                     Attributes\r
@@ -550,6 +588,8 @@ ShellExecute (
   name. If the DeviceName is not NULL, it returns the current directory name\r
   on specified drive.\r
 \r
+  Note that the current directory string should exclude the tailing backslash character.\r
+\r
   @param[in] DeviceName         The name of the file system to get directory on.\r
 \r
   @retval NULL                  The directory does not exist.\r
@@ -668,6 +708,7 @@ typedef enum {
   TypeStart,        ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).\r
   TypeDoubleValue,  ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").\r
   TypeMaxValue,     ///< A flag followed by all the command line data before the next flag.\r
+  TypeTimeValue,    ///< A flag that has a time value following it (IE "-a -5:00").\r
   TypeMax,\r
 } SHELL_PARAM_TYPE;\r
 \r
@@ -1007,6 +1048,23 @@ ShellStrToUintn(
   IN CONST CHAR16 *String\r
   );\r
 \r
+/**\r
+  Function return the number converted from a hex representation of a number.\r
+\r
+  Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
+  result.  Use ShellConvertStringToUint64 instead.\r
+\r
+  @param[in] String   String representation of a number.\r
+\r
+  @return             The unsigned integer result of the conversion.\r
+  @retval (UINTN)(-1) An error occured.\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellHexStrToUintn(\r
+  IN CONST CHAR16 *String\r
+  );\r
+\r
 /**\r
   Safely append with automatic string resizing given length of Destination and\r
   desired length of copy from Source.\r
@@ -1158,7 +1216,7 @@ typedef enum {
   Prompt the user and return the resultant answer to the requestor.\r
 \r
   This function will display the requested question on the shell prompt and then\r
-  wait for an apropriate answer to be input from the console.\r
+  wait for an appropriate answer to be input from the console.\r
 \r
   If the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue\r
   or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r
@@ -1313,6 +1371,7 @@ ShellFileHandleReturnLine(
 \r
   @retval EFI_SUCCESS           The operation was successful.  The line is stored in\r
                                 Buffer.\r
+  @retval EFI_END_OF_FILE       There are no more lines in the file.\r
   @retval EFI_INVALID_PARAMETER Handle was NULL.\r
   @retval EFI_INVALID_PARAMETER Size was NULL.\r
   @retval EFI_BUFFER_TOO_SMALL  Size was not large enough to store the line.\r
@@ -1330,9 +1389,9 @@ ShellFileHandleReadLine(
 \r
 /**\r
   Function to delete a file by name\r
-  \r
+\r
   @param[in]       FileName       Pointer to file name to delete.\r
-  \r
+\r
   @retval EFI_SUCCESS             the file was deleted sucessfully\r
   @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r
                                   deleted\r
@@ -1357,4 +1416,23 @@ ShellDeleteFileByName(
   IN CONST CHAR16               *FileName\r
   );\r
 \r
+/**\r
+  Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r
+\r
+  @param[in] CommandToGetHelpOn  Pointer to a string containing the command name of help file to be printed.\r
+  @param[in] SectionToGetHelpOn  Pointer to the section specifier(s).\r
+  @param[in] PrintCommandText    If TRUE, prints the command followed by the help content, otherwise prints\r
+                                 the help content only.\r
+  @retval EFI_DEVICE_ERROR       The help data format was incorrect.\r
+  @retval EFI_NOT_FOUND          The help data could not be found.\r
+  @retval EFI_SUCCESS            The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPrintHelp (\r
+  IN CONST CHAR16     *CommandToGetHelpOn,\r
+  IN CONST CHAR16     *SectionToGetHelpOn,\r
+  IN BOOLEAN          PrintCommandText\r
+  );\r
+\r
 #endif // __SHELL_LIB__\r