]> git.proxmox.com Git - mirror_edk2.git/commitdiff
updating comments mostly. also added some new lib functions.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Jan 2010 21:49:04 +0000 (21:49 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Jan 2010 21:49:04 +0000 (21:49 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9710 6f19259b-4bc3-4df7-8a09-765794883524

15 files changed:
ShellPkg/Application/ShellLibTestApp/sa3.c
ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
ShellPkg/Include/Library/FileHandleLib.h
ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/Library/SortLib.h
ShellPkg/Include/Protocol/EfiShellEnvironment2.h
ShellPkg/Include/Protocol/EfiShellInterface.h
ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.c
ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf
ShellPkg/Library/BaseSortLib/BaseSortLib.c
ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
ShellPkg/Library/UefiShellLib/UefiShellLib.c
ShellPkg/Library/UefiShellLib/UefiShellLib.h
ShellPkg/Library/UefiShellLib/UefiShellLib.inf
ShellPkg/Library/UefiSortLib/UefiSortLib.c

index b294003a3a61d8915d8d555b583f7569786f61bd..bc7986a97ae85a3a8e32ab3bfaed6ed7d656abb8 100644 (file)
 **/\r
 \r
 #include <Uefi.h>\r
+#include <Guid/FileInfo.h>\r
+#include <Protocol/SimpleFileSystem.h>\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 <Library/UefiApplicationEntryPoint.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/ShellLib.h>\r
index 83b5b5572daf0fad462e88143995e634eace6c96..e19967ef62559885f7c3acc2716e464d9ac04dee 100644 (file)
@@ -18,7 +18,7 @@
 #include <Library/ShellCEntryLib.h>\r
 #include <Library/SortLib.h>\r
 \r
-INTN Test(VOID*b1, VOID*b2)\r
+INTN Test(CONST VOID*b1, CONST VOID*b2)\r
 {\r
   if (*(INTN*)b1 == *(INTN*)b2) {\r
     return (0);\r
index d86089f04662fc80dd4cb87c78483ef1209c325f..b265d85bb9bf790b06135753c8e08bb18c34466b 100644 (file)
@@ -1,17 +1,26 @@
 /** @file\r
   Provides interface to EFI_FILE_HANDLE functionality.\r
 \r
-Copyright (c) 2009, Intel Corporation<BR>\r
-All rights reserved. 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
+  Copyright (c) 2009, Intel Corporation<BR>\r
+  All rights reserved. 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
+  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
 \r
 **/\r
 \r
+#if !defined (_FILE_HANDLE_LIBRARY_HEADER_)\r
+#define _FILE_HANDLE_LIBRARY_HEADER_\r
+\r
+/// Tag for use in identifying UNICODE files.\r
+/// If the file is UNICODE the first 16 bits of the file will equal this value.\r
+enum {\r
+  UnicodeFileTag = 0xFEFF\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
@@ -344,19 +353,23 @@ FileHandleGetFileName (
   );\r
 \r
 /**\r
-  Function to read a single line from a file. The \n is not included in the returned buffer.\r
+  Function to read a single line (up to but not including the \n) from a file.\r
 \r
-  @param[in]      Handle        FileHandle to read from.\r
-  @param[in,out]  Buffer        Pointer to buffer to read into\r
-  @param[in,out]  Size          Pointer to number of bytes in buffer\r
-  @param[in]      Truncate      If TRUE then allows for truncation of the line to fit.\r
-                                If FALSE will reset the position to the begining of the \r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be \r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]      Handle        FileHandle to read from\r
+  @param[in,out]  Buffer        pointer to buffer to read into\r
+  @param[in,out]  Size          pointer to number of bytes in buffer\r
+  @param[in]      Truncate      if TRUE then allows for truncation of the line to fit.\r
+                                if FALSE will reset the position to the begining of the \r
                                 line if the buffer is not large enough.\r
+  @param[in,out]  Ascii         Boolean value for indicating whether the file is \r
+                                Ascii (TRUE) or UCS2 (FALSE);\r
 \r
-  @retval EFI_SUCCESS           The operation was sucessful.  the line is stored in \r
-                                Buffer.  (Size was NOT updated)\r
+  @retval EFI_SUCCESS           the operation was sucessful.  the line is stored in \r
+                                Buffer.\r
   @retval EFI_INVALID_PARAMETER Handle was NULL.\r
-  @retval EFI_INVALID_PARAMETER Buffer was NULL.\r
   @retval EFI_INVALID_PARAMETER Size was NULL.\r
   @retval EFI_BUFFER_TOO_SMALL  Size was not enough space to store the line.  \r
                                 Size was updated to minimum space required.\r
@@ -368,7 +381,29 @@ FileHandleReadLine(
   IN EFI_FILE_HANDLE            Handle,\r
   IN OUT CHAR16                 *Buffer,\r
   IN OUT UINTN                  *Size,\r
-  IN BOOLEAN                    Truncate\r
+  IN BOOLEAN                    Truncate,\r
+  IN OUT BOOLEAN                *Ascii\r
+  );\r
+\r
+/**\r
+  Function to read a single line from a file. The \n is not included in the returned \r
+  buffer.  The returned buffer must be callee freed.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be \r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]      Handle        FileHandle to read from.\r
+  @param[in,out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
+\r
+  @return                       The line of text from the file.\r
+\r
+  @sa FileHandleReadLine\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FileHandleReturnLine(\r
+  IN EFI_FILE_HANDLE            Handle,\r
+  IN OUT BOOLEAN                *Ascii\r
   );\r
 \r
 /**\r
@@ -417,6 +452,8 @@ FileHandlePrintLine(
 \r
   This will NOT work on directories.\r
 \r
+  If Handle is NULL, then ASSERT.\r
+\r
   @param[in] Handle     the file handle\r
 \r
   @retval TRUE          the position is at the end of the file\r
@@ -427,3 +464,6 @@ EFIAPI
 FileHandleEof(\r
   IN EFI_FILE_HANDLE Handle\r
   );\r
+\r
+#endif //_FILE_HANDLE_LIBRARY_HEADER_\r
+\r
index fd46c7f43fb31165e0ae95364f613ca7266f6030..ecab001d4fac5dfb94ace43188639d1e887daf39 100644 (file)
@@ -1,22 +1,28 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-All rights reserved. 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
+  Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
+  All rights reserved. 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
+  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
 \r
 **/\r
 \r
 #if !defined(__SHELL_LIB__)\r
 #define __SHELL_LIB__\r
 \r
+#include <Uefi.h>\r
+#include <Guid/FileInfo.h>\r
 #include <Protocol/SimpleFileSystem.h>\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
 \r
 /**\r
   This function will retrieve the information about the file for the handle \r
@@ -69,12 +75,12 @@ ShellSetFileInfo (
   This function opens a file with the open mode according to the file path. The \r
   Attributes is valid only for EFI_FILE_MODE_CREATE.\r
 \r
-  @param[in]  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
+  @param[in]  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
 \r
   @retval EFI_SUCCESS                  The information was set.\r
   @retval EFI_INVALID_PARAMETER        One of the parameters has an invalid value.\r
@@ -617,6 +623,29 @@ ShellFindFilePath (
   IN CONST CHAR16 *FileName\r
   );\r
 \r
+/**\r
+  Find a file by searching the CWD and then the path with a variable set of file \r
+  extensions.  If the file is not found it will append each extension in the list \r
+  in the order provided and return the first one that is successful.\r
+\r
+  If FileName is NULL, then ASSERT.\r
+  If FileExtension is NULL, then behavior is identical to ShellFindFilePath.\r
+\r
+  If the return value is not NULL then the memory must be caller freed.\r
+\r
+  @param[in] FileName           Filename string.\r
+  @param[in] FileExtension      Semi-colon delimeted list of possible extensions.\r
+\r
+  @retval NULL                  The file was not found.\r
+  @retval !NULL                 The path to the file.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ShellFindFilePathEx (\r
+  IN CONST CHAR16 *FileName,\r
+  IN CONST CHAR16 *FileExtension\r
+  );\r
+\r
 typedef enum {\r
   TypeFlag  = 0,    ///< A flag that is present or not present only (IE "-a").\r
   TypeValue,        ///< A flag that has some data following it with a space (IE "-a 1").\r
@@ -901,6 +930,8 @@ ShellIsDirectory(
 /**\r
   Function to determine if a given filename represents a file.\r
 \r
+  This will search the CWD only.\r
+\r
   If Name is NULL, then ASSERT.\r
 \r
   @param[in] Name         Path to file to test.\r
@@ -915,6 +946,25 @@ ShellIsFile(
   IN CONST CHAR16 *Name\r
   );\r
 \r
+/**\r
+  Function to determine if a given filename represents a file.\r
+\r
+  This will search the CWD and then the Path.\r
+\r
+  If Name is NULL, then ASSERT.\r
+\r
+  @param[in] Name         Path to file to test.\r
+\r
+  @retval EFI_SUCCESS     The Path represents a file.\r
+  @retval EFI_NOT_FOUND   The Path does not represent a file.\r
+  @retval other           The path failed to open.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellIsFileInPath(\r
+  IN CONST CHAR16 *Name\r
+  );\r
+\r
 /**\r
   Function to determine whether a string is decimal or hex representation of a number \r
   and return the number converted from the string.\r
@@ -970,4 +1020,58 @@ StrnCatGrow (
   IN     UINTN            Count\r
   );\r
 \r
+/**\r
+  This is a find and replace function.  Upon successful return the NewString is a copy of \r
+  SourceString with each instance of FindTarget replaced with ReplaceWith.\r
+\r
+  If SourceString and NewString overlap the behavior is undefined.\r
+\r
+  If the string would grow bigger than NewSize it will halt and return error.\r
+\r
+  @param[in] SourceString             String with source buffer.\r
+  @param[in,out] NewString            String with resultant buffer.\r
+  @param[in] NewSize                  Size in bytes of NewString.\r
+  @param[in] FindTarget               String to look for.\r
+  @param[in] ReplaceWith              String to replace FindTarget with.\r
+\r
+  @retval EFI_INVALID_PARAMETER       SourceString was NULL.\r
+  @retval EFI_INVALID_PARAMETER       NewString was NULL.\r
+  @retval EFI_INVALID_PARAMETER       FindTarget was NULL.\r
+  @retval EFI_INVALID_PARAMETER       ReplaceWith was NULL.\r
+  @retval EFI_INVALID_PARAMETER       FindTarget had length < 1.\r
+  @retval EFI_INVALID_PARAMETER       SourceString had length < 1.\r
+  @retval EFI_BUFFER_TOO_SMALL        NewSize was less than the minimum size to hold \r
+                                      the new string (truncation occurred).\r
+  @retval EFI_SUCCESS                 the string was sucessfully copied with replacement.\r
+**/\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+ShellLibCopySearchAndReplace(\r
+  IN CHAR16 CONST                     *SourceString,\r
+  IN CHAR16                           *NewString,\r
+  IN UINTN                            NewSize,\r
+  IN CONST CHAR16                     *FindTarget,\r
+  IN CONST CHAR16                     *ReplaceWith\r
+  );\r
+\r
+/**\r
+  Check if a Unicode character is a hexadecimal character.\r
+\r
+  This internal function checks if a Unicode character is a \r
+  decimal character.  The valid hexadecimal character is \r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+  @param[in]  Char  The character to check.\r
+\r
+  @retval TRUE      The Char is a hexadecmial character.\r
+  @retval FALSE     The Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellLibIsHexaDecimalDigitCharacter (\r
+  IN      CHAR16                    Char\r
+  );\r
+\r
 #endif // __SHELL_LIB__\r
index e213b7a40e569f10e188ac13f3230eb4007d0ade..1ae47a7d994bfe659d716e47d235eab424ab6dff 100644 (file)
@@ -28,8 +28,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 typedef\r
 INTN\r
 (EFIAPI *SORT_COMPARE)(\r
-  IN VOID           *Buffer1,\r
-  IN VOID           *Buffer2\r
+  IN CONST VOID                 *Buffer1,\r
+  IN CONST VOID                 *Buffer2\r
   );\r
 \r
 /**\r
@@ -53,10 +53,10 @@ INTN
 VOID\r
 EFIAPI\r
 PerformQuickSort (\r
-  IN OUT VOID                           *BufferToSort,\r
-  IN CONST UINTN                        Count,\r
-  IN CONST UINTN                        ElementSize,\r
-  IN       SORT_COMPARE                 CompareFunction\r
+  IN OUT VOID                   *BufferToSort,\r
+  IN CONST UINTN                Count,\r
+  IN CONST UINTN                ElementSize,\r
+  IN       SORT_COMPARE         CompareFunction\r
   );\r
 \r
 \r
@@ -73,8 +73,8 @@ PerformQuickSort (
 INTN\r
 EFIAPI\r
 DevicePathCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
   );\r
 \r
 /**\r
@@ -90,8 +90,8 @@ DevicePathCompare (
 INTN\r
 EFIAPI\r
 StringNoCaseCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID                *Buffer1,\r
+  IN  CONST VOID                *Buffer2\r
   );\r
 \r
 #endif //__SORT_LIB_H__\r
index a0161b8accea00e6a09d5a2803132b2ea5be14de..ea06f8de96c6b1f8573e55128d9ad9d44d73c7ac 100644 (file)
@@ -1,36 +1,31 @@
 /** @file\r
   Defines for EFI shell environment 2 ported to EDK II build environment. (no spec)\r
 \r
-Copyright (c) 2005 - 2009, Intel Corporation<BR>\r
-All rights reserved. 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
+  Copyright (c) 2005 - 2010, Intel Corporation<BR>\r
+  All rights reserved. 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
+  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
 \r
 **/\r
 \r
   \r
-#ifndef _SHELLENV2_H_\r
-#define _SHELLENV2_H_\r
-\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/SimpleTextOut.h>\r
-#include <Protocol/EfiShellInterface.h>\r
+#if !defined (_SHELL_ENVIRONMENT_2_PROTOCOL_H_)\r
+#define _SHELL_ENVIRONMENT_2_PROTOCOL_H_\r
 \r
 #define DEFAULT_INIT_ROW    1\r
 #define DEFAULT_AUTO_LF     FALSE\r
 \r
-\r
 /**\r
   This function is a prototype for a function that dumps information on a protocol \r
   to a given location.  The location is dependant on the implementation.  This is \r
   used when programatically adding shell commands.\r
 \r
-  @param Handle                 the handle the protocol is on\r
-  @param Interface              the interface to the protocol\r
+  @param Handle                 The handle the protocol is on.\r
+  @param Interface              The interface to the protocol.\r
 \r
 **/\r
 typedef\r
@@ -68,7 +63,7 @@ EFI_STATUS
 \r
   @param Str                      Pointer to pointer to string to display for help.\r
 \r
-  @retval EFI_SUCCESS             Phe help string is in the parameter Str.\r
+  @retval EFI_SUCCESS             The help string is in the parameter Str.\r
 \r
 **/\r
 typedef\r
@@ -101,7 +96,7 @@ typedef struct {
 #define SHELL_FILE_ARG_SIGNATURE  SIGNATURE_32 ('g', 'r', 'a', 'f') \r
 \r
 /**\r
-*  GUID for the shell environment2 and shell environment\r
+GUID for the shell environment2 and shell environment.\r
 **/\r
 #define SHELL_ENVIRONMENT_PROTOCOL_GUID \\r
   { \\r
@@ -109,7 +104,7 @@ typedef struct {
   }\r
 \r
 /**\r
-*  GUID for the shell environment2 extension (main GUID same as shell environment).\r
+GUID for the shell environment2 extension (main GUID above).\r
 **/\r
 #define EFI_SE_EXT_SIGNATURE_GUID \\r
   { \\r
@@ -127,7 +122,7 @@ typedef struct {
   encountered directly to the screen.\r
   \r
   @param ParentImageHandle      Handle of image executing this operation.\r
-  @param CommandLine            string command line to execute.\r
+  @param CommandLine            The string command line to execute.\r
   @param DebugOutput            TRUE indicates that errors should be printed directly.\r
                                 FALSE supresses error messages.\r
 \r
@@ -147,13 +142,13 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this function returns a shell environment variable value.\r
+  This function returns a shell environment variable value.\r
 \r
-  @param Name                   pointer to the string with the shell environment \r
-                                variables name\r
+  @param Name                   Pointer to the string with the shell environment \r
+                                variable name.\r
 \r
-  @retval NULL                  the shell environment variable's value could not be found\r
-  @retval !NULL                 the value of the shell environment variable Name\r
+  @retval NULL                  The shell environment variable's value could not be found.\r
+  @retval !NULL                 The value of the shell environment variable Name.\r
 \r
 **/\r
 typedef \r
@@ -163,13 +158,13 @@ CHAR16 *
   );\r
 \r
 /**\r
-  this function returns a shell environment map value.\r
+  This function returns a shell environment map value.\r
 \r
-  @param Name                   pointer to the string with the shell environment \r
-                                map name\r
+  @param Name                   Pointer to the string with the shell environment \r
+                                map name.\r
 \r
-  @retval NULL                  the shell environment map's value could not be found\r
-  @retval !NULL                 the value of the shell environment map Name\r
+  @retval NULL                  The shell environment map's value could not be found.\r
+  @retval !NULL                 The value of the shell environment map Name.\r
 \r
 **/\r
 typedef \r
@@ -184,12 +179,12 @@ CHAR16 *
   This will allocate all required memory, put the new command on the command\r
   list in the correct location.\r
 \r
-  @param Handler                the handler function to call when the command gets called\r
-  @param CmdStr                 The command name\r
-  @param GetLineHelp            function to call of get help for this command\r
+  @param Handler                The handler function to call when the command gets called.\r
+  @param CmdStr                 The command name.\r
+  @param GetLineHelp            Function to call of get help for this command.\r
 \r
-  @retval EFI_SUCCESS           the command is now part of the command list\r
-  @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
+  @retval EFI_SUCCESS           The command is now part of the command list.\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
   @sa SHELLENV_INTERNAL_COMMAND\r
   @sa SHELLCMD_GET_LINE_HELP\r
 **/\r
@@ -208,13 +203,13 @@ EFI_STATUS
   This will get the current protocol info and add the new info or update existing info\r
   and then resave the info.\r
 \r
-  @param SaveId                 save this change as an EFI variable\r
-  @param Protocol               the protocol's GUID\r
+  @param SaveId                 Save this change as an EFI variable.\r
+  @param Protocol               The protocol's GUID.\r
   @param DumpToken              The function pointer to dump token function or \r
-                                NULL\r
+                                NULL.\r
   @param DumpInfo               The function pointer to dump infomation function \r
-                                or NULL\r
-  @param IdString               The english name of the protocol\r
+                                or NULL.\r
+  @param IdString               The english name of the protocol.\r
 **/\r
 typedef\r
 VOID\r
@@ -226,17 +221,17 @@ VOID
   );\r
 \r
 /**\r
-  this function finds a protocol handle by a GUID.  \r
+  This function finds a protocol handle by a GUID.  \r
 \r
   This function will check for already known protocols by GUID and if one is \r
-  found it will return the name of that protocol.  if no name is found and \r
+  found it will return the name of that protocol.  If no name is found and \r
   GenId is TRUE it will generate ths string.\r
 \r
-  @param Protocol               the GUID of the protocol to look for.\r
-  @param GenId                  whether to generate a name string if its not found.\r
+  @param Protocol               The GUID of the protocol to look for.\r
+  @param GenId                  Whether to generate a name string if its not found.\r
 \r
-  @return !NULL                 the Name of the protocol.\r
-  @retval NULL                  the Name was not found and GenId was not TRUE.\r
+  @return !NULL                 The Name of the protocol.\r
+  @retval NULL                  The Name was not found and GenId was not TRUE.\r
 **/\r
 typedef \r
 CHAR16*\r
@@ -246,15 +241,15 @@ CHAR16*
   );\r
 \r
 /**\r
-  this function returns the current directory on a given device\r
+  This function returns the current directory on a given device.\r
 \r
   If DeviceName is specified, then return the current shell directory on that \r
   device.  If DeviceName is NULL, then return the current directory on the \r
   current device.  The caller us responsible to free the returned string when\r
   no londer required.\r
 \r
-  @param DeviceName             the name of the device to get the current \r
-                                directory on or NULL for current device\r
+  @param DeviceName             The name of the device to get the current \r
+                                directory on or NULL for current device.\r
 \r
   @return The current directory on the current or specified device.\r
 \r
@@ -266,23 +261,23 @@ CHAR16*
   );\r
 \r
 /**\r
-  this function will open a group of files that match the Arg path, including \r
-  support for wildcard characters ('?' and '*') in the Arg path.  if there are \r
+  This function will open a group of files that match the Arg path, including \r
+  support for wildcard characters ('?' and '*') in the Arg path.  If there are \r
   any wildcard characters in the path this function will find any and all files\r
-  that match the wildcards.  the return is a double linked list based on the \r
-  LIST_ENTRY linked list structure.  use this in conjunction with the \r
+  that match the wildcards.  The return is a double linked list based on the \r
+  LIST_ENTRY linked list structure.  Use this in conjunction with the \r
   SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
   The memory allocated by the callee for this list is freed by making a call to \r
   SHELLENV_FREE_FILE_LIST.\r
 \r
-  @param Arg                    pointer Path to files to open\r
-  @param ListHead               pointer to allocated and initialized list head \r
+  @param Arg                    Pointer Path to files to open.\r
+  @param ListHead               Pointer to allocated and initialized list head \r
                                 upon which to append all the opened file structures.\r
 \r
   @retval EFI_SUCCESS           1 or more files was opened and a struct of each file's\r
                                 information was appended to ListHead.\r
-  @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
-  @retval EFI_NOT_FOUND         no matching files could be found.\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+  @retval EFI_NOT_FOUND         No matching files could be found.\r
   @sa SHELLENV_FREE_FILE_LIST\r
 **/typedef\r
 EFI_STATUS\r
@@ -292,7 +287,7 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this frees all of the nodes under the ListHead, but not ListHead itself.\r
+  This frees all of the nodes under the ListHead, but not ListHead itself.\r
 \r
   @param ListHead               Pointer to list to free all nodes of.\r
 \r
@@ -305,14 +300,14 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this function creates a new instance of the ShellInterface protocol for use on \r
+  This function creates a new instance of the ShellInterface protocol for use on \r
   the ImageHandle.\r
 \r
-  This function is for internal shell usage.  this will allocate and then populate \r
-  EFI_SHELL_INTERFACE protocol.  it is the caller's responsibility to free the \r
+  This function is for internal shell usage.  This will allocate and then populate \r
+  EFI_SHELL_INTERFACE protocol.  It is the caller's responsibility to free the \r
   memory.\r
 \r
-  @param ImageHandle            the handle which will use the new ShellInterface \r
+  @param ImageHandle            The handle which will use the new ShellInterface \r
                                 protocol.\r
 \r
   @return the newly allocated shell interface protocol.\r
@@ -325,14 +320,14 @@ EFI_SHELL_INTERFACE*
   );\r
 \r
 /**\r
-  this function determins whether a script file is currently being processed.\r
+  This function determins whether a script file is currently being processed.\r
 \r
-  a script file (.nsh file) can contain a series of commands and this is useful to \r
+  A script file (.nsh file) can contain a series of commands and this is useful to \r
   know for some shell commands whether they are being run manually or as part of a \r
   script.\r
 \r
-  @retval TRUE                  A script file is being processed\r
-  @return FALSE                 A script file is not being processed\r
+  @retval TRUE                  A script file is being processed.\r
+  @retval FALSE                 A script file is not being processed.\r
 **/\r
 typedef\r
 BOOLEAN\r
@@ -354,12 +349,12 @@ VOID
   This function enables the page break mode.\r
 \r
   This mode causes the output to pause after each complete screen to enable a \r
-  user to more easily read it.  if AutoWrap is TRUE then rows with too many \r
-  characters will be chopped and divided into 2 rows.  if FALSE then rows with \r
+  user to more easily read it.  If AutoWrap is TRUE then rows with too many \r
+  characters will be chopped and divided into 2 rows.  If FALSE then rows with \r
   too many characters may not be fully visible to the user on the screen.\r
 \r
-  @param StartRow               the row number to start this on.\r
-  @param AutoWrap               whether to auto wrap rows that are \r
+  @param StartRow               The row number to start this on.\r
+  @param AutoWrap               Whether to auto wrap rows that are too long.\r
 **/\r
 typedef\r
 VOID\r
@@ -371,7 +366,7 @@ VOID
 /**\r
   This function disables the page break mode.\r
 \r
-  disabling this causes the output to print out exactly as coded with no breaks \r
+  Tisabling this causes the output to print out exactly as coded with no breaks \r
   for readability.\r
 **/\r
 typedef\r
@@ -383,8 +378,8 @@ VOID
 /**\r
   Get the status of the page break output mode.\r
 \r
-  @retval FALSE                 page break output mode is not enabled\r
-  @retval TRUE                  page break output mode is enabled\r
+  @retval FALSE                 Page break output mode is not enabled.\r
+  @retval TRUE                  Page break output mode is enabled.\r
 **/\r
 typedef\r
 BOOLEAN\r
@@ -393,7 +388,7 @@ BOOLEAN
   );\r
 \r
 /**\r
-  this function sets the keys to filter for for the console in.  the valid \r
+  This function sets the keys to filter for for the console in.  The valid \r
   values to set are:\r
 \r
   #define EFI_OUTPUT_SCROLL   0x00000001\r
@@ -409,9 +404,9 @@ VOID
   );\r
 \r
 /**\r
-  this function gets the keys to filter for for the console in.  the valid \r
-  values to get are:\r
+  This function gets the keys to filter for for the console in.  \r
 \r
+  The valid values to get are:\r
   #define EFI_OUTPUT_SCROLL   0x00000001\r
   #define EFI_OUTPUT_PAUSE    0x00000002\r
   #define EFI_EXECUTION_BREAK 0x00000004\r
@@ -425,14 +420,14 @@ UINT32
   );\r
 \r
 /**\r
-  this function determins if the shell application should break.\r
+  This function determins if the shell application should break.\r
 \r
   This is used to inform a shell application that a break condition has been \r
-  initiated.  long loops should check this to prevent delays to the break.\r
+  initiated.  Long loops should check this to prevent delays to the break.\r
 \r
-  @retval TRUE                  a break has been signaled.  the application   \r
+  @retval TRUE                  A break has been signaled.  the application   \r
                                 should exit with EFI_ABORTED as soon as possible.\r
-  @retval FALSE                 continue as normal.\r
+  @retval FALSE                 Continue as normal.\r
 **/\r
 typedef\r
 BOOLEAN\r
@@ -460,10 +455,10 @@ VOID
   );\r
 \r
 /**\r
-  this function determins if the caller is running under the root shell.\r
+  This function determins if the caller is running under the root shell.\r
 \r
-  @retval TRUE                  The caller is running under the root shell\r
-  @retval FALSE                 The caller is not running under the root shell\r
+  @retval TRUE                  The caller is running under the root shell.\r
+  @retval FALSE                 The caller is not running under the root shell.\r
 \r
 **/\r
 typedef\r
@@ -475,14 +470,14 @@ BOOLEAN
 /**\r
   Close the console proxy to restore the original console.\r
 \r
-  This is an internal shell function to handle shell cascading.  it restores the \r
+  This is an internal shell function to handle shell cascading.  It restores the \r
   original set of console protocols.\r
   \r
   @param ConInHandle            The handle of ConIn.\r
-  @param ConIn                  pointer to the location to return the pointer to \r
+  @param ConIn                  Pointer to the location to return the pointer to \r
                                 the original console input.\r
   @param ConOutHandle           The handle of ConOut\r
-  @param ConOut                 pointer to the location to return the pointer to \r
+  @param ConOut                 Pointer to the location to return the pointer to \r
                                 the original console output.\r
 **/\r
 typedef\r
@@ -509,19 +504,19 @@ VOID
   );\r
 \r
 /**\r
-  this is an internal shell function to enumerate the handle database.\r
+  This is an internal shell function to enumerate the handle database.\r
 \r
-  this function gets the next handle in the handle database.  if no handles are \r
-  found EFI_NOT_FOUND is returned.  if the previous Handle was the last handle \r
+  This function gets the next handle in the handle database.  If no handles are \r
+  found EFI_NOT_FOUND is returned.  If the previous Handle was the last handle \r
   it is set to NULL before returning.\r
 \r
-  this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+  This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
 \r
-  @param Handle                 pointer to pointer to Handle.  will be set\r
+  @param Handle                 Pointer to pointer to Handle.  Will be set\r
                                 on a sucessful return.\r
 \r
-  @retval EFI_SUCCESS           the next handle in the handle database is *Handle\r
-  @retval EFI_NOT_FOUND         there is not another handle.\r
+  @retval EFI_SUCCESS           The next handle in the handle database is *Handle.\r
+  @retval EFI_NOT_FOUND         There is not another handle.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -530,13 +525,13 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this is an internal shell function to enumerate the handle database.\r
+  This is an internal shell function to enumerate the handle database.\r
 \r
-  this function skips the next SkipNum handles in the handle database.  If there \r
+  This function skips the next SkipNum handles in the handle database.  If there \r
   are not enough handles left to skip that many EFI_ACCESS_DENIED is returned and \r
   no skip is performed.\r
 \r
-  this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+  This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
 \r
   @param SkipNum                how many handles to skip\r
 \r
@@ -550,16 +545,16 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this is an internal shell function to enumerate the handle database.\r
+  This is an internal shell function to enumerate the handle database.\r
 \r
-  this function resets the the handle database so that NEXT_HANDLE and SKIP_HANDLE \r
+  This function resets the the handle database so that NEXT_HANDLE and SKIP_HANDLE \r
   will start from EnumIndex on the next call. \r
   \r
-  this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+  This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
 \r
-  @param EnumIndex              where to start.\r
+  @param EnumIndex              Where to start.\r
 \r
-  @retval the number of handles either read out or skipped before this reset.\r
+  @return the number of handles either read out or skipped before this reset.\r
 **/\r
 typedef\r
 UINTN\r
@@ -568,12 +563,12 @@ UINTN
   );\r
 \r
 /**\r
-  this is an internal shell function to enumerate the handle database.\r
+  This is an internal shell function to enumerate the handle database.\r
   \r
-  this must be called after INIT_HANDLE_ENUMERATOR.\r
+  This must be called after INIT_HANDLE_ENUMERATOR.\r
 \r
-  this function releases all memory and resources associated with the handle database.\r
-  after this no other handle enumerator functions except INIT_HANDLE_ENUMERATOR will \r
+  This function releases all memory and resources associated with the handle database.\r
+  Tfter this no other handle enumerator functions except INIT_HANDLE_ENUMERATOR will \r
   function properly.\r
 **/\r
 typedef\r
@@ -583,13 +578,13 @@ VOID
   );\r
 \r
 /**\r
-  this is an internal shell function to enumerate the handle database.\r
+  This is an internal shell function to enumerate the handle database.\r
 \r
-  this function returns the number of handles in the handle database.\r
+  This function returns the number of handles in the handle database.\r
   \r
-  this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+  This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
 \r
-  @retval the number of handles in the handle database.\r
+  @return the number of handles in the handle database.\r
 **/\r
 typedef\r
 UINTN\r
@@ -598,49 +593,50 @@ UINTN
   );\r
 \r
 /**\r
-Handle Enumerator structure\r
+Handle Enumerator structure.\r
 **/\r
 typedef struct {\r
-  INIT_HANDLE_ENUMERATOR  Init;   ///< pointer to INIT_HANDLE_ENUMERATOR function\r
-  NEXT_HANDLE             Next;   ///< pointer to NEXT_HANDLE function\r
-  SKIP_HANDLE             Skip;   ///< pointer to SKIP_HANDLE function\r
-  RESET_HANDLE_ENUMERATOR Reset;  ///< pointer to RESET_HANDLE_ENUMERATOR function\r
-  CLOSE_HANDLE_ENUMERATOR Close;  ///< pointer to CLOSE_HANDLE_ENUMERATOR function\r
-  GET_NUM                 GetNum; ///< pointer to GET_NUM function\r
+  INIT_HANDLE_ENUMERATOR  Init;   ///< Pointer to INIT_HANDLE_ENUMERATOR function.\r
+  NEXT_HANDLE             Next;   ///< Pointer to NEXT_HANDLE function.\r
+  SKIP_HANDLE             Skip;   ///< Pointer to SKIP_HANDLE function.\r
+  RESET_HANDLE_ENUMERATOR Reset;  ///< Pointer to RESET_HANDLE_ENUMERATOR function.\r
+  CLOSE_HANDLE_ENUMERATOR Close;  ///< Pointer to CLOSE_HANDLE_ENUMERATOR function.\r
+  GET_NUM                 GetNum; ///< Pointer to GET_NUM function.\r
 } HANDLE_ENUMERATOR;\r
+\r
 /**\r
-  signature for the PROTOCOL_INFO structure \r
+  Signature for the PROTOCOL_INFO structure.\r
 **/\r
 #define PROTOCOL_INFO_SIGNATURE SIGNATURE_32 ('s', 'p', 'i', 'n')\r
+\r
 /**\r
   PROTOCOL_INFO structure for protocol enumerator functions.\r
-\r
 **/\r
 typedef struct {\r
-  UINTN                       Signature;   ///< PROTOCOL_INFO_SIGNATURE \r
-  LIST_ENTRY                  Link;        ///< standard lined list helper member\r
+  UINTN                       Signature;   ///< PROTOCOL_INFO_SIGNATURE.\r
+  LIST_ENTRY                  Link;        ///< Standard lined list helper member.\r
   //\r
-  // parsing info for the protocol\r
+  // The parsing info for the protocol.\r
   //\r
-  EFI_GUID                    ProtocolId;  ///< GUID for the protocol\r
-  CHAR16                      *IdString;   ///< Name of the protocol\r
-  SHELLENV_DUMP_PROTOCOL_INFO DumpToken;   ///< pointer to DumpToken function for the protocol\r
-  SHELLENV_DUMP_PROTOCOL_INFO DumpInfo;    ///< pointer to DumpInfo function for the protocol\r
+  EFI_GUID                    ProtocolId;  ///< GUID for the protocol.\r
+  CHAR16                      *IdString;   ///< Name of the protocol.\r
+  SHELLENV_DUMP_PROTOCOL_INFO DumpToken;   ///< Pointer to DumpToken function for the protocol.\r
+  SHELLENV_DUMP_PROTOCOL_INFO DumpInfo;    ///< Pointer to DumpInfo function for the protocol.\r
   //\r
-  // database info on which handles are supporting this protocol\r
+  // Patabase info on which handles are supporting this protocol.\r
   //\r
-  UINTN                       NoHandles;   ///< how many handles produce this protocol\r
-  EFI_HANDLE                  *Handles;    ///< array of handles\r
+  UINTN                       NoHandles;   ///< How many handles produce this protocol.\r
+  EFI_HANDLE                  *Handles;    ///< The array of handles.\r
 \r
 } PROTOCOL_INFO;\r
 \r
 //\r
-// declarations of protocol info enumerator\r
+// Declarations of protocol info enumerator.\r
 //\r
 /**\r
-  this is an internal shell function to initialize the protocol enumerator.\r
+  This is an internal shell function to initialize the protocol enumerator.\r
 \r
-  this must be called before NEXT_PROTOCOL_INFO, SKIP_PROTOCOL_INFO, \r
+  This must be called before NEXT_PROTOCOL_INFO, SKIP_PROTOCOL_INFO, \r
   RESET_PROTOCOL_INFO_ENUMERATOR, and CLOSE_PROTOCOL_INFO_ENUMERATOR are\r
   called.\r
 **/\r
@@ -651,7 +647,7 @@ VOID
   );\r
 \r
 /**\r
-  this function is an internal shell function for enumeration of protocols.  \r
+  This function is an internal shell function for enumeration of protocols.  \r
 \r
   This functiol will return the next protocol in the list.  If this is called \r
   immediately after initialization it will return the first.  If this is called\r
@@ -660,10 +656,10 @@ VOID
   This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
   called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
 \r
-  @param ProtocolInfo           pointer to pointer to protocol information structure.\r
+  @param ProtocolInfo           Pointer to pointer to protocol information structure.\r
 \r
-  @retval EFI_SUCCESS           the next protocol's information was sucessfully returned.  \r
-                                If there were no more protocols NULL was returned.\r
+  @retval EFI_SUCCESS           The next protocol's information was sucessfully returned.\r
+  @retval NULL                  There are no more protocols.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -672,14 +668,14 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this function is an internal shell function for enumeration of protocols.  \r
+  This function is an internal shell function for enumeration of protocols.  \r
 \r
   This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
   called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
 \r
-  this function does nothing and always returns EFI_SUCCESS.\r
+  This function does nothing and always returns EFI_SUCCESS.\r
 \r
-  @retval EFI_SUCCESS           always returned (see note).\r
+  @retval EFI_SUCCESS           always returned (see above).\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -688,12 +684,12 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this function is an internal shell function for enumeration of protocols.  \r
+  This function is an internal shell function for enumeration of protocols.  \r
 \r
   This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
   called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
 \r
-  this function resets the list of protocols such that the next one in the \r
+  This function resets the list of protocols such that the next one in the \r
   list is the begining of the list.\r
 **/\r
 typedef\r
@@ -704,12 +700,12 @@ VOID
 \r
 \r
 /**\r
-  this function is an internal shell function for enumeration of protocols.  \r
+  This function is an internal shell function for enumeration of protocols.  \r
 \r
   This must be called after INIT_PROTOCOL_INFO_ENUMERATOR.  After this call\r
   no protocol enumerator calls except INIT_PROTOCOL_INFO_ENUMERATOR may be made.\r
 \r
-  this function frees any memory or resources associated with the protocol\r
+  This function frees any memory or resources associated with the protocol\r
   enumerator.\r
 **/\r
 typedef\r
@@ -719,18 +715,18 @@ VOID
   );\r
 \r
 /**\r
-*  protocol enumerator structure of function pointers.\r
+  Protocol enumerator structure of function pointers.\r
 **/\r
 typedef struct {\r
-  INIT_PROTOCOL_INFO_ENUMERATOR   Init;   ///< pointer to INIT_PROTOCOL_INFO_ENUMERATOR function\r
-  NEXT_PROTOCOL_INFO              Next;   ///< pointer to NEXT_PROTOCOL_INFO function\r
-  SKIP_PROTOCOL_INFO              Skip;   ///< pointer to SKIP_PROTOCOL_INFO function\r
-  RESET_PROTOCOL_INFO_ENUMERATOR  Reset;  ///< pointer to RESET_PROTOCOL_INFO_ENUMERATOR function\r
-  CLOSE_PROTOCOL_INFO_ENUMERATOR  Close;  ///< pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function\r
+  INIT_PROTOCOL_INFO_ENUMERATOR   Init;   ///< Pointer to INIT_PROTOCOL_INFO_ENUMERATOR function.\r
+  NEXT_PROTOCOL_INFO              Next;   ///< Pointer to NEXT_PROTOCOL_INFO function.\r
+  SKIP_PROTOCOL_INFO              Skip;   ///< Pointer to SKIP_PROTOCOL_INFO function.\r
+  RESET_PROTOCOL_INFO_ENUMERATOR  Reset;  ///< Pointer to RESET_PROTOCOL_INFO_ENUMERATOR function.\r
+  CLOSE_PROTOCOL_INFO_ENUMERATOR  Close;  ///< Pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function.\r
 } PROTOCOL_INFO_ENUMERATOR;\r
 \r
 /**\r
-  this function is used to retrieve a user-friendly display name for a handle.  \r
+  This function is used to retrieve a user-friendly display name for a handle.  \r
 \r
   If UseComponentName is TRUE then the component name protocol for this device \r
   or it's parent device (if required) will be used to obtain the name of the \r
@@ -748,17 +744,17 @@ typedef struct {
   \r
   Upon sucessful return the memory for *BestDeviceName is up to the caller to free.\r
 \r
-  @param DeviceHandle           the device handle whose name is desired\r
-  @param UseComponentName       whether to use the ComponentName protocol at all\r
-  @param UseDevicePath          whether to use the DevicePath protocol at all\r
-  @param Language               pointer to language string to use\r
-  @param BestDeviceName         pointer to pointer to string allocated with the name\r
-  @param ConfigurationStatus    pointer to status for opening a Configuration protocol\r
-  @param DiagnosticsStatus      pointer to status for opening a Diagnostics protocol\r
-  @param Display                Whether to Print this out to default Print location\r
-  @param Indent                 how many characters to indent the printing\r
+  @param DeviceHandle           The device handle whose name is desired.\r
+  @param UseComponentName       Whether to use the ComponentName protocol at all.\r
+  @param UseDevicePath          Whether to use the DevicePath protocol at all.\r
+  @param Language               Pointer to language string to use.\r
+  @param BestDeviceName         Pointer to pointer to string allocated with the name.\r
+  @param ConfigurationStatus    Pointer to status for opening a Configuration protocol.\r
+  @param DiagnosticsStatus      Pointer to status for opening a Diagnostics protocol.\r
+  @param Display                Whether to Print this out to default Print location.\r
+  @param Indent                 How many characters to indent the printing.\r
 \r
-  @retval EFI_SUCCESS           this function always returns EFI_SUCCESS\r
+  @retval EFI_SUCCESS           This function always returns EFI_SUCCESS.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -778,13 +774,13 @@ EFI_STATUS
 #define EFI_SHELL_ENHANCED_MODE_VER   L"1.1.2" ///< string for highest version this shell supports\r
 \r
 /**\r
-  this function gets the shell mode as stored in the shell environment \r
-  "efishellmode".  it will not fail.\r
+  This function gets the shell mode as stored in the shell environment \r
+  "efishellmode".  It will not fail.\r
 \r
-  @param Mode                   returns a string representing one of the \r
+  @param Mode                   Returns a string representing one of the \r
                                 2 supported modes of the shell.\r
 \r
-  @retval EFI_SUCCESS           this function always returns success\r
+  @retval EFI_SUCCESS           This function always returns success.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -793,17 +789,17 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  Convert a file system style name to an file path\r
+  Convert a file system style name to a device path.\r
 \r
   This function will convert a shell path name to a Device Path Protocol path.\r
   This function will allocate any required memory for this operation and it \r
   is the responsibility of the caller to free that memory when no longer required.\r
 \r
-  if anything prevents the complete conversion free any allocated memory and \r
+  If anything prevents the complete conversion free any allocated memory and \r
   return NULL.\r
 \r
-  @retval !NULL                 a pointer to the callee allocated Device Path\r
-  @retval NULL                  the operation could not be completed.\r
+  @retval !NULL                 A pointer to the callee allocated Device Path.\r
+  @retval NULL                  The operation could not be completed.\r
 **/\r
 typedef \r
 EFI_DEVICE_PATH_PROTOCOL* \r
@@ -812,25 +808,26 @@ EFI_DEVICE_PATH_PROTOCOL*
   );\r
 \r
 /**\r
-  converts a device path into a file system map name.\r
+  Converts a device path into a file system map name.\r
+\r
+  If DevPath is NULL, then ASSERT.\r
 \r
-  if DevPath is NULL then ASSERT\r
   This function looks through the shell environment map for a map whose device\r
   path matches the DevPath parameter.  If one is found the Name is returned via \r
   Name parameter.  If sucessful the caller must free the memory allocated for\r
   Name.\r
 \r
-  this function will use the internal lock to prevent changes to the map during \r
+  This function will use the internal lock to prevent changes to the map during \r
   the lookup operation.\r
   \r
-  @param DevPath                The device path to search for a name for\r
-  @param ConsistMapping         what state to verify map flag VAR_ID_CONSIST\r
-  @param Name                   on sucessful return the name of that device path\r
+  @param DevPath                The device path to search for a name for.\r
+  @param ConsistMapping         What state to verify map flag VAR_ID_CONSIST.\r
+  @param Name                   On sucessful return the name of that device path.\r
 \r
-  @retval EFI_SUCCESS           the DevPath was found and the name returned\r
+  @retval EFI_SUCCESS           The DevPath was found and the name returned\r
                                 in Name.  \r
   @retval EFI_OUT_OF_RESOURCES  A required memory allocation failed.\r
-  @retval EFI_UNSUPPORTED       the DevPath was not found in the map\r
+  @retval EFI_UNSUPPORTED       The DevPath was not found in the map.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -841,23 +838,23 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this function will open a group of files that match the Arg path, but will not \r
-  support the wildcard characters ('?' and '*') in the Arg path.  if there are \r
+  This function will open a group of files that match the Arg path, but will not \r
+  support the wildcard characters ('?' and '*') in the Arg path.  If there are \r
   any wildcard characters in the path this function will return \r
-  EFI_INVALID_PARAMETER.  the return is a double linked list based on the \r
-  LIST_ENTRY linked list structure.  use this in conjunction with the \r
+  EFI_INVALID_PARAMETER.  The return is a double linked list based on the \r
+  LIST_ENTRY linked list structure.  Use this in conjunction with the \r
   SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
   The memory allocated by the callee for this list is freed by making a call to \r
   SHELLENV_FREE_FILE_LIST.\r
 \r
-  @param Arg                    pointer Path to files to open\r
-  @param ListHead               pointer to allocated and initialized list head \r
+  @param Arg                    Pointer Path to files to open.\r
+  @param ListHead               Pointer to allocated and initialized list head \r
                                 upon which to append all the opened file structures.\r
 \r
   @retval EFI_SUCCESS           1 or more files was opened and a struct of each file's\r
                                 information was appended to ListHead.\r
-  @retval EFI_OUT_OF_RESOURCES  a memory allocation failed.\r
-  @retval EFI_NOT_FOUND         no matching files could be found.\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+  @retval EFI_NOT_FOUND         No matching files could be found.\r
   @sa SHELLENV_FREE_FILE_LIST\r
 **/\r
 typedef\r
@@ -868,18 +865,18 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  this function removes duplicate file listings from lists.\r
+  This function removes duplicate file listings from lists.\r
 \r
-  this is a function for use with SHELLENV_FILE_META_ARG_NO_WILDCARD and \r
-  SHELLENV_FILE_META_ARG.  this function will verify that there are no duplicate\r
-  files in the list of returned files.  any file listed twice will have one of its\r
+  This is a function for use with SHELLENV_FILE_META_ARG_NO_WILDCARD and \r
+  SHELLENV_FILE_META_ARG.  This function will verify that there are no duplicate\r
+  files in the list of returned files.  Any file listed twice will have one of its\r
   instances removed.\r
 \r
-  @param ListHead               pointer to linked list head that was returned from \r
+  @param ListHead               Pointer to linked list head that was returned from \r
                                 SHELLENV_FILE_META_ARG_NO_WILDCARD or\r
                                 SHELLENV_FILE_META_ARG.\r
 \r
-  @retval EFI_SUCCESS           this function always returns success.\r
+  @retval EFI_SUCCESS           This function always returns success.\r
 \r
 **/\r
 typedef\r
@@ -891,24 +888,24 @@ EFI_STATUS
 /**\r
   Converts a File System map name to a device path.\r
 \r
-  if DevPath is NULL then ASSERT()\r
+  if DevPath is NULL, then ASSERT().\r
 \r
   This function looks through the shell environment map for a map whose Name \r
   matches the Name parameter.  If one is found the device path pointer is \r
-  updated to point to that file systems device path.  the caller should not \r
+  updated to point to that file systems device path.  The caller should not \r
   free the memory from that device path.\r
 \r
-  this function will use the internal lock to prevent changes to the map during \r
+  This function will use the internal lock to prevent changes to the map during \r
   the lookup operation.\r
 \r
-  @param Name                   pointer to NULL terminated UNICODE string of the \r
-                                file system name\r
-  @param DevPath                pointer to pointer to DevicePath.  only valid on \r
-                                OUT if sucessful\r
+  @param Name                   Pointer to NULL terminated UNICODE string of the \r
+                                file system name.\r
+  @param DevPath                Pointer to pointer to DevicePath.  only valid on \r
+                                OUT if sucessful.\r
 \r
-  @retval EFI_SUCCESS           the conversion was successful and the device \r
+  @retval EFI_SUCCESS           The conversion was successful and the device \r
                                 path was returned.\r
-  @retval EFI_NOT_FOUND         the file system could not be found in the map.\r
+  @retval EFI_NOT_FOUND         The file system could not be found in the map.\r
 **/\r
 typedef\r
 EFI_STATUS\r
@@ -917,8 +914,7 @@ EFI_STATUS
   OUT EFI_DEVICE_PATH_PROTOCOL     **DevPath\r
   );\r
 \r
-/// EFI_SHELL_ENVIRONMENT2 protocol structure\r
-/// contains pointers to functions\r
+/// EFI_SHELL_ENVIRONMENT2 protocol structure.\r
 typedef struct {\r
   SHELLENV_EXECUTE                        Execute;\r
   SHELLENV_GET_ENV                        GetEnv;\r
@@ -931,7 +927,7 @@ typedef struct {
   SHELLENV_FREE_FILE_LIST                 FreeFileList;\r
 \r
   //\r
-  // The following services are only used by the shell itself\r
+  // The following services are only used by the shell itself.\r
   //\r
   SHELLENV_NEW_SHELL                      NewShell;\r
   SHELLENV_BATCH_IS_ACTIVE                BatchIsActive;\r
@@ -939,11 +935,11 @@ typedef struct {
   SHELLENV_FREE_RESOURCES                 FreeResources;\r
 \r
   //\r
-  // GUID to differentiate ShellEnvironment2 from ShellEnvironment\r
+  // GUID to differentiate ShellEnvironment2 from ShellEnvironment.\r
   //\r
   EFI_GUID                                SESGuid;\r
   //\r
-  // Major Version grows if shell environment interface has been changes\r
+  // Major Version grows if shell environment interface has been changes.\r
   //\r
   UINT32                                  MajorVersion;\r
   UINT32                                  MinorVersion;\r
@@ -973,4 +969,5 @@ typedef struct {
 \r
 extern EFI_GUID gEfiShellEnvironment2Guid;\r
 extern EFI_GUID gEfiShellEnvironment2ExtGuid;\r
-#endif // _SHELLENV_H_\r
+\r
+#endif // _SHELL_ENVIRONMENT_2_PROTOCOL_H_\r
index 884f9ecbfb78e12ba8fa896cc9bc87125fddf899..b5a514d60e104afd9c6809d8d6ab76f988480b7a 100644 (file)
 \r
 **/\r
 \r
-#ifndef _SHELLINTERFACE_H_\r
+#if !defined(_SHELLINTERFACE_H_)\r
 #define _SHELLINTERFACE_H_\r
 \r
-#include <Protocol/LoadedImage.h>\r
-\r
 #define SHELL_INTERFACE_PROTOCOL_GUID \\r
   { \\r
     0x47c7b223, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \\r
index ed068243d6976caa7f72e17762dd07bfb2eccda2..4b2ffb9d95787a2d74f30d04d4090079de7f7741 100644 (file)
@@ -22,6 +22,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
+#include <Library/FileHandleLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PrintLib.h>\r
 \r
 #define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
 #define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)\r
@@ -800,20 +803,64 @@ FileHandleGetFileName (
   return (Status);\r
 }\r
 \r
+/**\r
+  Function to read a single line from a file. The \n is not included in the returned \r
+  buffer.  The returned buffer must be callee freed.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be \r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]      Handle        FileHandle to read from.\r
+  @param[in,out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
+\r
+  @return                       The line of text from the file.\r
+\r
+  @sa FileHandleReadLine\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+FileHandleReturnLine(\r
+  IN EFI_FILE_HANDLE            Handle,\r
+  IN OUT BOOLEAN                *Ascii\r
+  )\r
+{\r
+  CHAR16          *RetVal;\r
+  UINTN           Size;\r
+  EFI_STATUS      Status;\r
+\r
+  Size = 0;\r
+  RetVal = NULL;\r
+\r
+  Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
+  if (Status == EFI_BUFFER_TOO_SMALL) {\r
+    RetVal = AllocatePool(Size);\r
+    Status = FileHandleReadLine(Handle, RetVal, &Size, FALSE, Ascii);\r
+  }\r
+  ASSERT_EFI_ERROR(Status);\r
+  if (EFI_ERROR(Status) && (RetVal != NULL)) {\r
+    FreePool(RetVal);\r
+    RetVal = NULL;\r
+  }\r
+  return (RetVal);\r
+}\r
+\r
 /**\r
   Function to read a single line (up to but not including the \n) from a file.\r
 \r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be \r
+  maintained and not changed for all operations with the same file.\r
+\r
   @param[in]      Handle        FileHandle to read from\r
   @param[in,out]  Buffer        pointer to buffer to read into\r
   @param[in,out]  Size          pointer to number of bytes in buffer\r
-  @param[in[      Truncate      if TRUE then allows for truncation of the line to fit.\r
+  @param[in]      Truncate      if TRUE then allows for truncation of the line to fit.\r
                                 if FALSE will reset the position to the begining of the \r
                                 line if the buffer is not large enough.\r
+  @param[in,out]  Ascii         Boolean value for indicating whether the file is Ascii (TRUE) or UCS2 (FALSE);\r
 \r
   @retval EFI_SUCCESS           the operation was sucessful.  the line is stored in \r
                                 Buffer.\r
   @retval EFI_INVALID_PARAMETER Handle was NULL.\r
-  @retval EFI_INVALID_PARAMETER Buffer was NULL.\r
   @retval EFI_INVALID_PARAMETER Size was NULL.\r
   @retval EFI_BUFFER_TOO_SMALL  Size was not enough space to store the line.  \r
                                 Size was updated to minimum space required.\r
@@ -823,31 +870,54 @@ EFI_STATUS
 EFIAPI\r
 FileHandleReadLine(\r
   IN EFI_FILE_HANDLE            Handle,\r
-  IN OUT VOID                   *Buffer,\r
+  IN OUT CHAR16                 *Buffer,\r
   IN OUT UINTN                  *Size,\r
-  IN BOOLEAN                    Truncate\r
+  IN BOOLEAN                    Truncate,\r
+  IN OUT BOOLEAN                *Ascii\r
   ){\r
   EFI_STATUS  Status;\r
   CHAR16      CharBuffer;\r
   UINTN       CharSize;\r
   UINTN       CountSoFar;\r
-  UINT64      Position;\r
+  UINT64      OriginalFilePosition;\r
 \r
 \r
   if (Handle == NULL\r
-    ||Buffer == NULL\r
     ||Size   == NULL\r
     ){\r
   return (EFI_INVALID_PARAMETER);\r
   }\r
-  FileHandleGetPosition(Handle, &Position);\r
+  FileHandleGetPosition(Handle, &OriginalFilePosition);\r
+  if (OriginalFilePosition == 0) {\r
+    CharSize = sizeof(CHAR16);\r
+    Status = FileHandleRead(Handle, &CharSize, &CharBuffer);\r
+    ASSERT_EFI_ERROR(Status);\r
+    if (CharBuffer == UnicodeFileTag) {\r
+      *Ascii = FALSE;\r
+    } else {\r
+      *Ascii = TRUE;\r
+      FileHandleSetPosition(Handle, OriginalFilePosition);\r
+    }\r
+  }\r
 \r
   for (CountSoFar = 0;;CountSoFar++){\r
-    CharSize = sizeof(CharBuffer);\r
+    CharBuffer = 0;\r
+    if (*Ascii) {\r
+      CharSize = sizeof(CHAR8);\r
+    } else {\r
+      CharSize = sizeof(CHAR16);\r
+    }\r
     Status = FileHandleRead(Handle, &CharSize, &CharBuffer);\r
+    if (OriginalFilePosition == 0 && *Ascii == FALSE && CountSoFar == 0) {\r
+      //\r
+      // we need to skip the unicode tag\r
+      //\r
+      continue;\r
+    }\r
     if (  EFI_ERROR(Status) \r
        || CharSize == 0 \r
-       || CharBuffer == '\n'\r
+       || (CharBuffer == L'\n' && *Ascii == FALSE)\r
+       || (CharBuffer ==  '\n' && *Ascii != FALSE )\r
       ){\r
       break;\r
     }\r
@@ -855,6 +925,7 @@ FileHandleReadLine(
     // if we have space save it...\r
     //\r
     if ((CountSoFar+1)*sizeof(CHAR16) < *Size){\r
+      ASSERT(Buffer != NULL);\r
       ((CHAR16*)Buffer)[CountSoFar] = CharBuffer;\r
       ((CHAR16*)Buffer)[CountSoFar+1] = CHAR_NULL;\r
     }\r
@@ -866,13 +937,16 @@ FileHandleReadLine(
   if ((CountSoFar+1)*sizeof(CHAR16) > *Size){\r
     *Size = (CountSoFar+1)*sizeof(CHAR16);\r
     if (Truncate == FALSE) {\r
-      FileHandleSetPosition(Handle, Position);\r
+      FileHandleSetPosition(Handle, OriginalFilePosition);\r
     } else {\r
-      DEBUG((DEBUG_WARN, "The line was truncated in ReadLine"));\r
+      DEBUG((DEBUG_WARN, "The line was truncated in FileHandleReadLine"));\r
     }\r
     return (EFI_BUFFER_TOO_SMALL);\r
   }\r
-  *Size = (CountSoFar+1)*sizeof(CHAR16);\r
+  while(Buffer[StrLen(Buffer)-1] == L'\r') {\r
+    Buffer[StrLen(Buffer)-1] = CHAR_NULL;\r
+  }\r
+\r
   return (Status);\r
 }\r
 \r
@@ -913,3 +987,95 @@ FileHandleWriteLine(
   Size = StrLen(L"\r\n");\r
   return FileHandleWrite(Handle, &Size, L"\r\n");\r
 }\r
+\r
+/**\r
+  function to take a formatted argument and print it to a file.\r
+\r
+  @param[in] Handle   the file handle for the file to write to\r
+  @param[in] Format   the format argument (see printlib for format specifier)\r
+  @param[in] ...      the variable arguments for the format\r
+\r
+  @retval EFI_SUCCESS the operation was sucessful\r
+  @return other       a return value from FileHandleWriteLine\r
+\r
+  @sa FileHandleWriteLine\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+FileHandlePrintLine(\r
+  IN EFI_FILE_HANDLE  Handle,\r
+  IN CONST CHAR16     *Format,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST           Marker;\r
+  CHAR16            *Buffer;\r
+  EFI_STATUS        Status;\r
+\r
+  VA_START (Marker, Format);\r
+\r
+  //\r
+  // Get a buffer to print into\r
+  //\r
+  Buffer = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));\r
+  ASSERT (Buffer != NULL);\r
+\r
+  //\r
+  // Print into our buffer\r
+  //\r
+  UnicodeVSPrint (Buffer, PcdGet16 (PcdShellPrintBufferSize), Format, Marker);\r
+\r
+  //\r
+  // Print buffer into file\r
+  //\r
+  Status = FileHandleWriteLine(Handle, Buffer);\r
+\r
+  //\r
+  // Cleanup and return \r
+  //\r
+  FreePool(Buffer);\r
+  return (Status);\r
+}\r
+\r
+/**\r
+  Function to determine if a FILE_HANDLE is at the end of the file.\r
+\r
+  This will NOT work on directories.\r
+\r
+  If Handle is NULL, then ASSERT.\r
+\r
+  @param[in] Handle     the file handle\r
+\r
+  @retval TRUE          the position is at the end of the file\r
+  @retval FALSE         the position is not at the end of the file\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+FileHandleEof(\r
+  IN EFI_FILE_HANDLE Handle\r
+  )\r
+{\r
+  EFI_FILE_INFO *Info;\r
+  UINT64        Pos;\r
+  BOOLEAN       RetVal;\r
+\r
+  //\r
+  // ASSERT if Handle is NULL\r
+  //\r
+  ASSERT(Handle != NULL);\r
+  \r
+  FileHandleGetPosition(Handle, &Pos);\r
+  Info = FileHandleGetInfo (Handle);\r
+  ASSERT(Info != NULL);\r
+  FileHandleSetPosition(Handle, Pos);\r
+  \r
+  if (Info == NULL) {\r
+    return (FALSE);\r
+  } \r
+\r
+  RetVal = (Pos == Info->FileSize)?TRUE:FALSE;\r
+\r
+  FreePool (Info);\r
+\r
+  return (RetVal);\r
+}
\ No newline at end of file
index 3d2583d1c0970641d78a3b3c828d716c4bf54039..141b55d39c0e1326f5472249418bc717dae3e502 100644 (file)
@@ -47,4 +47,4 @@
   gEfiFileInfoGuid                              # ALWAYS_CONSUMED\r
 \r
 [Pcd.common]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize # ALWAYS_CONSUMED
\ No newline at end of file
+  gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize # ALWAYS_CONSUMED\r
index 91b2a17e7abf2840baf9facd0630b345974e03db..a7b37a0f550573a3c7b9a5b8e178731ab155fe38 100644 (file)
@@ -178,8 +178,8 @@ PerformQuickSort (
 **/\r
 INTN\r
 DevicePathCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
   )\r
 {\r
   ASSERT(FALSE);\r
@@ -199,8 +199,8 @@ DevicePathCompare (
 INTN\r
 EFIAPI\r
 StringNoCaseCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
   )\r
 {\r
   ASSERT(FALSE);\r
index eda4f3b55bcb38da44a4f9df1c3aa82210f20a53..978edcf42c2452d2086090ee8a041429b8676812 100644 (file)
@@ -15,6 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Base.h>\r
 \r
 #include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/LoadedImage.h>\r
 #include <Protocol/EfiShellInterface.h>\r
 #include <Protocol/EfiShellParameters.h>\r
 \r
index fb763bde6162bc81f0e9514d4ca76912513d5b19..e1aaa9db80c818b6ff4b10fb493b2ce91a4d9aae 100644 (file)
@@ -1,37 +1,17 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-All rights reserved. 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
+  Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
+  All rights reserved. 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
+  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
 \r
 **/\r
 \r
-#include <Uefi.h>\r
-#include <Library/ShellLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/FileHandleLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/HiiLib.h>\r
-\r
-#include <Protocol/EfiShellEnvironment2.h>\r
-#include <Protocol/EfiShellInterface.h>\r
-#include <Protocol/EfiShell.h>\r
-#include <Protocol/EfiShellParameters.h>\r
-#include <Protocol/SimpleFileSystem.h>\r
-\r
 #include "UefiShellLib.h"\r
 \r
 #define MAX_FILE_NAME_LEN 522 // (20 * (6+5+2))+1) unicode characters from EFI FAT spec (doubled for bytes)\r
@@ -56,6 +36,7 @@ STATIC FILE_HANDLE_FUNCTION_MAP      FileFunctionMap;
 STATIC UINTN                         mTotalParameterCount;\r
 STATIC CHAR16                        *mPostReplaceFormat;\r
 STATIC CHAR16                        *mPostReplaceFormat2;\r
+\r
 /**\r
   Check if a Unicode character is a hexadecimal character.\r
 \r
@@ -72,7 +53,7 @@ STATIC CHAR16                        *mPostReplaceFormat2;
 **/\r
 BOOLEAN\r
 EFIAPI\r
-ShellInternalIsHexaDecimalDigitCharacter (\r
+ShellLibIsHexaDecimalDigitCharacter (\r
   IN      CHAR16                    Char\r
   ) {\r
   return (BOOLEAN) ((Char >= L'0' && Char <= L'9') || (Char >= L'A' && Char <= L'F') || (Char >= L'a' && Char <= L'f'));\r
@@ -161,10 +142,10 @@ ShellLibConstructorWorker (
   ) {\r
   EFI_STATUS Status;\r
 \r
-  ASSERT(PcdGet16 (PcdShellLibMaxPrintBufferSize) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
-  mPostReplaceFormat = AllocateZeroPool (PcdGet16 (PcdShellLibMaxPrintBufferSize));\r
+  ASSERT(PcdGet16 (PcdShellPrintBufferSize) < PcdGet32 (PcdMaximumUnicodeStringLength));\r
+  mPostReplaceFormat = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));\r
   ASSERT (mPostReplaceFormat != NULL);\r
-  mPostReplaceFormat2 = AllocateZeroPool (PcdGet16 (PcdShellLibMaxPrintBufferSize));\r
+  mPostReplaceFormat2 = AllocateZeroPool (PcdGet16 (PcdShellPrintBufferSize));\r
   ASSERT (mPostReplaceFormat2 != NULL);\r
 \r
   //\r
@@ -1487,9 +1468,9 @@ ShellCloseFileMetaArg (
 /**\r
   Find a file by searching the CWD and then the path.\r
 \r
-  if FileName is NULL then ASSERT.\r
+  If FileName is NULL then ASSERT.\r
 \r
-  if the return value is not NULL then the memory must be caller freed.\r
+  If the return value is not NULL then the memory must be caller freed.\r
 \r
   @param FileName               Filename string.\r
 \r
@@ -1557,6 +1538,62 @@ ShellFindFilePath (
   return (RetVal);\r
 }\r
 \r
+/**\r
+  Find a file by searching the CWD and then the path with a variable set of file \r
+  extensions.  If the file is not found it will append each extension in the list \r
+  in the order provided and return the first one that is successful.\r
+\r
+  If FileName is NULL, then ASSERT.\r
+  If FileExtension is NULL, then behavior is identical to ShellFindFilePath.\r
+\r
+  If the return value is not NULL then the memory must be caller freed.\r
+\r
+  @param[in] FileName           Filename string.\r
+  @param[in] FileExtension      Semi-colon delimeted list of possible extensions.\r
+\r
+  @retval NULL                  The file was not found.\r
+  @retval !NULL                 The path to the file.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ShellFindFilePathEx (\r
+  IN CONST CHAR16 *FileName,\r
+  IN CONST CHAR16 *FileExtension\r
+  )\r
+{\r
+  CHAR16            *TestPath;\r
+  CHAR16            *RetVal;\r
+  CONST CHAR16      *ExtensionWalker;\r
+  ASSERT(FileName != NULL);\r
+  if (FileExtension == NULL) {\r
+    return (ShellFindFilePath(FileName));\r
+  }\r
+  RetVal = ShellFindFilePath(FileName);\r
+  if (RetVal != NULL) {\r
+    return (RetVal);\r
+  }\r
+  TestPath = AllocateZeroPool(StrSize(FileName) + StrSize(FileExtension));\r
+  for (ExtensionWalker = FileExtension ;  ; ExtensionWalker = StrStr(ExtensionWalker, L";") + 1 ){\r
+    StrCpy(TestPath, FileName);\r
+    StrCat(TestPath, ExtensionWalker);\r
+    if (StrStr(TestPath, L";") != NULL) {\r
+      *(StrStr(TestPath, L";")) = CHAR_NULL;\r
+    }\r
+    RetVal = ShellFindFilePath(TestPath);\r
+    if (RetVal != NULL) {\r
+      break;\r
+    }\r
+    //\r
+    // Must be after first loop...\r
+    //\r
+    if (StrStr(ExtensionWalker, L";") == NULL) {\r
+      break;\r
+    }\r
+  }\r
+  FreePool(TestPath);\r
+  return (RetVal);\r
+}\r
+\r
 typedef struct {\r
   LIST_ENTRY     Link;\r
   CHAR16         *Name;\r
@@ -1647,7 +1684,7 @@ InternalIsFlag (
   //\r
   // If we accept numbers then dont return TRUE. (they will be values)\r
   //\r
-  if (((Name[0] == L'-' || Name[0] == L'+') && ShellInternalIsHexaDecimalDigitCharacter(Name[1])) && AlwaysAllowNumbers == TRUE) {\r
+  if (((Name[0] == L'-' || Name[0] == L'+') && ShellLibIsHexaDecimalDigitCharacter(Name[1])) && AlwaysAllowNumbers != FALSE) {\r
     return (FALSE);\r
   }\r
 \r
@@ -1738,7 +1775,7 @@ InternalCommandLineParse (
       //\r
       // do nothing for NULL argv\r
       //\r
-    } else if (InternalIsOnCheckList(Argv[LoopCounter], CheckList, &CurrentItemType) == TRUE) {\r
+    } else if (InternalIsOnCheckList(Argv[LoopCounter], CheckList, &CurrentItemType) != FALSE) {\r
       //\r
       // We might have leftover if last parameter didnt have optional value\r
       //\r
@@ -2200,9 +2237,11 @@ ShellCommandLineCheckDuplicate (
 }\r
 \r
 /**\r
-  This is a find and replace function.  it will return the NewString as a copy of \r
+  This is a find and replace function.  Upon successful return the NewString is a copy of \r
   SourceString with each instance of FindTarget replaced with ReplaceWith.\r
 \r
+  If SourceString and NewString overlap the behavior is undefined.\r
+\r
   If the string would grow bigger than NewSize it will halt and return error.\r
 \r
   @param[in] SourceString             String with source buffer\r
@@ -2224,7 +2263,7 @@ ShellCommandLineCheckDuplicate (
 \r
 EFI_STATUS\r
 EFIAPI\r
-CopyReplace(\r
+ShellLibCopySearchAndReplace(\r
   IN CHAR16 CONST                     *SourceString,\r
   IN CHAR16                           *NewString,\r
   IN UINTN                            NewSize,\r
@@ -2342,21 +2381,21 @@ InternalShellPrintWorker(
   //\r
   // Back and forth each time fixing up 1 of our flags...\r
   //\r
-  Status = CopyReplace(Format,             mPostReplaceFormat,  PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%N", L"%%N");\r
+  Status = ShellLibCopySearchAndReplace(Format,             mPostReplaceFormat,  PcdGet16 (PcdShellPrintBufferSize), L"%N", L"%%N");\r
   ASSERT_EFI_ERROR(Status);\r
-  Status = CopyReplace(mPostReplaceFormat,  mPostReplaceFormat2, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%E", L"%%E");\r
+  Status = ShellLibCopySearchAndReplace(mPostReplaceFormat,  mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), L"%E", L"%%E");\r
   ASSERT_EFI_ERROR(Status);\r
-  Status = CopyReplace(mPostReplaceFormat2, mPostReplaceFormat,  PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%H", L"%%H");\r
+  Status = ShellLibCopySearchAndReplace(mPostReplaceFormat2, mPostReplaceFormat,  PcdGet16 (PcdShellPrintBufferSize), L"%H", L"%%H");\r
   ASSERT_EFI_ERROR(Status);\r
-  Status = CopyReplace(mPostReplaceFormat,  mPostReplaceFormat2, PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%B", L"%%B");\r
+  Status = ShellLibCopySearchAndReplace(mPostReplaceFormat,  mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), L"%B", L"%%B");\r
   ASSERT_EFI_ERROR(Status);\r
-  Status = CopyReplace(mPostReplaceFormat2, mPostReplaceFormat,  PcdGet16 (PcdShellLibMaxPrintBufferSize), L"%V", L"%%V");\r
+  Status = ShellLibCopySearchAndReplace(mPostReplaceFormat2, mPostReplaceFormat,  PcdGet16 (PcdShellPrintBufferSize), L"%V", L"%%V");\r
   ASSERT_EFI_ERROR(Status);\r
 \r
   //\r
   // Use the last buffer from replacing to print from...\r
   //\r
-  Return = UnicodeVSPrint (mPostReplaceFormat2, PcdGet16 (PcdShellLibMaxPrintBufferSize), mPostReplaceFormat, Marker);\r
+  Return = UnicodeVSPrint (mPostReplaceFormat2, PcdGet16 (PcdShellPrintBufferSize), mPostReplaceFormat, Marker);\r
 \r
   if (Col != -1 && Row != -1) {\r
     Status = gST->ConOut->SetCursorPosition(gST->ConOut, Col, Row);\r
@@ -2593,6 +2632,39 @@ ShellIsFile(
   return (EFI_NOT_FOUND);\r
 }\r
 \r
+/**\r
+  Function to determine if a given filename represents a file.\r
+\r
+  This will search the CWD and then the Path.\r
+\r
+  If Name is NULL, then ASSERT.\r
+\r
+  @param[in] Name         Path to file to test.\r
+\r
+  @retval EFI_SUCCESS     The Path represents a file.\r
+  @retval EFI_NOT_FOUND   The Path does not represent a file.\r
+  @retval other           The path failed to open.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellIsFileInPath(\r
+  IN CONST CHAR16 *Name\r
+  ) {\r
+  CHAR16      *NewName;\r
+  EFI_STATUS  Status;\r
+\r
+  if (!EFI_ERROR(ShellIsFile(Name))) {\r
+    return (TRUE);\r
+  }\r
+\r
+  NewName = ShellFindFilePath(Name);\r
+  if (NewName == NULL) {\r
+    return (EFI_NOT_FOUND);\r
+  }\r
+  Status = ShellIsFile(NewName);\r
+  FreePool(NewName);\r
+  return (Status);\r
+}\r
 /**\r
   Function to determine whether a string is decimal or hex representation of a number \r
   and return the number converted from the string.\r
@@ -2608,7 +2680,7 @@ ShellStrToUintn(
   )\r
 {\r
   CONST CHAR16  *Walker;\r
-  for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker = Walker + 1);\r
+  for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker++);\r
   if (StrnCmp(Walker, L"0x", 2) == 0 || StrnCmp(Walker, L"0X", 2) == 0){\r
     return (StrHexToUintn(Walker));\r
   }\r
index 6be4a0397b34ee0bd9276c7fdf05471e3f0327e9..fe886ae79e2b8946c8df7cdaa1175a3665917036 100644 (file)
@@ -1,17 +1,41 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-All rights reserved. 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
+  Copyright (c) 2006 - 2010, Intel Corporation<BR>\r
+  All rights reserved. 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
+  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
 \r
 **/\r
 \r
+#include <Uefi.h>\r
+\r
+#include <Guid/FileInfo.h>\r
+\r
+#include <Protocol/SimpleFileSystem.h>\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
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/FileHandleLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/ShellLib.h>\r
+\r
 typedef struct  {\r
   EFI_SHELL_GET_FILE_INFO                   GetFileInfo;\r
   EFI_SHELL_SET_FILE_INFO                   SetFileInfo;\r
index 28fe8930337d2f11a86ffbd84cb6a6a3a11fa12e..b089ec61fceefbe09611cd7a4e02283e6f688b65 100644 (file)
@@ -65,5 +65,5 @@
 \r
 [Pcd.common]\r
   gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize     # ALWAYS_CONSUMED\r
-  gEfiShellPkgTokenSpaceGuid.PcdShellLibMaxPrintBufferSize # ALWAYS_CONSUMED\r
+  gEfiShellPkgTokenSpaceGuid.PcdShellPrintBufferSize       # ALWAYS_CONSUMED\r
   gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength   # ALWAYS_CONSUMED
\ No newline at end of file
index 1df45fb5ae0e0b811d386d94bfce7e113f813cb1..2a65f36507d09eee8ec04f6e2309903c28b8e5df 100644 (file)
@@ -192,8 +192,8 @@ PerformQuickSort (
 **/\r
 INTN\r
 DevicePathCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
   )\r
 {\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath1;\r
@@ -270,8 +270,8 @@ DevicePathCompare (
 INTN\r
 EFIAPI\r
 StringNoCaseCompare (\r
-  IN  VOID             *Buffer1,\r
-  IN  VOID             *Buffer2\r
+  IN  CONST VOID             *Buffer1,\r
+  IN  CONST VOID             *Buffer2\r
   )\r
 {\r
   EFI_STATUS                Status;\r