53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
#include "axl_io.h"
|
|
#include <windows.h>
|
|
#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;
|
|
}
|