TianoCore EDK2 master
Loading...
Searching...
No Matches
Shift.c
Go to the documentation of this file.
1
11
19EFIAPI
21 IN EFI_HANDLE ImageHandle,
22 IN EFI_SYSTEM_TABLE *SystemTable
23 )
24{
25 EFI_STATUS Status;
26 SCRIPT_FILE *CurrentScriptFile;
27 UINTN LoopVar;
28
29 Status = CommandInit ();
30 ASSERT_EFI_ERROR (Status);
31
32 if (!gEfiShellProtocol->BatchIsActive ()) {
33 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_NO_SCRIPT), gShellLevel1HiiHandle, L"shift");
34 return (SHELL_UNSUPPORTED);
35 }
36
37 CurrentScriptFile = ShellCommandGetCurrentScriptFile ();
38 if (CurrentScriptFile == NULL) {
39 ASSERT (CurrentScriptFile != NULL);
41 }
42
43 if (CurrentScriptFile->Argc < 2) {
44 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel1HiiHandle, L"shift");
45 return (SHELL_UNSUPPORTED);
46 }
47
48 for (LoopVar = 0; LoopVar < CurrentScriptFile->Argc; LoopVar++) {
49 if (LoopVar == 0) {
50 SHELL_FREE_NON_NULL (CurrentScriptFile->Argv[LoopVar]);
51 }
52
53 if (LoopVar < CurrentScriptFile->Argc -1) {
54 CurrentScriptFile->Argv[LoopVar] = CurrentScriptFile->Argv[LoopVar+1];
55 } else {
56 CurrentScriptFile->Argv[LoopVar] = NULL;
57 }
58 }
59
60 CurrentScriptFile->Argc--;
61 return (SHELL_SUCCESS);
62}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_UNSUPPORTED
Definition: Shell.h:40
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
EFI_STATUS EFIAPI CommandInit(VOID)
SCRIPT_FILE *EFIAPI ShellCommandGetCurrentScriptFile(VOID)
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
SHELL_STATUS EFIAPI ShellCommandRunShift(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: Shift.c:20
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define STRING_TOKEN(t)
UINTN Argc
The count of parameters.
CHAR16 ** Argv
The parmameters to the script file.