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.
9 //config:config SCRIPTREPLAY
10 //config: bool "scriptreplay (2.6 kb)"
13 //config: This program replays a typescript, using timing information
14 //config: given by script -t.
16 //applet:IF_SCRIPTREPLAY(APPLET(scriptreplay, BB_DIR_BIN, BB_SUID_DROP))
18 //kbuild:lib-$(CONFIG_SCRIPTREPLAY) += scriptreplay.o
20 //usage:#define scriptreplay_trivial_usage
21 //usage: "TIMINGFILE [TYPESCRIPT [DIVISOR]]"
22 //usage:#define scriptreplay_full_usage "\n\n"
23 //usage: "Play back typescripts, using timing information"
27 int scriptreplay_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28 int scriptreplay_main(int argc UNUSED_PARAM, char **argv)
30 const char *script = "typescript";
31 double delay, factor = 1000000.0;
42 factor /= atof(argv[3]);
45 tfp = xfopen_for_read(argv[1]);
46 fd = xopen(script, O_RDONLY);
47 while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) {
48 usleep(delay * factor);
49 bb_copyfd_exact_size(fd, STDOUT_FILENO, count);
51 if (ENABLE_FEATURE_CLEAN_UP) {