printf(" -l (--log) <logfile> - file to store output in, defaults to stdout.\n");
printf(" -s (--speed) <speed> - baudrate to use, defaults to 9600 baud.\n");
printf(" -p (--port2) <port2> - serial port to use instead of pty.\n");
+ printf(" -i (--in-tee) <file> - write all input raw data also to this file(s).\n");
+ printf(" -o (--out-tee) <file> - write all output raw data also to this file(s).\n");
printf(" --color <color> - color to use for normal output.\n");
printf(" --timecolor <color> - color to use for timestamp.\n");
printf(" --bytescolor <color> - color to use for number of bytes transmitted.\n\n");
write(out, buffer, n);
write(aux, buffer, n);
} else {
+ struct tee_entry *entry;
+
/* print timestamp if necessary */
if (tty_data.tstamp) {
if (out == STDOUT_FILENO) setColor(out, tty_data.tclr);
if (out == STDOUT_FILENO) setColor(out, tty_data.bclr);
write (out, buffer, strlen(buffer));
}
+ for (entry = (aux ? tee_inputs : tee_outputs); entry; entry=entry->next)
+ if (n!=write(entry->fd, buffer, n))
+ fatalError(TEEWRTFAIL);
}
}
}
{"color", 1, NULL, 'x'},
{"timecolor", 1, NULL, 'y'},
{"bytescolor", 1, NULL, 'z'},
+ {"in-tee", 1, NULL, 'i'},
+ {"out-tee", 1, NULL, 'o'},
{NULL, 0, NULL, 0}
};
#endif
strcat(tty_data.bclr, ptr1);
}
break;
+ case 'i':
+ case 'o': {
+ int fd=open(optarg, O_WRONLY|O_NOCTTY|O_CREAT|O_TRUNC, 0644);
+ struct tee_entry *entry=malloc(sizeof(*entry));
+ struct tee_entry **entryp=(optret=='i' ? &tee_inputs : &tee_outputs);
+
+ if (fd == -1)
+ fatalError(TEEFAIL);
+ if (!entry)
+ fatalError(MEMFAIL);
+ entry->fd = fd;
+ entry->next = *entryp;
+ *entryp = entry;
+ } break;
case 'h':
case '?':
default :