Line | Count | Source |
1 | /* Copyright (c) 2002-2006 Lucent Technologies; see LICENSE */ | |
2 | #include <stdarg.h> | |
3 | #include <unistd.h> | |
4 | #include "plan9.h" | |
5 | #include "fmt.h" | |
6 | #include "fmtdef.h" | |
7 | ||
8 | /* | |
9 | * generic routine for flushing a formatting buffer | |
10 | * to a file descriptor | |
11 | */ | |
12 | int | |
13 | __fmtFdFlush(Fmt *f) | |
14 | 40.7k | { |
15 | 40.7k | int n; |
16 | ||
17 | 40.7k | n = (char*)f->to - (char*)f->start; |
18 | 40.7k | if(n && write((uintptr)f->farg, f->start, n) != n) |
19 | 0 | return 0; |
20 | 40.7k | f->to = f->start; |
21 | 40.7k | return 1; |
22 | 40.7k | } |