]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.c
ShellPkg: Apply uncrustify changes
[mirror_edk2.git] / ShellPkg / Library / UefiShellLevel3CommandsLib / UefiShellLevel3CommandsLib.c
1 /** @file
2 Main file for NULL named library for level 3 shell command functions.
3
4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
5 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9 #include "UefiShellLevel3CommandsLib.h"
10
11 CONST CHAR16 gShellLevel3FileName[] = L"ShellCommands";
12 EFI_HII_HANDLE gShellLevel3HiiHandle = NULL;
13
14 /**
15 return the filename to get help from is not using HII.
16
17 @retval The filename.
18 **/
19 CONST CHAR16 *
20 EFIAPI
21 ShellCommandGetManFileNameLevel3 (
22 VOID
23 )
24 {
25 return (gShellLevel3FileName);
26 }
27
28 /**
29 Constructor for the Shell Level 3 Commands library.
30
31 Install the handlers for level 3 UEFI Shell 2.0 commands.
32
33 @param ImageHandle the image handle of the process
34 @param SystemTable the EFI System Table pointer
35
36 @retval EFI_SUCCESS the shell command handlers were installed sucessfully
37 @retval EFI_UNSUPPORTED the shell level required was not found.
38 **/
39 EFI_STATUS
40 EFIAPI
41 ShellLevel3CommandsLibConstructor (
42 IN EFI_HANDLE ImageHandle,
43 IN EFI_SYSTEM_TABLE *SystemTable
44 )
45 {
46 gShellLevel3HiiHandle = NULL;
47 //
48 // if shell level is less than 3 do nothing
49 //
50 if (PcdGet8 (PcdShellSupportLevel) < 3) {
51 return (EFI_SUCCESS);
52 }
53
54 gShellLevel3HiiHandle = HiiAddPackages (&gShellLevel3HiiGuid, gImageHandle, UefiShellLevel3CommandsLibStrings, NULL);
55 if (gShellLevel3HiiHandle == NULL) {
56 return (EFI_DEVICE_ERROR);
57 }
58
59 //
60 // install our shell command handlers that are always installed
61 //
62 // Note: that Time, Timezone, and Date are part of level 2 library
63 //
64 ShellCommandRegisterCommandName (L"type", ShellCommandRunType, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_TYPE));
65 ShellCommandRegisterCommandName (L"touch", ShellCommandRunTouch, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_TOUCH));
66 ShellCommandRegisterCommandName (L"ver", ShellCommandRunVer, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_VER));
67 ShellCommandRegisterCommandName (L"alias", ShellCommandRunAlias, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_ALIAS));
68 ShellCommandRegisterCommandName (L"cls", ShellCommandRunCls, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_CLS));
69 ShellCommandRegisterCommandName (L"echo", ShellCommandRunEcho, ShellCommandGetManFileNameLevel3, 3, L"", FALSE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_ECHO));
70 ShellCommandRegisterCommandName (L"pause", ShellCommandRunPause, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_PAUSE));
71 ShellCommandRegisterCommandName (L"getmtc", ShellCommandRunGetMtc, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_GETMTC));
72 ShellCommandRegisterCommandName (L"help", ShellCommandRunHelp, ShellCommandGetManFileNameLevel3, 3, L"", TRUE, gShellLevel3HiiHandle, STRING_TOKEN (STR_GET_HELP_HELP));
73
74 ShellCommandRegisterAlias (L"type", L"cat");
75
76 return (EFI_SUCCESS);
77 }
78
79 /**
80 Destructor for the library. free any resources.
81
82 @param ImageHandle The image handle of the process.
83 @param SystemTable The EFI System Table pointer.
84 **/
85 EFI_STATUS
86 EFIAPI
87 ShellLevel3CommandsLibDestructor (
88 IN EFI_HANDLE ImageHandle,
89 IN EFI_SYSTEM_TABLE *SystemTable
90 )
91 {
92 if (gShellLevel3HiiHandle != NULL) {
93 HiiRemovePackages (gShellLevel3HiiHandle);
94 }
95
96 return (EFI_SUCCESS);
97 }