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