wok view busybox/stuff/busybox-1.27-scriptreplay.u @ rev 21193

systemd: added build dependency glibc-dev
author Hans-G?nter Theisgen
date Fri Apr 05 17:46:01 2019 +0100 (2019-04-05)
parents
children
line source
1 --- busybox-1.26/util-linux/scriptreplay.c
2 +++ busybox-1.26/util-linux/scriptreplay.c
3 @@ -18,10 +18,20 @@
5 //kbuild:lib-$(CONFIG_SCRIPTREPLAY) += scriptreplay.o
7 +//config:config SCRIPTREPLAY_HOTKEYS
8 +//config: bool "speed control hotkeys"
9 +//config: default n
10 +//config: depends on SCRIPTREPLAY
11 +//config: help
12 +//config: Tune replay speed with + - = space return hotkeys.
13 +
14 //usage:#define scriptreplay_trivial_usage
15 //usage: "timingfile [typescript [divisor]]"
16 //usage:#define scriptreplay_full_usage "\n\n"
17 //usage: "Play back typescripts, using timing information"
18 +//usage: IF_SCRIPTREPLAY_HOTKEYS(
19 +//usage: " and + - = space return hotkeys"
20 +//usage: )
22 #include "libbb.h"
24 @@ -31,6 +41,10 @@
25 const char *script = "typescript";
26 double delay, factor = 1000000.0;
27 int fd;
28 +#if ENABLE_SCRIPTREPLAY_HOTKEYS
29 + int timeout = -1;
30 + char buffer[KEYCODE_BUFFER_SIZE];
31 +#endif
32 unsigned long count;
33 FILE *tfp;
35 @@ -48,6 +62,21 @@
36 while (fscanf(tfp, "%lf %lu\n", &delay, &count) == 2) {
37 usleep(delay * factor);
38 bb_copyfd_exact_size(fd, STDOUT_FILENO, count);
39 +#if ENABLE_SCRIPTREPLAY_HOTKEYS
40 + switch (read_key(0, buffer, timeout)) {
41 + case ' ':
42 + timeout = INT_MAX;
43 + break;
44 + case '=':
45 + factor = 1000000.0/2;
46 + case '-':
47 + factor *= 4;
48 + case '+':
49 + factor /= 2;
50 + default :
51 + timeout = -1;
52 + }
53 +#endif
54 }
55 if (ENABLE_FEATURE_CLEAN_UP) {
56 close(fd);