summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2015-07-14 22:08:11 +0200
committerjaseg <code@jaseg.net>2015-07-14 22:09:19 +0200
commitbc4fddbb4a018c05f7dd51aca7ed0464681fa860 (patch)
treeede1bb8f1ae7b9275ab00fc5d2950db28b929207
parent845a1016ece7a3b54de1f36c95eb71fcd2bad03c (diff)
downloadlolcat-bc4fddbb4a018c05f7dd51aca7ed0464681fa860.tar.gz
lolcat-bc4fddbb4a018c05f7dd51aca7ed0464681fa860.tar.bz2
lolcat-bc4fddbb4a018c05f7dd51aca7ed0464681fa860.zip
Added little censoring script
-rw-r--r--.gitignore1
-rw-r--r--Makefile18
-rwxr-xr-xcensorbin0 -> 26088 bytes
-rw-r--r--censor.c73
4 files changed, 87 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index 27af749..12b43b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
lolcat.o
+censor.o
diff --git a/Makefile b/Makefile
index b6ef5fe..0acbb89 100644
--- a/Makefile
+++ b/Makefile
@@ -1,19 +1,27 @@
-all: lolcat
+all: lolcat censor
musl/lib/libc.a musl/lib/crt1.o:
cd musl; ./configure
make -C musl
-lolcat: lolcat.c musl/lib/libc.a musl/lib/crt1.o
+musl: musl/lib/libc.a musl/lib/crt1.o
+
+lolcat: lolcat.c musl
gcc -c -std=c11 -Wall -Imusl/include -o lolcat.o lolcat.c
gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o lolcat lolcat.o musl/lib/crt1.o musl/lib/libc.a
-install: lolcat
+censor: censor.c musl
+ gcc -c -std=c11 -Wall -Imusl/include -o censor.o censor.c
+ gcc -s -nostartfiles -nodefaultlibs -nostdinc -static -ffunction-sections -fdata-sections -Wl,--gc-sections -o censor censor.o musl/lib/crt1.o musl/lib/libc.a
+
+install: lolcat censor
install lolcat /usr/local/bin
+ install censor /usr/local/bin
clean:
- rm -f lolcat lolcat.o
+ rm -f lolcat lolcat.o censor censor.o
+ make -C musl clean
-.PHONY: install clean
+.PHONY: install clean musl
diff --git a/censor b/censor
new file mode 100755
index 0000000..cecacce
--- /dev/null
+++ b/censor
Binary files differ
diff --git a/censor.c b/censor.c
new file mode 100644
index 0000000..659d19c
--- /dev/null
+++ b/censor.c
@@ -0,0 +1,73 @@
+/* Copyright (C) 2014 jaseg <github@jaseg.net>
+ *
+ * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ * Version 2, December 2004
+ *
+ * Everyone is permitted to copy and distribute verbatim or modified
+ * copies of this license document, and changing it is allowed as long
+ * as the name is changed.
+ *
+ * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+ *
+ * 0. You just DO WHAT THE FUCK YOU WANT TO.
+ */
+
+#define _GNU_SOURCE //for fmemopen
+
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <unistd.h>
+#include <sys/time.h>
+
+
+#define ARRAY_SIZE(foo) (sizeof(foo)/sizeof(foo[0]))
+const char codes[] = {39,38,44,43,49,48,84,83,119,118,154,148,184,178,214,208,209,203,204,198,199,163,164,128,129,93,99,63,69,33};
+
+int main(int argc, char **argv){
+ char **inputs = argv+1;
+ char **inputs_end = argv+argc;
+ if(inputs == inputs_end){
+ char *foo[] = {"-"};
+ inputs = foo;
+ inputs_end = inputs+1;
+ }
+
+ setlocale(LC_ALL, "");
+
+ for(char **filename=inputs; filename<inputs_end; filename++){
+ FILE *f = stdin;
+
+ if(strcmp(*filename, "-"))
+ f = fopen(*filename, "r");
+
+ if(!f){
+ fprintf(stderr, "Cannot open input file \"%s\": %s\n", *filename, strerror(errno));
+ return 2;
+ }
+
+ int c;
+ while((c = fgetwc(f)) > 0){
+ if(strchr("acemnopqrsuvwxyz", c))
+ printf("▄");
+ else if(strchr("bdfhijkltABCDEFGHIJKLMNOPQRSTUVWXYZ", c))
+ printf("█");
+ else
+ printf("%lc", c);
+ }
+
+ fclose(f);
+
+ if(c != WEOF && c != 0){
+ fprintf(stderr, "Error reading input file \"%s\": %s\n", *filename, strerror(errno));
+ return 2;
+ }
+ }
+}