]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
BaseTools: Clean up source files
[mirror_edk2.git] / BaseTools / Source / C / EfiLdrImage / EfiLdrImage.c
index 7a3b4a2234cf17912c304bb128d0591b54a84e75..1895e6961906c0aad5a2fca952bc8016318928b3 100644 (file)
@@ -1,28 +1,19 @@
 /** @file\r
-\r
-Copyright 2006 - 2010, 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
-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
-\r
-Module Name:\r
-\r
-  efildrimage.c\r
-\r
-Abstract:\r
-\r
-  Creates and EFILDR image.\r
-  This tool combines several PE Image files together using following format denoted as EBNF:\r
-  FILE := EFILDR_HEADER\r
-          EFILDR_IMAGE +\r
-          <PeImageFileContent> +\r
-  The order of EFILDR_IMAGE is same as the order of placing PeImageFileContent.\r
-\r
-Revision History\r
+Creates and EFILDR image.\r
+This tool combines several PE Image files together using following format denoted as EBNF:\r
+FILE := EFILDR_HEADER\r
+        EFILDR_IMAGE +\r
+        <PeImageFileContent> +\r
+The order of EFILDR_IMAGE is same as the order of placing PeImageFileContent.\r
+\r
+Copyright (c) 2006 - 2018, 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
+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
 \r
 **/\r
 \r
@@ -45,8 +36,8 @@ typedef struct {
   UINT8  FileName[52];\r
 } EFILDR_IMAGE;\r
 \r
-typedef struct {          \r
-  UINT32       Signature;     \r
+typedef struct {\r
+  UINT32       Signature;\r
   UINT32       HeaderCheckSum;\r
   UINT32       FileLength;\r
   UINT32       NumberOfImages;\r
@@ -60,8 +51,8 @@ typedef struct {
 //\r
 // Utility version information\r
 //\r
-#define UTILITY_MAJOR_VERSION 0\r
-#define UTILITY_MINOR_VERSION 1\r
+#define UTILITY_MAJOR_VERSION 1\r
+#define UTILITY_MINOR_VERSION 0\r
 \r
 void\r
 Version (\r
@@ -83,8 +74,7 @@ Returns:
 \r
 --*/\r
 {\r
-  printf ("%s v%d.%d -Utility to break a file into two pieces at the request offset.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);\r
-  printf ("Copyright (c) 1999-2010 Intel Corporation. All rights reserved.\n");\r
+  printf ("%s Version %d.%d Build %s\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);\r
 }\r
 \r
 VOID\r
@@ -93,7 +83,9 @@ Usage (
   )\r
 {\r
   printf ("Usage: EfiLdrImage -o OutImage LoaderImage PeImage1 PeImage2 ... PeImageN\n");\r
-  exit (1);\r
+  printf ("%s Version %d.%d Build %s\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);\r
+  printf ("Copyright (c) 1999-2017 Intel Corporation. All rights reserved.\n");\r
+  printf ("\n  The EfiLdrImage tool is used to combine PE files into EFILDR image with Efi loader header.\n");\r
 }\r
 \r
 EFI_STATUS\r
@@ -110,7 +102,7 @@ CountVerboseLevel (
     }\r
     ++(*ReturnValue);\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -181,33 +173,32 @@ Returns:
   CHAR8* OutputFileName = NULL;\r
   CHAR8* InputFileNames[MAX_PE_IMAGES + 1];\r
   UINT8 InputFileCount = 0;\r
-  BOOLEAN QuietFlag = FALSE;\r
   UINT64        DebugLevel = 0;\r
   UINT64        VerboseLevel = 0;\r
   EFI_STATUS Status = EFI_SUCCESS;\r
-  \r
+\r
   SetUtilityName (UTILITY_NAME);\r
 \r
   if (argc == 1) {\r
-    Usage();\r
+    printf ("Usage: EfiLdrImage -o OutImage LoaderImage PeImage1 PeImage2 ... PeImageN\n");\r
     return STATUS_ERROR;\r
   }\r
-  \r
+\r
   argc --;\r
   argv ++;\r
 \r
   if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {\r
     Usage();\r
-    return STATUS_SUCCESS;    \r
+    return STATUS_SUCCESS;\r
   }\r
 \r
   if (stricmp (argv[0], "--version") == 0) {\r
     Version();\r
-    return STATUS_SUCCESS;    \r
+    return STATUS_SUCCESS;\r
   }\r
 \r
   while (argc > 0) {\r
-   \r
+\r
     if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--output") == 0)) {\r
       OutputFileName = argv[1];\r
       if (OutputFileName == NULL) {\r
@@ -216,40 +207,39 @@ Returns:
       }\r
       argc -= 2;\r
       argv += 2;\r
-      continue; \r
+      continue;\r
     }\r
-    \r
+\r
     if ((stricmp (argv[0], "-q") == 0) || (stricmp (argv[0], "--quiet") == 0)) {\r
-      QuietFlag = TRUE;\r
       argc --;\r
       argv ++;\r
-      continue; \r
+      continue;\r
     }\r
-    \r
+\r
     if ((strlen(argv[0]) >= 2 && argv[0][0] == '-' && (argv[0][1] == 'v' || argv[0][1] == 'V')) || (stricmp (argv[0], "--verbose") == 0)) {\r
       VerboseLevel = 1;\r
       if (strlen(argv[0]) > 2) {\r
         Status = CountVerboseLevel (&argv[0][2], strlen(argv[0]) - 2, &VerboseLevel);\r
         if (EFI_ERROR (Status)) {\r
-          Error (NULL, 0, 1003, "Invalid option value", argv[0]);\r
-          return STATUS_ERROR;        \r
+          Error (NULL, 0, 1003, "Invalid option value", "%s", argv[0]);\r
+          return STATUS_ERROR;\r
         }\r
       }\r
-      \r
+\r
       argc --;\r
       argv ++;\r
-      continue; \r
+      continue;\r
     }\r
-    \r
+\r
     if ((stricmp (argv[0], "-d") == 0) || (stricmp (argv[0], "--debug") == 0)) {\r
       Status = AsciiStringToUint64 (argv[1], FALSE, &DebugLevel);\r
       if (EFI_ERROR (Status)) {\r
         Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);\r
-        return STATUS_ERROR;        \r
+        return STATUS_ERROR;\r
       }\r
       argc -= 2;\r
       argv += 2;\r
-      continue; \r
+      continue;\r
     }\r
     //\r
     // Don't recognize the parameter, should be regarded as the input file name.\r
@@ -272,7 +262,7 @@ Returns:
     return STATUS_ERROR;\r
   }\r
 \r
-  fpOut = fopen(OutputFileName, "w+b");\r
+  fpOut = fopen (LongFilePath (OutputFileName), "w+b");\r
   if (!fpOut) {\r
     Error (NULL, 0, 0001, "Could not open output file", OutputFileName);\r
     return STATUS_ERROR;\r
@@ -296,7 +286,7 @@ Returns:
     //\r
     // Copy the content of PeImage file to output file\r
     //\r
-    fpIn = fopen (InputFileNames[i], "rb");\r
+    fpIn = fopen (LongFilePath (InputFileNames[i]), "rb");\r
     if (!fpIn) {\r
       Error (NULL, 0, 0001, "Could not open input file", InputFileNames[i]);\r
       fclose (fpOut);\r