fmtfdflush.c (417B)
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 <unistd.h> 8 9 /* 10 * generic routine for flushing a formatting buffer 11 * to a file descriptor 12 */ 13 int __fmtFdFlush(Fmt* f) { 14 int n; 15 16 n = (char*) f->to - (char*) f->start; 17 if (n && write((uintptr) f->farg, f->start, n) != n) 18 return 0; 19 f->to = f->start; 20 return 1; 21 }