Files
applets
arch
archival
console-tools
coreutils
debianutils
docs
e2fsprogs
editors
examples
findutils
include
init
libbb
libpwdgrp
loginutils
mailutils
miscutils
modutils
networking
printutils
procps
runit
scripts
selinux
shell
sysklogd
testsuite
util-linux
volume_id
Config.src
Kbuild.src
acpid.c
blkid.c
blockdev.c
dmesg.c
fbset.c
fdformat.c
fdisk.c
fdisk_aix.c
fdisk_gpt.c
fdisk_osf.c
fdisk_sgi.c
fdisk_sun.c
findfs.c
flock.c
freeramdisk.c
fsck_minix.c
getopt.c
hexdump.c
hwclock.c
ipcrm.c
ipcs.c
losetup.c
lspci.c
lsusb.c
mdev.c
minix.h
mkfs_ext2.c
mkfs_ext2.txt
mkfs_ext2_test.sh
mkfs_minix.c
mkfs_reiser.c
mkfs_vfat.c
mkswap.c
more.c
mount.c
pivot_root.c
rdate.c
rdev.c
readprofile.c
rev.c
rtcwake.c
script.c
scriptreplay.c
setarch.c
swaponoff.c
switch_root.c
umount.c
.gitignore
.indent.pro
AUTHORS
Config.in
INSTALL
LICENSE
Makefile
Makefile.custom
Makefile.flags
Makefile.help
README
TEST_config_nommu
TEST_config_noprintf
TEST_config_rh9
TODO
TODO_unicode
busybox/util-linux/scriptreplay.c
Denys Vlasenko 0ef64bdb40 *: make GNU licensing statement forms more regular
This change retains "or later" state! No licensing _changes_ here,
only form is adjusted (article, space between "GPL" and "v2" and so on).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16 20:14:46 +02:00

42 lines
878 B
C

/* 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.
*
*/
#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;
}