Forgot attachment. -- see shy jo
Common subdirectories: old/ttyrec-1.0.8/debian and ttyrec-1.0.8/debian
diff -u old/ttyrec-1.0.8/ttyplay.1 ttyrec-1.0.8/ttyplay.1
--- old/ttyrec-1.0.8/ttyplay.1 2006-06-11 11:52:50.000000000 -0400
+++ ttyrec-1.0.8/ttyplay.1 2010-01-11 15:50:57.000000000 -0500
@@ -55,6 +55,11 @@
.TP
.B \-p
peek another person's tty session.
+.TP
+.B \-P " COUNT"
+When peeking at a tty session, display
+.I COUNT
+frames of previous context.
.SH "SEE ALSO"
.BR script (1),
.BR ttyrec (1),
diff -u old/ttyrec-1.0.8/ttyplay.c ttyrec-1.0.8/ttyplay.c
--- old/ttyrec-1.0.8/ttyplay.c 2010-01-11 15:47:38.000000000 -0500
+++ ttyrec-1.0.8/ttyplay.c 2010-01-11 16:02:50.000000000 -0500
@@ -190,6 +190,27 @@
/* do nothing */
}
+long int frame_count=0;
+long int frame_peek=0;
+
+void
+ttycountwrites (char *buf, int len)
+{
+ frame_count++;
+}
+
+void
+ttywritepeek (char *buf, int len)
+{
+ if (frame_count) {
+ frame_count--;
+ }
+ if (frame_count < frame_peek) {
+ ttywrite(buf, len);
+ }
+}
+
+
void
ttyplay (FILE *fp, double speed, ReadFunc read_func,
WriteFunc write_func, WaitFunc wait_func)
@@ -230,6 +251,20 @@
ttyplay(fp, 0, ttyread, ttynowrite, ttynowait);
}
+void
+ttyskippeek (FILE *fp)
+{
+ /*
+ * Count total number of records.
+ */
+ ttyplay(fp, 0, ttyread, ttycountwrites, ttynowait);
+ rewind(fp);
+ /*
+ * Play last N records.
+ */
+ ttyplay(fp, 0, ttyread, ttywritepeek, ttynowait);
+}
+
void ttyplayback (FILE *fp, double speed,
ReadFunc read_func, WaitFunc wait_func)
{
@@ -239,7 +274,12 @@
void ttypeek (FILE *fp, double speed,
ReadFunc read_func, WaitFunc wait_func)
{
- ttyskipall(fp);
+ if (! frame_peek) {
+ ttyskipall(fp);
+ }
+ else {
+ ttyskippeek(fp);
+ }
ttyplay(fp, speed, ttypread, ttywrite, ttynowait);
}
@@ -251,6 +291,7 @@
printf(" -s SPEED Set speed to SPEED [1.0]\n");
printf(" -n No wait mode\n");
printf(" -p Peek another person's ttyrecord\n");
+ printf(" -P COUNT Show COUNT frames of context when peeking\n");
exit(EXIT_FAILURE);
}
@@ -278,7 +319,7 @@
set_progname(argv[0]);
while (1) {
- int ch = getopt(argc, argv, "s:np");
+ int ch = getopt(argc, argv, "s:npP:n");
if (ch == EOF) {
break;
}
@@ -296,6 +337,13 @@
case 'p':
process = ttypeek;
break;
+ case 'P':
+ if (optarg == NULL) {
+ perror("-P option requires an argument");
+ exit(EXIT_FAILURE);
+ }
+ sscanf(optarg, "%li", &frame_peek);
+ break;
default:
usage();
}
signature.asc
Description: Digital signature

