From a9d8874980b5e450fda35a9f4a4848315677172b Mon Sep 17 00:00:00 2001 From: NukeBird Date: Tue, 2 Dec 2025 21:30:20 +0300 Subject: [PATCH] axl_putchar, axl_puts --- axl.h | 1 + axl_io.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ axl_io.h | 10 ++++++++++ main.c | 9 +++++++-- 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 axl_io.c create mode 100644 axl_io.h diff --git a/axl.h b/axl.h index 07e842c..844aefd 100644 --- a/axl.h +++ b/axl.h @@ -4,5 +4,6 @@ #include "axl_types.h" #include "axl_memory.h" #include "axl_string.h" +#include "axl_io.h" #endif diff --git a/axl_io.c b/axl_io.c new file mode 100644 index 0000000..91e9e5a --- /dev/null +++ b/axl_io.c @@ -0,0 +1,53 @@ +#include "axl_io.h" +#include +#include "axl_string.h" + +i8 axl_putchar(i32 c) +{ + HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE); + + if(console_handle == INVALID_HANDLE_VALUE) + { + return AXL_EOF; + } + + i8 char_to_write = (i8)c; + DWORD bytes_written = 0; + + BOOL status = WriteConsoleA(console_handle, &char_to_write, 1, + &bytes_written, NULL); + + if(!status || bytes_written != 1) + { + return AXL_EOF; + } + + return char_to_write; +} + +i8 axl_puts(const i8* str) +{ + HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE); + + if(console_handle == INVALID_HANDLE_VALUE) + { + return AXL_EOF; + } + + DWORD str_length = (DWORD)axl_strlen(str); + DWORD bytes_written = 0; + + BOOL status = WriteConsoleA(console_handle, str, str_length, &bytes_written, + NULL); + if(!status || bytes_written != str_length) + { + return AXL_EOF; + } + + if(axl_putchar('\n') != '\n') + { + return AXL_EOF; + } + + return AXL_SUCCESS; +} diff --git a/axl_io.h b/axl_io.h new file mode 100644 index 0000000..02e86bf --- /dev/null +++ b/axl_io.h @@ -0,0 +1,10 @@ +#ifndef AXL_IO_H +#include "axl_types.h" + +#define AXL_EOF -1 +#define AXL_SUCCESS 0 + +i8 axl_putchar(i32 c); +i8 axl_puts(const i8* str); + +#endif // !AXL_IO_H diff --git a/main.c b/main.c index 69c38b2..cc0c142 100644 --- a/main.c +++ b/main.c @@ -4,6 +4,13 @@ int _start(void) { axl_init(); + axl_puts("Potato activated"); + axl_puts("Quack quack motherducker"); + axl_puts("Meowdy partner"); + axl_puts("I am a meat popsicle"); + axl_puts("My spoon is too big"); + axl_puts("Blin!"); + void* fds = axl_malloc(83); int* f = axl_malloc(sizeof(int)); @@ -16,7 +23,5 @@ int _start(void) (void)fds; (void)f; - while(true){} - return 0; }