]> git.proxmox.com Git - mirror_edk2.git/commitdiff
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8633 6f19259b...
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Jun 2009 21:15:07 +0000 (21:15 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 23 Jun 2009 21:15:07 +0000 (21:15 +0000)
ShellPkg/Application/ShellLibTestApp/sa3.c
ShellPkg/Include/Library/FileHandleLib.h
ShellPkg/Include/Library/ShellLib.h
ShellPkg/Include/Protocol/EfiShellEnvironment2.h
ShellPkg/Library/UefiShellLib/UefiShellLib.c

index 135590bed1847d0ce148ba28f8ac13c51a4afbe3..3be58a1365d54f2ab5d9355136b046533677ef6d 100644 (file)
@@ -3,7 +3,7 @@
 \r
   This should be executed with "/Param2 Val1" and "/Param1" as the 2 command line options!\r
 \r
-  Copyright (c) 2008, Intel Corporation                                                         \r
+  Copyright (c) 2008-2009, Intel Corporation                                                         \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
@@ -211,7 +211,7 @@ UefiMain (
   ASSERT(NoFile == FALSE);\r
   Status = ShellFindNextFile(FileHandle, pFileInfo, &NoFile);\r
   ASSERT_EFI_ERROR(Status);\r
-  /// @todo - why is NoFile never set? limitation of NT32 file system?\r
+  ///@todo - why is NoFile never set? limitation of NT32 file system?\r
   Status = ShellDeleteFile(&FileHandle);\r
   ASSERT(Status == RETURN_WARN_DELETE_FAILURE);\r
   Print(L"FindFirst - pass\r\n");\r
index 8547fd2e91f58b28e927d7bf2c27589b8aa6a6df..c03a112ceca265bd8c75bcdcf201629b1fe1d5cf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides interface to EFI_FILE_HANDLE functionality.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation\r
+Copyright (c) 2009, Intel Corporation\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
index f0998d8346118e41bc891fd7be7287b057553183..37c85e94dcc771da4fdb3a644f215b75d0d31718 100644 (file)
@@ -455,7 +455,7 @@ ShellGetExecutionBreakFlag(
 CONST CHAR16*\r
 EFIAPI\r
 ShellGetEnvironmentVariable (\r
-  IN CHAR16                     *EnvKey\r
+  IN CONST CHAR16                *EnvKey\r
   );\r
 \r
 /**\r
@@ -566,7 +566,7 @@ ShellSetPageBreakMode (
   and will process '?' and '*' as such.  the list must be freed with a call to \r
   ShellCloseFileMetaArg().\r
 \r
-  This function will fail if called sequentially without freeing the list in the middle.\r
+  If you are NOT appending to an existing list *ListHead must be NULL.\r
 \r
   @param Arg                    pointer to path string\r
   @param OpenMode               mode to open files with\r
index 7dbe715afb11f4fd9294028b998af4919e063745..9271786372781fde54e954b16171c56cd8db9313 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  Defines for EFI shell environment 2 ported to EDK II build environment.\r
+  Defines for EFI shell environment 2 ported to EDK II build environment. (no spec)\r
 \r
 Copyright (c) 2005, 2009 Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
index 6d83e29346d0acf0c64a5c73017bf19ad436353e..3a56903789a1693b0c57a6215148e83337a6d8b7 100644 (file)
@@ -258,8 +258,7 @@ EFIAPI
 ShellLibDestructor (\r
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
+  ){\r
   if (mEfiShellEnvironment2 != NULL) {\r
     gBS->CloseProtocol(mEfiShellEnvironment2Handle==NULL?ImageHandle:mEfiShellEnvironment2Handle,\r
                        &gEfiShellEnvironment2Guid,\r
@@ -984,7 +983,7 @@ ShellGetExecutionBreakFlag(
 CONST CHAR16*\r
 EFIAPI\r
 ShellGetEnvironmentVariable (\r
-  IN CHAR16                     *EnvKey\r
+  IN CONST CHAR16                *EnvKey\r
   )\r
 {\r
   // \r
@@ -1002,7 +1001,7 @@ ShellGetEnvironmentVariable (
   //\r
   // using EFI Shell\r
   //\r
-  return (mEfiShellEnvironment2->GetEnv(EnvKey));\r
+  return (mEfiShellEnvironment2->GetEnv((CHAR16*)EnvKey));\r
 }\r
 /**\r
   set the value of an environment variable\r
@@ -1220,32 +1219,26 @@ typedef struct {
   EFI_SHELL_FILE_INFO based list.  it is up to the caller to free the memory via\r
   the ShellCloseFileMetaArg function.\r
 \r
-  @param FileList               the EFI shell list type\r
+  @param[in] FileList           the EFI shell list type\r
+  @param[in][out] ListHead      the list to add to\r
 \r
   @retval the resultant head of the double linked new format list;\r
 **/\r
 LIST_ENTRY*\r
 EFIAPI\r
 InternalShellConvertFileListType (\r
-  LIST_ENTRY                *FileList\r
-  )\r
-{\r
-  LIST_ENTRY                    *ListHead;\r
+  IN LIST_ENTRY                 *FileList,\r
+  IN OUT LIST_ENTRY             *ListHead\r
+  ){\r
   SHELL_FILE_ARG                *OldInfo;\r
-  LIST_ENTRY                *Link;\r
+  LIST_ENTRY                    *Link;\r
   EFI_SHELL_FILE_INFO_NO_CONST  *NewInfo;\r
 \r
   //\r
-  // ASSERT that FileList is not NULL\r
-  //\r
-  ASSERT(FileList != NULL);\r
-\r
-  //\r
-  // Allocate our list head and initialize the list\r
+  // ASSERTs\r
   //\r
-  ListHead = AllocateZeroPool(sizeof(LIST_ENTRY));\r
-  ASSERT (ListHead != NULL);\r
-  ListHead = InitializeListHead (ListHead);\r
+  ASSERT(FileList  != NULL);\r
+  ASSERT(ListHead  != NULL);\r
 \r
   //\r
   // enumerate through each member of the old list and copy\r
@@ -1299,7 +1292,7 @@ InternalShellConvertFileListType (
     //\r
     // add that to the list\r
     //\r
-    InsertTailList(ListHead, (LIST_ENTRY*)NewInfo);\r
+    InsertTailList(ListHead, &NewInfo->Link);\r
   }\r
   return (ListHead);\r
 }\r
@@ -1313,7 +1306,7 @@ InternalShellConvertFileListType (
   and will process '?' and '*' as such.  the list must be freed with a call to \r
   ShellCloseFileMetaArg().\r
 \r
-  This function will fail if called sequentially without freeing the list in the middle.\r
+  If you are NOT appending to an existing list *ListHead must be NULL.\r
 \r
   @param Arg                    pointer to path string\r
   @param OpenMode               mode to open files with\r
@@ -1336,8 +1329,7 @@ ShellOpenFileMetaArg (
   )\r
 {\r
   EFI_STATUS                    Status;\r
-  LIST_ENTRY                    *EmptyNode;\r
-  LIST_ENTRY                    *mOldStyleFileList;\r
+  LIST_ENTRY                    mOldStyleFileList;\r
   \r
   //\r
   // ASSERT that Arg and ListHead are not NULL\r
@@ -1359,43 +1351,36 @@ ShellOpenFileMetaArg (
   //\r
   ASSERT(mEfiShellEnvironment2 != NULL);\r
 \r
-  //\r
-  // allocate memory for old list head\r
-  //\r
-  mOldStyleFileList = (LIST_ENTRY*)AllocatePool(sizeof(LIST_ENTRY));\r
-  ASSERT(mOldStyleFileList != NULL);\r
-\r
   //\r
   // make sure the list head is initialized\r
   //\r
-  InitializeListHead((LIST_ENTRY*)mOldStyleFileList);\r
+  InitializeListHead(&mOldStyleFileList);\r
 \r
   //\r
   // Get the EFI Shell list of files\r
   //\r
-  Status = mEfiShellEnvironment2->FileMetaArg(Arg, mOldStyleFileList);\r
+  Status = mEfiShellEnvironment2->FileMetaArg(Arg, &mOldStyleFileList);\r
   if (EFI_ERROR(Status)) {\r
     *ListHead = NULL;\r
     return (Status);\r
   }\r
 \r
+  if (*ListHead == NULL) {\r
+    *ListHead = (EFI_SHELL_FILE_INFO    *)AllocateZeroPool(sizeof(EFI_SHELL_FILE_INFO));\r
+    if (*ListHead == NULL) {\r
+      return (EFI_OUT_OF_RESOURCES);\r
+    }\r
+  }\r
+\r
   //\r
   // Convert that to equivalent of UEFI Shell 2.0 structure\r
   //\r
-  EmptyNode = InternalShellConvertFileListType(mOldStyleFileList);\r
+  InternalShellConvertFileListType(&mOldStyleFileList, &(*ListHead)->Link);\r
 \r
   //\r
   // Free the EFI Shell version that was converted.\r
   //\r
-  ASSERT_EFI_ERROR(mEfiShellEnvironment2->FreeFileList(mOldStyleFileList));\r
-  FreePool(mOldStyleFileList);\r
-  mOldStyleFileList = NULL;\r
-\r
-  //\r
-  // remove the empty head of the list\r
-  //\r
-  *ListHead = (EFI_SHELL_FILE_INFO*)RemoveEntryList(EmptyNode);\r
-  FreePool(EmptyNode);  \r
+  mEfiShellEnvironment2->FreeFileList(&mOldStyleFileList);\r
 \r
   return (Status);\r
 }\r
@@ -1431,7 +1416,9 @@ ShellCloseFileMetaArg (
     // Since this is EFI Shell version we need to free our internally made copy \r
     // of the list\r
     //\r
-    for (Node = GetFirstNode((LIST_ENTRY*)*ListHead) ; IsListEmpty((LIST_ENTRY*)*ListHead) == FALSE ; Node = GetFirstNode((LIST_ENTRY*)*ListHead)) {\r
+    for ( Node = GetFirstNode(&(*ListHead)->Link) \r
+        ; IsListEmpty(&(*ListHead)->Link) == FALSE \r
+        ; Node = GetFirstNode(&(*ListHead)->Link)) {\r
       RemoveEntryList(Node);\r
       ((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Handle->Close(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->Handle);\r
       FreePool(((EFI_SHELL_FILE_INFO_NO_CONST*)Node)->FullName);\r
@@ -1444,7 +1431,7 @@ ShellCloseFileMetaArg (
 }\r
 \r
 typedef struct {\r
-  LIST_ENTRY List;\r
+  LIST_ENTRY     Link;\r
   CHAR16         *Name;\r
   ParamType      Type;\r
   CHAR16         *Value;\r
@@ -1636,7 +1623,7 @@ InternalCommandLineParse (
         //\r
         // this item has no value expected; we are done\r
         //\r
-        InsertHeadList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
+        InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
       }\r
     } else if (GetItemValue == TRUE && InternalIsFlag(Argv[LoopCounter]) == FALSE) {\r
       ASSERT(CurrentItemPackage != NULL);\r
@@ -1647,7 +1634,7 @@ InternalCommandLineParse (
       CurrentItemPackage->Value = AllocateZeroPool(StrSize(Argv[LoopCounter]));\r
       ASSERT(CurrentItemPackage->Value != NULL);\r
       StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
-      InsertHeadList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
+      InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
     } else if (InternalIsFlag(Argv[LoopCounter]) == FALSE) {\r
       //\r
       // add this one as a non-flag\r
@@ -1660,7 +1647,7 @@ InternalCommandLineParse (
       ASSERT(CurrentItemPackage->Value != NULL);\r
       StrCpy(CurrentItemPackage->Value, Argv[LoopCounter]);\r
       CurrentItemPackage->OriginalPosition = Count++;\r
-      InsertHeadList(*CheckPackage, (LIST_ENTRY*)CurrentItemPackage);\r
+      InsertHeadList(*CheckPackage, &CurrentItemPackage->Link);\r
     } else if (ProblemParam) {\r
       //\r
       // this was a non-recognised flag... error!\r