summaryrefslogtreecommitdiff
path: root/sys/src/cmd/unix/drawterm/libc/fmtfdflush.c
blob: 9bed1859b3f3b9a49c7ec7daf52f0d508e285a89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <inttypes.h>
#include <u.h>
#include <libc.h>
#include "fmtdef.h"

/*
 * generic routine for flushing a formatting buffer
 * to a file descriptor
 */
int
__fmtFdFlush(Fmt *f)
{
	int n;

	n = (char*)f->to - (char*)f->start;
	if(n && write((uintptr_t)f->farg, f->start, n) != n)
		return 0;
	f->to = f->start;
	return 1;
}