Fix libkeymap.pc installation
[platform/upstream/kbd.git] / contrib / sti.c
1 /*
2  * sti.c: put text in some tty input buffer - aeb, 951009
3  *
4  * You may have to be root if the tty is not your controlling tty.
5  */
6 #include <stdio.h>
7 #include <fcntl.h>
8 #include <termios.h>
9 #include <sys/ioctl.h>
10
11 int
12 main(int argc, char **argv) {
13     int fd;
14     char *s;
15
16     if(argc != 3) {
17         fprintf(stderr, "call: sti tty text\n");
18         exit(1);
19     }
20     fd = open(argv[1], O_RDONLY);
21     if(fd < 0) {
22         perror(argv[1]);
23         fprintf(stderr, "sti: could not open tty\n");
24         exit(1);
25     }
26     s = argv[2];
27     while(*s) {
28         if(ioctl(fd, TIOCSTI, s)) {
29             perror("TIOCSTI");
30             fprintf(stderr, "sti: TIOCSTI ioctl failed\n");
31             exit(1);
32         }
33         s++;
34     }
35     return 0;
36 }