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