UINTN Aprint ( IN CONST CHAR8 *Format, ... ) /*++ Routine Description: Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii characters. Arguments: Format - Ascii format string see file header for more details. ... - Vararg list consumed by processing Format. Returns: Number of characters printed. --*/ { UINTN Return; VA_LIST Marker; UINTN Index; UINTN MaxIndex; CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format); if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) { // // Format string was too long for use to process. // return 0; } for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) { UnicodeFormat[Index] = (CHAR16) Format[Index]; } VA_START (Marker, Format); Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker); VA_END (Marker); // // Need to convert to Unicode to do an OutputString // if (gST->ConOut != NULL) { // // To be extra safe make sure ConOut has been initialized // gST->ConOut->OutputString (gST->ConOut, Buffer); } return Return; }
EFI_STATUS EFIAPI StslRecordMessage ( IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *This, IN EFI_VERBOSE_LEVEL VerboseLevel, IN CHAR16 *Message, ... ) /*++ Routine Description: Records the test message. Arguments: This - Standard test library protocol instance. VerboseLevel - Minimal verbose level to record this message. For example, EFI_VERBOSE_LEVEL_QUIET means this message should be recorded even the test is run in QUIET mode. On the contrary, EFI_VERBOSE_LEVEL_EXHAUSTIVE means this message will only be recorded when the test is run in EXHAUSTIVE mode. Message - Format string for the detail test information. Returns: EFI_SUCCESS - record the message successfully. --*/ { EFI_STATUS Status; VA_LIST Marker; CHAR16 Buffer[EFI_MAX_PRINT_BUFFER]; STANDARD_TEST_PRIVATE_DATA *Private; Status = EFI_SUCCESS; Private = STANDARD_TEST_PRIVATE_DATA_FROM_STSL (This); if (VerboseLevel <= Private->VerboseLevel) { VA_START(Marker, Message); VSPrint (Buffer, EFI_MAX_PRINT_BUFFER, Message, Marker); VA_END (Marker); if ( EfiStrLen (Buffer) + 3 < EFI_MAX_PRINT_BUFFER ) { EfiStrCat (Buffer, L"\r\n"); } Status = StslWriteLogFile (Private, Buffer); } return Status; }
UINTN UvSPrint ( OUT CHAR16 *Buffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString, IN VA_LIST Marker ) /*++ Routine Description: Internal implementation of USPrint. Process format and place the results in Buffer for wide chars. Arguments: Buffer - Wide char buffer to print the results of the parsing of Format into. BufferSize - Maximum number of characters to put into buffer. FormatString - Format string Marker - Vararg list consumed by processing Format. Returns: Number of characters printed. --*/ { UINTN Index; CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { AsciiFormat[Index] = (CHAR8) FormatString[Index]; } AsciiFormat[Index] = '\0'; Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker); for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) { Buffer[Index] = (CHAR16) AsciiResult[Index]; } Buffer[Index] = '\0'; return Index++; }
UINTN AvSPrint ( OUT CHAR8 *Buffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString, IN VA_LIST Marker ) /*++ Routine Description: Internal implementation of ASPrint. Process format and place the results in Buffer for narrow chars. Arguments: Buffer - Narrow char buffer to print the results of the parsing of Format into. BufferSize - Maximum number of characters to put into buffer. FormatString - Format string Marker - Vararg list consumed by processing Format. Returns: Number of characters printed. --*/ { UINTN Index; CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1]; CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1]; for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) { UnicodeFormat[Index] = (CHAR16) FormatString[Index]; } UnicodeFormat[Index] = '\0'; Index = VSPrint (UnicodeResult, sizeof (UnicodeResult), UnicodeFormat, Marker); for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) { Buffer[Index] = (CHAR8) UnicodeResult[Index]; } Buffer[Index] = '\0'; return Index++; }
UINTN UPrint ( IN CONST CHAR16 *Format, ... ) /*++ Routine Description: Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii characters. Arguments: Format - Ascii format string see file header for more details. ... - Vararg list consumed by processing Format. Returns: Number of characters printed. --*/ { UINTN Return; VA_LIST Marker; CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; VA_START (Marker, Format); Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker); VA_END (Marker); if (gST->ConOut != NULL) { // // To be extra safe make sure ConOut has been initialized // gST->ConOut->OutputString (gST->ConOut, Buffer); } return Return; }
UINTN SPrint ( OUT CHAR_W *Buffer, IN UINTN BufferSize, IN CONST CHAR_W *Format, ... ) /*++ Routine Description: SPrint function to process format and place the results in Buffer. Arguments: Buffer - Wide char buffer to print the results of the parsing of Format into. BufferSize - Maximum number of characters to put into buffer. Zero means no limit. Format - Format string see file header for more details. ... - Vararg list consumed by processing Format. Returns: Number of characters printed. --*/ { UINTN Return; VA_LIST Marker; VA_START (Marker, Format); Return = VSPrint (Buffer, BufferSize, Format, Marker); VA_END (Marker); return Return; }
void Progress() { int i; int vs1, vs2; int result[3]={0}; for(i=0; i<3; i++) { vs1=Dice(); vs2=Dice(); printf("\n########## %d번째 게임 ##########\n", i+1); printf(" 민수: %d \t민수의 친구: %d\n", vs1, vs2); if(vs1>vs2) { VSPrint(0); result[0]++; } else if(vs1<vs2) { VSPrint(1); result[1]++; } else { VSPrint(2); result[2]++; } system("PAUSE"); } puts("\n---------------------------------------------------"); printf("민수가 이긴 횟수: %d \n", result[0]); printf("민수의 친구가 이긴 횟수: %d \n", result[1]); printf("비긴 횟수: %d \n", result[2]); puts("---------------------------------------------------"); if(result[0]>result[1]) { VSPrint(0); if(choice==1) { puts("당신은 배팅금의 2배를 얻었습니다."); money+=bet; } else { puts("당신은 배팅금만큼의 돈을 잃었습니다."); money-=bet; } } else if(result[0]<result[1]) { VSPrint(1); if(choice==2) { puts("당신은 배팅금의 2배를 얻었습니다."); money+=bet; } else { puts("당신은 배팅금만큼의 돈을 잃었습니다."); money-=bet; } } else VSPrint(2); puts("---------------------------------------------------\n"); }
UINTN ErrorPrint ( IN CONST CHAR16 *ErrorString, IN CONST CHAR8 *Format, ... ) /*++ Routine Description: Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii characters. Arguments: ErrorString - String of error infomation. Format - Ascii format string see file header for more details. ... - Vararg list consumed by processing Format. Returns: Number of characters printed. --*/ { UINTN Return; VA_LIST Marker; UINTN Index; UINTN MaxIndex; CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER]; MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format); if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) { // // Format string was too long for use to process. // return 0; } if (ErrorString != '\0') { if (gST->StdErr != NULL) { // // To be extra safe make sure StdErr has been initialized // gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK)); gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString); gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK)); } } for (Index = 0; Index < MaxIndex; Index++) { UnicodeFormat[Index] = (CHAR16) Format[Index]; } UnicodeFormat[Index] = 0; VA_START (Marker, Format); Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker); VA_END (Marker); // // Need to convert to Unicode to do an OutputString // if (gST->StdErr != NULL) { // // To be extra safe make sure StdErr has been initialized // gST->StdErr->OutputString (gST->StdErr, Buffer); } return Return; }
EFI_STATUS EFIAPI StslRecordAssertion ( IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *This, IN EFI_TEST_ASSERTION Type, IN EFI_GUID EventId, IN CHAR16 *Description, IN CHAR16 *Detail, ... ) /*++ Routine Description: Records the test result. Arguments: This - Standard test library protocol instance. Type - Test result. EventId - GUID for the checkpoint. Description - Simple description for the checkpoint. Detail - Format string for the detail test information. Returns: EFI_SUCCESS - record the assertion successfully. EFI_BAD_BUFFER_SIZE - the Description string is too long. EFI_INVALID_PARAMETER - invalid Type. --*/ { EFI_STATUS Status; VA_LIST Marker; CHAR16 Buffer[EFI_MAX_PRINT_BUFFER]; CHAR16 AssertionType[10]; STANDARD_TEST_PRIVATE_DATA *Private; Private = STANDARD_TEST_PRIVATE_DATA_FROM_STSL (This); // // Check the parameter // if (EfiStrLen (Description) + 14 > EFI_MAX_PRINT_BUFFER) { return EFI_BAD_BUFFER_SIZE; } // // Write log file detail data // switch (Type) { case EFI_TEST_ASSERTION_PASSED: EfiStrCpy (AssertionType, L"PASS"); Private->PassCount ++; break; case EFI_TEST_ASSERTION_WARNING: EfiStrCpy (AssertionType, L"WARNING"); Private->WarningCount ++; break; case EFI_TEST_ASSERTION_FAILED: EfiStrCpy (AssertionType, L"FAILURE"); Private->FailCount ++; break; default: return EFI_INVALID_PARAMETER; break; } SPrint (Buffer, EFI_MAX_PRINT_BUFFER, L"%s -- %s\n", Description, AssertionType); Status = StslWriteLogFile (Private, Buffer); if (EFI_ERROR (Status)) { return Status; } SPrint (Buffer, EFI_MAX_PRINT_BUFFER, L"%g\n", &EventId); Status = StslWriteLogFile (Private, Buffer); if (EFI_ERROR (Status)) { return Status; } VA_START(Marker, Detail); VSPrint (Buffer, EFI_MAX_PRINT_BUFFER, Detail, Marker); VA_END (Marker); if ( EfiStrLen (Buffer) + 5 < EFI_MAX_PRINT_BUFFER ) { EfiStrCat (Buffer, L"\r\n\r\n"); } Status = StslWriteLogFile (Private, Buffer); if (EFI_ERROR (Status)) { return Status; } // // write key file detail line // SPrint (Buffer, EFI_MAX_PRINT_BUFFER, L"%g:%s|%s:", &EventId, AssertionType, Description); Status = StslWriteKeyFile (Private, Buffer); if (EFI_ERROR (Status)) { return Status; } VA_START(Marker, Detail); VSPrint (Buffer, EFI_MAX_PRINT_BUFFER, Detail, Marker); VA_END (Marker); if ( EfiStrLen (Buffer) + 3 < EFI_MAX_PRINT_BUFFER ) { EfiStrCat (Buffer, L"\r\n"); } Status = StslWriteKeyFile (Private, Buffer); if (EFI_ERROR (Status)) { return Status; } return Status; }