From bc4fddbb4a018c05f7dd51aca7ed0464681fa860 Mon Sep 17 00:00:00 2001 From: jaseg Date: Tue, 14 Jul 2015 22:08:11 +0200 Subject: Added little censoring script --- .gitignore | 1 + Makefile | 18 ++++++++++----- censor | Bin 0 -> 26088 bytes censor.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 5 deletions(-) create mode 100755 censor create mode 100644 censor.c 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 Binary files /dev/null and b/censor 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#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 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; + } + } +} -- cgit