]> git.proxmox.com Git - mirror_edk2.git/commitdiff
cls - add input verification.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 21:01:08 +0000 (21:01 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 25 Mar 2011 21:01:08 +0000 (21:01 +0000)
echo - add input verificaiton.
help - prints out commands in sorted order.
touch - add comments.
type - add error when file not found.  add comments.

main lib files:
add comments, clarify error messages.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11427 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiShellLevel3CommandsLib/Cls.c
ShellPkg/Library/UefiShellLevel3CommandsLib/Echo.c
ShellPkg/Library/UefiShellLevel3CommandsLib/Help.c
ShellPkg/Library/UefiShellLevel3CommandsLib/Touch.c
ShellPkg/Library/UefiShellLevel3CommandsLib/Type.c
ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c
ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.h
ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni

index 019aaf723179efd2724940b5fa919e6e208e1d55..dec24776ff53033e97dfafeceb55f65f94547d12 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for attrib shell level 2 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -83,11 +83,11 @@ ShellCommandRunCls (
         ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);\r
         ShellStatus = SHELL_INVALID_PARAMETER;\r
       } else {\r
-        if (StrDecimalToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {\r
+        if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {\r
           ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);\r
           ShellStatus = SHELL_INVALID_PARAMETER;\r
         } else {\r
-          switch (StrDecimalToUintn(Param1)) {\r
+          switch (ShellStrToUintn(Param1)) {\r
             case 0:\r
               Background = EFI_BACKGROUND_BLACK;\r
               break;\r
@@ -113,7 +113,7 @@ ShellCommandRunCls (
               Background = EFI_BACKGROUND_LIGHTGRAY;\r
               break;\r
           }\r
-          ForeColor = (~StrDecimalToUintn(Param1)) & 0xF;\r
+          ForeColor = (~ShellStrToUintn(Param1)) & 0xF;\r
           Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);\r
           ASSERT_EFI_ERROR(Status);\r
           Status = gST->ConOut->ClearScreen (gST->ConOut);\r
index dc6bca0b8ad6541a5f8d838c73596b32508ecb42..febfc000b3fe32ebda74477f47fa6869fada57df 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for Echo shell level 3 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -37,11 +37,11 @@ ShellCommandRunEcho (
 {\r
   EFI_STATUS          Status;\r
   LIST_ENTRY          *Package;\r
-//  CHAR16              *ProblemParam;\r
   SHELL_STATUS        ShellStatus;\r
   UINTN               ParamCount;\r
+  CHAR16              *ProblemParam;\r
 \r
-//  ProblemParam        = NULL;\r
+  ProblemParam        = NULL;\r
   ShellStatus         = SHELL_SUCCESS;\r
 \r
   //\r
@@ -53,16 +53,16 @@ ShellCommandRunEcho (
   //\r
   // parse the command line\r
   //\r
-  Status = ShellCommandLineParseEx (ParamList, &Package, NULL, TRUE, TRUE);\r
-//  if (EFI_ERROR(Status)) {\r
-//    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
-//      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
-//      FreePool(ProblemParam);\r
-//      ShellStatus = SHELL_INVALID_PARAMETER;\r
-//    } else {\r
-//      ASSERT(FALSE);\r
-//    }\r
-//  } else {\r
+  Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, TRUE);\r
+  if (EFI_ERROR(Status)) {\r
+    if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
+      ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
+      FreePool(ProblemParam);\r
+      ShellStatus = SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      ASSERT(FALSE);\r
+    }\r
+  } else {\r
     //\r
     // check for "-?"\r
     //\r
@@ -109,7 +109,7 @@ ShellCommandRunEcho (
     // free the command line package\r
     //\r
     ShellCommandLineFreeVarList (Package);\r
-//  }\r
+  }\r
 \r
   return (ShellStatus);\r
 }\r
index 04e3d31dba7ae9e93a6cc4a413a167455327d05c..1c643b0e578f6536e2118efb06c2e3a56a209365 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for Help shell level 3 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -18,7 +18,7 @@
 \r
 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
   {L"-usage", TypeFlag},\r
-  {L"-section", TypeValue},\r
+  {L"-section", TypeMaxValue},\r
   {L"-verbose", TypeFlag},\r
   {L"-v", TypeFlag},\r
   {NULL, TypeMax}\r
@@ -133,19 +133,24 @@ ShellCommandRunHelp (
         FreePool(HiiString);\r
         Found = TRUE;\r
       } else {\r
-        CommandList = ShellCommandGetCommandList();\r
+        CommandList = ShellCommandGetCommandList(TRUE);\r
         ASSERT(CommandList != NULL);\r
         for ( Node = (COMMAND_LIST*)GetFirstNode(&CommandList->Link)\r
             ; CommandList != NULL && !IsListEmpty(&CommandList->Link) && !IsNull(&CommandList->Link, &Node->Link)\r
             ; Node = (COMMAND_LIST*)GetNextNode(&CommandList->Link, &Node->Link)\r
            ){\r
-          if (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, CommandToGetHelpOn)) {\r
+          if ((gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, CommandToGetHelpOn)) ||\r
+             (gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL) != NULL && (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, (CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {\r
             //\r
             // We have a command to look for help on.\r
             //\r
             Status = gEfiShellProtocol->GetHelpText(Node->CommandString, SectionToGetHelpOn, &OutText);\r
             if (EFI_ERROR(Status) || OutText == NULL) {\r
-              ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, Node->CommandString);\r
+              if (Status == EFI_DEVICE_ERROR) {\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, Node->CommandString);\r
+              } else {\r
+                ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, Node->CommandString);\r
+              }\r
               ShellStatus = SHELL_NOT_FOUND;\r
             } else {\r
               while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {\r
index 0252f7748de588be1fdbc8f827b9c3b303ba65ba..7eb3c8c0e8b10edb52ec68f7682f4881d2df2901 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for Touch shell level 3 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 \r
 #include <Library/ShellLib.h>\r
 \r
+/**\r
+  Do the touch operation on a single handle.\r
+\r
+  @param[in] Handle   The handle to update the date/time on.\r
+\r
+  @retval EFI_ACCESS_DENIED The file referenced by Handle is read only.\r
+  @retval EFI_SUCCESS       The operation was successful.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 TouchFileByHandle (\r
@@ -40,6 +48,17 @@ TouchFileByHandle (
   return (Status);\r
 }\r
 \r
+/**\r
+  Touch a given file and potantially recurse down if it was a directory.\r
+\r
+  @param[in] Name   The name of this file.\r
+  @param[in] FS     The name of the file system this file is on.\r
+  @param[in] Handle The handle of this file already opened.\r
+  @param[in] Rec    TRUE to recurse if possible.\r
+\r
+  @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 DoTouchByHandle (\r
index 05f13f07565da2ec9f4eaa7f11a69399645d47be..3e4ccb36e34c7cae73984e3e204e846267e13c68 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for Type shell level 3 function.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 \r
 #include <Library/ShellLib.h>\r
 \r
+/**\r
+  Display a single file to StdOut.\r
+\r
+  If both Ascii and UCS2 are FALSE attempt to discover the file type.\r
+\r
+  @param[in] Handle   The handle to the file to display.\r
+  @param[in] Ascii    TRUE to force ASCII, FALSE othewise.\r
+  @param[in] UCS2     TRUE to force UCS2, FALSE othewise.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 TypeFileByHandle (\r
@@ -31,7 +43,7 @@ TypeFileByHandle (
   CHAR16      AsciiChar;\r
 \r
   ReadSize = PcdGet16(PcdShellFileOperationSize);\r
-  Buffer = AllocatePool(ReadSize);\r
+  Buffer = AllocateZeroPool(ReadSize);\r
   if (Buffer == NULL) {\r
     return (EFI_OUT_OF_RESOURCES);\r
   }\r
@@ -47,7 +59,7 @@ TypeFileByHandle (
     }\r
 \r
     if (!(Ascii|UCS2)){\r
-      if (*(UINT16*)Buffer == UnicodeFileTag) {\r
+      if (*(UINT16*)Buffer == gUnicodeFileTag) {\r
         UCS2 = TRUE;\r
         Buffer = ((UINT16*)Buffer) + 1;\r
       } else {\r
@@ -71,7 +83,7 @@ TypeFileByHandle (
       Print(L"%s", Buffer);\r
     }\r
   }\r
-  Status = Print(L"\r\n", Buffer);\r
+  Print(L"\r\n", Buffer);\r
   return (Status);\r
 }\r
 \r
@@ -161,6 +173,7 @@ ShellCommandRunType (
          ){\r
         Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);\r
         if (EFI_ERROR(Status)) {\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, (CHAR16*)Param);\r
           ShellStatus = SHELL_NOT_FOUND;\r
           break;\r
         }\r
index 3ce39d7ea2329e054257550fe5881f106cdc90e7..ef708cb17c0caffb1af1fc584e9f57370a1e9e40 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Main file for NULL named library for level 3 shell command functions.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,6 +20,11 @@ STATIC CONST EFI_GUID gShellLevel3HiiGuid = \
     0x4344558d, 0x4ef9, 0x4725, { 0xb1, 0xe4, 0x33, 0x76, 0xe8, 0xd6, 0x97, 0x4f } \\r
   };\r
 \r
+/**\r
+  return the filename to get help from is not using HII.\r
+\r
+  @retval The filename.\r
+**/\r
 CONST CHAR16*\r
 EFIAPI\r
 ShellCommandGetManFileNameLevel3 (\r
@@ -79,6 +84,9 @@ ShellLevel3CommandsLibConstructor (
 \r
 /**\r
   Destructor for the library.  free any resources.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+  @param SystemTable            The EFI System Table pointer.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
index b6ac99658d76567ae739de8fda77161d5346cb1f..6d19d9cc6803d3fc3c954803fa904d60a0e7a360 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   header file for NULL named library for level 3 shell command functions.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -12,6 +12,9 @@
 \r
 **/\r
 \r
+#if !defined (_UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_)\r
+#define _UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_\r
+\r
 #include <Uefi.h>\r
 #include <ShellBase.h>\r
 \r
@@ -154,3 +157,5 @@ ShellCommandRunHelp (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   );\r
 \r
+#endif\r
+\r
index ce5caf1249776fb7759487021e623176b123c9ea..723c25faf518dccebc2fa8559305372c32c23cd0 100644 (file)
Binary files a/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni and b/ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.uni differ