aboutsummaryrefslogtreecommitdiff
path: root/src/base/bufio/vprint.c
blob: 70be6bf41a910c3172b37004357a8c1fb884bbbd (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
#include "internal.h"

static int
flush(fmt·State *fmt)
{
    io·Header *io = fmt->file;
    io->olen = fmt->buffer.cur - fmt->buffer.end;
    if(bio·flush(io))
        return 0;

    fmt->buffer.end = (char*)io->e;
    fmt->buffer.cur = fmt->buffer.beg = fmt->buffer.end + io->olen;
    return 1;
}

int
bio·vprint(io·Header *io, char *fmt, va_list args)
{
    int n;
    fmt·State f;

    f.buffer.end = (char*)io->e;
    f.buffer.beg = f.buffer.cur = (char*)(io->e + io->olen);
    f.n     = 0;
    f.file  = io;
    f.flush = flush;

    va_copy(f.args,args);
    n = fmt·do(&f, fmt);
    va_end(f.args);

    io->olen = f.buffer.cur - f.buffer.beg;
    return n;
}