-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsett.c
44 lines (40 loc) · 1.04 KB
/
sett.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Code to set the terminal to operational VDU
* workings before installation of working system
* with new tty driver
*/
#include "sys/sgtty.h"
#include "sys/deftty.h"
struct sgttyb sgttyb; /* stty/gtty - TIOCSETA/TIOCGETA */
struct tchars tchars; /* extra characters - TIOCSETC/TIOCGETC */
main()
{
int fd = 1;
if (ioctl(fd, TIOCGETA, &sgttyb) < 0) {
perror("Cannot get stty information");
}
if (ioctl(fd, TIOCGETC, &tchars) < 0) {
perror("Cannot get ttchars information");
}
sgttyb.sg_erase = CERASE;
sgttyb.sg_kill = CKILL;
sgttyb.sg_width = 0;
sgttyb.sg_length = 0;
sgttyb.sg_nldly = 0;
sgttyb.sg_crdly = 0;
sgttyb.sg_htdly = 0;
sgttyb.sg_vtdly = 0;
sgttyb.sg_flags = ECHO|CRMOD|ODDP|EVENP|ANYP|SCOPE|INDCTL;
tchars.t_intrc = CINTR;
tchars.t_quitc = CQUIT;
tchars.t_startc = CSTART;
tchars.t_stopc = CSTOP;
tchars.t_eofc = CEOT;
tchars.t_brkc = CBRK;
if (ioctl(fd, TIOCSETA, &sgttyb) < 0) {
perror("Cannot set stty information");
}
if (ioctl(fd, TIOCSETC, &tchars) < 0) {
perror("Cannot get ttchars information");
}
}