mirror of https://github.com/acidanthera/audk.git
cls - add input verification.
echo - add input verificaiton. help - prints out commands in sorted order. touch - add comments. type - add error when file not found. add comments. main lib files: add comments, clarify error messages. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11427 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b54fd049bd
commit
345cd2357a
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Main file for attrib shell level 2 function.
|
Main file for attrib shell level 2 function.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -83,11 +83,11 @@ ShellCommandRunCls (
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel3HiiHandle);
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
if (StrDecimalToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {
|
if (ShellStrToUintn(Param1) > 7 || StrLen(Param1) > 1 || !ShellIsDecimalDigitCharacter(*Param1)) {
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, Param1);
|
||||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
} else {
|
} else {
|
||||||
switch (StrDecimalToUintn(Param1)) {
|
switch (ShellStrToUintn(Param1)) {
|
||||||
case 0:
|
case 0:
|
||||||
Background = EFI_BACKGROUND_BLACK;
|
Background = EFI_BACKGROUND_BLACK;
|
||||||
break;
|
break;
|
||||||
|
@ -113,7 +113,7 @@ ShellCommandRunCls (
|
||||||
Background = EFI_BACKGROUND_LIGHTGRAY;
|
Background = EFI_BACKGROUND_LIGHTGRAY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ForeColor = (~StrDecimalToUintn(Param1)) & 0xF;
|
ForeColor = (~ShellStrToUintn(Param1)) & 0xF;
|
||||||
Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);
|
Status = gST->ConOut->SetAttribute (gST->ConOut, ForeColor | Background);
|
||||||
ASSERT_EFI_ERROR(Status);
|
ASSERT_EFI_ERROR(Status);
|
||||||
Status = gST->ConOut->ClearScreen (gST->ConOut);
|
Status = gST->ConOut->ClearScreen (gST->ConOut);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Main file for Echo shell level 3 function.
|
Main file for Echo shell level 3 function.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -37,11 +37,11 @@ ShellCommandRunEcho (
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
LIST_ENTRY *Package;
|
LIST_ENTRY *Package;
|
||||||
// CHAR16 *ProblemParam;
|
|
||||||
SHELL_STATUS ShellStatus;
|
SHELL_STATUS ShellStatus;
|
||||||
UINTN ParamCount;
|
UINTN ParamCount;
|
||||||
|
CHAR16 *ProblemParam;
|
||||||
|
|
||||||
// ProblemParam = NULL;
|
ProblemParam = NULL;
|
||||||
ShellStatus = SHELL_SUCCESS;
|
ShellStatus = SHELL_SUCCESS;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -53,16 +53,16 @@ ShellCommandRunEcho (
|
||||||
//
|
//
|
||||||
// parse the command line
|
// parse the command line
|
||||||
//
|
//
|
||||||
Status = ShellCommandLineParseEx (ParamList, &Package, NULL, TRUE, TRUE);
|
Status = ShellCommandLineParseEx (ParamList, &Package, &ProblemParam, TRUE, TRUE);
|
||||||
// if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
// if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
|
||||||
// ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);
|
||||||
// FreePool(ProblemParam);
|
FreePool(ProblemParam);
|
||||||
// ShellStatus = SHELL_INVALID_PARAMETER;
|
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||||
// } else {
|
} else {
|
||||||
// ASSERT(FALSE);
|
ASSERT(FALSE);
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
//
|
//
|
||||||
// check for "-?"
|
// check for "-?"
|
||||||
//
|
//
|
||||||
|
@ -109,7 +109,7 @@ ShellCommandRunEcho (
|
||||||
// free the command line package
|
// free the command line package
|
||||||
//
|
//
|
||||||
ShellCommandLineFreeVarList (Package);
|
ShellCommandLineFreeVarList (Package);
|
||||||
// }
|
}
|
||||||
|
|
||||||
return (ShellStatus);
|
return (ShellStatus);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Main file for Help shell level 3 function.
|
Main file for Help shell level 3 function.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
||||||
{L"-usage", TypeFlag},
|
{L"-usage", TypeFlag},
|
||||||
{L"-section", TypeValue},
|
{L"-section", TypeMaxValue},
|
||||||
{L"-verbose", TypeFlag},
|
{L"-verbose", TypeFlag},
|
||||||
{L"-v", TypeFlag},
|
{L"-v", TypeFlag},
|
||||||
{NULL, TypeMax}
|
{NULL, TypeMax}
|
||||||
|
@ -133,19 +133,24 @@ ShellCommandRunHelp (
|
||||||
FreePool(HiiString);
|
FreePool(HiiString);
|
||||||
Found = TRUE;
|
Found = TRUE;
|
||||||
} else {
|
} else {
|
||||||
CommandList = ShellCommandGetCommandList();
|
CommandList = ShellCommandGetCommandList(TRUE);
|
||||||
ASSERT(CommandList != NULL);
|
ASSERT(CommandList != NULL);
|
||||||
for ( Node = (COMMAND_LIST*)GetFirstNode(&CommandList->Link)
|
for ( Node = (COMMAND_LIST*)GetFirstNode(&CommandList->Link)
|
||||||
; CommandList != NULL && !IsListEmpty(&CommandList->Link) && !IsNull(&CommandList->Link, &Node->Link)
|
; CommandList != NULL && !IsListEmpty(&CommandList->Link) && !IsNull(&CommandList->Link, &Node->Link)
|
||||||
; Node = (COMMAND_LIST*)GetNextNode(&CommandList->Link, &Node->Link)
|
; Node = (COMMAND_LIST*)GetNextNode(&CommandList->Link, &Node->Link)
|
||||||
){
|
){
|
||||||
if (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, CommandToGetHelpOn)) {
|
if ((gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, CommandToGetHelpOn)) ||
|
||||||
|
(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL) != NULL && (gUnicodeCollation->MetaiMatch(gUnicodeCollation, Node->CommandString, (CHAR16*)(gEfiShellProtocol->GetAlias(CommandToGetHelpOn, NULL)))))) {
|
||||||
//
|
//
|
||||||
// We have a command to look for help on.
|
// We have a command to look for help on.
|
||||||
//
|
//
|
||||||
Status = gEfiShellProtocol->GetHelpText(Node->CommandString, SectionToGetHelpOn, &OutText);
|
Status = gEfiShellProtocol->GetHelpText(Node->CommandString, SectionToGetHelpOn, &OutText);
|
||||||
if (EFI_ERROR(Status) || OutText == NULL) {
|
if (EFI_ERROR(Status) || OutText == NULL) {
|
||||||
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, Node->CommandString);
|
if (Status == EFI_DEVICE_ERROR) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_INV), gShellLevel3HiiHandle, Node->CommandString);
|
||||||
|
} else {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HELP_NF), gShellLevel3HiiHandle, Node->CommandString);
|
||||||
|
}
|
||||||
ShellStatus = SHELL_NOT_FOUND;
|
ShellStatus = SHELL_NOT_FOUND;
|
||||||
} else {
|
} else {
|
||||||
while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
|
while (OutText[StrLen(OutText)-1] == L'\r' || OutText[StrLen(OutText)-1] == L'\n' || OutText[StrLen(OutText)-1] == L' ') {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Main file for Touch shell level 3 function.
|
Main file for Touch shell level 3 function.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -16,6 +16,14 @@
|
||||||
|
|
||||||
#include <Library/ShellLib.h>
|
#include <Library/ShellLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Do the touch operation on a single handle.
|
||||||
|
|
||||||
|
@param[in] Handle The handle to update the date/time on.
|
||||||
|
|
||||||
|
@retval EFI_ACCESS_DENIED The file referenced by Handle is read only.
|
||||||
|
@retval EFI_SUCCESS The operation was successful.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
TouchFileByHandle (
|
TouchFileByHandle (
|
||||||
|
@ -40,6 +48,17 @@ TouchFileByHandle (
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Touch a given file and potantially recurse down if it was a directory.
|
||||||
|
|
||||||
|
@param[in] Name The name of this file.
|
||||||
|
@param[in] FS The name of the file system this file is on.
|
||||||
|
@param[in] Handle The handle of this file already opened.
|
||||||
|
@param[in] Rec TRUE to recurse if possible.
|
||||||
|
|
||||||
|
@retval EFI_INVALID_PARAMETER A parameter was invalid.
|
||||||
|
@retval EFI_SUCCESS The operation was successful.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
DoTouchByHandle (
|
DoTouchByHandle (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Main file for Type shell level 3 function.
|
Main file for Type shell level 3 function.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -16,6 +16,18 @@
|
||||||
|
|
||||||
#include <Library/ShellLib.h>
|
#include <Library/ShellLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a single file to StdOut.
|
||||||
|
|
||||||
|
If both Ascii and UCS2 are FALSE attempt to discover the file type.
|
||||||
|
|
||||||
|
@param[in] Handle The handle to the file to display.
|
||||||
|
@param[in] Ascii TRUE to force ASCII, FALSE othewise.
|
||||||
|
@param[in] UCS2 TRUE to force UCS2, FALSE othewise.
|
||||||
|
|
||||||
|
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
|
||||||
|
@retval EFI_SUCCESS The operation was successful.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
TypeFileByHandle (
|
TypeFileByHandle (
|
||||||
|
@ -31,7 +43,7 @@ TypeFileByHandle (
|
||||||
CHAR16 AsciiChar;
|
CHAR16 AsciiChar;
|
||||||
|
|
||||||
ReadSize = PcdGet16(PcdShellFileOperationSize);
|
ReadSize = PcdGet16(PcdShellFileOperationSize);
|
||||||
Buffer = AllocatePool(ReadSize);
|
Buffer = AllocateZeroPool(ReadSize);
|
||||||
if (Buffer == NULL) {
|
if (Buffer == NULL) {
|
||||||
return (EFI_OUT_OF_RESOURCES);
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +59,7 @@ TypeFileByHandle (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(Ascii|UCS2)){
|
if (!(Ascii|UCS2)){
|
||||||
if (*(UINT16*)Buffer == UnicodeFileTag) {
|
if (*(UINT16*)Buffer == gUnicodeFileTag) {
|
||||||
UCS2 = TRUE;
|
UCS2 = TRUE;
|
||||||
Buffer = ((UINT16*)Buffer) + 1;
|
Buffer = ((UINT16*)Buffer) + 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,7 +83,7 @@ TypeFileByHandle (
|
||||||
Print(L"%s", Buffer);
|
Print(L"%s", Buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Status = Print(L"\r\n", Buffer);
|
Print(L"\r\n", Buffer);
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +173,7 @@ ShellCommandRunType (
|
||||||
){
|
){
|
||||||
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);
|
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ, &FileList);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
|
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, (CHAR16*)Param);
|
||||||
ShellStatus = SHELL_NOT_FOUND;
|
ShellStatus = SHELL_NOT_FOUND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
Main file for NULL named library for level 3 shell command functions.
|
Main file for NULL named library for level 3 shell command functions.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -20,6 +20,11 @@ STATIC CONST EFI_GUID gShellLevel3HiiGuid = \
|
||||||
0x4344558d, 0x4ef9, 0x4725, { 0xb1, 0xe4, 0x33, 0x76, 0xe8, 0xd6, 0x97, 0x4f } \
|
0x4344558d, 0x4ef9, 0x4725, { 0xb1, 0xe4, 0x33, 0x76, 0xe8, 0xd6, 0x97, 0x4f } \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
return the filename to get help from is not using HII.
|
||||||
|
|
||||||
|
@retval The filename.
|
||||||
|
**/
|
||||||
CONST CHAR16*
|
CONST CHAR16*
|
||||||
EFIAPI
|
EFIAPI
|
||||||
ShellCommandGetManFileNameLevel3 (
|
ShellCommandGetManFileNameLevel3 (
|
||||||
|
@ -79,6 +84,9 @@ ShellLevel3CommandsLibConstructor (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destructor for the library. free any resources.
|
Destructor for the library. free any resources.
|
||||||
|
|
||||||
|
@param ImageHandle The image handle of the process.
|
||||||
|
@param SystemTable The EFI System Table pointer.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
header file for NULL named library for level 3 shell command functions.
|
header file for NULL named library for level 3 shell command functions.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>
|
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved. <BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -12,6 +12,9 @@
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#if !defined (_UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_)
|
||||||
|
#define _UEFI_SHELL_LEVEL3_COMMANDS_LIB_H_
|
||||||
|
|
||||||
#include <Uefi.h>
|
#include <Uefi.h>
|
||||||
#include <ShellBase.h>
|
#include <ShellBase.h>
|
||||||
|
|
||||||
|
@ -154,3 +157,5 @@ ShellCommandRunHelp (
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue