Add support for fprintf(stderr, ...).

This commit is contained in:
whitequark 2015-07-26 12:42:53 +03:00
parent f5cc6fb72d
commit 10f719a830
1 changed files with 20 additions and 1 deletions

View File

@ -3,6 +3,8 @@
#include <stdio.h>
#include <stdarg.h>
FILE *stdin, *stdout, *stderr;
static console_write_hook write_hook;
static console_read_hook read_hook;
static console_read_nonblock_hook read_nonblock_hook;
@ -60,11 +62,28 @@ void putsnonl(const char *s)
}
}
#define PRINTF_BUFFER_SIZE 256
int printf(const char *fmt, ...)
{
va_list args;
int len;
char outbuf[256];
char outbuf[PRINTF_BUFFER_SIZE];
va_start(args, fmt);
len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);
va_end(args);
outbuf[len] = 0;
putsnonl(outbuf);
return len;
}
int fprintf(FILE *stream, const char *fmt, ...)
{
va_list args;
int len;
char outbuf[PRINTF_BUFFER_SIZE];
va_start(args, fmt);
len = vscnprintf(outbuf, sizeof(outbuf), fmt, args);