]> git.proxmox.com Git - mirror_edk2.git/commitdiff
build break fix and new function
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 20 Nov 2009 21:13:41 +0000 (21:13 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 20 Nov 2009 21:13:41 +0000 (21:13 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9461 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/Protocol/EfiShell.h
ShellPkg/Include/Protocol/EfiShellParameters.h
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 617d90b692d1fe1ac1db376daf6edae3ad883146..96ec2648a14efa4db3694ab3e263a42387421f3d 100644 (file)
@@ -718,8 +718,8 @@ ShellCommandLineGetFlag (
   \r
   If CheckPackage is NULL, then return NULL.\r
 \r
-  @param CheckPackage           The package of parsed command line arguments.\r
-  @param KeyString              The Key of the command line argument to check for.\r
+  @param[in] CheckPackage       The package of parsed command line arguments.\r
+  @param[in] KeyString          The Key of the command line argument to check for.\r
 \r
   @retval NULL                  The flag is not on the command line.\r
   @retval !=NULL                Pointer to unicode string of the value.\r
@@ -736,10 +736,10 @@ ShellCommandLineGetValue (
 \r
   Raw value parameters are in the form of "value" in a specific position in the list.\r
   \r
-  If CheckPackage is NULL, then return NULL;\r
+  If CheckPackage is NULL, then return NULL.\r
 \r
-  @param CheckPackage           The package of parsed command line arguments.\r
-  @param Position               The position of the value.\r
+  @param[in] CheckPackage       The package of parsed command line arguments.\r
+  @param[in] Position           The position of the value.\r
 \r
   @retval NULL                  The flag is not on the command line.\r
   @retval !=NULL                Pointer to unicode string of the value.\r
@@ -765,6 +765,27 @@ ShellCommandLineGetCount(
   VOID\r
   );\r
 \r
+/**\r
+  Determins if a parameter is duplicated.\r
+\r
+  If Param is not NULL then it will point to a callee allocated string buffer \r
+  with the parameter value if a duplicate is found.\r
+\r
+  If CheckPackage is NULL, then ASSERT.\r
+\r
+  @param[in] CheckPackage       The package of parsed command line arguments.\r
+  @param[out] Param             Upon finding one, a pointer to the duplicated parameter.\r
+\r
+  @retval EFI_SUCCESS           No parameters were duplicated.\r
+  @retval EFI_DEVICE_ERROR      A duplicate was found.\r
+  **/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCommandLineCheckDuplicate (\r
+  IN CONST LIST_ENTRY              *CheckPackage,\r
+  OUT CHAR16                       **Param\r
+  );\r
+\r
 /**\r
   This function causes the shell library to initialize itself.  If the shell library\r
   is already initialized it will de-initialize all the current protocol poitners and\r
index 92bb03fa5e6d9534fb66032c14633ad9deb5308d..82d228187d4ee1178fcc44afeab982cd838acbad 100644 (file)
@@ -791,7 +791,7 @@ EFI_STATUS
                                 If Alias is NULL, ReturnedData points to a \91;\92 \r
                                 delimited list of alias (e.g. \r
                                 ReturnedData = \93dir;del;copy;mfp\94) that is null-terminated.  \r
-  @retval NULL                  an error ocurred.\r
+  @retval NULL                  An error ocurred.\r
   @retval NULL                  Alias was not a valid Alias.\r
 **/\r
 typedef \r
index 8f6658b6b5139ac77067193318eb414bb94b9e6f..dcf4b72ad39ddcaee4592acb938361413a9f94a3 100644 (file)
   }\r
 \r
 typedef struct _EFI_SHELL_PARAMETERS_PROTOCOL {\r
-///\r
-/// Points to an Argc-element array of points to null-terminated strings containing\r
-/// the command-line parameters. The first entry in the array is always the full file\r
-/// path of the executable. Any quotation marks that were used to preserve\r
-/// whitespace have been removed.\r
-///\r
+  ///\r
+  /// Points to an Argc-element array of points to null-terminated strings containing\r
+  /// the command-line parameters. The first entry in the array is always the full file\r
+  /// path of the executable. Any quotation marks that were used to preserve\r
+  /// whitespace have been removed.\r
+  ///\r
   CHAR16 **Argv;\r
 \r
-///\r
-/// The number of elements in the Argv array.\r
-/// \r
+  ///\r
+  /// The number of elements in the Argv array.\r
+  /// \r
   UINTN Argc;\r
 \r
-///\r
-/// The file handle for the standard input for this executable. This may be different\r
-/// from the ConInHandle in the EFI_SYSTEM_TABLE.\r
-///\r
+  ///\r
+  /// The file handle for the standard input for this executable. This may be different\r
+  /// from the ConInHandle in the EFI_SYSTEM_TABLE.\r
+  ///\r
   EFI_FILE_HANDLE StdIn;\r
 \r
-///\r
-/// The file handle for the standard output for this executable. This may be different\r
-/// from the ConOutHandle in the EFI_SYSTEM_TABLE.\r
-///\r
+  ///\r
+  /// The file handle for the standard output for this executable. This may be different\r
+  /// from the ConOutHandle in the EFI_SYSTEM_TABLE.\r
+  ///\r
   EFI_FILE_HANDLE StdOut;\r
 \r
-///\r
-/// The file handle for the standard error output for this executable. This may be\r
-/// different from the StdErrHandle in the EFI_SYSTEM_TABLE.\r
-///\r
+  ///\r
+  /// The file handle for the standard error output for this executable. This may be\r
+  /// different from the StdErrHandle in the EFI_SYSTEM_TABLE.\r
+  ///\r
   EFI_FILE_HANDLE StdErr;\r
 } EFI_SHELL_PARAMETERS_PROTOCOL;\r
 \r
index e52d1e76271e2010d976745620f2654fddf1d1b5..b1128ffc14ed2aef5376d2f3d8b0b4183483d6f6 100644 (file)
@@ -1489,12 +1489,15 @@ ShellFindFilePath (
   CHAR16            *RetVal;\r
   CHAR16            *TestPath;\r
   CONST CHAR16      *Walker;\r
+  UINTN             Size;\r
 \r
   RetVal = NULL;\r
 \r
   Path = ShellGetEnvironmentVariable(L"cwd");\r
   if (Path != NULL) {\r
-    TestPath = AllocateZeroPool((StrSize(Path) + StrSize(FileName)));\r
+    Size = StrSize(Path);\r
+    Size += StrSize(FileName);\r
+    TestPath = AllocateZeroPool(Size);\r
     StrCpy(TestPath, Path);\r
     StrCat(TestPath, FileName);\r
     Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
@@ -1508,7 +1511,9 @@ ShellFindFilePath (
   }\r
   Path = ShellGetEnvironmentVariable(L"path");\r
   if (Path != NULL) {\r
-    TestPath = AllocateZeroPool((StrSize(Path)+StrSize(FileName)));\r
+    Size = StrSize(Path);\r
+    Size += StrSize(FileName);\r
+    TestPath = AllocateZeroPool(Size);\r
     Walker = (CHAR16*)Path; \r
     do {\r
       CopyMem(TestPath, Walker, StrSize(Walker));\r
@@ -2129,6 +2134,52 @@ ShellCommandLineGetCount(
   return (mTotalParameterCount);\r
 }\r
 \r
+/**\r
+  Determins if a parameter is duplicated.\r
+\r
+  If Param is not NULL then it will point to a callee allocated string buffer \r
+  with the parameter value if a duplicate is found.\r
+\r
+  If CheckPackage is NULL, then ASSERT.\r
+\r
+  @param[in] CheckPackage       The package of parsed command line arguments.\r
+  @param[out] Param             Upon finding one, a pointer to the duplicated parameter.\r
+\r
+  @retval EFI_SUCCESS           No parameters were duplicated.\r
+  @retval EFI_DEVICE_ERROR      A duplicate was found.\r
+  **/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCommandLineCheckDuplicate (\r
+  IN CONST LIST_ENTRY              *CheckPackage,\r
+  OUT CHAR16                       **Param\r
+  )\r
+{\r
+  LIST_ENTRY                    *Node1;\r
+  LIST_ENTRY                    *Node2;\r
+  \r
+  ASSERT(CheckPackage != NULL);\r
+\r
+  for ( Node1 = GetFirstNode(CheckPackage) \r
+      ; !IsNull (CheckPackage, Node1) \r
+      ; Node1 = GetNextNode(CheckPackage, Node1) \r
+      ){\r
+    for ( Node2 = GetNextNode(CheckPackage, Node1) \r
+        ; !IsNull (CheckPackage, Node2) \r
+        ; Node2 = GetNextNode(CheckPackage, Node2) \r
+        ){\r
+      if (StrCmp(((SHELL_PARAM_PACKAGE*)Node1)->Name, ((SHELL_PARAM_PACKAGE*)Node2)->Name) == 0) {\r
+        if (Param != NULL) {\r
+          *Param = NULL;\r
+          *Param = StrnCatGrow(Param, NULL, ((SHELL_PARAM_PACKAGE*)Node1)->Name, 0);\r
+        }\r
+        return (EFI_DEVICE_ERROR);\r
+      }\r
+    }\r
+  }\r
+  return (EFI_SUCCESS);\r
+}\r
+\r
 /**\r
   This is a find and replace function.  it will return the NewString as a copy of \r
   SourceString with each instance of FindTarget replaced with ReplaceWith.\r
@@ -2459,6 +2510,39 @@ ShellIsDirectory(
   return (EFI_NOT_FOUND);\r
 }\r
 \r
+/**\r
+  Function to determine if a given filename represents a file.\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
+ShellIsFile(\r
+  IN CONST CHAR16 *Name\r
+  )\r
+{\r
+  EFI_STATUS        Status;\r
+  EFI_FILE_HANDLE   Handle;\r
+\r
+  Handle = NULL;\r
+\r
+  Status = ShellOpenFileByName(Name, &Handle, EFI_FILE_MODE_READ, 0);\r
+  if (EFI_ERROR(Status)) {\r
+    return (Status);\r
+  }\r
+\r
+  if (FileHandleIsDirectory(Handle) != EFI_SUCCESS) {\r
+    ShellCloseFile(&Handle);\r
+    return (EFI_SUCCESS);\r
+  }\r
+  ShellCloseFile(&Handle);\r
+  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