void-packages/srcpkgs/ttyrec/patches/tty.diff
2014-04-12 10:23:11 +02:00

82 lines
2.1 KiB
Diff

diff -upr ttyplay.c ttyplay.c
--- ttyplay.c 2006-06-11 17:52:50.000000000 +0200
+++ ttyplay.c 2014-04-11 13:17:47.870307005 +0200
@@ -132,6 +132,26 @@ ttywait (struct timeval prev, struct tim
return speed;
}
+int dropCommands = 0;
+double
+ttyspacewait (struct timeval prev, struct timeval cur, double speed)
+{
+ char c = '0';
+ if(dropCommands != 0) {
+ dropCommands--;
+ return 0;
+ }
+
+ while(strchr("\n ", c = fgetc(stdin)) == NULL) {
+ if(c < '0' || c > '9') {
+ dropCommands = 0;
+ continue;
+ }
+ dropCommands = dropCommands * 10 + (c - '0');
+ }
+ return 0; /* Speed isn't important. */
+}
+
double
ttynowait (struct timeval prev, struct timeval cur, double speed)
{
@@ -241,6 +261,8 @@ usage (void)
printf("Usage: ttyplay [OPTION] [FILE]\n");
printf(" -s SPEED Set speed to SPEED [1.0]\n");
printf(" -n No wait mode\n");
+ printf(" -t type mode. space or enter for next sequence\n");
+ printf(" -d STEPS drop STEPS steps before pausing in type mode\n");
printf(" -p Peek another person's ttyrecord\n");
exit(EXIT_FAILURE);
}
@@ -270,7 +292,7 @@ main (int argc, char **argv)
set_progname(argv[0]);
while (1) {
- int ch = getopt(argc, argv, "s:np");
+ int ch = getopt(argc, argv, "s:nptd:");
if (ch == EOF) {
break;
}
@@ -282,9 +304,19 @@ main (int argc, char **argv)
}
sscanf(optarg, "%lf", &speed);
break;
+ case 'd':
+ if (optarg == NULL) {
+ perror("-d option requires an argument");
+ exit(EXIT_FAILURE);
+ }
+ dropCommands = atoi(optarg);
+ break;
case 'n':
wait_func = ttynowait;
break;
+ case 't':
+ wait_func = ttyspacewait;
+ break;
case 'p':
process = ttypeek;
break;
diff -upr ttyrec-1.0.8/ttyrec.c ttyrec-1.0.8.new/ttyrec.c
--- ttyrec.c 2006-06-11 17:52:50.000000000 +0200
+++ ttyrec.c 2014-04-11 13:10:07.403341468 +0200
@@ -71,7 +71,9 @@
#define _(FOO) FOO
#ifdef HAVE_openpty
-#include <libutil.h>
+/* #include <libutil.h> */
+#include <pty.h> // for openpty and forkpty
+#include <utmp.h> // for login_tty
#endif
#if defined(SVR4) && !defined(CDEL)