11#include "irx_imports.h"
27int _start(
int argc,
char *argv[])
29 if (RegisterLibraryEntries(&_exp_stdio) != 0) {
30 return MODULE_NO_RESIDENT_END;
32 return MODULE_RESIDENT_END;
35void stdio_prnt_callback(
void *userdata,
int c)
37 size_t current_length;
41 current_length = context->current_length;
42 tmp_buf = context->tmp_buf;
46 context->current_length = 0;
49 if (current_length == 0) {
54 stdio_prnt_callback(context,
'\r');
58 tmp_buf[current_length] = c;
60 context->current_length = current_length;
61 if (current_length == 64) {
62 context->current_length = 0;
64 io_write(context->fd, tmp_buf, current_length);
68int fdprintf(
int fd,
const char *format, ...)
76 context.current_length = 0;
77 res = prnt(&stdio_prnt_callback, &context, format, va);
82int vfdprintf(
int fd,
const char *format, va_list va)
87 context.current_length = 0;
88 return prnt(&stdio_prnt_callback, &context, format, va);
91int printf(
const char *format, ...)
99 context.current_length = 0;
100 res = prnt(&stdio_prnt_callback, &context, format, va);
105static u32 tab_stop_padding = 0;
107int fdputc(
int c,
int fd)
112 if ((
char)c ==
'\t') {
113 io_write(fd,
" ", 8 - (tab_stop_padding & 7));
114 tab_stop_padding = (tab_stop_padding & 0xFFFFFFF8) + 8;
115 }
else if ((
char)c ==
'\n') {
116 io_write(fd,
"\r\n", 2);
117 tab_stop_padding = 0;
119 if (isprint(c) != 0) {
120 tab_stop_padding += 1;
122 io_write(fd, buf, 1);
132int fdputs(
const char *s,
int fd)
140 while (*s_s !=
'\x00') {
147int puts(
const char *s)
165char *fdgets(
char *buf,
int fd)
225 if (isprint(v7) == 0) {