wok-6.x annotate busybox/stuff/busybox-1.32-scriptreplay.u @ rev 23877

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