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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
* 92/02/01 07:30:28
* @(#) mytinfo term.tail 3.2 92/02/01 public domain, By Ross Ridge
*
*/
#if defined(_USE_TERMIO) || defined(_USE_TERMIOS)
#ifndef ICANON
#ifdef _USE_TERMIO
#include <termio.h>
#else
#include <termios.h>
#endif
#endif
#if defined(_USE_WINSZ) && defined(__FreeBSD__)
#include <sys/ioctl.h>
#endif
#if defined(_USE_WINSZ) && defined(xenix)
#include <sys/stream.h>
#include <sys/ptem.h>
#endif
#endif
#ifdef _USE_SGTTY
#ifndef CBREAK
#include <sgtty.h>
#endif
#endif
typedef struct _terminal {
int fd;
#ifdef _USE_SMALLMEM
#ifdef _USE_TERMIOS
speed_t baudrate;
#else
unsigned short baudrate;
#endif
unsigned pad:1, xon:1, termcap:1;
#else
int pad;
int xon;
int termcap;
#ifdef _USE_TERMIOS
speed_t baudrate;
#else
long baudrate;
#endif
#endif
char padch;
short true_lines, true_columns;
struct strbuf {
struct strbuf *next;
#ifdef _USE_SMALLMEM
short len;
#else
int len;
#endif
char buf[_MAX_CHUNK];
} *strbuf;
char *name, *name_long, *name_all;
#ifdef _USE_SGTTY
struct sgtty_str {
struct sgttyb v6;
#ifdef TIOCGETC
struct tchars v7;
#endif
#ifdef TIOCLGET
int bsd;
#endif
#ifdef TIOCGLTC
struct ltchars bsd_new;
#endif
} prog_mode, shell_mode;
#else /* _USE_SGTTY */
#ifdef _USE_TERMIOS
struct termios prog_mode, shell_mode;
#else
#ifdef _USE_TERMIO
struct termio prog_mode, shell_mode;
#endif
#endif
#endif /* else _USE_SGTTY */
#ifdef _USE_WINSZ
#ifdef TIOCGWINSZ
struct winsize prog_winsz, shell_winsz;
#endif
#endif
char bools[NUM_OF_BOOLS];
short nums[NUM_OF_NUMS];
char *strs[NUM_OF_STRS];
} TERMINAL;
#ifndef _CUR_TERM
#ifdef SINGLE
#define _CUR_TERM _term_buf
#else
#define _CUR_TERM (*cur_term)
#endif
#endif
extern TERMINAL *cur_term;
extern TERMINAL _term_buf;
#ifndef __P
#if defined(_USE_PROTOTYPES) && (defined(__STDC__) || defined(__cplusplus))
#define __P(protos) protos /* full-blown ANSI C */
#else
#define __P(protos) () /* traditional C preprocessor */
#endif
#endif
extern char *tparm __P((char *, ...));
extern int setupterm __P((char *, int, int *)), set_curterm __P((TERMINAL *));
extern int del_curterm __P((TERMINAL *)), tputs __P((char *, int, int (*)(char)));
extern int putp __P((char *));
extern int tigetflag __P((char *)), tigetnum __P((char *));
extern char *tigetstr __P((char *));
extern int def_prog_mode __P((void)), def_shell_mode __P((void));
extern int reset_prog_mode __P((void)), reset_shell_mode __P((void));
extern char *boolnames[], *boolcodes[], *boolfnames[];
extern char *numnames[], *numcodes[], *numfnames[];
extern char *strnames[], *strcodes[], *strfnames[];
#ifndef OK
#undef ERR
#define OK (0)
#define ERR (-1)
#endif
/* Compatibility */
#define Filedes fd
#define Ottyb shell_mode
#define Nttyb prog_mode
#define TTY struct termios
#endif /* _TERM_H_ */
|