diff --git a/tprint/Makefile b/tprint/Makefile new file mode 100644 index 0000000..4f56b47 --- /dev/null +++ b/tprint/Makefile @@ -0,0 +1,9 @@ +PREFIX ?= /usr + +tprint: tprint.c + gcc -o tprint tprint.c + +install: tprint + install -D -m 755 tprint ${DESTDIR}${PREFIX}/bin/tprint + +.PHONY: tprint diff --git a/tprint/tprint.c b/tprint/tprint.c new file mode 100644 index 0000000..6caeb0e --- /dev/null +++ b/tprint/tprint.c @@ -0,0 +1,42 @@ +/*** + * Small program to output stdin or a file one character a time, like it would be typed + * Author: madmaurice + * License: GPL + */ + +#include +#include +#include +#include + +int main(int argc, char** argv) { + //Options + float speed = 0.3; + char* file = NULL; + + FILE* fh = stdin; + char c; + int v; + argv++; // Cut first element + for(int i = 1; i < argc; i++, argv++) { + if(strcmp(*argv,"-s") == 0) { + argv++; i++; + v = atoi(*argv); + if(v == 0) v = 1000; + speed = 1.0/v; + } else { + fh = fopen(*argv,"r"); + } + } + + while((c = fgetc(fh)) != EOF) { + fputc(c,stdout); + fflush(stdout); + usleep(speed * 1000000); + } + + return 0; +} + + +