2020-03-21 14:12:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "stdarg.h"
|
|
|
|
#include <Library/printf_lite.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/PrintLib.h>
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "../../cpp_foundation/XString.h"
|
2020-03-28 07:36:07 +01:00
|
|
|
#include "../../cpp_foundation/XStringW.h"
|
|
|
|
|
|
|
|
static XString stdio_static_buf;
|
|
|
|
static XStringW stdio_static_wbuf;
|
2020-03-21 14:12:26 +01:00
|
|
|
|
|
|
|
int printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
2020-03-28 07:36:07 +01:00
|
|
|
// AsciiPrint seems no to work with utf8 chars. We have to use Print instead
|
2020-03-21 14:12:26 +01:00
|
|
|
va_start (va, format);
|
2020-03-31 18:10:30 +02:00
|
|
|
stdio_static_wbuf.vSWPrintf(format, va);
|
2020-03-28 07:36:07 +01:00
|
|
|
int ret = (int)Print(L"%s", stdio_static_wbuf.wc_str());
|
2020-03-21 14:12:26 +01:00
|
|
|
va_end(va);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-26 13:59:20 +01:00
|
|
|
const char* strerror(EFI_STATUS Status)
|
2020-03-21 14:12:26 +01:00
|
|
|
{
|
|
|
|
UINTN n = 0;
|
|
|
|
do {
|
|
|
|
stdio_static_buf.CheckSize(stdio_static_buf.length()+10);
|
2020-03-26 13:59:20 +01:00
|
|
|
n = AsciiSPrint(stdio_static_buf.dataSized(0, stdio_static_buf.allocatedSize()), stdio_static_buf.allocatedSize(), "%r", Status);
|
|
|
|
} while ( n > stdio_static_buf.allocatedSize() - 2 );
|
2020-03-21 14:12:26 +01:00
|
|
|
|
|
|
|
return stdio_static_buf.data();
|
|
|
|
}
|
|
|
|
|
2020-03-26 13:59:20 +01:00
|
|
|
const char* strguid(EFI_GUID* guid)
|
2020-03-21 14:12:26 +01:00
|
|
|
{
|
|
|
|
UINTN n = 0;
|
|
|
|
do {
|
|
|
|
stdio_static_buf.CheckSize(stdio_static_buf.length()+10);
|
2020-03-26 13:59:20 +01:00
|
|
|
n = AsciiSPrint(stdio_static_buf.dataSized(0, stdio_static_buf.allocatedSize()), stdio_static_buf.allocatedSize(), "%g", guid);
|
|
|
|
} while ( n > stdio_static_buf.allocatedSize() - 2 );
|
2020-03-21 14:12:26 +01:00
|
|
|
|
|
|
|
return stdio_static_buf.data();
|
|
|
|
}
|
|
|
|
|