]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
21eacac5e341885325f8dfc446ff8a73b663f650
[mirror_edk2.git] / ShellPkg / Application / ShellSortTestApp / ShellSortTestApp.c
1 /** @file
2 This is a test application that demonstrates how to use the sorting functions.
3
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <Uefi.h>
10 #include <Library/UefiLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/ShellCEntryLib.h>
13 #include <Library/SortLib.h>
14
15 /**
16 Test comparator.
17
18 @param[in] b1 The first INTN
19 @param[in] b2 The other INTN
20
21 @retval 0 They are the same.
22 @retval -1 b1 is less than b2
23 @retval 1 b1 is greater then b2
24 **/
25 INTN
26 EFIAPI
27 Test(CONST VOID *b1, CONST VOID *b2)
28 {
29 if (*(INTN*)b1 == *(INTN*)b2) {
30 return (0);
31 }
32 if (*(INTN*)b1 < *(INTN*)b2) {
33 return(-1);
34 }
35 return (1);
36 }
37
38 /**
39 UEFI application entry point which has an interface similar to a
40 standard C main function.
41
42 The ShellCEntryLib library instance wrappers the actual UEFI application
43 entry point and calls this ShellAppMain function.
44
45 @param Argc Argument count
46 @param Argv The parsed arguments
47
48 @retval 0 The application exited normally.
49 @retval Other An error occurred.
50
51 **/
52 INTN
53 EFIAPI
54 ShellAppMain (
55 IN UINTN Argc,
56 IN CHAR16 **Argv
57 )
58 {
59 INTN Array[10];
60
61 Array[0] = 2;
62 Array[1] = 3;
63 Array[2] = 4;
64 Array[3] = 1;
65 Array[4] = 5;
66 Array[5] = 6;
67 Array[6] = 7;
68 Array[7] = 8;
69 Array[8] = 1;
70 Array[9] = 5;
71
72 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]);
73 PerformQuickSort(Array, 10, sizeof(INTN), Test);
74 Print(L"POST-SORT\r\n");
75 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]);
76 return 0;
77 }