[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/busybox/src/util-linux/scriptreplay.c b/ap/app/busybox/src/util-linux/scriptreplay.c
new file mode 100644
index 0000000..382f56d
--- /dev/null
+++ b/ap/app/busybox/src/util-linux/scriptreplay.c
@@ -0,0 +1,47 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * scriptreplay - play back typescripts, using timing information
+ *
+ * pascal.bellard@ads-lu.com
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this source tree.
+ *
+ */
+
+//usage:#define scriptreplay_trivial_usage
+//usage: "timingfile [typescript [divisor]]"
+//usage:#define scriptreplay_full_usage "\n\n"
+//usage: "Play back typescripts, using timing information"
+
+#include "libbb.h"
+
+int scriptreplay_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+int scriptreplay_main(int argc UNUSED_PARAM, char **argv)
+{
+ const char *script = "typescript";
+ double delay, factor = 1000000.0;
+ int fd;
+ unsigned long count;
+ FILE *tfp;
+
+ if (!argv[1])
+ bb_show_usage();
+
+ if (argv[2]) {
+ script = argv[2];
+ if (argv[3])
+ factor /= atof(argv[3]);
+ }
+
+ tfp = xfopen_for_read(argv[1]);
+ fd = xopen(script, O_RDONLY);
+ while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) {
+ usleep(delay * factor);
+ bb_copyfd_exact_size(fd, STDOUT_FILENO, count);
+ }
+ if (ENABLE_FEATURE_CLEAN_UP) {
+ close(fd);
+ fclose(tfp);
+ }
+ return EXIT_SUCCESS;
+}