aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-single-colour.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-07-16 00:59:42 +0200
committerMattias Andrée <maandree@kth.se>2017-07-16 00:59:42 +0200
commitc216ac3049102422a41ba2c9476b0dbf4f3e4034 (patch)
tree809793e1f01fafcb67422f654b6e9dbcab897660 /src/blind-single-colour.c
parentInstall the scripts (diff)
downloadblind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.gz
blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.bz2
blind-c216ac3049102422a41ba2c9476b0dbf4f3e4034.tar.xz
Use #include instead of #define
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/blind-single-colour.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/src/blind-single-colour.c b/src/blind-single-colour.c
index 9dd1df9..8017a25 100644
--- a/src/blind-single-colour.c
+++ b/src/blind-single-colour.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */
+#ifndef TYPE
#include "common.h"
USAGE("[-f frames | -f 'inf'] [-F pixel-format] -w width -h height (X Y Z | Y) [alpha]")
@@ -7,29 +8,8 @@ static struct stream stream = { .width = 0, .height = 0, .frames = 1 };
static double X, Y, Z, alpha = 1;
static int inf = 0;
-#define PROCESS(TYPE)\
- do {\
- typedef TYPE pixel_t[4];\
- pixel_t buf[BUFSIZ / 4];\
- size_t x, y, n;\
- ssize_t r;\
- \
- for (x = 0; x < ELEMENTSOF(buf); x++) {\
- buf[x][0] = (TYPE)X;\
- buf[x][1] = (TYPE)Y;\
- buf[x][2] = (TYPE)Z;\
- buf[x][3] = (TYPE)alpha;\
- }\
- while (inf || stream.frames--)\
- for (y = stream.height; y--;)\
- for (x = stream.width * sizeof(*buf); x;)\
- for (x -= n = MIN(sizeof(buf), x); n; n -= (size_t)r)\
- if ((r = write(STDOUT_FILENO, buf, n)) < 0)\
- eprintf("write <stdout>:");\
- } while (0)
-
-static void process_xyza(void) {PROCESS(double);}
-static void process_xyzaf(void) {PROCESS(float);}
+#define FILE "blind-single-colour.c"
+#include "define-functions.h"
int
main(int argc, char *argv[])
@@ -79,9 +59,9 @@ main(int argc, char *argv[])
pixfmt = get_pixel_format(pixfmt, "xyza");
if (!strcmp(pixfmt, "xyza"))
- process = process_xyza;
+ process = process_lf;
else if (!strcmp(pixfmt, "xyza f"))
- process = process_xyzaf;
+ process = process_f;
else
eprintf("pixel format %s is not supported, try xyza\n", pixfmt);
@@ -92,3 +72,28 @@ main(int argc, char *argv[])
process();
return 0;
}
+
+#else
+
+static void
+PROCESS(void)
+{
+ typedef TYPE pixel_t[4];
+ pixel_t buf[BUFSIZ / 4];
+ size_t x, y, n;
+ ssize_t r;
+ for (x = 0; x < ELEMENTSOF(buf); x++) {
+ buf[x][0] = (TYPE)X;
+ buf[x][1] = (TYPE)Y;
+ buf[x][2] = (TYPE)Z;
+ buf[x][3] = (TYPE)alpha;
+ }
+ while (inf || stream.frames--)
+ for (y = stream.height; y--;)
+ for (x = stream.width * sizeof(*buf); x;)
+ for (x -= n = MIN(sizeof(buf), x); n; n -= (size_t)r)
+ if ((r = write(STDOUT_FILENO, buf, n)) < 0)
+ eprintf("write <stdout>:");
+}
+
+#endif