aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-flip.c
blob: b37a9d83f01f6595ecea148e273d306e5f126b8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* See LICENSE file for copyright and license details. */
#include "stream.h"
#include "util.h"

#include <string.h>
#include <unistd.h>

USAGE("")

int
main(int argc, char *argv[])
{
	struct stream stream;
	size_t n, ptr, row_size;
	char *buf;

	UNOFLAGS(argc);

	stream.file = "<stdin>";
	stream.fd = STDIN_FILENO;
	einit_stream(&stream);
	fprint_stream_head(stdout, &stream);
	efflush(stdout, "<stdout>");

	echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, stream.file);
	n = stream.height * (row_size = stream.width * stream.pixel_size);
	buf = emalloc(n);

	while (eread_frame(&stream, buf, n))
		for (ptr = n; ptr;)
			ewriteall(STDOUT_FILENO, buf + (ptr -= row_size), row_size, "<stdout>");

	free(buf);
	return 0;
}