blob: 64e2c654c74dcea4f9133239bf042938229fb61a (
plain)
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
75
76
|
#include "kern/print.hpp"
#include <string_view>
namespace teachos
{
namespace
{
print_handler * current_print_handler{};
println_handler * current_println_handler{};
print_handler * current_print_error_handler{};
println_handler * current_println_error_handler{};
} // namespace
auto print(std::string_view text) -> void
{
if (current_print_handler)
{
current_print_handler(text);
}
}
auto println(std::string_view text) -> void
{
if (current_println_handler)
{
current_println_handler(text);
}
}
auto print_error(std::string_view text) -> void
{
if (current_print_error_handler)
{
current_print_error_handler(text);
}
}
auto println_error(std::string_view text) -> void
{
if (current_println_error_handler)
{
current_println_error_handler(text);
}
}
auto set_print_handler(print_handler handler) -> print_handler *
{
auto old = current_print_handler;
current_print_handler = handler;
return old;
}
auto set_println_handler(println_handler handler) -> print_handler *
{
auto old = current_println_handler;
current_println_handler = handler;
return old;
}
auto set_print_error_handler(print_handler handler) -> print_handler *
{
auto old = current_print_error_handler;
current_print_error_handler = handler;
return old;
}
auto set_println_error_handler(println_handler handler) -> print_handler *
{
auto old = current_println_error_handler;
current_println_error_handler = handler;
return old;
}
} // namespace teachos
|