Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5496 | leency | 1 | /* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */ |
2 | #ifndef __dj_include_libc_ttyprvt_h__ |
||
3 | #define __dj_include_libc_ttyprvt_h__ |
||
4 | |||
5 | #ifdef __cplusplus |
||
6 | extern "C" { |
||
7 | #endif |
||
8 | |||
9 | #ifndef __dj_ENFORCE_ANSI_FREESTANDING |
||
10 | |||
11 | #ifndef __STRICT_ANSI__ |
||
12 | |||
13 | #ifndef _POSIX_SOURCE |
||
14 | |||
15 | #include |
||
16 | #include |
||
17 | |||
18 | #define _TTY_CTRL(x) ((x) & 0x1f) |
||
19 | #define _TTY_QUEUE_SIZE 2048 |
||
20 | #define _TTY_EDITLINE_SIZE ((_TTY_QUEUE_SIZE) / 2) |
||
21 | #define _TTY_EDITLINE_CTRL 0 |
||
22 | #define _TTY_EDITLINE_SINGLE 1 |
||
23 | #define _TTY_EDITLINE_INVALID -1 |
||
24 | |||
25 | struct tty_queue |
||
26 | { |
||
27 | int size; |
||
28 | unsigned char *top; |
||
29 | unsigned char *bottom; |
||
30 | int count; |
||
31 | unsigned char *rpos; |
||
32 | unsigned char *wpos; |
||
33 | }; |
||
34 | |||
35 | struct tty |
||
36 | { |
||
37 | struct termios __libc_termios; |
||
38 | struct tty_queue __libc_tty_queue; |
||
39 | int __libc_tty_status; |
||
40 | }; |
||
41 | |||
42 | struct tty_editline |
||
43 | { |
||
44 | int col; |
||
45 | char flag[_TTY_EDITLINE_SIZE]; |
||
46 | unsigned char buf[_TTY_EDITLINE_SIZE]; |
||
47 | }; |
||
48 | |||
49 | #if !defined (_POSIX_VDISABLE) || (_POSIX_VDISABLE == 0) |
||
50 | #error _POSIX_VDISABLE is undefine or zero. |
||
51 | #endif |
||
52 | |||
53 | #define TTYDEFAULT \ |
||
54 | { \ |
||
55 | { \ |
||
56 | /* c_cc[] */ \ |
||
57 | { \ |
||
58 | (cc_t) 0, /* pad */ \ |
||
59 | (cc_t) _TTY_CTRL ('d'), /* VEOF */ \ |
||
60 | (cc_t) _POSIX_VDISABLE, /* VEOL */ \ |
||
61 | (cc_t) _TTY_CTRL ('h'), /* VERASE */ \ |
||
62 | (cc_t) _TTY_CTRL ('c'), /* VINTR */ \ |
||
63 | (cc_t) _TTY_CTRL ('u'), /* VKILL */ \ |
||
64 | (cc_t) 1, /* VMIN */ \ |
||
65 | (cc_t) _TTY_CTRL ('\\'),/* VQUIT */ \ |
||
66 | (cc_t) _TTY_CTRL ('q'), /* VSTART */ \ |
||
67 | (cc_t) _TTY_CTRL ('s'), /* VSTOP */ \ |
||
68 | (cc_t) _TTY_CTRL ('z'), /* VSUSP */ \ |
||
69 | (cc_t) 0, /* VTIME */ \ |
||
70 | }, \ |
||
71 | (tcflag_t) (CS8|CREAD|CLOCAL), /* c_cflag */ \ |
||
72 | (tcflag_t) (BRKINT|ICRNL|IMAXBEL), /* c_iflag */ \ |
||
73 | (tcflag_t) (ISIG|ICANON|ECHO|IEXTEN|ECHOE|ECHOKE|ECHOCTL), /* c_lflag */ \ |
||
74 | (tcflag_t) (OPOST|ONLCR|ONOEOT), /* c_oflag */ \ |
||
75 | (speed_t) (B9600), /* c_ispeed */ \ |
||
76 | (speed_t) (B9600), /* c_ospeed */ \ |
||
77 | }, \ |
||
78 | /* struct tty_queue __libc_tty_queue */ \ |
||
79 | { \ |
||
80 | _TTY_QUEUE_SIZE, \ |
||
81 | __libc_tty_queue_buffer, \ |
||
82 | __libc_tty_queue_buffer + _TTY_QUEUE_SIZE, \ |
||
83 | 0, \ |
||
84 | __libc_tty_queue_buffer, \ |
||
85 | __libc_tty_queue_buffer, \ |
||
86 | }, \ |
||
87 | /* __libc_tty_status */ \ |
||
88 | 0, \ |
||
89 | } |
||
90 | |||
91 | #define t_termios __libc_termios |
||
92 | #define t_iflag __libc_termios.c_iflag |
||
93 | #define t_oflag __libc_termios.c_oflag |
||
94 | #define t_cflag __libc_termios.c_cflag |
||
95 | #define t_lflag __libc_termios.c_lflag |
||
96 | #define t_ispeed __libc_termios.c_ispeed |
||
97 | #define t_ospeed __libc_termios.c_ospeed |
||
98 | #define t_cc __libc_termios.c_cc |
||
99 | #define t_status __libc_tty_status |
||
100 | |||
101 | #define t_size __libc_tty_queue.size |
||
102 | #define t_top __libc_tty_queue.top |
||
103 | #define t_bottom __libc_tty_queue.bottom |
||
104 | #define t_count __libc_tty_queue.count |
||
105 | #define t_rpos __libc_tty_queue.rpos |
||
106 | #define t_wpos __libc_tty_queue.wpos |
||
107 | |||
108 | #define _TS_LNCH 0x01 /* next character is literal */ |
||
109 | #define _CC_EQU(v,c) (((c) == (unsigned char) __libc_tty_p->t_cc[(v)]) \ |
||
110 | && ((c) != (unsigned char) _POSIX_VDISABLE)) |
||
111 | #define _CC_NEQU(v,c) (((c) != (unsigned char)__libc_tty_p->t_cc[(v)]) \ |
||
112 | && ((c) != (unsigned char) _POSIX_VDISABLE)) |
||
113 | |||
114 | /* internal buffers */ |
||
115 | extern unsigned char __libc_tty_queue_buffer[]; |
||
116 | extern struct tty __libc_tty_internal; |
||
117 | extern struct tty *__libc_tty_p; |
||
118 | extern struct tty_editline __libc_tty_editline; |
||
119 | |||
120 | /* termios hooks */ |
||
121 | extern ssize_t (*__libc_read_termios_hook)(int handle, void *buffer, size_t count, |
||
122 | ssize_t *rv); |
||
123 | extern ssize_t (*__libc_write_termios_hook)(int handle, const void *buffer, size_t count, |
||
124 | ssize_t *rv); |
||
125 | extern int __libc_termios_hook_common_count; |
||
126 | |||
127 | /* functions */ |
||
128 | void __libc_termios_init (void); |
||
129 | |||
130 | #endif /* !_POSIX_SOURCE */ |
||
131 | #endif /* !__STRICT_ANSI__ */ |
||
132 | #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */ |
||
133 | |||
134 | #ifdef __cplusplus |
||
135 | } |
||
136 | #endif |
||
137 | |||
138 | #endif /* !__dj_include_libc_ttyprvt_h__ */ |