Introduction
Introduction Statistics Contact Development Disclaimer Help
blind-split-cols.c - blind - suckless command-line video editing utility
git clone git://git.suckless.org/blind
Log
Files
Refs
README
LICENSE
---
blind-split-cols.c (1171B)
---
1 /* See LICENSE file for copyright and license details. */
2 #include "common.h"
3
4 USAGE("(file columns) ...")
5
6 int
7 main(int argc, char *argv[])
8 {
9 struct stream stream;
10 size_t *cols, period = 0, parts, i;
11 int *fds;
12
13 UNOFLAGS(argc % 2 || !argc);
14
15 eopen_stream(&stream, NULL);
16
17 parts = (size_t)argc / 2;
18 cols = alloca(parts * sizeof(*cols));
19 fds = alloca(parts * sizeof(*fds));
20
21 for (i = 0; i < parts; i++) {
22 fds[i] = eopen(argv[i * 2], O_WRONLY | O_CREAT | O_TRUNC…
23 cols[i] = etozu_arg("columns", argv[i * 2 + 1], 1, SIZE_…
24 }
25 for (i = 0; i < parts; i++) {
26 if (cols[i] > SIZE_MAX - period)
27 goto bad_col_count;
28 period += cols[i];
29 }
30 if (period != stream.width)
31 goto bad_col_count;
32
33 for (i = 0; i < parts; i++)
34 if (DPRINTF_HEAD(fds[i], stream.frames, cols[i], stream.…
35 eprintf("dprintf %s:", argv[i * 2]);
36 for (i = 0; i < parts; i++, i = i == parts ? 0 : i)
37 if (esend_pixels(&stream, fds[i], cols[i], argv[i * 2]) …
38 break;
39 for (i = 0; i < parts; i++)
40 close(fds[i]);
41
42 return 0;
43
44 bad_col_count:
45 eprintf("the sum of all columns must add up to the width of the …
46 return 1;
47 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.