本文整理匯總了C++中AsciiStrLen函數的典型用法代碼示例。如果您正苦於以下問題:C++ AsciiStrLen函數的具體用法?C++ AsciiStrLen怎麽用?C++ AsciiStrLen使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AsciiStrLen函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CpuBreakpoint
/**
Prints an assert message containing a filename, line number, and description.
This may be followed by a breakpoint or a dead loop.
Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
CpuDeadLoop() is called. If neither of these bits are set, then this function
returns immediately after the message is printed to the debug output device.
DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while
processing another DebugAssert(), then DebugAssert() must return immediately.
If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
@param FileName Pointer to the name of the source file that generated the assert condition.
@param LineNumber The line number in the source file that generated the assert condition
@param Description Pointer to the description of the assert condition.
**/
VOID
EFIAPI
DebugAssert (
IN CONST CHAR8 *FileName,
IN UINTN LineNumber,
IN CONST CHAR8 *Description
)
{
UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];
EFI_DEBUG_ASSERT_DATA *AssertData;
UINTN TotalSize;
CHAR8 *Temp;
UINTN FileNameLength;
UINTN DescriptionLength;
//
// Make sure it will all fit in the passed in buffer
//
FileNameLength = AsciiStrLen (FileName);
DescriptionLength = AsciiStrLen (Description);
TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + FileNameLength + 1 + DescriptionLength + 1;
if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) {
//
// Fill in EFI_DEBUG_ASSERT_DATA
//
AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
AssertData->LineNumber = (UINT32)LineNumber;
//
// Copy Ascii FileName including NULL.
//
Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName);
//
// Copy Ascii Description
//
AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description);
REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
(EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
AssertData,
TotalSize
);
}
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
//
if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
CpuBreakpoint ();
} else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
CpuDeadLoop ();
}
}
示例2: FileDelete
EFI_STATUS
FileDelete (
IN EFI_FILE *File
)
{
SEMIHOST_FCB *Fcb = NULL;
EFI_STATUS Status;
CHAR8 *FileName;
UINTN NameSize;
Fcb = SEMIHOST_FCB_FROM_THIS(File);
if (!Fcb->IsRoot) {
// Get the filename from the Fcb
NameSize = AsciiStrLen (Fcb->FileName);
FileName = AllocatePool (NameSize + 1);
AsciiStrCpy (FileName, Fcb->FileName);
// Close the file if it's open. Disregard return status,
// since it might give an error if the file isn't open.
File->Close (File);
// Call the semihost interface to delete the file.
Status = SemihostFileRemove (FileName);
} else {
Status = EFI_UNSUPPORTED;
}
return Status;
}
示例3: WriteGeneralRegisters
/** ‘G XX...’
Writes the new values received into the input buffer to the general registers
@param SystemContext Register content at time of the exception
@param InBuffer Pointer to the input buffer received from gdb server
**/
VOID
EFIAPI
WriteGeneralRegisters (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN CHAR8 *InBuffer
)
{
UINTN i;
CHAR8 *InBufPtr; /// pointer to the input buffer
// check to see if the buffer is the right size which is
// 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129
if (AsciiStrLen(InBuffer) != 129) { // 16 regs, 8 hex chars each, and the end '\0' (escape seq)
//Bad message. Message is not the right length
SendError (GDB_EBADBUFSIZE);
return;
}
InBufPtr = &InBuffer[1];
// Read the new values for the registers from the input buffer to an array, NewValueArray.
// The values in the array are in the gdb ordering
for(i=0; i < sizeof (gRegisterOffsets)/sizeof (UINTN); i++) { // there are only 16 registers to write
InBufPtr = BasicWriteRegister(SystemContext, i, InBufPtr);
}
SendSuccess();
}
示例4: GetDebugPrintErrorLevel
/**
Prints a debug message to the debug output device if the specified error level is enabled.
If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
GetDebugPrintErrorLevel (), then print the message specified by Format and the
associated variable argument list to the debug output device.
If Format is NULL, then ASSERT().
@param ErrorLevel The error level of the debug message.
@param Format Format string for the debug message to print.
@param ... A variable argument list whose contents are accessed
based on the format string specified by Format.
**/
VOID
EFIAPI
DebugPrint (
IN UINTN ErrorLevel,
IN CONST CHAR8 *Format,
...
)
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
VA_LIST Marker;
//
// If Format is NULL, then ASSERT().
//
ASSERT (Format != NULL);
//
// Check driver debug mask value and global mask
//
if ((ErrorLevel & GetDebugPrintErrorLevel ()) == 0) {
return;
}
//
// Convert the DEBUG() message to an ASCII String
//
VA_START (Marker, Format);
AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
VA_END (Marker);
//
// Send the print string to EFI_DEBUGPORT_PROTOCOL.Write.
//
UefiDebugLibDebugPortProtocolWrite (Buffer, AsciiStrLen (Buffer));
}
示例5: ASSERT
/**
Extracts ASSERT() information from a status code structure.
Converts the status code specified by CodeType, Value, and Data to the ASSERT()
arguments specified by Filename, Description, and LineNumber. If CodeType is
an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
Filename, Description, and LineNumber from the optional data area of the
status code buffer specified by Data. The optional data area of Data contains
a Null-terminated ASCII string for the FileName, followed by a Null-terminated
ASCII string for the Description, followed by a 32-bit LineNumber. If the
ASSERT() information could be extracted from Data, then return TRUE.
Otherwise, FALSE is returned.
If Data is NULL, then ASSERT().
If Filename is NULL, then ASSERT().
If Description is NULL, then ASSERT().
If LineNumber is NULL, then ASSERT().
@param CodeType The type of status code being converted.
@param Value The status code value being converted.
@param Data Pointer to status code data buffer.
@param Filename Pointer to the source file name that generated the ASSERT().
@param Description Pointer to the description of the ASSERT().
@param LineNumber Pointer to source line number that generated the ASSERT().
@retval TRUE The status code specified by CodeType, Value, and Data was
converted ASSERT() arguments specified by Filename, Description,
and LineNumber.
@retval FALSE The status code specified by CodeType, Value, and Data could
not be converted to ASSERT() arguments.
**/
BOOLEAN
EFIAPI
ReportStatusCodeExtractAssertInfo (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN CONST EFI_STATUS_CODE_DATA *Data,
OUT CHAR8 **Filename,
OUT CHAR8 **Description,
OUT UINT32 *LineNumber
)
{
EFI_DEBUG_ASSERT_DATA *AssertData;
ASSERT (Data != NULL);
ASSERT (Filename != NULL);
ASSERT (Description != NULL);
ASSERT (LineNumber != NULL);
if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
*Filename = (CHAR8 *)(AssertData + 1);
*Description = *Filename + AsciiStrLen (*Filename) + 1;
*LineNumber = AssertData->LineNumber;
return TRUE;
}
return FALSE;
}
示例6: WriteGeneralRegisters
VOID
EFIAPI
WriteGeneralRegisters (
IN EFI_SYSTEM_CONTEXT SystemContext,
IN CHAR8 *InBuffer
)
{
UINTN i;
CHAR8 *InBufPtr; /// pointer to the input buffer
UINTN MinLength;
UINTN RegisterCount = (sizeof (gRegisterOffsets)/sizeof (UINTN));
MinLength = (RegisterCount * 8) + 1; // 'G' plus the registers in ASCII format
if (AsciiStrLen(InBuffer) < MinLength) {
//Bad message. Message is not the right length
SendError (GDB_EBADBUFSIZE);
return;
}
InBufPtr = &InBuffer[1];
// Read the new values for the registers from the input buffer to an array, NewValueArray.
// The values in the array are in the gdb ordering
for(i = 0; i < RegisterCount; i++) {
InBufPtr = BasicWriteRegister (SystemContext, i, InBufPtr);
}
SendSuccess ();
}
示例7: SetupCmdlineTag
STATIC
VOID
SetupCmdlineTag (
IN CONST CHAR8 *CmdLine
)
{
UINT32 LineLength;
// Increment the line length by 1 to account for the null string terminator character
LineLength = AsciiStrLen(CmdLine) + 1;
/* Check for NULL strings.
* Do not insert a tag for an empty CommandLine, don't even modify the tag address pointer.
* Remember, you have at least one null string terminator character.
*/
if(LineLength > 1) {
mLinuxKernelCurrentAtag->header.size = ((UINT32)sizeof(LINUX_ATAG_HEADER) + LineLength + (UINT32)3) >> 2;
mLinuxKernelCurrentAtag->header.type = ATAG_CMDLINE;
/* place CommandLine into tag */
AsciiStrCpy(mLinuxKernelCurrentAtag->body.cmdline_tag.cmdline, CmdLine);
// move pointer to next tag
mLinuxKernelCurrentAtag = next_tag_address(mLinuxKernelCurrentAtag);
}
示例8: SemihostFileOpen
RETURN_STATUS
SemihostFileOpen (
IN CHAR8 *FileName,
IN UINT32 Mode,
OUT UINT32 *FileHandle
)
{
SEMIHOST_FILE_OPEN_BLOCK OpenBlock;
INT32 Result;
if (FileHandle == NULL) {
return RETURN_INVALID_PARAMETER;
}
OpenBlock.FileName = FileName;
OpenBlock.Mode = Mode;
OpenBlock.NameLength = AsciiStrLen(FileName);
Result = Semihost_SYS_OPEN(&OpenBlock);
if (Result == -1) {
return RETURN_NOT_FOUND;
} else {
*FileHandle = Result;
return RETURN_SUCCESS;
}
}
示例9: GetGuidFromDataFile
/**
Get section entry GUID value.
@param[in] Context INI Config file context.
@param[in] SectionName Section name.
@param[in] EntryName Section entry name.
@param[out] Guid Point to the got GUID value.
@retval EFI_SUCCESS Section entry GUID value is got.
@retval EFI_NOT_FOUND Section is not found.
**/
EFI_STATUS
EFIAPI
GetGuidFromDataFile (
IN VOID *Context,
IN CHAR8 *SectionName,
IN CHAR8 *EntryName,
OUT EFI_GUID *Guid
)
{
CHAR8 *Value;
EFI_STATUS Status;
if (Context == NULL || SectionName == NULL || EntryName == NULL || Guid == NULL) {
return EFI_INVALID_PARAMETER;
}
Status = GetStringFromDataFile(
Context,
SectionName,
EntryName,
&Value
);
if (EFI_ERROR(Status)) {
return EFI_NOT_FOUND;
}
ASSERT (Value != NULL);
if (!IsValidGuid(Value, AsciiStrLen(Value))) {
return EFI_NOT_FOUND;
}
Status = AsciiStrToGuid(Value, Guid);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
示例10: IScsiCHAPAuthTarget
/**
The initator checks the CHAP response replied by target against its own
calculation of the expected hash value.
@param[in] AuthData iSCSI CHAP authentication data.
@param[in] TargetResponse The response from target.
@retval EFI_SUCCESS The response from target passed authentication.
@retval EFI_SECURITY_VIOLATION The response from target was not expected value.
@retval Others Other errors as indicated.
**/
EFI_STATUS
IScsiCHAPAuthTarget (
IN ISCSI_CHAP_AUTH_DATA *AuthData,
IN UINT8 *TargetResponse
)
{
EFI_STATUS Status;
UINT32 SecretSize;
UINT8 VerifyRsp[ISCSI_CHAP_RSP_LEN];
Status = EFI_SUCCESS;
SecretSize = (UINT32) AsciiStrLen (AuthData->AuthConfig->ReverseCHAPSecret);
Status = IScsiCHAPCalculateResponse (
AuthData->OutIdentifier,
AuthData->AuthConfig->ReverseCHAPSecret,
SecretSize,
AuthData->OutChallenge,
AuthData->OutChallengeLength,
VerifyRsp
);
if (CompareMem (VerifyRsp, TargetResponse, ISCSI_CHAP_RSP_LEN) != 0) {
Status = EFI_SECURITY_VIOLATION;
}
return Status;
}
示例11: NewSymbol
CHAR8* NewSymbol(CHAR8* string)
{
SymbolPtr lastGuy = 0;
SymbolPtr symbol;
// Look for string in the list of symbols.
symbol = FindSymbol(string, 0);
// Add the new symbol.
if (symbol == NULL)
{
symbol = (SymbolPtr)AllocateZeroPool(sizeof(Symbol) + 1 + AsciiStrLen(string));
if (symbol == NULL)
return NULL;
// Set the symbol's data.
symbol->refCount = 0;
AsciiStrCpy(symbol->string, string);
// Add the symbol to the list.
symbol->next = gSymbolsHead;
gSymbolsHead = symbol;
}
// Update the refCount and return the string.
symbol->refCount++;
if (lastGuy && lastGuy->next != 0)
return NULL;
return symbol->string;
}
示例12: CpuBreakpoint
/**
Prints an assert message containing a filename, line number, and description.
This may be followed by a breakpoint or a dead loop.
Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
CpuDeadLoop() is called. If neither of these bits are set, then this function
returns immediately after the message is printed to the debug output device.
DebugAssert() must actively prevent recursion. If DebugAssert() is called while
processing another DebugAssert(), then DebugAssert() must return immediately.
If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
@param FileName The pointer to the name of the source file that generated the assert condition.
@param LineNumber The line number in the source file that generated the assert condition
@param Description The pointer to the description of the assert condition.
**/
VOID
EFIAPI
DebugAssert (
IN CONST CHAR8 *FileName,
IN UINTN LineNumber,
IN CONST CHAR8 *Description
)
{
CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
//
// Generate the ASSERT() message in Ascii format
//
AsciiSPrint (Buffer, sizeof (Buffer), "ASSERT %a(%d): %a\n", FileName, LineNumber, Description);
//
// Send the print string to the Console Output device
//
AcquireSpinLock (&mInternalDebugLock);
SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen(Buffer));
ReleaseSpinLock (&mInternalDebugLock);
//
// Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
//
if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
CpuBreakpoint ();
} else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
CpuDeadLoop ();
}
}
示例13: GetHexUint64FromDataFile
/**
Get section entry heximal UINT64 value.
@param[in] Context INI Config file context.
@param[in] SectionName Section name.
@param[in] EntryName Section entry name.
@param[out] Data Point to the got heximal UINT64 value.
@retval EFI_SUCCESS Section entry heximal UINT64 value is got.
@retval EFI_NOT_FOUND Section is not found.
**/
EFI_STATUS
EFIAPI
GetHexUint64FromDataFile (
IN VOID *Context,
IN CHAR8 *SectionName,
IN CHAR8 *EntryName,
OUT UINT64 *Data
)
{
CHAR8 *Value;
EFI_STATUS Status;
if (Context == NULL || SectionName == NULL || EntryName == NULL || Data == NULL) {
return EFI_INVALID_PARAMETER;
}
Status = GetStringFromDataFile(
Context,
SectionName,
EntryName,
&Value
);
if (EFI_ERROR(Status)) {
return EFI_NOT_FOUND;
}
ASSERT (Value != NULL);
if (!IsValidHexString(Value, AsciiStrLen(Value))) {
return EFI_NOT_FOUND;
}
*Data = AsciiStrHexToUint64(Value);
return EFI_SUCCESS;
}
示例14: SetCmdHistory
/**
Save this command in the circular history buffer. Older commands are
overwritten with newer commands.
@param Cmd Command line to archive the history of.
@return None
**/
VOID
SetCmdHistory (
IN CHAR8 *Cmd
)
{
// Don't bother adding empty commands to the list
if (AsciiStrLen(Cmd) != 0) {
// First entry
if (mCmdHistoryStart == -1) {
mCmdHistoryStart = 0;
mCmdHistoryEnd = 0;
} else {
// Record the new command at the next index
RingBufferIncrement(&mCmdHistoryStart);
// If the next index runs into the end index, shuffle end back by one
if (mCmdHistoryStart == mCmdHistoryEnd) {
RingBufferIncrement(&mCmdHistoryEnd);
}
}
// Copy the new command line into the ring buffer
AsciiStrnCpyS (&mCmdHistory[mCmdHistoryStart][0], MAX_CMD_LINE, Cmd, MAX_CMD_LINE);
}
// Reset the command history for the next up arrow press
mCmdHistoryCurrent = mCmdHistoryStart;
}
示例15: ASSERT
/**
Prints a debug message to the debug output device if the specified error level is enabled.
If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
the message specified by Format and the associated variable argument list to
the debug output device.
If Format is NULL, then ASSERT().
@param ErrorLevel The error level of the debug message.
@param Format Format string for the debug message to print.
**/
VOID
EFIAPI
DebugPrint (
IN UINTN ErrorLevel,
IN CONST CHAR8 *Format,
...
)
{
UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];
EFI_DEBUG_INFO *DebugInfo;
UINTN TotalSize;
UINTN Index;
VA_LIST Marker;
UINT64 *ArgumentPointer;
//
// If Format is NULL, then ASSERT().
//
ASSERT (Format != NULL);
//
// Check driver Debug Level value and global debug level
//
if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
return;
}
TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1;
if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {
return;
}
//
// Then EFI_DEBUG_INFO
//
DebugInfo = (EFI_DEBUG_INFO *)Buffer;
DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
//
// 256 byte mini Var Arg stack. That is followed by the format string.
//
VA_START (Marker, Format);
for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) {
WriteUnaligned64(ArgumentPointer, VA_ARG (Marker, UINT64));
}
VA_END (Marker);
AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format);
REPORT_STATUS_CODE_EX (
EFI_DEBUG_CODE,
(EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
0,
NULL,
&gEfiStatusCodeDataTypeDebugGuid,
DebugInfo,
TotalSize
);
}