]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.c
ShellPkg: Apply uncrustify changes
[mirror_edk2.git] / ShellPkg / Library / UefiShellCEntryLib / UefiShellCEntryLib.c
index 80f56c00148f2915799d421dd8da6e01786947de..17e48443ac1e47f82911e1195d3622ba9bf946d9 100644 (file)
@@ -1,33 +1,21 @@
 /** @file\r
-  Provides application point extension for "C" style main funciton \r
+  Provides application point extension for "C" style main function\r
 \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
-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
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #include <Base.h>\r
 \r
 #include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/LoadedImage.h>\r
 #include <Protocol/EfiShellInterface.h>\r
-#include <Protocol/EfiShellParameters.h>\r
+#include <Protocol/ShellParameters.h>\r
 \r
 #include <Library/ShellCEntryLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
-INTN\r
-EFIAPI \r
-ShellAppMain (\r
-  IN INTN Argc, \r
-  IN CHAR16 **Argv\r
-  );\r
-\r
 /**\r
   UEFI entry point for an application that will in turn call the\r
   ShellAppMain function which has parameters similar to a standard C\r
@@ -36,6 +24,10 @@ ShellAppMain (
   An application that uses UefiShellCEntryLib must have a ShellAppMain\r
   function as prototyped in Include/Library/ShellCEntryLib.h.\r
 \r
+  Note that the Shell uses POSITIVE integers for error values, while UEFI\r
+  uses NEGATIVE values.  If the application is to be used within a script,\r
+  it needs to return one of the SHELL_STATUS values defined in Protocol/Shell.h.\r
+\r
   @param  ImageHandle  The image handle of the UEFI Application.\r
   @param  SystemTable  A pointer to the EFI System Table.\r
 \r
@@ -51,22 +43,23 @@ ShellCEntryLib (
   )\r
 {\r
   INTN                           ReturnFromMain;\r
-  EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;\r
-  EFI_SHELL_INTERFACE           *EfiShellInterface;\r
-  EFI_STATUS                    Status;\r
+  EFI_SHELL_PARAMETERS_PROTOCOL  *EfiShellParametersProtocol;\r
+  EFI_SHELL_INTERFACE            *EfiShellInterface;\r
+  EFI_STATUS                     Status;\r
 \r
-  ReturnFromMain = -1;\r
+  ReturnFromMain             = -1;\r
   EfiShellParametersProtocol = NULL;\r
-  EfiShellInterface = NULL;\r
+  EfiShellInterface          = NULL;\r
 \r
-  Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
-                             &gEfiShellParametersProtocolGuid,\r
-                             (VOID **)&EfiShellParametersProtocol,\r
-                             ImageHandle,\r
-                             NULL,\r
-                             EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                             );\r
-  if (!EFI_ERROR(Status)) {\r
+  Status = SystemTable->BootServices->OpenProtocol (\r
+                                        ImageHandle,\r
+                                        &gEfiShellParametersProtocolGuid,\r
+                                        (VOID **)&EfiShellParametersProtocol,\r
+                                        ImageHandle,\r
+                                        NULL,\r
+                                        EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                                        );\r
+  if (!EFI_ERROR (Status)) {\r
     //\r
     // use shell 2.0 interface\r
     //\r
@@ -78,28 +71,26 @@ ShellCEntryLib (
     //\r
     // try to get shell 1.0 interface instead.\r
     //\r
-    Status = SystemTable->BootServices->OpenProtocol(ImageHandle, \r
-                               &gEfiShellInterfaceGuid,\r
-                               (VOID **)&EfiShellInterface,\r
-                               ImageHandle,\r
-                               NULL,\r
-                               EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                               );\r
-    if (!EFI_ERROR(Status)) {\r
+    Status = SystemTable->BootServices->OpenProtocol (\r
+                                          ImageHandle,\r
+                                          &gEfiShellInterfaceGuid,\r
+                                          (VOID **)&EfiShellInterface,\r
+                                          ImageHandle,\r
+                                          NULL,\r
+                                          EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                                          );\r
+    if (!EFI_ERROR (Status)) {\r
       //\r
       // use shell 1.0 interface\r
-      // \r
+      //\r
       ReturnFromMain = ShellAppMain (\r
                          EfiShellInterface->Argc,\r
                          EfiShellInterface->Argv\r
                          );\r
     } else {\r
-      ASSERT(FALSE);\r
+      ASSERT (FALSE);\r
     }\r
   }\r
-  if (ReturnFromMain == 0) {\r
-    return (EFI_SUCCESS);\r
-  } else {\r
-    return (EFI_UNSUPPORTED);\r
-  }\r
+\r
+  return ReturnFromMain;\r
 }\r