1 /* vi: set sw=4 ts=4: */
3 * scriptreplay - play back typescripts, using timing information
5 * pascal.bellard@ads-lu.com
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
11 //usage:#define scriptreplay_trivial_usage
12 //usage: "timingfile [typescript [divisor]]"
13 //usage:#define scriptreplay_full_usage "\n\n"
14 //usage: "Play back typescripts, using timing information"
18 int scriptreplay_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
19 int scriptreplay_main(int argc UNUSED_PARAM, char **argv)
21 const char *script = "typescript";
22 double delay, factor = 1000000.0;
33 factor /= atof(argv[3]);
36 tfp = xfopen_for_read(argv[1]);
37 fd = xopen(script, O_RDONLY);
38 while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) {
39 usleep(delay * factor);
40 bb_copyfd_exact_size(fd, STDOUT_FILENO, count);
42 if (ENABLE_FEATURE_CLEAN_UP) {