blob: 305c0d8b6cacf8a594504cebaad2cef27eeae23b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc,char *argv[]) {
short in;
FILE *fp=stdin;
if(argc < 2 || (argc >= 2 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help")))) {
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;
}
|