Annotation of /trunk/mkinitrd-magellan/busybox/util-linux/scriptreplay.c
Parent Directory | Revision Log
Revision 984 -
(hide annotations)
(download)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 886 byte(s)
Sun May 30 11:32:42 2010 UTC (14 years ago) by niro
File MIME type: text/plain
File size: 886 byte(s)
-updated to busybox-1.16.1 and enabled blkid/uuid support in default config
1 | niro | 984 | /* vi: set sw=4 ts=4: */ |
2 | /* | ||
3 | * scriptreplay - play back typescripts, using timing information | ||
4 | * | ||
5 | * pascal.bellard@ads-lu.com | ||
6 | * | ||
7 | * Licensed under GPLv2 or later, see file License in this tarball for details. | ||
8 | * | ||
9 | */ | ||
10 | #include "libbb.h" | ||
11 | |||
12 | int scriptreplay_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
13 | int scriptreplay_main(int argc UNUSED_PARAM, char **argv) | ||
14 | { | ||
15 | const char *script = "typescript"; | ||
16 | double delay, factor = 1000000.0; | ||
17 | int fd; | ||
18 | unsigned long count; | ||
19 | FILE *tfp; | ||
20 | |||
21 | if (!argv[1]) | ||
22 | bb_show_usage(); | ||
23 | |||
24 | if (argv[2]) { | ||
25 | script = argv[2]; | ||
26 | if (argv[3]) | ||
27 | factor /= atof(argv[3]); | ||
28 | } | ||
29 | |||
30 | tfp = xfopen_for_read(argv[1]); | ||
31 | fd = xopen(script, O_RDONLY); | ||
32 | while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) { | ||
33 | usleep(delay * factor); | ||
34 | bb_copyfd_exact_size(fd, STDOUT_FILENO, count); | ||
35 | } | ||
36 | if (ENABLE_FEATURE_CLEAN_UP) { | ||
37 | close(fd); | ||
38 | fclose(tfp); | ||
39 | } | ||
40 | return EXIT_SUCCESS; | ||
41 | } |