aboutsummaryrefslogtreecommitdiffstats
path: root/com32/elflink/ldlinux/eprintf.c
blob: f15edc6e4acbe8e396ad715a92c795f66befb75c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <core.h>

#define BUFFER_SIZE	4096

static void veprintf(const char *format, va_list ap)
{
    int rv, _rv;
    char buffer[BUFFER_SIZE];
    char *p;

    _rv = rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);

    if (rv < 0)
	return;

    if (rv > BUFFER_SIZE - 1)
	rv = BUFFER_SIZE - 1;

    p = buffer;
    while (rv--)
	    write_serial(*p++);

    _fwrite(buffer, _rv, stdout);
}

void eprintf(const char *format, ...)
{
    va_list ap;

    va_start(ap, format);
    veprintf(format, ap);
    va_end(ap);
}