summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2016-09-12 14:52:25 -0400
committerJune McEnroe <june@causal.agency>2016-09-12 14:52:25 -0400
commit748d73ecd18f7236218a147bf30cd05df36d2c8d (patch)
tree2a509d9ab7d44626a113367b09c8494d53880e9b
parentAdd .bin/xx.c (diff)
downloadsrc-748d73ecd18f7236218a147bf30cd05df36d2c8d.tar.gz
src-748d73ecd18f7236218a147bf30cd05df36d2c8d.zip
Add -c option to xx
-rwxr-xr-x.bin/xx.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/.bin/xx.c b/.bin/xx.c
index d2d86574..153ba74e 100755
--- a/.bin/xx.c
+++ b/.bin/xx.c
@@ -1,17 +1,24 @@
 #if 0
-exec cc -Weverything -o ~/.bin/xx $0
+exec cc -Weverything -Wno-vla -o ~/.bin/xx $0
 #endif
 
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 int main(int argc, char **argv)
 {
+    size_t cols = 16;
     char *path = NULL;
 
-    if (argc > 1)
-        path = argv[1];
+    while (getopt(argc, argv, "c:") > 0)
+        if (optopt == 'c') {
+            cols = (size_t) strtol(optarg, NULL, 10);
+            if (!cols) return EXIT_FAILURE;
+        } else return EXIT_FAILURE;
+    if (argc > optind)
+        path = argv[optind];
 
     FILE *file = path ? fopen(path, "r") : stdin;
     if (!file) {
@@ -19,7 +26,7 @@ int main(int argc, char **argv)
         return EXIT_FAILURE;
     }
 
-    uint8_t buf[16];
+    uint8_t buf[cols];
     for (;;) {
         size_t n = fread(buf, 1, sizeof(buf), file);
         for (size_t i = 0; i < n; ++i)
/home/.config/X/resources?id=11db1d928fcd0fe72d9bc70a7a3a2f9d5ecc1685&follow=1'>Set urgency on bell in xtermJune McEnroe 2021-02-07Add bindings for brightness controlJune McEnroe 2021-02-07Set X key repeat rateJune McEnroe 2021-02-07Bump font size to 12June McEnroe 2021-02-07Fully configure and rebind cwmJune McEnroe 2021-02-07Add BintiJune McEnroe 2021-02-07Finish configuring xtermJune McEnroe 2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe 2021-02-06Set root window to black on purple snowJune McEnroe 2021-02-06Add xmodmap configurationJune McEnroe 2021-02-06Add initial OpenBSD X configurationJune McEnroe 2021-02-06Add xterm output to schemeJune McEnroe