2015-06-07 04:05:37 -04:00
|
|
|
#include <time.h>
|
2015-06-12 04:19:19 -04:00
|
|
|
#include <errno.h>
|
2015-06-07 04:05:37 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2015-06-07 17:09:03 -04:00
|
|
|
static int process(char *name);
|
2015-06-07 04:54:52 -04:00
|
|
|
|
2015-06-07 04:05:37 -04:00
|
|
|
static int
|
2015-06-07 17:09:03 -04:00
|
|
|
process(char *name)
|
2015-06-07 04:05:37 -04:00
|
|
|
{
|
2015-06-07 04:10:23 -04:00
|
|
|
FILE *file = fopen(name, "r");
|
2015-06-07 17:09:03 -04:00
|
|
|
struct timespec ts;
|
|
|
|
|
|
|
|
ts.tv_sec = 0;
|
|
|
|
ts.tv_nsec = 10 * 1000000;
|
2015-06-07 04:05:37 -04:00
|
|
|
|
2015-06-12 04:19:19 -04:00
|
|
|
if (file == 0) {
|
|
|
|
fprintf(stderr, "[err] no such file or directory\n");
|
|
|
|
return ENOENT;
|
2015-06-07 04:10:23 -04:00
|
|
|
}
|
2015-06-07 04:05:37 -04:00
|
|
|
|
2015-06-07 04:10:23 -04:00
|
|
|
int x;
|
|
|
|
while ((x = fgetc(file)) != EOF) {
|
2015-06-07 04:54:52 -04:00
|
|
|
printf("%c", x);
|
2015-06-12 04:19:19 -04:00
|
|
|
fflush(stdout);
|
2015-06-07 17:09:03 -04:00
|
|
|
nanosleep(&ts, NULL);
|
2015-06-07 04:10:23 -04:00
|
|
|
}
|
2015-06-07 04:05:37 -04:00
|
|
|
|
2015-06-12 04:19:19 -04:00
|
|
|
fclose(file);
|
2015-06-07 04:10:23 -04:00
|
|
|
return 0;
|
2015-06-07 04:05:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
2015-06-12 04:19:19 -04:00
|
|
|
return process(argv[1]);
|
2015-06-07 17:09:03 -04:00
|
|
|
}
|