fmtfd.c - 9base - revived minimalist port of Plan 9 userland to Unix
 (HTM) git clone git://git.suckless.org/9base
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       fmtfd.c (676B)
       ---
            1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
            2 #include <stdarg.h>
            3 #include <string.h>
            4 #include "plan9.h"
            5 #include "fmt.h"
            6 #include "fmtdef.h"
            7 
            8 /*
            9  * public routine for final flush of a formatting buffer
           10  * to a file descriptor; returns total char count.
           11  */
           12 int
           13 fmtfdflush(Fmt *f)
           14 {
           15         if(__fmtFdFlush(f) <= 0)
           16                 return -1;
           17         return f->nfmt;
           18 }
           19 
           20 /*
           21  * initialize an output buffer for buffered printing
           22  */
           23 int
           24 fmtfdinit(Fmt *f, int fd, char *buf, int size)
           25 {
           26         f->runes = 0;
           27         f->start = buf;
           28         f->to = buf;
           29         f->stop = buf + size;
           30         f->flush = __fmtFdFlush;
           31         f->farg = (void*)(uintptr_t)fd;
           32         f->flags = 0;
           33         f->nfmt = 0;
           34         fmtlocaleinit(f, nil, nil, nil);
           35         return 0;
           36 }