1 |
#ifndef INIT_H_ |
2 |
#define INIT_H_ |
3 |
|
4 |
#undef CERASE /* TODO */ |
5 |
#define CERASE '\010' /* ^H */ |
6 |
|
7 |
#ifdef HAVE_XSETLOCALE |
8 |
# define X_LOCALE |
9 |
# include <X11/Xlocale.h> |
10 |
#else |
11 |
# ifdef HAVE_SETLOCALE |
12 |
# include <clocale> |
13 |
# endif |
14 |
#endif /* HAVE_XLOCALE */ |
15 |
|
16 |
#ifdef TTY_GID_SUPPORT |
17 |
# include <grp.h> |
18 |
#endif |
19 |
|
20 |
/* ways to deal with getting/setting termios structure */ |
21 |
|
22 |
#ifdef HAVE_TERMIOS_H |
23 |
/* termios interface */ |
24 |
# ifdef TCSANOW /* POSIX */ |
25 |
# define GET_TERMIOS(fd,tios) tcgetattr (fd, tios) |
26 |
# define SET_TERMIOS(fd,tios) \ |
27 |
cfsetospeed (tios, BAUDRATE), \ |
28 |
cfsetispeed (tios, BAUDRATE), \ |
29 |
tcsetattr (fd, TCSANOW, tios) |
30 |
# else |
31 |
# ifdef TIOCSETA |
32 |
# define GET_TERMIOS(fd,tios) ioctl (fd, TIOCGETA, tios) |
33 |
# define SET_TERMIOS(fd,tios) \ |
34 |
tios->c_cflag |= BAUDRATE, \ |
35 |
ioctl (fd, TIOCSETA, tios) |
36 |
# else |
37 |
# define GET_TERMIOS(fd,tios) ioctl (fd, TCGETS, tios) |
38 |
# define SET_TERMIOS(fd,tios) \ |
39 |
tios->c_cflag |= BAUDRATE, \ |
40 |
ioctl (fd, TCSETS, tios) |
41 |
# endif |
42 |
# endif |
43 |
# define SET_TTYMODE(fd,tios) SET_TERMIOS (fd, tios) |
44 |
#else |
45 |
/* sgtty interface */ |
46 |
|
47 |
# define SET_TTYMODE(fd,tt) \ |
48 |
tt->sg.sg_ispeed = tt->sg.sg_ospeed = BAUDRATE, \ |
49 |
ioctl (fd, TIOCSETP, & (tt->sg)), \ |
50 |
ioctl (fd, TIOCSETC, & (tt->tc)), \ |
51 |
ioctl (fd, TIOCSLTC, & (tt->lc)), \ |
52 |
ioctl (fd, TIOCSETD, & (tt->line)), \ |
53 |
ioctl (fd, TIOCLSET, & (tt->local)) |
54 |
#endif /* HAVE_TERMIOS_H */ |
55 |
|
56 |
/* use the fastest baud-rate */ |
57 |
#ifdef B38400 |
58 |
# define BAUDRATE B38400 |
59 |
#else |
60 |
# ifdef B19200 |
61 |
# define BAUDRATE B19200 |
62 |
# else |
63 |
# define BAUDRATE B9600 |
64 |
# endif |
65 |
#endif |
66 |
|
67 |
/* Disable special character functions */ |
68 |
#ifdef _POSIX_VDISABLE |
69 |
# define VDISABLE _POSIX_VDISABLE |
70 |
#else |
71 |
# define VDISABLE 255 |
72 |
#endif |
73 |
|
74 |
/*----------------------------------------------------------------------* |
75 |
* system default characters if defined and reasonable |
76 |
*/ |
77 |
#ifndef CINTR |
78 |
# define CINTR '\003' /* ^C */ |
79 |
#endif |
80 |
#ifndef CQUIT |
81 |
# define CQUIT '\034' /* ^\ */ |
82 |
#endif |
83 |
#ifndef CERASE |
84 |
# ifdef linux |
85 |
# define CERASE '\177' /* ^? */ |
86 |
# else |
87 |
# define CERASE '\010' /* ^H */ |
88 |
# endif |
89 |
#endif |
90 |
#ifndef CKILL |
91 |
# define CKILL '\025' /* ^U */ |
92 |
#endif |
93 |
#ifndef CEOF |
94 |
# define CEOF '\004' /* ^D */ |
95 |
#endif |
96 |
#ifndef CSTART |
97 |
# define CSTART '\021' /* ^Q */ |
98 |
#endif |
99 |
#ifndef CSTOP |
100 |
# define CSTOP '\023' /* ^S */ |
101 |
#endif |
102 |
#ifndef CSUSP |
103 |
# define CSUSP '\032' /* ^Z */ |
104 |
#endif |
105 |
#ifndef CDSUSP |
106 |
# define CDSUSP '\031' /* ^Y */ |
107 |
#endif |
108 |
#ifndef CRPRNT |
109 |
# define CRPRNT '\022' /* ^R */ |
110 |
#endif |
111 |
#ifndef CFLUSH |
112 |
# define CFLUSH '\017' /* ^O */ |
113 |
#endif |
114 |
#ifndef CWERASE |
115 |
# define CWERASE '\027' /* ^W */ |
116 |
#endif |
117 |
#ifndef CLNEXT |
118 |
# define CLNEXT '\026' /* ^V */ |
119 |
#endif |
120 |
|
121 |
#ifndef VDISCRD |
122 |
# ifdef VDISCARD |
123 |
# define VDISCRD VDISCARD |
124 |
# endif |
125 |
#endif |
126 |
|
127 |
#ifndef VWERSE |
128 |
# ifdef VWERASE |
129 |
# define VWERSE VWERASE |
130 |
# endif |
131 |
#endif |
132 |
|
133 |
#ifndef O_NOCTTY |
134 |
# define O_NOCTTY 0 |
135 |
#endif |
136 |
#ifndef ONLCR |
137 |
# define ONLCR 0 |
138 |
#endif |
139 |
|
140 |
#define CONSOLE "/dev/console" /* console device */ |
141 |
|
142 |
#endif /* _INIT_H_ */ |