Removed note from BUGS section of several man pages saying
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / trmsbr.c,v
1 head    2.5;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 2.5
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    2.4;
12
13 2.4
14 date    92.11.02.22.52.56;      author jromine; state Exp;
15 branches;
16 next    2.3;
17
18 2.3
19 date    92.10.16.21.37.46;      author jromine; state Exp;
20 branches;
21 next    2.2;
22
23 2.2
24 date    90.04.05.14.57.28;      author sources; state Exp;
25 branches;
26 next    2.1;
27
28 2.1
29 date    90.02.05.15.03.14;      author sources; state Exp;
30 branches;
31 next    2.0;
32
33 2.0
34 date    89.11.17.15.58.13;      author sources; state Exp;
35 branches;
36 next    1.1;
37
38 1.1
39 date    89.11.17.15.44.56;      author sources; state Exp;
40 branches;
41 next    ;
42
43
44 desc
45 @@
46
47
48 2.5
49 log
50 @endif sugar
51 @
52 text
53 @/* trmsbr.c - minor termcap support (load with -ltermlib) */
54 #ifndef lint
55 static char ident[] = "@@(#)$Id: trmsbr.c,v 2.4 1992/11/02 22:52:56 jromine Exp jromine $";
56 #endif  /* lint */
57
58 #include "../h/mh.h"
59 #include <stdio.h>
60 #ifndef SYS5
61 #include <sgtty.h>
62 #if     defined(ULTRIX) && !defined(BSD43)
63 #undef  TIOCGWINSZ
64 #endif
65 #else   /* SYS5 */
66 #include <sys/types.h>
67 #include <termio.h>
68 #ifndef NOIOCTLH
69 #include <sys/ioctl.h>
70 #endif  /* NOIOCTLH */
71 #undef  TIOCGWINSZ
72 #endif  /* SYS5 */
73
74
75 #if     BUFSIZ<2048
76 #define TXTSIZ  2048
77 #else
78 #define TXTSIZ  BUFSIZ
79 #endif
80
81 #ifndef SYS5
82 extern char PC;
83 extern short    ospeed;
84 #else   /*   SYS5 */
85 char    PC;
86 short   ospeed;
87 #endif  /* SYS5 */
88
89 int     tgetent (), tgetnum ();
90 char   *tgetstr ();
91
92 /* \f */
93
94 static int  HC = 0;
95
96 static int  initLI = 0;
97 static int  LI = 40;
98 static int  initCO = 0;
99 static int  CO = 80;
100 static char *CL = NULL;
101 static char *SE = NULL;
102 static char *SO = NULL;
103
104 static char termcap[TXTSIZ];
105
106 /* \f */
107
108 static  read_termcap () {
109     register char  *bp,
110                    *term;
111     char   *cp,
112             myterm[TXTSIZ];
113 #ifndef SYS5
114     struct sgttyb   sg;
115 #else   /* SYS5 */
116     struct termio   sg;
117 #endif  /* SYS5 */
118     static int  inited = 0;
119
120     if (inited++)
121         return;
122
123     if ((term = getenv ("TERM")) == NULL || tgetent (myterm, term) <= OK)
124         return;
125
126 #ifndef SYS5
127     ospeed = ioctl (fileno (stdout), TIOCGETP, (char *) &sg) != NOTOK
128                 ? sg.sg_ospeed : 0;
129 #else   /* SYS5 */
130     ospeed = ioctl (fileno (stdout), TCGETA, &sg) != NOTOK
131                 ? sg.c_cflag & CBAUD : 0;
132 #endif  /* SYS5 */
133
134     HC = tgetflag ("hc");
135
136     if (!initCO && (CO = tgetnum ("co")) <= 0)
137         CO = 80;
138     if (!initLI && (LI = tgetnum ("li")) <= 0)
139         LI = 24;
140
141     cp = termcap;
142     CL = tgetstr ("cl", &cp);
143     if (bp = tgetstr ("pc", &cp))
144         PC = *bp;
145     if (tgetnum ("sg") <= 0) {
146         SE = tgetstr ("se", &cp);
147         SO = tgetstr ("so", &cp);
148     }
149 }
150
151 /* \f */
152
153 int     sc_width () {
154 #ifdef  TIOCGWINSZ
155     struct winsize win;
156     int width;
157
158     if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
159             && (width = win.ws_col) > 0) {
160         CO = width;
161         initCO++;
162     } else
163 #endif  /* TIOCGWINSZ */
164         read_termcap ();
165
166     return CO;
167 }
168
169
170 int     sc_length () {
171 #ifdef  TIOCGWINSZ
172     struct winsize win;
173
174     if (ioctl (fileno (stderr), TIOCGWINSZ, &win) != NOTOK
175             && (LI = win.ws_row) > 0)
176         initLI++;
177     else
178 #endif  /* TIOCGWINSZ */
179         read_termcap ();
180
181     return LI;
182 }
183
184 /* \f */
185
186 static int  outc (c)
187 register char    c;
188 {
189     (void) putchar (c);
190 }
191
192
193 void clear_screen () {
194     read_termcap ();
195
196     if (CL && ospeed)
197         tputs (CL, LI, outc);
198     else {
199         printf ("\f");
200         if (ospeed)
201             printf ("\200");
202     }
203
204     (void) fflush (stdout);
205 }
206
207 /* \f */
208
209 /* VARARGS1 */
210
211 int     SOprintf (fmt, a, b, c, d, e, f)
212 char   *fmt,
213        *a,
214        *b,
215        *c,
216        *d,
217        *e,
218        *f;
219 {
220     read_termcap ();
221     if (SO == NULL || SE == NULL)
222         return NOTOK;
223
224     tputs (SO, 1, outc);
225     printf (fmt, a, b, c, d, e, f);
226     tputs (SE, 1, outc);
227
228     return OK;
229 }
230
231 /* \f */
232
233 int     sc_hardcopy () {
234     read_termcap ();
235
236     return HC;
237 }
238 @
239
240
241 2.4
242 log
243 @delete fflush -- it makes output look jumpy
244 @
245 text
246 @d3 2
247 a4 2
248 static char ident[] = "@@(#)$Id: trmsbr.c,v 2.3 1992/10/16 21:37:46 jromine Exp jromine $";
249 #endif  lint
250 d13 1
251 a13 1
252 #else   SYS5
253 d18 1
254 a18 1
255 #endif  NOIOCTLH
256 d20 1
257 a20 1
258 #endif  SYS5
259 d32 1
260 a32 1
261 #else   SYS5
262 d35 1
263 a35 1
264 #endif  SYS5
265 d63 1
266 a63 1
267 #else   SYS5
268 d65 1
269 a65 1
270 #endif  SYS5
271 d77 1
272 a77 1
273 #else   SYS5
274 d80 1
275 a80 1
276 #endif  SYS5
277 d111 1
278 a111 1
279 #endif  TIOCGWINSZ
280 d126 1
281 a126 1
282 #endif  TIOCGWINSZ
283 @
284
285
286 2.3
287 log
288 @add fflush()
289 @
290 text
291 @d3 1
292 a3 1
293 static char ident[] = "@@(#)$Id: trmsbr.c,v 2.2 1990/04/05 14:57:28 sources Exp jromine $";
294 a174 1
295     (void) fflush (stdout);
296 @
297
298
299 2.2
300 log
301 @add ID
302 @
303 text
304 @d3 1
305 a3 1
306 static char ident[] = "@@(#)$Id:$";
307 d175 1
308 @
309
310
311 2.1
312 log
313 @*** empty log message ***
314 @
315 text
316 @d2 3
317 @
318
319
320 2.0
321 log
322 @changes for SUN40 shared libraries and NNTP under bbc
323 @
324 text
325 @d13 1
326 d15 1
327 @
328
329
330 1.1
331 log
332 @Initial revision
333 @
334 text
335 @d14 1
336 @