1 #include <u.h> 2 #include <libc.h> 3 #include "fmtdef.h" 4 5 /* 6 * public routine for final flush of a formatting buffer 7 * to a file descriptor; returns total char count. 8 */ 9 int fmtfdflush(Fmt * f)10fmtfdflush(Fmt *f) 11 { 12 if(_fmtFdFlush(f) <= 0) 13 return -1; 14 return f->nfmt; 15 } 16 17 /* 18 * initialize an output buffer for buffered printing 19 */ 20 int fmtfdinit(Fmt * f,int fd,char * buf,int size)21fmtfdinit(Fmt *f, int fd, char *buf, int size) 22 { 23 f->runes = 0; 24 f->start = buf; 25 f->to = buf; 26 f->stop = buf + size; 27 f->flush = _fmtFdFlush; 28 f->farg = (void*)fd; 29 f->nfmt = 0; 30 return 0; 31 } 32