/* keystuffer quick and dirty for blue v1.1
* (C) 2024 Pegasus Epsilon <pegasus@pimpninjas.org>
*/
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
int main (int argc, char **argv) {
if (3 != argc) {
printf("Usage: %s /dev/ttyN [command]\n", argv[0]);
return -2;
}
int dst = open(argv[1], O_RDWR);
if (0 > dst) {
perror(argv[1]);
return errno;
}
int src = open(argv[2], O_RDONLY);
if (0 > src) {
perror("open()");
return errno;
}
char buf;
while (1 == read(src, &buf, 1))
if (-1 == ioctl(dst, TIOCSTI, &buf)) perror("ioctl()");
close(src);
close(dst);
return 0;
}