]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
add:
[mirror_edk2.git] / ShellPkg / Application / ShellSortTestApp / ShellSortTestApp.c
diff --git a/ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c b/ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
new file mode 100644 (file)
index 0000000..5a671e0
--- /dev/null
@@ -0,0 +1,58 @@
+/** @file\r
+  This is a test application that demonstrates how to use the sorting functions.\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
+\r
+**/\r
+\r
+#include <Uefi.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/ShellCEntryLib.h>\r
+#include <Library/SortLib.h>\r
+\r
+INTN Test(VOID*b1, VOID*b2)\r
+{\r
+  if (*(INTN*)b1 == *(INTN*)b2) {\r
+    return (0);\r
+  }\r
+  if (*(INTN*)b1 < *(INTN*)b2) {\r
+    return(-1);\r
+  }\r
+  return (1);\r
+}\r
+\r
+/**\r
+  UEFI application entry point which has an interface similar to a\r
+  standard C main function.\r
+\r
+  The ShellCEntryLib library instance wrappers the actual UEFI application\r
+  entry point and calls this ShellAppMain function.\r
+\r
+  @param  ImageHandle  The image handle of the UEFI Application.\r
+  @param  SystemTable  A pointer to the EFI System Table.\r
+\r
+  @retval  0               The application exited normally.\r
+  @retval  Other           An error occurred.\r
+\r
+**/\r
+INTN \r
+EFIAPI \r
+ShellAppMain (\r
+  IN UINTN Argc, \r
+  IN CHAR16 **Argv\r
+  ){\r
+  INTN Array[10] = {2,3,4,1,5,6,7,8,1,5};\r
+  Print(L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0],Array[1],Array[2],Array[3],Array[4],Array[5],Array[6],Array[7],Array[8],Array[9]);\r
+  PerformQuickSort(Array, 10, sizeof(INTN), Test);\r
+  Print(L"POST-SORT\r\n");\r
+  Print(L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0],Array[1],Array[2],Array[3],Array[4],Array[5],Array[6],Array[7],Array[8],Array[9]);\r
+  return 0;\r
+}\r