mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-10 04:52:14 -04:00
Implement printf
This commit is contained in:
parent
0b6c3b3b3c
commit
185c49c35b
@ -12,5 +12,6 @@ void k_print(const char* string);
|
|||||||
void k_print(std::size_t number);
|
void k_print(std::size_t number);
|
||||||
void k_print_line();
|
void k_print_line();
|
||||||
void k_print_line(const char* string);
|
void k_print_line(const char* string);
|
||||||
|
void k_printf(const char* fmt, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdarg>
|
||||||
|
|
||||||
#include "console.hpp"
|
#include "console.hpp"
|
||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
@ -109,3 +110,28 @@ void wipeout(){
|
|||||||
current_line = 0;
|
current_line = 0;
|
||||||
current_column = 0;
|
current_column = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void k_printf(const char* fmt, ...){
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
while ((ch=*(fmt++))) {
|
||||||
|
if(ch != '%'){
|
||||||
|
k_print(ch);
|
||||||
|
} else {
|
||||||
|
ch = *(fmt++);
|
||||||
|
|
||||||
|
if(ch == 'd'){
|
||||||
|
auto arg = va_arg(va, std::size_t);
|
||||||
|
k_print(arg);
|
||||||
|
} else if(ch == 's'){
|
||||||
|
auto arg = va_arg(va, const char*);
|
||||||
|
k_print(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
@ -100,9 +100,7 @@ void exec_command(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
k_print("The command \"");
|
k_printf("The command \"%s\" does not exist\n", current_input);
|
||||||
k_print(current_input);
|
|
||||||
k_print("\" does not exist \n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_command(const char*){
|
void clear_command(const char*){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user