fiss

Friedel's Initialization and Service Supervision
Log | Files | Refs | LICENSE

fmtfd.c (686B)


      1 /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */
      2 #include "fmt.h"
      3 #include "fmtdef.h"
      4 #include "plan9.h"
      5 
      6 #include <stdarg.h>
      7 #include <string.h>
      8 
      9 /*
     10  * public routine for final flush of a formatting buffer
     11  * to a file descriptor; returns total char count.
     12  */
     13 int fmtfdflush(Fmt* f) {
     14 	if (__fmtFdFlush(f) <= 0)
     15 		return -1;
     16 	return f->nfmt;
     17 }
     18 
     19 /*
     20  * initialize an output buffer for buffered printing
     21  */
     22 int fmtfdinit(Fmt* f, int fd, char* buf, int size) {
     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*) (uintptr_t) fd;
     29 	f->flags = 0;
     30 	f->nfmt  = 0;
     31 	fmtlocaleinit(f, nil, nil, nil);
     32 	return 0;
     33 }