-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdio.c
More file actions
74 lines (63 loc) · 1.15 KB
/
stdio.c
File metadata and controls
74 lines (63 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <libefi.h>
static VOID put(const CHAR16 *string)
{
ST->ConOut->OutputString(ST->ConOut, (CHAR16 *) string);
}
static VOID puti(INTN number)
{
CHAR16 string[21] = {0};
itos(string, number);
put(string);
}
static VOID print_hex(UINT64 number)
{
CHAR16 str[17] = {0};
uitoh(str, number);
put(str);
}
VOID puts(const CHAR16 *string)
{
put(string);
put(L"\n\r");
}
VOID putchar(CHAR16 character)
{
CHAR16 string[2] = {character, L'\0'};
ST->ConOut->OutputString(ST->ConOut, string);
}
INTN printf(const CHAR16 *format, ...)
{
va_list vl;
va_start(vl, format);
while(*format)
{
if(*format == L'%')
{
format++;
switch(*format)
{
case L'%':
putchar(L'%');
break;
case L'i':
puti(va_arg(vl, INTN));
break;
case L'c':
putchar((CHAR16) va_arg(vl, UINTN));
break;
case L's':
put(va_arg(vl, CHAR16 *));
break;
case L'X':
case L'x':
print_hex(va_arg(vl, UINT64));
break;
}
}
else
putchar(*format);
format++;
}
va_end(vl);
return 0;
}