libkernaux/src/console.c

47 lines
927 B
C
Raw Normal View History

2020-12-07 04:46:37 +00:00
#ifdef HAVE_CONFIG_H
2020-11-30 11:40:33 +00:00
#include "config.h"
2020-12-07 04:46:37 +00:00
#endif
2020-11-30 11:40:33 +00:00
#ifdef ASM_I386
#include <kernaux/asm/i386.h>
2020-11-30 11:32:12 +00:00
#endif
2022-01-10 04:45:02 +00:00
#include <kernaux/console.h>
2021-12-15 10:45:40 +00:00
#include <kernaux/libc.h>
#include <kernaux/printf.h>
2020-11-30 11:32:12 +00:00
2020-12-06 01:41:31 +00:00
void kernaux_console_putc(const char c __attribute__((unused)))
{
2022-01-11 06:16:36 +00:00
#if defined(ASM_I386) || defined(ASM_X86_64)
kernaux_asm_i386_outportb(0x3F8, c);
2020-11-30 11:32:12 +00:00
#endif
}
void kernaux_console_print(const char *const s)
{
for (const char *c = s; *c; ++c) {
kernaux_console_putc(*c);
}
}
void kernaux_console_printf(const char *format, ...)
{
va_list va;
va_start(va, format);
kernaux_printf_va(kernaux_console_putc, format, va);
va_end(va);
}
2020-11-30 11:32:12 +00:00
void kernaux_console_puts(const char *const s)
{
kernaux_console_print(s);
kernaux_console_putc('\n');
}
2021-12-16 15:26:16 +00:00
void kernaux_console_write(const char *const data, const size_t size)
2020-12-06 01:41:31 +00:00
{
2021-12-16 15:26:16 +00:00
for (size_t i = 0; i < size; i++) {
2020-11-30 11:32:12 +00:00
kernaux_console_putc(data[i]);
}
}