1
0
Fork 0
mirror of https://github.com/tailix/kernel.git synced 2025-04-14 17:33:13 -04:00

Use function "kernaux_console_printf"

This commit is contained in:
Alex Kotov 2020-12-06 07:49:59 +05:00
parent 7fe1a796b2
commit e23553de85
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 2 additions and 64 deletions

View file

@ -92,64 +92,3 @@ void print_prefix(const unsigned char level, const char *const source)
kernaux_console_print(": ");
}
}
void print(const char *format, ...)
{
char **arg = (char **) &format;
int c;
char buf[20];
arg++;
while ((c = *format++) != 0)
{
if (c == '\n') {
if (*format != 0) {
kernaux_console_putc('\n');
}
}
else if (c != '%') {
kernaux_console_putc(c);
}
else {
char *p, *p2;
int pad0 = 0, pad = 0;
c = *format++;
if (c == '0')
{
pad0 = 1;
c = *format++;
}
if (c >= '0' && c <= '9')
{
pad = c - '0';
c = *format++;
}
switch (c)
{
case 'd':
case 'u':
case 'x':
kernaux_itoa(*((int*)arg++), buf, c);
p = buf;
goto string;
break;
case 's':
p = *arg++;
if (! p)
p = "(null)";
string:
for (p2 = p; *p2; p2++);
for (; p2 < p + pad; p2++)
kernaux_console_putc(pad0 ? '0' : ' ');
while (*p)
kernaux_console_putc(*p++);
break;
default:
kernaux_console_putc(*((int *) arg++));
break;
}
}
}
kernaux_console_putc('\n');
}

View file

@ -13,6 +13,4 @@
void logger_log(unsigned char level, const char *source, const char *format, ...);
void print(const char *format, ...);
#endif

View file

@ -9,6 +9,7 @@
#include "elf.h"
#include "logger.h"
#include <kernaux/console.h>
#include <kernaux/multiboot2.h>
#include <kernaux/pfa.h>
#include <kernaux/stdlib.h>
@ -32,7 +33,7 @@ void main(
panic("Multiboot 2 magic number is invalid.");
}
KernAux_Multiboot2_print(multiboot2_info, print);
KernAux_Multiboot2_print(multiboot2_info, kernaux_console_printf);
if (!KernAux_Multiboot2_is_valid(multiboot2_info)) {
panic("Multiboot 2 info is invalid.");