]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
Refine code to follow coding style.
[mirror_edk2.git] / ShellPkg / Application / ShellSortTestApp / ShellSortTestApp.c
CommitLineData
4983ca93 1/** @file\r
2 This is a test application that demonstrates how to use the sorting functions.\r
3\r
3a888f2a 4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
1e6e84c7 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
4983ca93 9\r
1e6e84c7 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
4983ca93 12\r
13**/\r
14\r
15#include <Uefi.h>\r
16#include <Library/UefiLib.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/ShellCEntryLib.h>\r
19#include <Library/SortLib.h>\r
20\r
0f87f732 21/**\r
22 Test comparator.\r
23\r
24 @param[in] b1 The first INTN\r
25 @param[in] b2 The other INTN\r
26\r
27 @retval 0 They are the same.\r
28 @retval -1 b1 is less than b2\r
29 @retval 1 b1 is greater then b2\r
30**/\r
e26d7b59 31INTN\r
32EFIAPI\r
f62f07ee 33Test(CONST VOID *b1, CONST VOID *b2)\r
4983ca93 34{\r
35 if (*(INTN*)b1 == *(INTN*)b2) {\r
36 return (0);\r
37 }\r
38 if (*(INTN*)b1 < *(INTN*)b2) {\r
39 return(-1);\r
40 }\r
41 return (1);\r
42}\r
43\r
44/**\r
45 UEFI application entry point which has an interface similar to a\r
46 standard C main function.\r
47\r
48 The ShellCEntryLib library instance wrappers the actual UEFI application\r
49 entry point and calls this ShellAppMain function.\r
50\r
4ff7e37b
ED
51 @param Argc Argument count\r
52 @param Argv The parsed arguments\r
4983ca93 53\r
54 @retval 0 The application exited normally.\r
55 @retval Other An error occurred.\r
56\r
57**/\r
1e6e84c7 58INTN\r
59EFIAPI\r
4983ca93 60ShellAppMain (\r
1e6e84c7 61 IN UINTN Argc,\r
4983ca93 62 IN CHAR16 **Argv\r
125c2cf4 63 )\r
64{\r
f62f07ee
ED
65 INTN Array[10];\r
66\r
67 Array[0] = 2;\r
68 Array[1] = 3;\r
69 Array[2] = 4;\r
70 Array[3] = 1;\r
71 Array[4] = 5;\r
72 Array[5] = 6;\r
73 Array[6] = 7;\r
74 Array[7] = 8;\r
75 Array[8] = 1;\r
76 Array[9] = 5;\r
77\r
4983ca93 78 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
79 PerformQuickSort(Array, 10, sizeof(INTN), Test);\r
80 Print(L"POST-SORT\r\n");\r
81 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
82 return 0;\r
83}\r