summaryrefslogtreecommitdiff
path: root/src/slowcat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/slowcat.c')
-rw-r--r--src/slowcat.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/slowcat.c b/src/slowcat.c
new file mode 100644
index 0000000..facd2cc
--- /dev/null
+++ b/src/slowcat.c
@@ -0,0 +1,28 @@
+#define _BSD_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+int main(int argc,char *argv[]) {
+ short in;
+ FILE *fp=stdin;
+ if(argc < 2) {
+ fprintf(stderr,"usage: slowcat delay [file1] [file2] [...]\n");
+ return 1;
+ }
+ if(argc > 2) {
+ fp=fopen(argv[2],"r");
+ }
+ do {
+ while((in=fgetc(fp)) != -1) {
+ printf("%c",in);
+ if(in == '\n') {
+ fflush(stdout);
+ usleep(atoi(argv[1]));
+ }
+ }
+ fclose(fp);
+ argv++;
+ } while((fp=fopen(argv[1],"r")));
+ return 0;
+}