Blob
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"8 /*9 * public routine for final flush of a formatting buffer10 * to a file descriptor; returns total char count.11 */12 int13 fmtfdflush(Fmt *f)14 {15 if(__fmtFdFlush(f) <= 0)16 return -1;17 return f->nfmt;18 }20 /*21 * initialize an output buffer for buffered printing22 */23 int24 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 }