blind

suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log | Files | Refs | README | LICENSE

blind-cat-rows.c (930B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "common.h"
      3 
      4 USAGE("stream ...")
      5 
      6 int
      7 main(int argc, char *argv[])
      8 {
      9 	struct stream *streams;
     10 	size_t height = 0, *rows;
     11 	int i;
     12 
     13 	UNOFLAGS(!argc);
     14 
     15 	streams = emalloc2((size_t)argc, sizeof(*streams));
     16 	rows    = alloca((size_t)argc * sizeof(*rows));
     17 
     18 	for (i = 0; i < argc; i++) {
     19 		eopen_stream(streams + i, argv[i]);
     20 		if (streams[i].height > SIZE_MAX - height)
     21 			eprintf("output video is too wide\n");
     22 		height += rows[i] = streams[i].height;
     23 		if (i) {
     24 			streams[i].height = streams->height;
     25 			echeck_compat(streams, streams + i);
     26 		}
     27 	}
     28 
     29 	streams->height = height;
     30 	fprint_stream_head(stdout, streams);
     31 	efflush(stdout, "<stdout>");
     32 
     33 	for (i = 0; i < argc; i++, i = i == argc ? 0 : i)
     34 		if (esend_rows(streams + i, STDOUT_FILENO, rows[i], "<stdout>") != rows[i])
     35 			break;
     36 	for (i = 0; i < argc; i++)
     37 		close(streams[i].fd);
     38 
     39 	free(streams);
     40 	return 0;
     41 }