blob: 647d2f0ec42f246dc0548d6dd6807ac981e3e338 (
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) {
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;
}
|