本文整理汇总了C++中STRING_TOKEN函数的典型用法代码示例。如果您正苦于以下问题:C++ STRING_TOKEN函数的具体用法?C++ STRING_TOKEN怎么用?C++ STRING_TOKEN使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STRING_TOKEN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoDiagnostics
/**
Do the diagnostics call for some set of handles.
@param[in] Mode The type of diagnostic test to run.
@param[in] Lang The language code to use.
@param[in] AllChilds Should the test be on all children.
@param[in] DriverHandle The driver handle to test with.
@param[in] ControllerHandle The specific controller handle to test.
@param[in] ChildHandle The specific child handle to test.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_INVALID_PARAMETER A parameter had an invalid value.
@retval EFI_NOT_FOUND No diagnostic handle could be found.
**/
EFI_STATUS
EFIAPI
DoDiagnostics (
IN CONST DRV_DIAG_TEST_MODE Mode,
IN CONST CHAR8 *Lang,
IN CONST BOOLEAN AllChilds,
IN CONST EFI_HANDLE DriverHandle,
IN CONST EFI_HANDLE ControllerHandle,
IN CONST EFI_HANDLE ChildHandle
)
{
EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2;
EFI_HANDLE *DriverHandleList;
EFI_HANDLE *ControllerHandleList;
EFI_HANDLE *ChildHandleList;
EFI_HANDLE *Walker;
UINTN DriverHandleListCount;
UINTN ControllerHandleListCount;
UINTN ChildHandleListCount;
UINTN DriverHandleListLoop;
UINTN ControllerHandleListLoop;
UINTN ChildHandleListLoop;
EFI_STATUS Status;
EFI_STATUS Status2;
EFI_GUID *ErrorType;
UINTN OutBufferSize;
CHAR16 *OutBuffer;
UINTN HandleIndex1;
UINTN HandleIndex2;
CHAR8 *Language;
BOOLEAN Found;
if ((ChildHandle != NULL && AllChilds) || (Mode >= TestModeMax)){
return (EFI_INVALID_PARAMETER);
}
DriverDiagnostics = NULL;
DriverDiagnostics2 = NULL;
Status = EFI_SUCCESS;
Status2 = EFI_SUCCESS;
DriverHandleList = NULL;
ControllerHandleList = NULL;
ChildHandleList = NULL;
Language = NULL;
OutBuffer = NULL;
ErrorType = NULL;
DriverHandleListCount = 0;
ControllerHandleListCount = 0;
ChildHandleListCount = 0;
if (DriverHandle != NULL) {
DriverHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
ASSERT(DriverHandleList!=NULL);
DriverHandleList[0] = DriverHandle;
DriverHandleListCount = 1;
} else {
DriverHandleList = GetHandleListByProtocolList(DiagGuidList);
if (DriverHandleList == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"gEfiDriverDiagnosticsProtocolGuid", &gEfiDriverDiagnosticsProtocolGuid);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROTOCOL_NF), gShellDriver1HiiHandle, L"gEfiDriverDiagnostics2ProtocolGuid", &gEfiDriverDiagnostics2ProtocolGuid);
return (EFI_NOT_FOUND);
}
for (Walker = DriverHandleList ; Walker != NULL && *Walker != NULL ; DriverHandleListCount++, Walker++);
}
if (ControllerHandle != NULL) {
ControllerHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
ASSERT(ControllerHandleList!=NULL);
ControllerHandleList[0] = ControllerHandle;
ControllerHandleListCount = 1;
} else {
ControllerHandleList = NULL;
}
if (ChildHandle != NULL) {
ChildHandleList = AllocateZeroPool(2*sizeof(EFI_HANDLE));
ASSERT(ChildHandleList!=NULL);
ChildHandleList[0] = ChildHandle;
ChildHandleListCount = 1;
} else if (AllChilds) {
ChildHandleList = NULL;
//
// This gets handled in the loop below.
//
} else {
//.........这里部分代码省略.........
示例2: SEnvCmdEcho
EFI_STATUS
SEnvCmdEcho (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Shell command "echo".
Arguments:
ImageHandle - The image handle
SystemTable - The system table
Returns:
--*/
{
EFI_STATUS Status;
SHELL_VAR_CHECK_CODE RetCode;
CHAR16 *Useful;
SHELL_VAR_CHECK_PACKAGE ChkPck;
SHELL_ARG_LIST *Item;
BOOLEAN PageBreak;
EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
if (!EFI_PROPER_VERSION (0, 99)) {
PrintToken (
STRING_TOKEN (STR_SHELLENV_GNC_COMMAND_NOT_SUPPORT),
HiiEnvHandle,
L"echo",
EFI_VERSION_0_99
);
Status = EFI_UNSUPPORTED;
goto Done;
}
Status = EFI_SUCCESS;
PageBreak = FALSE;
ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
//
// No args: print status
// One arg, either -on or -off: set console echo flag
// Otherwise: echo all the args. Shell parser will expand any args or vars.
//
RetCode = LibCheckVariables (SI, EchoCheckList, &ChkPck, &Useful);
if (VarCheckOk != RetCode) {
switch (RetCode) {
case VarCheckDuplicate:
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_DUP_FLAG), HiiEnvHandle, L"echo", Useful);
break;
case VarCheckUnknown:
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiEnvHandle, L"echo", Useful);
break;
case VarCheckConflict:
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_FLAG_CONFLICT), HiiEnvHandle, L"echo", Useful);
break;
default:
break;
}
Status = EFI_INVALID_PARAMETER;
goto Done;
}
if (LibCheckVarGetFlag (&ChkPck, L"-b") != NULL) {
EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
PageBreak = TRUE;
}
//
// Out put help.
//
if (LibCheckVarGetFlag (&ChkPck, L"-?") != NULL) {
if (IS_OLD_SHELL) {
PrintToken (STRING_TOKEN (STR_NO_HELP), HiiEnvHandle);
} else if (ChkPck.ValueCount > 0 ||
ChkPck.FlagCount > 2 ||
(2 == ChkPck.FlagCount && !LibCheckVarGetFlag (&ChkPck, L"-b"))
) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiEnvHandle, L"echo");
Status = EFI_INVALID_PARAMETER;
} else {
PrintToken (STRING_TOKEN (STR_SHELLENV_ECHO_VERBOSE_HELP), HiiEnvHandle);
}
goto Done;
}
if (LibCheckVarGetFlag (&ChkPck, L"-on") != NULL) {
if (ChkPck.ValueCount != 0) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiEnvHandle, L"echo");
Status = EFI_INVALID_PARAMETER;
//.........这里部分代码省略.........
示例3: Image
/**
Function for 'mm' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunMm (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoDev;
UINT64 Address;
UINT64 PciEAddress;
UINT64 Value;
UINT32 SegmentNumber;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width;
EFI_ACCESS_TYPE AccessType;
UINT64 Buffer;
UINTN Index;
UINTN Size;
// CHAR16 *ValueStr;
BOOLEAN Complete;
CHAR16 *InputStr;
BOOLEAN Interactive;
EFI_HANDLE *HandleBuffer;
UINTN BufferSize;
UINTN ItemValue;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *Temp;
Address = 0;
PciEAddress = 0;
IoDev = NULL;
HandleBuffer = NULL;
BufferSize = 0;
SegmentNumber = 0;
ShellStatus = SHELL_SUCCESS;
InputStr = NULL;
//
// Parse arguments
//
Width = EfiPciWidthUint8;
Size = 1;
AccessType = EfiMemory;
// ValueStr = NULL;
Interactive = TRUE;
Package = NULL;
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
} else if (ShellCommandLineGetCount(Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
} else if (ShellCommandLineGetFlag(Package, L"-w") && ShellCommandLineGetValue(Package, L"-w") == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDebug1HiiHandle, L"-w");
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
} else {
if (ShellCommandLineGetFlag(Package, L"-mmio")) {
AccessType = EFIMemoryMappedIo;
if (ShellCommandLineGetFlag(Package, L"-mem")
||ShellCommandLineGetFlag(Package, L"-io")
||ShellCommandLineGetFlag(Package, L"-pci")
||ShellCommandLineGetFlag(Package, L"-pcie")
){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
} else if (ShellCommandLineGetFlag(Package, L"-mem")) {
AccessType = EfiMemory;
if (ShellCommandLineGetFlag(Package, L"-io")
||ShellCommandLineGetFlag(Package, L"-pci")
||ShellCommandLineGetFlag(Package, L"-pcie")
){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
goto Done;
}
//.........这里部分代码省略.........
示例4: ParseParameterData
//.........这里部分代码省略.........
DataType = TestDataType (Data);
if (DataType == DataTypeHexNumber) {
//
// hex number
//
StrHexToUint64S (Data + 2, NULL, &HexNumber);
HexNumberLen = StrLen (Data + 2);
if (HexNumberLen >= 1 && HexNumberLen <= 2) {
Size = 1;
} else if (HexNumberLen >= 3 && HexNumberLen <= 4) {
Size = 2;
} else if (HexNumberLen >= 5 && HexNumberLen <= 8) {
Size = 4;
} else if (HexNumberLen >= 9 && HexNumberLen <= 16) {
Size = 8;
}
if (Buffer != NULL && *BufferSize >= Size) {
CopyMem(Buffer, (VOID *)&HexNumber, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeHexArray) {
//
// hex array
//
if (*Data == L'H') {
Data = Data + 1;
}
Size = StrLen (Data) / 2;
if (Buffer != NULL && *BufferSize >= Size) {
StrHexToBytes(Data, StrLen (Data), (UINT8 *)Buffer, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeAscii) {
//
// ascii text
//
if (*Data == L'S') {
Data = Data + 1;
}
AsciiBuffer = AllocateZeroPool (StrSize (Data) / 2);
if (AsciiBuffer == NULL) {
Status = EFI_OUT_OF_RESOURCES;
} else {
AsciiSPrint (AsciiBuffer, StrSize (Data) / 2, "%s", (CHAR8 *)Data);
Size = StrSize (Data) / 2 - 1;
if (Buffer != NULL && *BufferSize >= Size) {
CopyMem (Buffer, AsciiBuffer, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
}
SHELL_FREE_NON_NULL (AsciiBuffer);
} else if (DataType == DataTypeUnicode) {
//
// unicode text
//
if (*Data == L'L') {
Data = Data + 1;
}
Size = StrSize (Data) - sizeof (CHAR16);
if (Buffer != NULL && *BufferSize >= Size) {
CopyMem (Buffer, Data, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
} else if (DataType == DataTypeDevicePath) {
if (*Data == L'P') {
Data = Data + 1;
} else if (StrnCmp (Data, L"--", 2) == 0) {
Data = Data + 2;
}
DevPath = ConvertTextToDevicePath (Data);
if (DevPath == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_DPFT), gShellDebug1HiiHandle, L"setvar");
Status = EFI_INVALID_PARAMETER;
} else {
Size = GetDevicePathSize (DevPath);
if (Buffer != NULL && *BufferSize >= Size) {
CopyMem (Buffer, DevPath, Size);
} else {
Status = EFI_BUFFER_TOO_SMALL;
}
*BufferSize = Size;
}
SHELL_FREE_NON_NULL (DevPath);
} else {
Status = EFI_INVALID_PARAMETER;
}
return Status;
}
示例5: Image
/**
Function for 'setvar' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunSetVar (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
RETURN_STATUS RStatus;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
CONST CHAR16 *VariableName;
EFI_GUID Guid;
CONST CHAR16 *StringGuid;
UINT32 Attributes;
VOID *Buffer;
UINTN Size;
UINTN LoopVar;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
Buffer = NULL;
Size = 0;
Attributes = 0;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
// ASSERT_EFI_ERROR(Status);
Status = CommandInit();
// ASSERT_EFI_ERROR(Status);
if (EFI_ERROR(Status)) {
return SHELL_UNSUPPORTED;
}
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} /* else {
ASSERT(FALSE);
} */
} else if (ShellCommandLineCheckDuplicate (Package,&ProblemParam) != EFI_SUCCESS) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DUPLICATE), gShellDebug1HiiHandle, L"setvar", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
if (ShellCommandLineGetCount(Package) < 2) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle, L"setvar");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
VariableName = ShellCommandLineGetRawValue(Package, 1);
if (!ShellCommandLineGetFlag(Package, L"-guid")){
CopyGuid(&Guid, &gEfiGlobalVariableGuid);
} else {
StringGuid = ShellCommandLineGetValue(Package, L"-guid");
RStatus = StrToGuid (StringGuid, &Guid);
if (RETURN_ERROR (RStatus) || (StringGuid[GUID_STRING_LENGTH] != L'\0')) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDebug1HiiHandle, L"setvar", StringGuid);
ShellStatus = SHELL_INVALID_PARAMETER;
}
}
if (ShellCommandLineGetCount(Package) == 2) {
//
// Display
//
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
if (Status == EFI_BUFFER_TOO_SMALL) {
Buffer = AllocateZeroPool(Size);
Status = gRT->GetVariable((CHAR16*)VariableName, &Guid, &Attributes, &Size, Buffer);
}
if (!EFI_ERROR(Status) && Buffer != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_SETVAR_PRINT), gShellDebug1HiiHandle, &Guid, VariableName, Size);
for (LoopVar = 0; LoopVar < Size; LoopVar++) {
ShellPrintEx(-1, -1, L"%02x ", ((UINT8*)Buffer)[LoopVar]);
}
ShellPrintEx(-1, -1, L"\r\n");
} else {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_SETVAR_ERROR_GET), gShellDebug1HiiHandle, L"setvar", &Guid, VariableName);
ShellStatus = SHELL_ACCESS_DENIED;
}
} else {
//
// Create, Delete or Modify.
//.........这里部分代码省略.........
示例6: PERF_INIT_CUM_DATA
/// Timer Specific Information.
TIMER_INFO TimerInfo;
/// Items for which to gather cumulative statistics.
PERF_CUM_DATA CumData[] = {
PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK),
PERF_INIT_CUM_DATA (START_IMAGE_TOK),
PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),
PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK)
};
/// Number of items for which we are gathering cumulative statistics.
UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
PARAM_ITEM_LIST ParamList[] = {
{STRING_TOKEN (STR_DP_OPTION_QH), TypeFlag}, // -? Help
{STRING_TOKEN (STR_DP_OPTION_LH), TypeFlag}, // -h Help
{STRING_TOKEN (STR_DP_OPTION_UH), TypeFlag}, // -H Help
{STRING_TOKEN (STR_DP_OPTION_LV), TypeFlag}, // -v Verbose Mode
{STRING_TOKEN (STR_DP_OPTION_UA), TypeFlag}, // -A All, Cooked
{STRING_TOKEN (STR_DP_OPTION_UR), TypeFlag}, // -R RAW All
{STRING_TOKEN (STR_DP_OPTION_LS), TypeFlag}, // -s Summary
#if PROFILING_IMPLEMENTED
{STRING_TOKEN (STR_DP_OPTION_UP), TypeFlag}, // -P Dump Profile Data
{STRING_TOKEN (STR_DP_OPTION_UT), TypeFlag}, // -T Dump Trace Data
#endif
{STRING_TOKEN (STR_DP_OPTION_LX), TypeFlag}, // -x eXclude Cumulative Items
{STRING_TOKEN (STR_DP_OPTION_LI), TypeFlag}, // -i Display Identifier
{STRING_TOKEN (STR_DP_OPTION_LC), TypeValue}, // -c Display cumulative data.
{STRING_TOKEN (STR_DP_OPTION_LN), TypeValue}, // -n # Number of records to display for A and R
{STRING_TOKEN (STR_DP_OPTION_LT), TypeValue} // -t # Threshold of interest
示例7: InitializeDp
//.........这里部分代码省略.........
StringDpOptionUs = NULL;
StringDpOptionLs = NULL;
StringDpOptionUa = NULL;
StringDpOptionUr = NULL;
StringDpOptionUt = NULL;
StringDpOptionUp = NULL;
StringDpOptionLx = NULL;
StringDpOptionLn = NULL;
StringDpOptionLt = NULL;
StringDpOptionLi = NULL;
StringDpOptionLc = NULL;
StringPtr = NULL;
// Get DP's entry time as soon as possible.
// This is used as the Shell-Phase end time.
//
Ticker = GetPerformanceCounter ();
// Register our string package with HII and return the handle to it.
//
gHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, DPStrings, NULL);
ASSERT (gHiiHandle != NULL);
// Initial the command list
//
InitialShellParamList ();
/****************************************************************************
**** Process Command Line arguments ****
****************************************************************************/
Status = ShellCommandLineParse (DpParamList, &ParamPackage, NULL, TRUE);
if (EFI_ERROR(Status)) {
PrintToken (STRING_TOKEN (STR_DP_INVALID_ARG));
ShowHelp();
}
else {
StringDpOptionQh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_QH), NULL);
StringDpOptionLh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LH), NULL);
StringDpOptionUh = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UH), NULL);
if (ShellCommandLineGetFlag (ParamPackage, StringDpOptionQh) ||
ShellCommandLineGetFlag (ParamPackage, StringDpOptionLh) ||
ShellCommandLineGetFlag (ParamPackage, StringDpOptionUh))
{
ShowHelp();
}
else {
StringDpOptionLv = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LV), NULL);
StringDpOptionUs = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_US), NULL);
StringDpOptionLs = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LS), NULL);
StringDpOptionUa = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UA), NULL);
StringDpOptionUr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UR), NULL);
StringDpOptionUt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UT), NULL);
StringDpOptionUp = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_UP), NULL);
StringDpOptionLx = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LX), NULL);
StringDpOptionLn = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LN), NULL);
StringDpOptionLt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LT), NULL);
StringDpOptionLi = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LI), NULL);
StringDpOptionLc = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LC), NULL);
// Boolean Options
//
VerboseMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLv);
SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, StringDpOptionUs) ||
ShellCommandLineGetFlag (ParamPackage, StringDpOptionLs));
示例8: Image
/**
Function for 'mkdir' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunMkDir (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
CONST CHAR16 *NewDirName;
UINTN DirCreateCount;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_FILE_HANDLE FileHandle;
SHELL_STATUS ShellStatus;
ShellStatus = SHELL_SUCCESS;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"mkdir", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
//
// create a set of directories
//
if (ShellCommandLineGetRawValue(Package, 1) == NULL) {
//
// we didnt get a single parameter
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"mkdir");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
for ( DirCreateCount = 1
;
; DirCreateCount++
){
//
// loop through each directory specified
//
NewDirName = ShellCommandLineGetRawValue(Package, DirCreateCount);
if (NewDirName == NULL) {
break;
}
//
// check if that already exists... if yes fail
//
FileHandle = NULL;
Status = ShellOpenFileByName(NewDirName,
&FileHandle,
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE,
EFI_FILE_DIRECTORY
);
if (!EFI_ERROR(Status)) {
ShellCloseFile(&FileHandle);
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_ALREADY), gShellLevel2HiiHandle, NewDirName);
ShellStatus = SHELL_INVALID_PARAMETER;
break;
} else {
ASSERT(FileHandle == NULL);
//
// create the directory named NewDirName
//
Status = ShellCreateDirectory(NewDirName, &FileHandle);
if (FileHandle != NULL) {
gEfiShellProtocol->CloseFile(FileHandle);
}
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_CREATEFAIL), gShellLevel2HiiHandle, NewDirName);
ShellStatus = SHELL_ACCESS_DENIED;
break;
}
}
//.........这里部分代码省略.........
示例9: SEnvCmdGoto
EFI_STATUS
EFIAPI
SEnvCmdGoto (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Transfers execution of batch file to location following a label (:labelname).
Arguments:
ImageHandle The image handle
SystemTable The system table
Returns:
EFI_SUCCESS The command finished sucessfully
EFI_UNSUPPORTED Unsupported
EFI_INVALID_PARAMETER Invalid parameter
EFI_OUT_OF_RESOURCES Out of resources
--*/
{
EFI_STATUS Status;
EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
//
// Output help
//
if (SI->Argc == 2) {
if (StriCmp (SI->Argv[1], L"-?") == 0) {
if (IS_OLD_SHELL) {
PrintToken (STRING_TOKEN (STR_NO_HELP), HiiEnvHandle);
} else {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_VERBOSE_HELP), HiiEnvHandle);
}
return EFI_SUCCESS;
}
} else if (SI->Argc == 3) {
if ((StriCmp (SI->Argv[1], L"-?") == 0 && StriCmp (SI->Argv[2], L"-b") == 0) ||
(StriCmp (SI->Argv[2], L"-?") == 0 && StriCmp (SI->Argv[1], L"-b") == 0)
) {
EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
if (IS_OLD_SHELL) {
PrintToken (STRING_TOKEN (STR_NO_HELP), HiiEnvHandle);
} else {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_VERBOSE_HELP), HiiEnvHandle);
}
return EFI_SUCCESS;
}
}
if (!SEnvBatchIsActive ()) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_ONLY_SUPPORTED_SCRIPT), HiiEnvHandle);
return EFI_UNSUPPORTED;
}
if (SI->Argc > 2) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_TOO_MANY_ARGS), HiiEnvHandle, SEnvGetLineNumber ());
SEnvSetBatchAbort ();
return EFI_INVALID_PARAMETER;
}
if (SI->Argc < 2) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_TOO_FEW_ARGS), HiiEnvHandle, SEnvGetLineNumber ());
SEnvSetBatchAbort ();
return EFI_INVALID_PARAMETER;
}
TargetLabel = StrDuplicate (SI->Argv[1]);
if (TargetLabel == NULL) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_OUT_OF_RESOURCES), HiiEnvHandle);
SEnvSetBatchAbort ();
return EFI_OUT_OF_RESOURCES;
}
SEnvBatchSetGotoActive ();
Status = SEnvBatchResetJumpStmt ();
if (EFI_ERROR (Status)) {
PrintToken (STRING_TOKEN (STR_SHELLENV_GOTO_CANNOT_EXECUTE_SCRIPT), HiiEnvHandle, Status);
SEnvSetBatchAbort ();
return Status;
}
return Status;
}
示例10: UpdateFileExplorePage
VOID
UpdateFileExplorePage (
IN BMM_CALLBACK_DATA *CallbackData,
BM_MENU_OPTION *MenuOption
)
/*++
Routine Description:
Update the File Explore page.
Arguments:
MenuOption - Pointer to menu options to display.
Returns:
None.
--*/
{
UINT8 *Location;
UINTN Index;
BM_MENU_ENTRY *NewMenuEntry;
BM_FILE_CONTEXT *NewFileContext;
FORM_ID FormId;
NewMenuEntry = NULL;
NewFileContext = NULL;
FormId = 0;
//
// Clean up file explore page.
//
RefreshUpdateData (FALSE, 0, FALSE, 0, 0xff);
//
// Remove all op-codes from dynamic page
//
CallbackData->Hii->UpdateForm (
CallbackData->Hii,
CallbackData->FeHiiHandle,
FORM_FILE_EXPLORER_ID,
FALSE,
UpdateData
);
RefreshUpdateData (TRUE, (EFI_PHYSICAL_ADDRESS) (UINTN) CallbackData->FeCallbackHandle, FALSE, 0, 0);
Location = (UINT8 *) &UpdateData->Data;
for (Index = 0; Index < MenuOption->MenuNumber; Index++) {
NewMenuEntry = BOpt_GetMenuEntry (MenuOption, Index);
NewFileContext = (BM_FILE_CONTEXT *) NewMenuEntry->VariableContext;
if (NewFileContext->IsBootLegacy) {
continue;
}
if ((NewFileContext->IsDir) || (BOOT_FROM_FILE_STATE == CallbackData->FeCurrentState)) {
//
// Create Text opcode for directory, also create Text opcode for file in BOOT_FROM_FILE_STATE.
//
CreateTextOpCode (
NewMenuEntry->DisplayStringToken,
STR_NULL_STRING,
STR_NULL_STRING,
EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,
(UINT16) (FILE_OPTION_OFFSET + Index),
Location
);
} else {
//
// Create Goto opcode for file in ADD_BOOT_OPTION_STATE or ADD_DRIVER_OPTION_STATE.
//
if (ADD_BOOT_OPTION_STATE == CallbackData->FeCurrentState) {
FormId = FORM_BOOT_ADD_DESCRIPTION_ID;
} else if (ADD_DRIVER_OPTION_STATE == CallbackData->FeCurrentState) {
FormId = FORM_DRIVER_ADD_FILE_DESCRIPTION_ID;
}
CreateGotoOpCode (
FormId,
NewMenuEntry->DisplayStringToken,
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_INTERACTIVE | EFI_IFR_FLAG_NV_ACCESS,
(UINT16) (FILE_OPTION_OFFSET + Index),
Location
);
}
UpdateData->DataCount++;
Location = Location + ((EFI_IFR_OP_HEADER *) Location)->Length;
}
CallbackData->Hii->UpdateForm (
CallbackData->Hii,
CallbackData->FeHiiHandle,
FORM_FILE_EXPLORER_ID,
TRUE,
UpdateData
);
}
示例11: BdsMemoryTest
/**
Perform the memory test base on the memory test intensive level,
and update the memory resource.
@param Level The memory test intensive level.
@retval EFI_STATUS Success test all the system memory and update
the memory resource
**/
EFI_STATUS
EFIAPI
BdsMemoryTest (
IN EXTENDMEM_COVERAGE_LEVEL Level
)
{
EFI_STATUS Status;
EFI_STATUS KeyStatus;
EFI_STATUS InitStatus;
EFI_STATUS ReturnStatus;
BOOLEAN RequireSoftECCInit;
EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
UINT64 TestedMemorySize;
UINT64 TotalMemorySize;
UINTN TestPercent;
UINT64 PreviousValue;
BOOLEAN ErrorOut;
BOOLEAN TestAbort;
EFI_INPUT_KEY Key;
CHAR16 StrPercent[80];
CHAR16 *StrTotalMemory;
CHAR16 *Pos;
CHAR16 *TmpStr;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color;
BOOLEAN IsFirstBoot;
UINT32 TempData;
UINTN StrTotalMemorySize;
ReturnStatus = EFI_SUCCESS;
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
StrTotalMemorySize = 128;
Pos = AllocateZeroPool (StrTotalMemorySize);
if (Pos == NULL) {
return ReturnStatus;
}
StrTotalMemory = Pos;
TestedMemorySize = 0;
TotalMemorySize = 0;
PreviousValue = 0;
ErrorOut = FALSE;
TestAbort = FALSE;
SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
SetMem (&Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0x0);
SetMem (&Color, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
RequireSoftECCInit = FALSE;
Status = gBS->LocateProtocol (
&gEfiGenericMemTestProtocolGuid,
NULL,
(VOID **) &GenMemoryTest
);
if (EFI_ERROR (Status)) {
FreePool (Pos);
return EFI_SUCCESS;
}
InitStatus = GenMemoryTest->MemoryTestInit (
GenMemoryTest,
Level,
&RequireSoftECCInit
);
if (InitStatus == EFI_NO_MEDIA) {
//
// The PEI codes also have the relevant memory test code to check the memory,
// it can select to test some range of the memory or all of them. If PEI code
// checks all the memory, this BDS memory test will has no not-test memory to
// do the test, and then the status of EFI_NO_MEDIA will be returned by
// "MemoryTestInit". So it does not need to test memory again, just return.
//
FreePool (Pos);
return EFI_SUCCESS;
}
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
TmpStr = GetStringById (STRING_TOKEN (STR_ESC_TO_SKIP_MEM_TEST));
if (TmpStr != NULL) {
PrintXY (10, 10, NULL, NULL, TmpStr);
FreePool (TmpStr);
}
} else {
DEBUG ((EFI_D_INFO, "Enter memory test.\n"));
//.........这里部分代码省略.........
示例12: Image
/**
Function for 'cp' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunCp (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
UINTN ParamCount;
UINTN LoopCounter;
EFI_SHELL_FILE_INFO *FileList;
BOOLEAN SilentMode;
BOOLEAN RecursiveMode;
CONST CHAR16 *Cwd;
CHAR16 *FullCwd;
ProblemParam = NULL;
ShellStatus = SHELL_SUCCESS;
ParamCount = 0;
FileList = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cp", ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
//
// check for "-?"
//
if (ShellCommandLineGetFlag(Package, L"-?")) {
ASSERT(FALSE);
}
//
// Initialize SilentMode and RecursiveMode
//
if (gEfiShellProtocol->BatchIsActive()) {
SilentMode = TRUE;
} else {
SilentMode = ShellCommandLineGetFlag(Package, L"-q");
}
RecursiveMode = ShellCommandLineGetFlag(Package, L"-r");
switch (ParamCount = ShellCommandLineGetCount(Package)) {
case 0:
case 1:
//
// we have insufficient parameters
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
break;
case 2:
//
// must have valid CWD for single parameter...
//
Cwd = ShellGetCurrentDir(NULL);
if (Cwd == NULL){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);
if (FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));
ShellStatus = SHELL_NOT_FOUND;
} else {
FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));
if (FullCwd == NULL) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"cp");
ShellStatus = SHELL_OUT_OF_RESOURCES;
} else {
StrCpyS (FullCwd, StrSize (Cwd) / sizeof (CHAR16) + 1, Cwd);
ShellStatus = ProcessValidateAndCopyFiles (FileList, FullCwd, SilentMode, RecursiveMode);
FreePool (FullCwd);
//.........这里部分代码省略.........
示例13: CopySingleFile
/**
Function to Copy one file to another location
If the destination exists the user will be prompted and the result put into *resp
@param[in] Source pointer to source file name
@param[in] Dest pointer to destination file name
@param[out] Resp pointer to response from question. Pass back on looped calling
@param[in] SilentMode whether to run in quiet mode or not
@param[in] CmdName Source command name requesting single file copy
@retval SHELL_SUCCESS The source file was copied to the destination
**/
SHELL_STATUS
CopySingleFile(
IN CONST CHAR16 *Source,
IN CONST CHAR16 *Dest,
OUT VOID **Resp,
IN BOOLEAN SilentMode,
IN CONST CHAR16 *CmdName
)
{
VOID *Response;
UINTN ReadSize;
SHELL_FILE_HANDLE SourceHandle;
SHELL_FILE_HANDLE DestHandle;
EFI_STATUS Status;
VOID *Buffer;
CHAR16 *TempName;
UINTN Size;
EFI_SHELL_FILE_INFO *List;
SHELL_STATUS ShellStatus;
UINT64 SourceFileSize;
UINT64 DestFileSize;
EFI_FILE_PROTOCOL *DestVolumeFP;
EFI_FILE_SYSTEM_INFO *DestVolumeInfo;
UINTN DestVolumeInfoSize;
ASSERT(Resp != NULL);
SourceHandle = NULL;
DestHandle = NULL;
Response = *Resp;
List = NULL;
DestVolumeInfo = NULL;
ShellStatus = SHELL_SUCCESS;
ReadSize = PcdGet32(PcdShellFileOperationSize);
// Why bother copying a file to itself
if (StrCmp(Source, Dest) == 0) {
return (SHELL_SUCCESS);
}
//
// if the destination file existed check response and possibly prompt user
//
if (ShellFileExists(Dest) == EFI_SUCCESS) {
if (Response == NULL && !SilentMode) {
Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response);
}
//
// possibly return based on response
//
if (!SilentMode) {
switch (*(SHELL_PROMPT_RESPONSE*)Response) {
case ShellPromptResponseNo:
//
// return success here so we dont stop the process
//
return (SHELL_SUCCESS);
case ShellPromptResponseCancel:
*Resp = Response;
//
// indicate to stop everything
//
return (SHELL_ABORTED);
case ShellPromptResponseAll:
*Resp = Response;
case ShellPromptResponseYes:
break;
default:
return SHELL_ABORTED;
}
}
}
if (ShellIsDirectory(Source) == EFI_SUCCESS) {
Status = ShellCreateDirectory(Dest, &DestHandle);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);
return (SHELL_ACCESS_DENIED);
}
//
// Now copy all the files under the directory...
//
TempName = NULL;
Size = 0;
StrnCatGrow(&TempName, &Size, Source, 0);
StrnCatGrow(&TempName, &Size, L"\\*", 0);
//.........这里部分代码省略.........
示例14: query
/**
function to take a list of files to copy and a destination location and do
the verification and copying of those files to that location. This function
will report any errors to the user and halt.
The key is to have this function called ONLY once. this allows for the parameter
verification to happen correctly.
@param[in] FileList A LIST_ENTRY* based list of files to move.
@param[in] DestDir The destination location.
@param[in] SilentMode TRUE to eliminate screen output.
@param[in] RecursiveMode TRUE to copy directories.
@param[in] Resp The response to the overwrite query (if always).
@retval SHELL_SUCCESS the files were all moved.
@retval SHELL_INVALID_PARAMETER a parameter was invalid
@retval SHELL_SECURITY_VIOLATION a security violation ocurred
@retval SHELL_WRITE_PROTECTED the destination was write protected
@retval SHELL_OUT_OF_RESOURCES a memory allocation failed
**/
SHELL_STATUS
ValidateAndCopyFiles(
IN CONST EFI_SHELL_FILE_INFO *FileList,
IN CONST CHAR16 *DestDir,
IN BOOLEAN SilentMode,
IN BOOLEAN RecursiveMode,
IN VOID **Resp
)
{
CHAR16 *HiiOutput;
CHAR16 *HiiResultOk;
CONST EFI_SHELL_FILE_INFO *Node;
SHELL_STATUS ShellStatus;
EFI_STATUS Status;
CHAR16 *DestPath;
VOID *Response;
UINTN PathSize;
CONST CHAR16 *Cwd;
UINTN NewSize;
CHAR16 *CleanFilePathStr;
if (Resp == NULL) {
Response = NULL;
} else {
Response = *Resp;
}
DestPath = NULL;
ShellStatus = SHELL_SUCCESS;
PathSize = 0;
Cwd = ShellGetCurrentDir(NULL);
CleanFilePathStr = NULL;
ASSERT(FileList != NULL);
ASSERT(DestDir != NULL);
Status = ShellLevel2StripQuotes (DestDir, &CleanFilePathStr);
if (EFI_ERROR (Status)) {
if (Status == EFI_OUT_OF_RESOURCES) {
return SHELL_OUT_OF_RESOURCES;
} else {
return SHELL_INVALID_PARAMETER;
}
}
ASSERT (CleanFilePathStr != NULL);
//
// If we are trying to copy multiple files... make sure we got a directory for the target...
//
if (EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {
//
// Error for destination not a directory
//
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);
FreePool (CleanFilePathStr);
return (SHELL_INVALID_PARAMETER);
}
for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link)
; !IsNull(&FileList->Link, &Node->Link)
; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link)
){
//
// skip the directory traversing stuff...
//
if (StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {
continue;
}
NewSize = StrSize(CleanFilePathStr);
NewSize += StrSize(Node->FullName);
NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16));
if (NewSize > PathSize) {
PathSize = NewSize;
}
//
// Make sure got -r if required
//
//.........这里部分代码省略.........
示例15: Image
/**
Function for 'decompress' command.
@param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal).
**/
SHELL_STATUS
EFIAPI
ShellCommandRunEfiDecompress (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
LIST_ENTRY *Package;
CHAR16 *ProblemParam;
SHELL_STATUS ShellStatus;
SHELL_FILE_HANDLE InFileHandle;
SHELL_FILE_HANDLE OutFileHandle;
UINT32 OutSize;
UINTN OutSizeTemp;
VOID *OutBuffer;
UINTN InSize;
VOID *InBuffer;
CHAR16 *InFileName;
CONST CHAR16 *OutFileName;
UINT64 Temp64Bit;
UINT32 ScratchSize;
VOID *ScratchBuffer;
EFI_DECOMPRESS_PROTOCOL *Decompress;
CONST CHAR16 *TempParam;
InFileName = NULL;
OutFileName = NULL;
OutSize = 0;
ShellStatus = SHELL_SUCCESS;
Status = EFI_SUCCESS;
OutBuffer = NULL;
InBuffer = NULL;
ScratchBuffer = NULL;
InFileHandle = NULL;
OutFileHandle = NULL;
//
// initialize the shell lib (we must be in non-auto-init...)
//
Status = ShellInitialize();
ASSERT_EFI_ERROR(Status);
Status = CommandInit();
ASSERT_EFI_ERROR(Status);
//
// parse the command line
//
Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
if (EFI_ERROR(Status)) {
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDebug1HiiHandle, ProblemParam);
FreePool(ProblemParam);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
ASSERT(FALSE);
}
} else {
if (ShellCommandLineGetCount(Package) > 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else if (ShellCommandLineGetCount(Package) < 3) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);
ShellStatus = SHELL_INVALID_PARAMETER;
} else {
TempParam = ShellCommandLineGetRawValue(Package, 1);
ASSERT(TempParam != NULL);
InFileName = ShellFindFilePath(TempParam);
OutFileName = ShellCommandLineGetRawValue(Package, 2);
if (InFileName == NULL) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, TempParam);
ShellStatus = SHELL_NOT_FOUND;
} else {
if (ShellIsDirectory(InFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, InFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellIsDirectory(OutFileName) == EFI_SUCCESS){
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_NOT_DIR), gShellDebug1HiiHandle, OutFileName);
ShellStatus = SHELL_INVALID_PARAMETER;
}
if (ShellStatus == SHELL_SUCCESS) {
Status = ShellOpenFileByName(InFileName, &InFileHandle, EFI_FILE_MODE_READ, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status);
ShellStatus = SHELL_NOT_FOUND;
}
Status = ShellOpenFileByName(OutFileName, &OutFileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
if (EFI_ERROR(Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status);
ShellStatus = SHELL_NOT_FOUND;
}
}
//.........这里部分代码省略.........