]> git.proxmox.com Git - mirror_edk2.git/commitdiff
updating headers from code review.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 18 Nov 2009 21:36:50 +0000 (21:36 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 18 Nov 2009 21:36:50 +0000 (21:36 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9449 6f19259b-4bc3-4df7-8a09-765794883524

13 files changed:
ShellPkg/Application/ShellLibTestApp/SA3.inf
ShellPkg/Application/ShellLibTestApp/sa3.c
ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
ShellPkg/Include/Guid/ShellPkgTokenSpace.h
ShellPkg/Include/Library/FileHandleLib.h
ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/Library/SortLib.h
ShellPkg/Include/Protocol/EfiShell.h
ShellPkg/Include/ShellBase.h
ShellPkg/Library/BaseFileHandleLib/BaseFileHandleLib.inf
ShellPkg/Library/BaseSortLib/BaseSortLib.c
ShellPkg/Library/UefiShellLib/UefiShellLib.c
ShellPkg/Library/UefiSortLib/UefiSortLib.c

index dbfa78335369862a7df7e59721355c43957f7eba..6ed4b00b7416f2f959ca3e3e37525bc079503a12 100644 (file)
@@ -17,7 +17,7 @@
 \r
 [Defines]\r
   INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = SimpleApplication\r
+  BASE_NAME                      = ShellLibTestApp\r
   FILE_GUID                      = 10C75C00-3052-4467-9ED8-7196CAAF610F\r
   MODULE_TYPE                    = UEFI_APPLICATION\r
   VERSION_STRING                 = 1.0\r
index d131cba2d64f3a95cb1cbe1a2d232193674c0590..a5b1a94c64768ca32e384dc875d9f19af83e17d7 100644 (file)
@@ -24,6 +24,8 @@
 SHELL_PARAM_ITEM ParamList[] = {\r
   {L"/Param1", TypeFlag},\r
   {L"/Param2", TypeValue},\r
+  {L"/Param3", TypeDoubleValue},\r
+  {L"/Param4", TypeMaxValue},\r
   {NULL, TypeMax}};\r
 \r
 /**\r
@@ -46,26 +48,47 @@ UefiMain (
   EFI_FILE_HANDLE     FileHandle;\r
   EFI_STATUS          Status;\r
   CHAR16              FileName[100];\r
-  UINTN               BufferSize;\r
-  UINT64              Position;\r
-  UINT8               Buffer[200];\r
+//  UINTN               BufferSize;\r
+//  UINT64              Position;\r
+//  UINT8               Buffer[200];\r
   EFI_FILE_INFO       *pFileInfo;\r
   UINT64              Size;\r
   BOOLEAN             NoFile;\r
   EFI_SHELL_FILE_INFO *pShellFileInfo;\r
   LIST_ENTRY          *List;\r
+  CONST CHAR16              *Tester;\r
   \r
   FileHandle = NULL;\r
   StrCpy(FileName, L"testfile.txt");\r
-  Position = 0;\r
+//  Position = 0;\r
   pFileInfo = NULL;\r
   Size = 0;\r
   NoFile = FALSE;\r
   pShellFileInfo = NULL;\r
   List = NULL;\r
 \r
+  // command line param functions\r
+  Status = ShellCommandLineParse(ParamList, &List, NULL, FALSE);\r
+  // if you put an invalid parameter you SHOULD hit this assert.\r
+  ASSERT_EFI_ERROR(Status);\r
+  if (List) {\r
+    ASSERT(ShellCommandLineGetFlag(List, L"/Param5") == FALSE);\r
+    ASSERT(ShellCommandLineGetFlag(List, L"/Param1") != FALSE);\r
+    ASSERT(StrCmp(ShellCommandLineGetValue(List, L"/Param2"), L"Val1")==0);\r
+    ASSERT(StrCmp(ShellCommandLineGetRawValue(List, 0), L"SimpleApplication.efi")==0);\r
+    Tester = ShellCommandLineGetValue(List, L"/Param3");\r
+    Tester = ShellCommandLineGetValue(List, L"/Param4");\r
+\r
+    ShellCommandLineFreeVarList(List);\r
+  } else {\r
+    Print(L"param checking skipped.\r\n");\r
+  }\r
+\r
+  return (EFI_SUCCESS);\r
+/*\r
+\r
   ASSERT(ShellGetExecutionBreakFlag() == FALSE);\r
-  ASSERT(StrCmp(ShellGetCurrentDir(NULL), L"f8:\\") == 0);\r
+  ASSERT(StrCmp(ShellGetCurrentDir(NULL), L"f10:\\") == 0);\r
   Print(L"execution break and get cur dir - pass\r\n");\r
 \r
   ShellSetPageBreakMode(TRUE);\r
@@ -253,7 +276,7 @@ UefiMain (
 \r
   // get environment variable\r
   // made for testing under nt32\r
-  ASSERT(StrCmp(ShellGetEnvironmentVariable(L"path"), L".;f8:\\efi\\tools;f8:\\efi\\boot;f8:\\;f9:\\efi\\tools;f9:\\efi\\boot;f9:\\") == 0);\r
+  ASSERT(StrCmp(ShellGetEnvironmentVariable(L"path"), L".;f10:\\efi\\tools;f10:\\efi\\boot;f10:\\;f9:\\efi\\tools;f9:\\efi\\boot;f9:\\") == 0);\r
   Print(L"ShellGetEnvironmentVariable - pass\r\n");\r
 \r
   // set environment variable\r
@@ -266,21 +289,6 @@ UefiMain (
   ASSERT_EFI_ERROR(Status);\r
   // the pass printout for this is performed by EmptyApplication\r
   Print(L"\r\n");\r
-    \r
-  // command line param functions\r
-  Status = ShellCommandLineParse(ParamList, &List, NULL, FALSE);\r
-  // if you put an invalid parameter you SHOULD hit this assert.\r
-  ASSERT_EFI_ERROR(Status);\r
-  if (List) {\r
-    ASSERT(ShellCommandLineGetFlag(List, L"/Param5") == FALSE);\r
-    ASSERT(ShellCommandLineGetFlag(List, L"/Param1") != FALSE);\r
-    ASSERT(StrCmp(ShellCommandLineGetValue(List, L"/Param2"), L"Val1")==0);\r
-    ASSERT(StrCmp(ShellCommandLineGetRawValue(List, 0), L"SimpleApplication.efi")==0);\r
-\r
-    ShellCommandLineFreeVarList(List);\r
-  } else {\r
-    Print(L"param checking skipped.\r\n");\r
-  }\r
 \r
   // page break mode (done last so we can see the results)\r
   // we set this true at the begining of the program\r
@@ -290,6 +298,7 @@ UefiMain (
   Print(L"1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28\r\n29\r\n30\r\n31\r\n32\r\n33\r\n34\r\n35\r\n36\r\n37\r\n38\r\n39\r\n40\r\n41\r\n42\r\n43\r\n44\r\n45\r\n46\r\n47\r\n48\r\n49\r\n50\r\n51\r\n52\r\n53\r\n54\r\n55\r\n56\r\n57\r\n58\r\n59\r\n60\r\n");\r
 \r
   return EFI_SUCCESS;\r
+*/\r
 }\r
 \r
 \r
index 5a671e0395915b01be836745a71a0a264e8029b4..83b5b5572daf0fad462e88143995e634eace6c96 100644 (file)
@@ -48,7 +48,8 @@ EFIAPI
 ShellAppMain (\r
   IN UINTN Argc, \r
   IN CHAR16 **Argv\r
-  ){\r
+  )\r
+{\r
   INTN Array[10] = {2,3,4,1,5,6,7,8,1,5};\r
   Print(L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0],Array[1],Array[2],Array[3],Array[4],Array[5],Array[6],Array[7],Array[8],Array[9]);\r
   PerformQuickSort(Array, 10, sizeof(INTN), Test);\r
index 9803e9c4aa7649c49da95fe95a52631df742358e..ac9bbd08ad4af3ad79b05b8f23f0cc014f404591 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  GUID for ShellPkg PCD Token Space \r
+  GUID for ShellPkg PCD Token Space.\r
 \r
   Copyright (c) 2009, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
 #ifndef _SHELLPKG_TOKEN_SPACE_GUID_H_\r
 #define _SHELLPKG_TOKEN_SPACE_GUID_H_\r
 \r
-#define SHELLPKG_TOKEN_SPACE_GUID \\r
+#define EFI_SHELLPKG_TOKEN_SPACE_GUID \\r
 { \\r
   0x171e9188, 0x31d3, 0x40f5, { 0xb1, 0xc, 0x53, 0x9b, 0x2d, 0xb9, 0x40, 0xcd } \\r
-};\r
+}\r
 \r
 extern EFI_GUID gEfiShellPkgTokenSpaceGuid;\r
 \r
index c9cf2acefd4a5e5c10ca043714bd539689cd3e0a..ee5b52642208cf29d340ab50209c7bf5f773357b 100644 (file)
@@ -17,14 +17,14 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   specified and store it in allocated pool memory.\r
 \r
   This function allocates a buffer to store the file's information. It is the \r
-  caller's responsibility to free the buffer\r
+  caller's responsibility to free the buffer.\r
 \r
   @param  FileHandle  The file handle of the file for which information is \r
-  being requested.\r
+                      being requested.\r
 \r
-  @retval NULL information could not be retrieved.\r
+  @retval NULL        information could not be retrieved.\r
 \r
-  @return the information about the file\r
+  @retval !NULL       the information about the file\r
 **/\r
 EFI_FILE_INFO*\r
 EFIAPI\r
@@ -37,18 +37,18 @@ FileHandleGetInfo (
   specified.\r
 \r
   @param  FileHandle            The file handle of the file for which information \r
-  is being set\r
+                                is being set.\r
 \r
-  @param  FileInfo              The infotmation to set.\r
+  @param  FileInfo              The information to set.\r
 \r
-  @retval EFI_SUCCESS          The information was set.\r
-  @retval EFI_UNSUPPORTED The InformationType is not known.\r
-  @retval EFI_NO_MEDIA         The device has no medium.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_SUCCESS                  The information was set.\r
+  @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
+  @retval EFI_NO_MEDIA               The device has no medium.\r
+  @retval EFI_DEVICE_ERROR         The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED  The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED    The file was opened read only.\r
-  @retval EFI_VOLUME_FULL      The volume is full.\r
+  @retval EFI_WRITE_PROTECTED    The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED        The file was opened read only.\r
+  @retval EFI_VOLUME_FULL            The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -73,16 +73,16 @@ FileHandleSetInfo (
   are no more directory entries, the read returns a zero-length buffer. \r
   EFI_FILE_INFO is the structure returned as the directory entry.\r
 \r
-  @param FileHandle             the opened file handle\r
-  @param BufferSize             on input the size of buffer in bytes.  on return \r
+  @param FileHandle             The opened file handle.\r
+  @param BufferSize             On input the size of buffer in bytes.  on return \r
                                 the number of bytes written.\r
-  @param Buffer                 the buffer to put read data into.\r
+  @param Buffer                 The buffer to put read data into.\r
 \r
   @retval EFI_SUCCESS            Data was read.\r
   @retval EFI_NO_MEDIA         The device has no media.\r
-  @retval EFI_DEVICE_ERROR     The device reported an error.\r
+  @retval EFI_DEVICE_ERROR         The device reported an error.\r
   @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_BUFFER_TO_SMALL  Buffer is too small. ReadSize contains required \r
+  @retval EFI_BUFFER_TO_SMALL    Buffer is too small. ReadSize contains required \r
                                 size.\r
 \r
 **/\r
@@ -105,18 +105,18 @@ FileHandleRead(
   opened directories are not supported.\r
 \r
   @param FileHandle           The opened file for writing\r
-  @param BufferSize           on input the number of bytes in Buffer.  On output\r
+  @param BufferSize           On input the number of bytes in Buffer.  On output\r
                               the number of bytes written.\r
-  @param Buffer               the buffer containing data to write is stored.\r
-\r
@retval EFI_SUCCESS           Data was written.\r
@retval EFI_UNSUPPORTED           Writes to an open directory are not supported.\r
@retval EFI_NO_MEDIA          The device has no media.\r
@retval EFI_DEVICE_ERROR          The device reported an error.\r
@retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
@retval EFI_WRITE_PROTECTED   The device is write-protected.\r
@retval EFI_ACCESS_DENIED       The file was open for read only.\r
@retval EFI_VOLUME_FULL           The volume is full.\r
+  @param Buffer               The buffer containing data to write is stored.\r
+\r
 @retval EFI_SUCCESS          Data was written.\r
 @retval EFI_UNSUPPORTED          Writes to an open directory are not supported.\r
 @retval EFI_NO_MEDIA         The device has no media.\r
 @retval EFI_DEVICE_ERROR         The device reported an error.\r
 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
 @retval EFI_WRITE_PROTECTED  The device is write-protected.\r
 @retval EFI_ACCESS_DENIED      The file was open for read only.\r
 @retval EFI_VOLUME_FULL          The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -133,9 +133,9 @@ FileHandleWrite(
   flushed to the device, and the file is closed. In all cases the handle is \r
   closed.\r
 \r
-@param FileHandle               the file handle to close.\r
+  @param FileHandle               The file handle to close.\r
 \r
-@retval EFI_SUCCESS             the file handle was closed sucessfully.\r
+  @retval EFI_SUCCESS             The file handle was closed sucessfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -144,18 +144,18 @@ FileHandleClose (
   );\r
 \r
 /**\r
-  Delete a file and close the handle\r
+  Delete a file and close the handle.\r
 \r
   This function closes and deletes a file. In all cases the file handle is closed.\r
   If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r
   returned, but the handle is still closed.\r
 \r
-  @param FileHandle             the file handle to delete\r
+  @param FileHandle             The file handle to delete.\r
 \r
-  @retval EFI_SUCCESS           the file was closed sucessfully\r
-  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not \r
-                                deleted\r
-  @retval INVALID_PARAMETER            One of the parameters has an invalid value.\r
+  @retval EFI_SUCCESS               The file was closed sucessfully.\r
+  @retval EFI_WARN_DELETE_FAILURE   the handle was closed, but the file was not \r
+                                    deleted\r
+  @retval INVALID_PARAMETER                One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -190,7 +190,7 @@ FileHandleSetPosition (
   );\r
 \r
 /** \r
-  Gets a file's current position\r
+  Gets a file's current position.\r
 \r
   This function retrieves the current file position for the file handle. For \r
   directories, the current file position has no meaning outside of the file \r
@@ -211,11 +211,11 @@ FileHandleGetPosition (
   OUT UINT64                    *Position\r
   );\r
 /**\r
-  Flushes data on a file\r
+  Flushes data on a file.\r
   \r
   This function flushes all modified data associated with a file to a device.\r
 \r
-  @param FileHandle             The file handle on which to flush data\r
+  @param FileHandle             The file handle on which to flush data.\r
 \r
   @retval EFI_SUCCESS           The data was flushed.\r
   @retval EFI_NO_MEDIA          The device has no media.\r
@@ -231,14 +231,14 @@ FileHandleFlush (
   );\r
 \r
 /**\r
-  function to determine if a given handle is a directory handle\r
+  Function to determine if a given handle is a directory handle.\r
 \r
-  if DirHandle is NULL then ASSERT()\r
+  If DirHandle is NULL then ASSERT().\r
 \r
-  open the file information on the DirHandle and verify that the Attribute\r
+  Open the file information on the DirHandle and verify that the Attribute\r
   includes EFI_FILE_DIRECTORY bit set.\r
 \r
-  @param DirHandle              Handle to open file\r
+  @param DirHandle              Handle to open file.\r
 \r
   @retval EFI_SUCCESS           DirHandle is a directory\r
   @retval EFI_INVALID_PARAMETER DirHandle did not have EFI_FILE_INFO available\r
@@ -251,7 +251,7 @@ FileHandleIsDirectory (
   );\r
 \r
 /**\r
-  Retrieves the first file from a directory\r
+  Retrieves the first file from a directory.\r
 \r
   This function opens a directory and gets the first file's info in the \r
   directory. Caller can use FileHandleFindNextFile() to get other files.  When \r
@@ -304,14 +304,14 @@ FileHandleFindNextFile(
 /**\r
   Retrieve the size of a file.\r
 \r
-  if FileHandle is NULL then ASSERT()\r
-  if Size is NULL then ASSERT()\r
+  If FileHandle is NULL then ASSERT()\r
+  If Size is NULL then ASSERT()\r
 \r
   This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r
   data.\r
 \r
-  @param FileHandle             file handle from which size is retrieved\r
-  @param Size                   pointer to size\r
+  @param FileHandle             The file handle from which size is retrieved.\r
+  @param Size                   pointer to size.\r
 \r
   @retval EFI_SUCCESS           operation was completed sucessfully\r
   @retval EFI_DEVICE_ERROR      cannot access the file\r
@@ -327,10 +327,8 @@ FileHandleGetSize (
   Function to get a full filename given a EFI_FILE_HANDLE somewhere lower on the \r
   directory 'stack'.\r
 \r
-  if Handle is NULL, return EFI_INVALID_PARAMETER\r
-\r
   @param[in] Handle             Handle to the Directory or File to create path to.\r
-  @param[out] FullFileName      pointer to pointer to generated full file name.  It \r
+  @param[out] FullFileName      Pointer to pointer to generated full file name.  It \r
                                 is the responsibility of the caller to free this memory\r
                                 with a call to FreePool().\r
   @retval EFI_SUCCESS           the operation was sucessful and the FullFileName is valid.\r
@@ -346,16 +344,16 @@ FileHandleGetFileName (
   );\r
 \r
 /**\r
-  Function to read a single line (up to but not including the \n) from a file.\r
+  Function to read a single line from a file. The \n is not included in the returned buffer.\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
+  @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
 \r
-  @retval EFI_SUCCESS           the operation was sucessful.  the line is stored in \r
+  @retval EFI_SUCCESS           The operation was sucessful.  the line is stored in \r
                                 Buffer.  (Size was NOT updated)\r
   @retval EFI_INVALID_PARAMETER Handle was NULL.\r
   @retval EFI_INVALID_PARAMETER Buffer was NULL.\r
@@ -368,19 +366,19 @@ 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
   );\r
 \r
 /**\r
-  function to write a line of unicode text to a file.\r
+  Function to write a line of unicode text to a file.\r
 \r
-  if Handle is NULL, ASSERT.\r
-  if Buffer is NULL, do nothing.  (return SUCCESS)\r
+  If Handle is NULL, ASSERT.\r
 \r
   @param[in]     Handle         FileHandle to write to\r
-  @param[in]     Buffer         Buffer to write\r
+  @param[in]     Buffer         Buffer to write, if NULL the function will \r
+                                take no action and return EFI_SUCCESS.\r
 \r
   @retval  EFI_SUCCESS          the data was written.\r
   @retval  other                failure.\r
@@ -393,3 +391,39 @@ FileHandleWriteLine(
   IN EFI_FILE_HANDLE Handle,\r
   IN CHAR16          *Buffer\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
+/**\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
+  @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
index 6211343f1690f5aa0e5a0d0e00fd83f61cd3243e..eab8271ae9f0ee7bd27d1434acff80cd09e45897 100644 (file)
@@ -69,7 +69,7 @@ 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  FilePath                 on input the device path to the file.  On output \r
+  @param  FilePath                 On input the device path to the file.  On output \r
                           the remaining device path.\r
   @param  DeviceHandle         pointer to the system device handle.\r
   @param  FileHandle             pointer to the file handle.\r
@@ -148,12 +148,12 @@ ShellOpenFileByName(
   otherwise, the Filehandle is NULL. If the directory already existed, this \r
   function opens the existing directory.\r
 \r
-  @param  DirectoryName         pointer to Directory name\r
-  @param  FileHandle                   pointer to the file handle.\r
+  @param  DirectoryName         Pointer to Directory name.\r
+  @param  FileHandle                   Pointer to the file handle.\r
 \r
   @retval EFI_SUCCESS                  The information was set.\r
   @retval EFI_INVALID_PARAMETER        One of the parameters has an invalid value.\r
-  @retval EFI_UNSUPPORTED      Could not open the file path.   \r
+  @retval EFI_UNSUPPORTED            Could not open the file path.     \r
   @retval EFI_NOT_FOUND                The specified file could not be found on the \r
                                 device or the file system could not be found \r
                                 on the device.\r
@@ -191,18 +191,16 @@ ShellCreateDirectory(
   are no more directory entries, the read returns a zero-length buffer. \r
   EFI_FILE_INFO is the structure returned as the directory entry.\r
 \r
-  @param FileHandle             the opened file handle\r
-  \r
-  @param ReadSize               on input the size of buffer in bytes.  on return \r
+  @param FileHandle             The opened file handle.\r
+  @param ReadSize               On input the size of buffer in bytes.  On return \r
                                 the number of bytes written.\r
+  @param Buffer                 The buffer to put read data into.\r
 \r
-  @param Buffer                 the buffer to put read data into.\r
-\r
- @retval EFI_SUCCESS             Data was read.\r
- @retval EFI_NO_MEDIA            The device has no media.\r
- @retval EFI_DEVICE_ERROR            The device reported an error.\r
- @retval EFI_VOLUME_CORRUPTED    The file system structures are corrupted.\r
- @retval EFI_BUFFER_TO_SMALL     Buffer is too small. ReadSize contains required \r
+  @retval EFI_SUCCESS            Data was read.\r
+  @retval EFI_NO_MEDIA         The device has no media.\r
+  @retval EFI_DEVICE_ERROR         The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_BUFFER_TO_SMALL    Buffer is too small. ReadSize contains required \r
                                 size.\r
 \r
 **/\r
@@ -224,21 +222,21 @@ ShellReadFile(
   The file is automatically grown to hold the data if required. Direct writes to \r
   opened directories are not supported.\r
 \r
-  @param FileHandle             The opened file for writing\r
+  @param FileHandle             The opened file for writing.\r
 \r
-  @param BufferSize             on input the number of bytes in Buffer.  On output\r
+  @param BufferSize             On input the number of bytes in Buffer.  On output\r
                                 the number of bytes written.\r
 \r
-  @param Buffer                 the buffer containing data to write is stored.\r
+  @param Buffer                 The buffer containing data to write is stored.\r
 \r
@retval EFI_SUCCESS           Data was written.\r
@retval EFI_UNSUPPORTED           Writes to an open directory are not supported.\r
@retval EFI_NO_MEDIA          The device has no media.\r
@retval EFI_DEVICE_ERROR          The device reported an error.\r
@retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
@retval EFI_WRITE_PROTECTED   The device is write-protected.\r
@retval EFI_ACCESS_DENIED       The file was open for read only.\r
@retval EFI_VOLUME_FULL           The volume is full.\r
 @retval EFI_SUCCESS            Data was written.\r
 @retval EFI_UNSUPPORTED            Writes to an open directory are not supported.\r
 @retval EFI_NO_MEDIA         The device has no media.\r
 @retval EFI_DEVICE_ERROR         The device reported an error.\r
 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
 @retval EFI_WRITE_PROTECTED    The device is write-protected.\r
 @retval EFI_ACCESS_DENIED        The file was open for read only.\r
 @retval EFI_VOLUME_FULL            The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -255,10 +253,10 @@ ShellWriteFile(
   flushed to the device, and the file is closed. In all cases the handle is \r
   closed.\r
 \r
-@param FileHandle               the file handle to close.\r
+  @param FileHandle               The file handle to close.\r
 \r
-@retval EFI_SUCCESS             the file handle was closed sucessfully.\r
-@retval INVALID_PARAMETER              One of the parameters has an invalid value.\r
+  @retval EFI_SUCCESS             The file handle was closed sucessfully.\r
+  @retval INVALID_PARAMETER            One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -273,12 +271,12 @@ ShellCloseFile (
   If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r
   returned, but the handle is still closed.\r
 \r
-  @param FileHandle             the file handle to delete\r
+  @param FileHandle                 The file handle to delete.\r
 \r
-  @retval EFI_SUCCESS           the file was closed sucessfully\r
-  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not \r
-                                deleted\r
-  @retval INVALID_PARAMETER            One of the parameters has an invalid value.\r
+  @retval EFI_SUCCESS               The file was closed sucessfully.\r
+  @retval EFI_WARN_DELETE_FAILURE   The handle was closed, but the file was not \r
+                                    deleted.\r
+  @retval INVALID_PARAMETER                One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -414,11 +412,11 @@ ShellFindNextFile(
   This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r
   data.\r
 \r
-  @param FileHandle             file handle from which size is retrieved\r
-  @param Size                   pointer to size\r
+  @param FileHandle             The file handle from which size is retrieved.\r
+  @param Size                   Pointer to size.\r
 \r
-  @retval EFI_SUCCESS           operation was completed sucessfully\r
-  @retval EFI_DEVICE_ERROR      cannot access the file\r
+  @retval EFI_SUCCESS           The operation was completed sucessfully.\r
+  @retval EFI_DEVICE_ERROR      cannot access the file.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -442,15 +440,15 @@ ShellGetExecutionBreakFlag(
   );\r
 \r
 /**\r
-  return the value of an environment variable\r
+  Return the value of an environment variable.\r
 \r
-  this function gets the value of the environment variable set by the \r
-  ShellSetEnvironmentVariable function\r
+  This function gets the value of the environment variable set by the \r
+  ShellSetEnvironmentVariable function.\r
 \r
   @param EnvKey                 The key name of the environment variable.\r
 \r
   @retval NULL                  the named environment variable does not exist.\r
-  @return != NULL               pointer to the value of the environment variable\r
+  @return != NULL               pointer to the value of the environment variable.\r
 **/\r
 CONST CHAR16*\r
 EFIAPI\r
@@ -461,13 +459,13 @@ ShellGetEnvironmentVariable (
 /**\r
   set the value of an environment variable\r
 \r
-This function changes the current value of the specified environment variable. If the\r
-environment variable exists and the Value is an empty string, then the environment\r
-variable is deleted. If the environment variable exists and the Value is not an empty\r
-string, then the value of the environment variable is changed. If the environment\r
-variable does not exist and the Value is an empty string, there is no action. If the\r
-environment variable does not exist and the Value is a non-empty string, then the\r
-environment variable is created and assigned the specified value.\r
+  This function changes the current value of the specified environment variable. If the\r
+  environment variable exists and the Value is an empty string, then the environment\r
+  variable is deleted. If the environment variable exists and the Value is not an empty\r
+  string, then the value of the environment variable is changed. If the environment\r
+  variable does not exist and the Value is an empty string, there is no action. If the\r
+  environment variable does not exist and the Value is a non-empty string, then the\r
+  environment variable is created and assigned the specified value.\r
 \r
   This is not supported pre-UEFI Shell 2.0.\r
 \r
@@ -487,19 +485,19 @@ ShellSetEnvironmentVariable (
   );\r
 \r
 /**\r
-  cause the shell to parse and execute a command line.\r
+  Cause the shell to parse and execute a command line.\r
 \r
   This function creates a nested instance of the shell and executes the specified\r
-command (CommandLine) with the specified environment (Environment). Upon return,\r
-the status code returned by the specified command is placed in StatusCode.\r
-If Environment is NULL, then the current environment is used and all changes made\r
-by the commands executed will be reflected in the current environment. If the\r
-Environment is non-NULL, then the changes made will be discarded.\r
-The CommandLine is executed from the current working directory on the current\r
-device.\r
+  command (CommandLine) with the specified environment (Environment). Upon return,\r
+  the status code returned by the specified command is placed in StatusCode.\r
+  If Environment is NULL, then the current environment is used and all changes made\r
+  by the commands executed will be reflected in the current environment. If the\r
+  Environment is non-NULL, then the changes made will be discarded.\r
+  The CommandLine is executed from the current working directory on the current\r
+  device.\r
 \r
-EnvironmentVariables and Status are only supported for UEFI Shell 2.0.\r
-Output is only supported for pre-UEFI Shell 2.0\r
+  EnvironmentVariables and Status are only supported for UEFI Shell 2.0.\r
+  Output is only supported for pre-UEFI Shell 2.0\r
 \r
   @param ImageHandle            Parent image that is starting the operation\r
   @param CommandLine            pointer to null terminated command line.\r
@@ -543,9 +541,9 @@ ShellGetCurrentDir (
   );\r
 \r
 /**\r
-  sets (enabled or disabled) the page break mode\r
+  Sets (enabled or disabled) the page break mode.\r
 \r
-  when page break mode is enabled the screen will stop scrolling \r
+  When page break mode is enabled the screen will stop scrolling \r
   and wait for operator input before scrolling a subsequent screen.\r
 \r
   @param CurrentState           TRUE to enable and FALSE to disable\r
@@ -563,21 +561,19 @@ ShellSetPageBreakMode (
   file has a SHELL_FILE_ARG structure to record the file information. These \r
   structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r
   structures from ListHead to access each file. This function supports wildcards\r
-  and will process '?' and '*' as such.  the list must be freed with a call to \r
+  and will process '?' and '*' as such.  The list must be freed with a call to \r
   ShellCloseFileMetaArg().\r
 \r
   If you are NOT appending to an existing list *ListHead must be NULL.  If \r
   *ListHead is NULL then it must be callee freed.\r
 \r
-  @param Arg                    pointer to path string\r
-  @param OpenMode               mode to open files with\r
-  @param ListHead               head of linked list of results\r
+  @param Arg                    Pointer to path string.\r
+  @param OpenMode               Mode to open files with.\r
+  @param ListHead               Head of linked list of results.\r
 \r
-  @retval EFI_SUCCESS           the operation was sucessful and the list head \r
-                                contains the list of opened files\r
-  #retval EFI_UNSUPPORTED       a previous ShellOpenFileMetaArg must be closed first.\r
-                                *ListHead is set to NULL.\r
-  @return != EFI_SUCCESS        the operation failed\r
+  @retval EFI_SUCCESS           The operation was sucessful and the list head \r
+                                contains the list of opened files.\r
+  @return != EFI_SUCCESS        The operation failed.\r
 \r
   @sa InternalShellConvertFileListType\r
 **/\r
@@ -603,11 +599,31 @@ ShellCloseFileMetaArg (
   IN OUT EFI_SHELL_FILE_INFO    **ListHead\r
   );\r
 \r
+/**\r
+  Find a file by searching the CWD and then the path.\r
+\r
+  if FileName is NULL then ASSERT.\r
+\r
+  if the return value is not NULL then the memory must be caller freed.\r
+\r
+  @param FileName               Filename string.\r
+\r
+  @retval NULL                  the file was not found\r
+  @return !NULL                 the path to the file.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ShellFindFilePath (\r
+  IN CONST CHAR16 *FileName\r
+  );\r
+\r
 typedef enum {\r
-  TypeFlag  = 0,\r
-  TypeValue,\r
-  TypePosition,\r
-  TypeStart,\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
+  TypePosition,     /// some data that did not follow a parameter (IE "filename.txt")\r
+  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
   TypeMax,\r
 } ParamType;\r
 \r
@@ -626,11 +642,11 @@ extern SHELL_PARAM_ITEM EmptyParamList[];
   \r
   If no initialization is required, then return RETURN_SUCCESS.\r
   \r
-  @param CheckList              pointer to list of parameters to check\r
-  @param CheckPackage           Package of checked values\r
-  @param ProblemParam           optional pointer to pointer to unicode string for \r
+  @param CheckList              Pointer to list of parameters to check.\r
+  @param CheckPackage           Package of checked values.\r
+  @param ProblemParam           Pptional pointer to pointer to unicode string for \r
                                 the paramater that caused failure.\r
-  @param AutoPageBreak          will automatically set PageBreakEnabled\r
+  @param AutoPageBreak          Will automatically set PageBreakEnabled.\r
 \r
   @retval EFI_SUCCESS           The operation completed sucessfully.\r
   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed\r
@@ -638,10 +654,10 @@ extern SHELL_PARAM_ITEM EmptyParamList[];
   @retval EFI_VOLUME_CORRUPTED  the command line was corrupt.  an argument was \r
                                 duplicated.  the duplicated command line argument \r
                                 was returned in ProblemParam if provided.\r
-  @retval EFI_DEVICE_ERROR      the commands contained 2 opposing arguments.  one\r
+  @retval EFI_DEVICE_ERROR      The commands contained 2 opposing arguments.  one\r
                                 of the command line arguments was returned in \r
                                 ProblemParam if provided.\r
-  @retval EFI_NOT_FOUND         a argument required a value that was missing.  \r
+  @retval EFI_NOT_FOUND         A argument required a value that was missing.  \r
                                 the invalid command line argument was returned in\r
                                 ProblemParam if provided.\r
 **/\r
@@ -767,6 +783,7 @@ ShellCommandLineGetCount(
 EFI_STATUS\r
 EFIAPI\r
 ShellInitialize (\r
+  VOID\r
   );\r
 \r
 /**\r
@@ -861,5 +878,59 @@ ShellIsDirectory(
   IN CONST CHAR16 *DirName\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
+\r
+  @param[in] String   String representation of a number\r
+\r
+  @retval all         the number\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellStrToUintn(\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
+\r
+  append the first D characters of Source to the end of Destination, where D is \r
+  the lesser of Count and the StrLen() of Source. If appending those D characters \r
+  will fit within Destination (whose Size is given as CurrentSize) and \r
+  still leave room for a null terminator, then those characters are appended, \r
+  starting at the original terminating null of Destination, and a new terminating \r
+  null is appended.\r
+\r
+  If appending D characters onto Destination will result in a overflow of the size\r
+  given in CurrentSize the string will be grown such that the copy can be performed\r
+  and CurrentSize will be updated to the new size.\r
+\r
+  If Source is NULL, there is nothing to append, just return the current buffer in \r
+  Destination.\r
+\r
+  if Destination is NULL, then ASSERT()\r
+  if Destination's current length (including NULL terminator) is already more then \r
+  CurrentSize, then ASSERT()\r
+\r
+  @param[in,out] Destination   The String to append onto\r
+  @param[in,out] CurrentSize   on call the number of bytes in Destination.  On \r
+                                return possibly the new size (still in bytes).  if NULL\r
+                                then allocate whatever is needed.\r
+  @param[in]      Source        The String to append from\r
+  @param[in]      Count         Maximum number of characters to append.  if 0 then \r
+                                all are appended.\r
+\r
+  @return Destination           return the resultant string.\r
+**/\r
+CHAR16* \r
+EFIAPI\r
+StrnCatGrow (\r
+  IN OUT CHAR16           **Destination,\r
+  IN OUT UINTN            *CurrentSize,\r
+  IN     CONST CHAR16     *Source,\r
+  IN     UINTN            Count\r
+  );\r
 \r
 #endif // __SHELL_LIB__\r
index ecc538e4b379099b0722872629ee116813482ded..1345a52d59a61a52944d15cbdb0f9208016aa133 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  Library used for sorting routines.\r
+  Library used for sorting and comparison routines.\r
 \r
 Copyright (c) 2009, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
@@ -59,4 +59,20 @@ PerformQuickSort (
   IN       SORT_COMPARE                 CompareFunction\r
   );\r
 \r
+\r
+/**\r
+  Function to compare 2 device paths for use as CompareFunction.\r
+\r
+  @param[in] Buffer1            pointer to Device Path to compare\r
+  @param[in] Buffer2            pointer to second DevicePath to compare\r
+\r
+  @retval 0                           Buffer1 equal to Buffer2\r
+  @return < 0                         Buffer1 is less than Buffer2\r
+  @return > 0                         Buffer1 is greater than Buffer2                     \r
+**/\r
+INTN\r
+DevicePathCompare (\r
+  IN  VOID             *Buffer1,\r
+  IN  VOID             *Buffer2\r
+  );\r
 #endif //__SORT_LIB_H__\r
index 658f892f07c4efbe923efd0a0481c07458e40139..8b489dac6bc0428052bdb30a1a0e5701e22fa3f6 100644 (file)
 // replaced EFI_LIST_ENTRY with LIST_ENTRY for simplicity.\r
 // they are identical outside of the name.\r
 typedef struct {\r
-  LIST_ENTRY Link;\r
-  EFI_STATUS Status;\r
-  CONST CHAR16 *FullName;\r
-  CONST CHAR16 *FileName;\r
-  EFI_FILE_HANDLE Handle;\r
-  EFI_FILE_INFO *Info;\r
+  LIST_ENTRY Link;          /// Linked list members\r
+  EFI_STATUS Status;        /// Status of opening the file.  Valid only if Handle != NULL.\r
+  CONST CHAR16 *FullName;   /// Fully qualified filename.\r
+  CONST CHAR16 *FileName;   /// name of this file.\r
+  EFI_FILE_HANDLE Handle;   /// Handle for interacting with the opened file or NULL if closed.\r
+  EFI_FILE_INFO *Info;      /// Pointer to the FileInfo struct for this file or NULL.\r
 } EFI_SHELL_FILE_INFO;\r
 /**\r
   Returns whether any script files are currently being processed.\r
@@ -85,7 +85,7 @@ EFI_STATUS
   @retval EFI_SUCCESS       The file was opened.  FileHandle points to the new file's handle.\r
   @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
   @retval EFI_UNSUPPORTED   could not open the file path\r
-  @retval EFI_NOT_FOUND     the specified file could not be found on the devide, or could not\r
+  @retval EFI_NOT_FOUND     The specified file could not be found on the device, or could not\r
                             file the file system on the device.\r
   @retval EFI_NO_MEDIA      the device has no medium.\r
   @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
@@ -846,10 +846,10 @@ EFI_STATUS
   For a description of volatile and non-volatile environment variables, see UEFI Shell \r
   2.0 specification section 3.6.1.\r
 \r
-  @param[in] Name                   Points to the null-terminated environment variable name.\r
-  @param[in] Value                  Points to the null-terminated environment variable value. If the value is an\r
+  @param[in] Name               Points to the null-terminated environment variable name.\r
+  @param[in] Value              Points to the null-terminated environment variable value. If the value is an\r
                                 empty string then the environment variable is deleted.\r
-  @param[in] Volatile               Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
+  @param[in] Volatile           Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
 \r
   @retval EFI_SUCCESS           The environment variable was successfully updated.\r
 **/\r
index 0005be0cae2722ffdfa755b5a8c51afd2ddcea90..3929df7b77c3ba1193bdf5cf67c7df65a1fd123b 100644 (file)
@@ -12,6 +12,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
+#if !defined(__SHELL_BASE__)\r
+#define __SHELL_BASE__\r
+\r
 typedef enum {\r
 ///\r
 /// The operation completed successfully.\r
@@ -140,3 +143,4 @@ SHELL_SECURITY_VIOLATION    = 26,
 SHELL_CRC_ERROR             = 27\r
 }SHELL_STATUS;\r
 \r
+#endif //__SHELL_BASE__
\ No newline at end of file
index 111551609af4b367e3d66f5dae3d6abd48f51800..3d2583d1c0970641d78a3b3c828d716c4bf54039 100644 (file)
@@ -17,7 +17,7 @@
   INF_VERSION                    = 0x00010006\r
   BASE_NAME                      = BaseFileHandleLib\r
   FILE_GUID                      = 9495D344-9D8A-41f3-8D17-E2FD238C4E71\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
+  MODULE_TYPE                    = DXE_DRIVER\r
   VERSION_STRING                 = 1.0\r
   LIBRARY_CLASS                  = FileHandleLib|DXE_DRIVER UEFI_APPLICATION UEFI_DRIVER\r
 \r
   ShellPkg/ShellPkg.dec\r
 \r
 [LibraryClasses]\r
-  UefiBootServicesTableLib\r
   MemoryAllocationLib\r
-  DevicePathLib\r
   BaseLib\r
   BaseMemoryLib\r
   DebugLib\r
+  PrintLib\r
+  PcdLib\r
 \r
 [Protocols]\r
+  gEfiSimpleFileSystemProtocolGuid             # ALWAYS_USED\r
   \r
 [Guids]\r
   gEfiFileInfoGuid                              # ALWAYS_CONSUMED\r
 \r
 [Pcd.common]\r
-\r
+  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize # ALWAYS_CONSUMED
\ No newline at end of file
index 04d818efd1d3a54d8d641fd50227b35d58ac9e68..3da6d4a9679f343a1928ca3403f98768ec21634b 100644 (file)
@@ -50,7 +50,8 @@ QuickSortWorker (
   IN CONST UINTN                        ElementSize,\r
   IN       SORT_COMPARE                 CompareFunction,\r
   IN VOID                               *Buffer\r
-  ){\r
+  )\r
+{\r
   VOID        *Pivot;\r
   UINTN       LoopCount;\r
   UINTN       NextSwapLocation;\r
@@ -149,7 +150,8 @@ PerformQuickSort (
   IN CONST UINTN                        Count,\r
   IN CONST UINTN                        ElementSize,\r
   IN       SORT_COMPARE                 CompareFunction\r
-  ){\r
+  )\r
+{\r
   VOID  *Buffer;\r
 \r
   ASSERT(BufferToSort     != NULL);\r
@@ -168,3 +170,18 @@ PerformQuickSort (
   FreePool(Buffer);\r
   return;\r
 }\r
+\r
+/**\r
+  Not supported in Base version.\r
+  \r
+  ASSERT and return 0.\r
+**/\r
+INTN\r
+DevicePathCompare (\r
+  IN  VOID             *Buffer1,\r
+  IN  VOID             *Buffer2\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}
\ No newline at end of file
index 0d79880dffb026b71f7d0d84e969e0a63562d447..f0b1e95b5fea0c4a656a736f9072bc5b4617e4a8 100644 (file)
@@ -1249,7 +1249,8 @@ EFIAPI
 InternalShellConvertFileListType (\r
   IN LIST_ENTRY                 *FileList,\r
   IN OUT LIST_ENTRY             *ListHead\r
-  ){\r
+  )\r
+{\r
   SHELL_FILE_ARG                *OldInfo;\r
   LIST_ENTRY                    *Link;\r
   EFI_SHELL_FILE_INFO_NO_CONST  *NewInfo;\r
@@ -1464,6 +1465,74 @@ ShellCloseFileMetaArg (
   }\r
 }\r
 \r
+/**\r
+  Find a file by searching the CWD and then the path.\r
+\r
+  if FileName is NULL then ASSERT.\r
+\r
+  if the return value is not NULL then the memory must be caller freed.\r
+\r
+  @param FileName               Filename string.\r
+\r
+  @retval NULL                  the file was not found\r
+  @return !NULL                 the full path to the file.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ShellFindFilePath (\r
+  IN CONST CHAR16 *FileName\r
+  )\r
+{\r
+  CONST CHAR16      *Path;\r
+  EFI_FILE_HANDLE   Handle;\r
+  EFI_STATUS        Status;\r
+  CHAR16            *RetVal;\r
+  CHAR16            *TestPath;\r
+  CONST CHAR16      *Walker;\r
+\r
+  RetVal = NULL;\r
+\r
+  Path = ShellGetEnvironmentVariable(L"cwd");\r
+  if (Path != NULL) {\r
+    TestPath = AllocateZeroPool(StrSize(Path) + StrSize(FileName));\r
+    StrCpy(TestPath, Path);\r
+    StrCat(TestPath, FileName);\r
+    Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
+    if (!EFI_ERROR(Status)){\r
+      RetVal = StrnCatGrow(&RetVal, NULL, TestPath, 0);\r
+      ShellCloseFile(&Handle);\r
+      FreePool(TestPath);\r
+      return (RetVal);\r
+    }\r
+    FreePool(TestPath);\r
+  }\r
+  Path = ShellGetEnvironmentVariable(L"path");\r
+  if (Path != NULL) {\r
+    TestPath = AllocateZeroPool(StrSize(Path)+StrSize(FileName) );\r
+    Walker = (CHAR16*)Path; \r
+    do {\r
+      CopyMem(TestPath, Walker, StrSize(Walker));\r
+      if (StrStr(TestPath, L";") != NULL) {\r
+        *(StrStr(TestPath, L";")) = CHAR_NULL;\r
+      }\r
+      StrCat(TestPath, FileName);\r
+      if (StrStr(Walker, L";") != NULL) {\r
+        Walker = StrStr(Walker, L";") + 1;\r
+      } else {\r
+        Walker = NULL;\r
+      }\r
+      Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
+      if (!EFI_ERROR(Status)){\r
+        RetVal = StrnCatGrow(&RetVal, NULL, TestPath, 0);\r
+        ShellCloseFile(&Handle);\r
+        break;\r
+      }\r
+    } while (Walker != NULL && Walker[0] != CHAR_NULL);\r
+    FreePool(TestPath);\r
+  }\r
+  return (RetVal);\r
+}\r
+\r
 typedef struct {\r
   LIST_ENTRY     Link;\r
   CHAR16         *Name;\r
@@ -1609,11 +1678,13 @@ InternalCommandLineParse (
   UINTN                         LoopCounter;\r
   ParamType                     CurrentItemType;\r
   SHELL_PARAM_PACKAGE           *CurrentItemPackage;\r
-  BOOLEAN                       GetItemValue;\r
+  UINTN                         GetItemValue;\r
+  UINTN                         ValueSize;\r
 \r
   CurrentItemPackage = NULL;\r
   mTotalParameterCount = 0;\r
-  GetItemValue = FALSE;\r
+  GetItemValue = 0;\r
+  ValueSize = 0;\r
 \r
   //\r
   // If there is only 1 item we dont need to do anything\r
@@ -1647,8 +1718,8 @@ InternalCommandLineParse (
       //\r
       // We might have leftover if last parameter didnt have optional value\r
       //\r
-      if (GetItemValue == TRUE) {\r
-        GetItemValue = FALSE;\r
+      if (GetItemValue != 0) {\r
+        GetItemValue = 0;\r
         InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
       }\r
       //\r
@@ -1666,27 +1737,48 @@ InternalCommandLineParse (
       //\r
       // Does this flag require a value\r
       //\r
-      if (CurrentItemPackage->Type == TypeValue) {\r
+      switch (CurrentItemPackage->Type) {\r
         //\r
-        // trigger the next loop to populate the value of this item\r
-        //\r
-        GetItemValue = TRUE; \r
-      } else {\r
-        //\r
-        // this item has no value expected; we are done\r
-        //\r
-        InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
+        // possibly trigger the next loop(s) to populate the value of this item\r
+        //        \r
+        case TypeValue:\r
+          GetItemValue = 1; \r
+          ValueSize = 0;\r
+          break;\r
+        case TypeDoubleValue:\r
+          GetItemValue = 2;\r
+          ValueSize = 0;\r
+          break;\r
+        case TypeMaxValue:\r
+          GetItemValue = (UINTN)(-1);\r
+          ValueSize = 0;\r
+          break;\r
+        default:\r
+          //\r
+          // this item has no value expected; we are done\r
+          //\r
+          InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
+          ASSERT(GetItemValue == 0);\r
+          break;\r
       }\r
-    } else if (GetItemValue == TRUE && InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers) == FALSE) {\r
+    } else if (GetItemValue != 0 && InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers) == FALSE) {\r
       ASSERT(CurrentItemPackage != NULL);\r
       //\r
-      // get the item VALUE for the previous flag\r
+      // get the item VALUE for a previous flag\r
       //\r
-      GetItemValue = FALSE;\r
-      CurrentItemPackage->Value = AllocateZeroPool(StrSize(Argv[LoopCounter]));\r
+      CurrentItemPackage->Value = ReallocatePool(ValueSize, ValueSize + StrSize(Argv[LoopCounter]) + sizeof(CHAR16), CurrentItemPackage->Value);\r
       ASSERT(CurrentItemPackage->Value != NULL);\r
-      StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
-      InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
+      if (ValueSize == 0) {\r
+        StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+      } else {\r
+        StrCat(CurrentItemPackage->Value, L" ");\r
+        StrCat(CurrentItemPackage->Value, Argv[LoopCounter]);\r
+      }\r
+      ValueSize += StrSize(Argv[LoopCounter]) + sizeof(CHAR16);\r
+      GetItemValue--;\r
+      if (GetItemValue == 0) {\r
+        InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
+      }\r
     } else if (InternalIsFlag(Argv[LoopCounter], AlwaysAllowNumbers) == FALSE) {\r
       //\r
       // add this one as a non-flag\r
@@ -1716,6 +1808,10 @@ InternalCommandLineParse (
       return (EFI_VOLUME_CORRUPTED);\r
     }\r
   }\r
+  if (GetItemValue != 0) {\r
+    GetItemValue = 0;\r
+    InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
+  }\r
   //\r
   // support for AutoPageBreak\r
   //\r
@@ -2028,7 +2124,8 @@ UINTN
 EFIAPI\r
 ShellCommandLineGetCount(\r
   VOID\r
-  ){\r
+  )\r
+{\r
   return (mTotalParameterCount);\r
 }\r
 \r
@@ -2362,3 +2459,126 @@ ShellIsDirectory(
   return (EFI_NOT_FOUND);\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
+\r
+  @param[in] String   String representation of a number\r
+\r
+  @retval all         the number\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellStrToUintn(\r
+  IN CONST CHAR16 *String\r
+  )\r
+{\r
+  CONST CHAR16  *Walker;\r
+  for (Walker = String; Walker != NULL && *Walker != CHAR_NULL && *Walker == L' '; Walker = Walker + 1);\r
+  if (StrnCmp(Walker, L"0x", 2) == 0 || StrnCmp(Walker, L"0X", 2) == 0){\r
+    return (StrHexToUintn(Walker));\r
+  }\r
+  return (StrDecimalToUintn(Walker));\r
+}\r
+\r
+/**\r
+  Safely append with automatic string resizing given length of Destination and\r
+  desired length of copy from Source.\r
+\r
+  append the first D characters of Source to the end of Destination, where D is\r
+  the lesser of Count and the StrLen() of Source. If appending those D characters\r
+  will fit within Destination (whose Size is given as CurrentSize) and\r
+  still leave room for a null terminator, then those characters are appended,\r
+  starting at the original terminating null of Destination, and a new terminating\r
+  null is appended.\r
+\r
+  If appending D characters onto Destination will result in a overflow of the size\r
+  given in CurrentSize the string will be grown such that the copy can be performed\r
+  and CurrentSize will be updated to the new size.\r
+\r
+  If Source is NULL, there is nothing to append, just return the current buffer in\r
+  Destination.\r
+\r
+  if Destination is NULL, then ASSERT()\r
+  if Destination's current length (including NULL terminator) is already more then\r
+  CurrentSize, then ASSERT()\r
+\r
+  @param[in,out] Destination   The String to append onto\r
+  @param[in,out] CurrentSize   on call the number of bytes in Destination.  On\r
+                                return possibly the new size (still in bytes).  if NULL\r
+                                then allocate whatever is needed.\r
+  @param[in]      Source        The String to append from\r
+  @param[in]      Count         Maximum number of characters to append.  if 0 then\r
+                                all are appended.\r
+\r
+  @return Destination           return the resultant string.\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+StrnCatGrow (\r
+  IN OUT CHAR16           **Destination,\r
+  IN OUT UINTN            *CurrentSize,\r
+  IN     CONST CHAR16     *Source,\r
+  IN     UINTN            Count\r
+  )\r
+{\r
+  UINTN DestinationStartSize;\r
+  UINTN NewSize;\r
+\r
+  //\r
+  // ASSERTs\r
+  //\r
+  ASSERT(Destination != NULL);\r
+\r
+  //\r
+  // If there's nothing to do then just return Destination\r
+  //\r
+  if (Source == NULL) {\r
+    return (*Destination);\r
+  }\r
+\r
+  //\r
+  // allow for un-initialized pointers, based on size being 0\r
+  //\r
+  if (CurrentSize != NULL && *CurrentSize == 0) {\r
+    *Destination = NULL;\r
+  }\r
+\r
+  //\r
+  // allow for NULL pointers address as Destination\r
+  //\r
+  if (*Destination != NULL) {\r
+    ASSERT(CurrentSize != 0);\r
+    DestinationStartSize = StrSize(*Destination);\r
+    ASSERT(DestinationStartSize <= *CurrentSize);\r
+  } else {\r
+    DestinationStartSize = 0;\r
+//    ASSERT(*CurrentSize == 0);\r
+  }\r
+\r
+  //\r
+  // Append all of Source?\r
+  //\r
+  if (Count == 0) {\r
+    Count = StrLen(Source);\r
+  }\r
+\r
+  //\r
+  // Test and grow if required\r
+  //\r
+  if (CurrentSize != NULL) {\r
+    NewSize = *CurrentSize;\r
+    while (NewSize < (DestinationStartSize + (Count*sizeof(CHAR16)))) {\r
+      NewSize += 2 * Count * sizeof(CHAR16);\r
+    }\r
+    *Destination = ReallocatePool(*CurrentSize, NewSize, *Destination);\r
+    *CurrentSize = NewSize;\r
+  } else {\r
+    *Destination = AllocateZeroPool((Count+1)*sizeof(CHAR16));\r
+  }\r
+\r
+  //\r
+  // Now use standard StrnCat on a big enough buffer\r
+  //\r
+  return StrnCat(*Destination, Source, Count);\r
+}\r
index e7a8d1e9525ee6f652c3c05fcb78adc2892a6596..f8a43db67345882da65cec5473b81adbf89aeb70 100644 (file)
@@ -55,7 +55,8 @@ QuickSortWorker (
   IN CONST UINTN                        ElementSize,\r
   IN       SORT_COMPARE                 CompareFunction,\r
   IN VOID                               *Buffer\r
-  ){\r
+  )\r
+{\r
   VOID        *Pivot;\r
   UINTN       LoopCount;\r
   UINTN       NextSwapLocation;\r
@@ -154,7 +155,8 @@ PerformQuickSort (
   IN CONST UINTN                        Count,\r
   IN CONST UINTN                        ElementSize,\r
   IN       SORT_COMPARE                 CompareFunction\r
-  ){\r
+  )\r
+{\r
   VOID  *Buffer;\r
 \r
   ASSERT(BufferToSort     != NULL);\r
@@ -188,7 +190,8 @@ INTN
 DevicePathCompare (\r
   IN  VOID             *Buffer1,\r
   IN  VOID             *Buffer2\r
-  ){\r
+  )\r
+{\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath1;\r
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath2;\r
   CHAR16                    *TextPath1;\r