fix: include

This commit is contained in:
starnakin 2024-09-07 01:09:07 +02:00
parent 7fe298d6f0
commit a495e0dc2c
7 changed files with 43 additions and 24 deletions

View File

@ -13,7 +13,7 @@ enum print_level {
KERN_DEBUG,
KERN_DEFAULT,
KERN_CONT
}
};
int kprintf(enum print_level level, const char *restrict format, ...);
int vprintf(enum print_level level, const char *restrict format, va_list ap);
int kprintf(int level, const char *restrict format, ...);
int kvprintf(int level, const char *restrict format, va_list ap);

View File

@ -1,5 +1,9 @@
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
enum vga_color {
VGA_COLOR_BLACK = 0,
VGA_COLOR_BLUE = 1,
@ -22,6 +26,7 @@ enum vga_color {
void terminal_initialize(void);
void terminal_setcolor(uint8_t color);
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y);
void terminal_putchar(char c);
void terminal_write(const char* data, size_t size);
void terminal_writestring(const char* data);
int terminal_putchar(char c);
int terminal_write(const char* data, size_t size);
int terminal_writestring(const char* data);
int terminal_writelong(long number);

View File

@ -1,4 +1,4 @@
#include "kprint.h"
#include "kprintf.h"
#include "string.h"
#include "terminal.h"
#include "ctype.h"
@ -11,7 +11,7 @@ int kprintf(int level, const char *restrict format, ...)
int i;
va_start(va, format);
i = ft_vdprintf(level, format, va);
i = kvprintf(level, format, va);
va_end(va);
return (i);

View File

@ -1,7 +1,8 @@
#include "../../headers/kprint.h"
#include "../../headers/string.h"
#include "../../headers/terminal.h"
#include "../../headers/ctype.h"
#include "kprintf.h"
#include "string.h"
#include "terminal.h"
#include "ctype.h"
#include "stdlib.h"
#include <stdarg.h>
@ -30,9 +31,9 @@ int kvprintf(int level, const char *restrict format, va_list ap)
flag = strchr(start, '%');
if (flag != NULL) {
padding = atoll(start + 1);
for (; isdigit(*padding); padding++);
ret += print_flag(*padding, ap);
start = padding + 1;
for (; isdigit(*flag); flag++);
ret += print_flag(*flag, ap);
start = flag + 1;
}
else {
terminal_writestring(start);

View File

@ -1,8 +1,8 @@
#include <stddef.h>
char *strchr(const char *str, int c)
{
const char *start = str;
char *start = (char *) str;
while (*start)
{

View File

@ -1,6 +1,10 @@
#include "string.h"
#include <stddef.h>
char *strstr(const char *haystack, const char *needle)
{
const char *start = haystack;
char *start = (char *) haystack;
size_t len;
len = strlen(needle);

View File

@ -1,5 +1,9 @@
#include "../../headers/terminal.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
static inline uint8_t vga_entry_color(enum vga_color fg, enum vga_color bg)
{
return fg | bg << 4;
@ -51,7 +55,7 @@ void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
terminal_buffer[index] = vga_entry(c, color);
}
void terminal_putchar(char c)
int terminal_putchar(char c)
{
terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
if (++terminal_column == VGA_WIDTH) {
@ -59,20 +63,25 @@ void terminal_putchar(char c)
if (++terminal_row == VGA_HEIGHT)
terminal_row = 0;
}
return 1;
}
void terminal_write(const char* data, size_t size)
int terminal_write(const char* data, size_t size)
{
for (size_t i = 0; i < size; i++)
size_t i;
for (i = 0; i < size; i++)
terminal_putchar(data[i]);
return (int) i;
}
void terminal_writestring(const char* data)
int terminal_writestring(const char* data)
{
terminal_write(data, strlen(data));
size_t len = strlen(data);
terminal_write(data, len);
return len;
}
void terminal_writelong(long number)
int terminal_writelong(long number)
{
unsigned long number2 = number;