Print this page
702 tput calls gets()
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/tput/tput.c
+++ new/usr/src/cmd/tput/tput.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 + * Copyright (c) 2012 Gary Mills
25 26 */
26 27
27 28 /* Copyright (c) 1988 AT&T */
28 29 /* All Rights Reserved */
29 30
30 31 /*
31 32 * tput - print terminal attribute
32 33 *
33 34 * return-codes - command line arguments:
34 35 * 0: ok if boolean capname -> TRUE
35 36 * 1: for boolean capname -> FALSE
36 37 *
37 38 * return-codes - standard input arguments:
38 39 * 0: ok; tput for all lines was successful
39 40 *
40 41 * return-codes - both cases:
41 42 * 2 usage error
42 43 * 3 bad terminal type given or no terminfo database
43 44 * 4 unknown capname
44 45 * -1 capname is a numeric variable that is not specified in the
45 46 * terminfo database(E.g. tpu -T450 lines).
46 47 *
47 48 * tput printfs a value if an INT capname was given; e.g. cols.
48 49 * putp's a string if a STRING capname was given; e.g. clear. and
49 50 * for BOOLEAN capnames, e.g. hard-copy, just returns the boolean value.
50 51 */
51 52
52 53 #include <curses.h>
53 54 #include <term.h>
54 55 #include <fcntl.h>
55 56 #include <ctype.h>
56 57 #include <stdlib.h>
57 58 #include <string.h>
58 59 #include <sys/types.h>
59 60 #include <unistd.h>
60 61 #include <locale.h>
61 62
62 63 /* externs from libcurses */
63 64 extern int tigetnum();
64 65
65 66 static int outputcap(char *cap, int argc, char **argv);
66 67 static int allnumeric(char *string);
67 68 static int getpad(char *cap);
68 69 static void setdelay();
69 70 static void settabs();
70 71 static void cat(char *file);
71 72 static void initterm();
72 73 static void reset_term();
73 74
74 75 static char *progname; /* argv[0] */
75 76 static int CurrentBaudRate; /* current baud rate */
76 77 static int reset = 0; /* called as reset_term */
77 78 static int fildes = 1;
78 79
79 80 int
80 81 main(int argc, char **argv)
81 82 {
82 83 int i, std_argc;
83 84 char *term = getenv("TERM");
84 85 char *cap, std_input = FALSE;
85 86 int setuperr;
86 87
87 88 (void) setlocale(LC_ALL, "");
88 89 #if !defined(TEXT_DOMAIN)
89 90 #define TEXT_DOMAIN "SYS_TEST"
90 91 #endif
91 92 (void) textdomain(TEXT_DOMAIN);
92 93
93 94 progname = argv[0];
94 95
95 96 while ((i = getopt(argc, argv, "ST:")) != EOF) {
96 97 switch (i) {
97 98 case 'T':
98 99 fildes = -1;
99 100 (void) putenv("LINES=");
100 101 (void) putenv("COLUMNS=");
101 102 term = optarg;
102 103 break;
103 104
104 105 case 'S':
105 106 std_input = TRUE;
106 107 break;
107 108
108 109 case '?': /* FALLTHROUGH */
109 110 usage: /* FALLTHROUGH */
110 111 default:
111 112 (void) fprintf(stderr, gettext(
112 113 "usage:\t%s [-T [term]] capname "
113 114 "[parm argument...]\n"), progname);
114 115 (void) fprintf(stderr, gettext("OR:\t%s -S <<\n"),
115 116 progname);
116 117 exit(2);
117 118 }
118 119 }
119 120
120 121 if (!term || !*term) {
121 122 (void) fprintf(stderr,
122 123 gettext("%s: No value for $TERM and no -T specified\n"),
123 124 progname);
124 125 exit(2);
125 126 }
126 127
127 128 (void) setupterm(term, fildes, &setuperr);
128 129
129 130 switch (setuperr) {
130 131 case -2:
131 132 (void) fprintf(stderr,
132 133 gettext("%s: unreadable terminal descriptor \"%s\"\n"),
133 134 progname, term);
134 135 exit(3);
135 136 break;
136 137
137 138 case -1:
138 139 (void) fprintf(stderr,
139 140 gettext("%s: no terminfo database\n"), progname);
140 141 exit(3);
141 142 break;
142 143
143 144 case 0:
144 145 (void) fprintf(stderr,
145 146 gettext("%s: unknown terminal \"%s\"\n"),
146 147 progname, term);
147 148 exit(3);
148 149 }
149 150
150 151 reset_shell_mode();
151 152
152 153 /* command line arguments */
153 154 if (!std_input) {
154 155 if (argc == optind)
155 156 goto usage;
156 157
157 158 cap = argv[optind++];
158 159
159 160 if (strcmp(cap, "init") == 0)
160 161 initterm();
161 162 else if (strcmp(cap, "reset") == 0)
162 163 reset_term();
163 164 else if (strcmp(cap, "longname") == 0)
164 165 (void) printf("%s\n", longname());
165 166 else
166 167 exit(outputcap(cap, argc, argv));
↓ open down ↓ |
132 lines elided |
↑ open up ↑ |
167 168 return (0);
168 169 } else { /* standard input argumets */
169 170 char buff[128];
170 171 char **v;
171 172
172 173 /* allocate storage for the 'faked' argv[] array */
173 174 v = (char **)malloc(10 * sizeof (char *));
174 175 for (i = 0; i < 10; i++)
175 176 v[i] = (char *)malloc(32 * sizeof (char));
176 177
177 - while (gets(buff) != NULL) {
178 + while (fgets(buff, sizeof (buff), stdin) != NULL) {
178 179 /* read standard input line; skip over empty lines */
179 180 if ((std_argc =
180 - sscanf(buff, "%s %s %s %s %s %s %s %s %s %s",
181 + sscanf(buff,
182 + "%31s %31s %31s %31s %31s %31s %31s %31s "
183 + "%31s %31s",
181 184 v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7],
182 185 v[8], v[9])) < 1) {
183 186 continue;
184 187 }
185 188
186 189 cap = v[0];
187 190 optind = 1;
188 191
189 192 if (strcmp(cap, "init") == 0) {
190 193 initterm();
191 194 } else if (strcmp(cap, "reset") == 0) {
192 195 reset_term();
193 196 } else if (strcmp(cap, "longname") == 0) {
194 197 (void) printf("%s\n", longname());
195 198 } else {
196 199 (void) outputcap(cap, std_argc, v);
197 200 }
198 201 (void) fflush(stdout);
199 202 }
200 203
201 204 return (0);
202 205 }
203 206 }
204 207
205 208 static long parm[9] = {
206 209 0, 0, 0, 0, 0, 0, 0, 0, 0
207 210 };
208 211
209 212 static int
210 213 outputcap(char *cap, int argc, char **argv)
211 214 {
212 215 int parmset = 0;
213 216 char *thisstr;
214 217 int i;
215 218
216 219 if ((i = tigetflag(cap)) >= 0)
217 220 return (1 - i);
218 221
219 222 if ((i = tigetnum(cap)) >= -1) {
220 223 (void) printf("%d\n", i);
221 224 return (0);
222 225 }
223 226
224 227 if ((thisstr = tigetstr(cap)) != (char *)-1) {
225 228 if (!thisstr) {
226 229 return (1);
227 230 }
228 231 for (parmset = 0; optind < argc; optind++, parmset++)
229 232 if (allnumeric(argv[optind]))
230 233 parm[parmset] = atoi(argv[optind]);
231 234 else
232 235 parm[parmset] = (int)argv[optind];
233 236
234 237 if (parmset)
235 238 putp(tparm(thisstr,
236 239 parm[0], parm[1], parm[2], parm[3],
237 240 parm[4], parm[5], parm[6], parm[7], parm[8]));
238 241 else
239 242 putp(thisstr);
240 243 return (0);
241 244 }
242 245
243 246 (void) fprintf(stderr,
244 247 gettext("%s: unknown terminfo capability '%s'\n"), progname, cap);
245 248
246 249 exit(4);
247 250 /* NOTREACHED */
248 251 }
249 252
250 253 /*
251 254 * The decision as to whether an argument is a number or not is to simply
252 255 * look at whether there are any non-digits in the string.
253 256 */
254 257 static int
255 258 allnumeric(char *string)
256 259 {
257 260 if (*string) {
258 261 while (*string) {
259 262 if (!isdigit(*string++)) {
260 263 return (0);
261 264 }
262 265 }
263 266 return (1);
264 267 } else {
265 268 return (0);
266 269 }
267 270 }
268 271
269 272 /*
270 273 * SYSTEM DEPENDENT TERMINAL DELAY TABLES
271 274 *
272 275 * These tables maintain the correspondence between the delays
273 276 * defined in terminfo and the delay algorithms in the tty driver
274 277 * on the particular systems. For each type of delay, the bits used
275 278 * for that delay must be specified, in XXbits, and a table
276 279 * must be defined giving correspondences between delays and
277 280 * algorithms. Algorithms which are not fixed delays, such
278 281 * as dependent on current column or line number, must be
279 282 * kludged in some way at this time.
280 283 *
281 284 * Some of this was taken from tset(1).
282 285 */
283 286
284 287 struct delay
285 288 {
286 289 int d_delay;
287 290 int d_bits;
288 291 };
289 292
290 293 /* The appropriate speeds for various termio settings. */
291 294 static int speeds[] = {
292 295 0, /* B0, */
293 296 50, /* B50, */
294 297 75, /* B75, */
295 298 110, /* B110, */
296 299 134, /* B134, */
297 300 150, /* B150, */
298 301 200, /* B200, */
299 302 300, /* B300, */
300 303 600, /* B600, */
301 304 1200, /* B1200, */
302 305 1800, /* B1800, */
303 306 2400, /* B2400, */
304 307 4800, /* B4800, */
305 308 9600, /* B9600, */
306 309 19200, /* EXTA, */
307 310 38400, /* EXTB, */
308 311 57600, /* B57600, */
309 312 76800, /* B76800, */
310 313 115200, /* B115200, */
311 314 153600, /* B153600, */
312 315 230400, /* B230400, */
313 316 307200, /* B307200, */
314 317 460800, /* B460800, */
315 318 921600, /* B921600, */
316 319 0,
317 320 };
318 321
319 322 #if defined(SYSV) || defined(USG)
320 323 /* Unix 3.0 on up */
321 324
322 325 /* Carriage Return delays */
323 326
324 327 static int CRbits = CRDLY;
325 328 static struct delay CRdelay[] =
326 329 {
327 330 0, CR0,
328 331 80, CR1,
329 332 100, CR2,
330 333 150, CR3,
331 334 -1
332 335 };
333 336
334 337 /* New Line delays */
335 338
336 339 static int NLbits = NLDLY;
337 340 static struct delay NLdelay[] =
338 341 {
339 342 0, NL0,
340 343 100, NL1,
341 344 -1
342 345 };
343 346
344 347 /* Back Space delays */
345 348
346 349 static int BSbits = BSDLY;
347 350 static struct delay BSdelay[] =
348 351 {
349 352 0, BS0,
350 353 50, BS1,
351 354 -1
352 355 };
353 356
354 357 /* TaB delays */
355 358
356 359 static int TBbits = TABDLY;
357 360 static struct delay TBdelay[] =
358 361 {
359 362 0, TAB0,
360 363 11, TAB1, /* special M37 delay */
361 364 100, TAB2,
362 365 /* TAB3 is XTABS and not a delay */
363 366 -1
364 367 };
365 368
366 369 /* Form Feed delays */
367 370
368 371 static int FFbits = FFDLY;
369 372 static struct delay FFdelay[] =
370 373 {
371 374 0, FF0,
372 375 2000, FF1,
373 376 -1
374 377 };
375 378
376 379 #else /* BSD */
377 380
378 381 /* Carriage Return delays */
379 382
380 383 int CRbits = CRDELAY;
381 384 struct delay CRdelay[] =
382 385 {
383 386 0, CR0,
384 387 9, CR3,
385 388 80, CR1,
386 389 160, CR2,
387 390 -1
388 391 };
389 392
390 393 /* New Line delays */
391 394
392 395 int NLbits = NLDELAY;
393 396 struct delay NLdelay[] =
394 397 {
395 398 0, NL0,
396 399 66, NL1, /* special M37 delay */
397 400 100, NL2,
398 401 -1
399 402 };
400 403
401 404 /* Tab delays */
402 405
403 406 int TBbits = TBDELAY;
404 407 struct delay TBdelay[] =
405 408 {
406 409 0, TAB0,
407 410 11, TAB1, /* special M37 delay */
408 411 -1
409 412 };
410 413
411 414 /* Form Feed delays */
412 415
413 416 int FFbits = VTDELAY;
414 417 struct delay FFdelay[] =
415 418 {
416 419 0, FF0,
417 420 2000, FF1,
418 421 -1
419 422 };
420 423 #endif /* BSD */
421 424
422 425 /*
423 426 * Initterm, a.k.a. reset_term, does terminal specific initialization. In
424 427 * particular, the init_strings from terminfo are output and tabs are
425 428 * set, if they aren't hardwired in. Much of this stuff was done by
426 429 * the tset(1) program.
427 430 */
428 431
429 432 /*
430 433 * Figure out how many milliseconds of padding the capability cap
431 434 * needs and return that number. Padding is stored in the string as "$<n>",
432 435 * where n is the number of milliseconds of padding. More than one
433 436 * padding string is allowed within the string, although this is unlikely.
434 437 */
435 438
436 439 static int
437 440 getpad(char *cap)
438 441 {
439 442 int padding = 0;
440 443
441 444 /* No padding needed at speeds below padding_baud_rate */
442 445 if (padding_baud_rate > CurrentBaudRate || cap == NULL)
443 446 return (0);
444 447
445 448 while (*cap) {
446 449 if ((cap[0] == '$') && (cap[1] == '<')) {
447 450 cap++;
448 451 cap++;
449 452 padding += atoi(cap);
450 453 while (isdigit (*cap))
451 454 cap++;
452 455 while (*cap == '.' || *cap == '/' || *cap == '*' ||
453 456 isdigit(*cap))
454 457 cap++;
455 458 while (*cap == '>')
456 459 cap++;
457 460 } else {
458 461 cap++;
459 462 }
460 463 }
461 464
462 465 return (padding);
463 466 }
464 467
465 468 /*
466 469 * Set the appropriate delay bits in the termio structure for
467 470 * the given delay.
468 471 */
469 472 static void
470 473 setdelay(delay, delaytable, bits, flags)
471 474 register int delay;
472 475 struct delay delaytable[];
473 476 int bits;
474 477 #ifdef SYSV
475 478 tcflag_t *flags;
476 479 #else /* SYSV */
477 480 unsigned short *flags;
478 481 #endif /* SYSV */
479 482 {
480 483 register struct delay *p;
481 484 register struct delay *lastdelay;
482 485
483 486 /* Clear out the bits, replace with new ones */
484 487 *flags &= ~bits;
485 488
486 489 /* Scan the delay table for first entry with adequate delay */
487 490 for (lastdelay = p = delaytable;
488 491 (p -> d_delay >= 0) && (p -> d_delay < delay);
489 492 p++) {
490 493 lastdelay = p;
491 494 }
492 495
493 496 /* use last entry if none will do */
494 497 *flags |= lastdelay -> d_bits;
495 498 }
496 499
497 500 /*
498 501 * Set the hardware tabs on the terminal, using clear_all_tabs,
499 502 * set_tab, and column_address capabilities. Cursor_address and cursor_right
500 503 * may also be used, if necessary.
501 504 * This is done before the init_file and init_3string, so they can patch in
502 505 * case we blow this.
503 506 */
504 507
505 508 static void
506 509 settabs()
507 510 {
508 511 register int c;
509 512
510 513 /* Do not set tabs if they power up properly. */
511 514 if (init_tabs == 8)
512 515 return;
513 516
514 517 if (set_tab) {
515 518 /* Force the cursor to be at the left margin. */
516 519 if (carriage_return)
517 520 putp(carriage_return);
518 521 else
519 522 (void) putchar('\r');
520 523
521 524 /* Clear any current tab settings. */
522 525 if (clear_all_tabs)
523 526 putp(clear_all_tabs);
524 527
525 528 /* Set the tabs. */
526 529 for (c = 8; c < columns; c += 8) {
527 530 /* Get to that column. */
528 531 (void) fputs(" ", stdout);
529 532
530 533 /* Set the tab. */
531 534 putp(set_tab);
532 535 }
533 536
534 537 /* Get back to the left column. */
535 538 if (carriage_return)
536 539 putp(carriage_return);
537 540 else
538 541 (void) putchar('\r');
539 542
540 543 }
541 544 }
542 545
543 546 /*
544 547 * Copy "file" onto standard output.
545 548 */
546 549
547 550 static void
548 551 cat(file)
549 552 char *file; /* File to copy. */
550 553 {
551 554 register int fd; /* File descriptor. */
552 555 register ssize_t i; /* Number characters read. */
553 556 char buf[BUFSIZ]; /* Buffer to read into. */
554 557
555 558 fd = open(file, O_RDONLY);
556 559
557 560 if (fd < 0) {
558 561 perror("Cannot open initialization file");
559 562 } else {
560 563 while ((i = read(fd, buf, BUFSIZ)) > (ssize_t)0)
561 564 (void) write(fileno(stdout), buf, (unsigned)i);
562 565 (int)close(fd);
563 566 }
564 567 }
565 568
566 569 /*
567 570 * Initialize the terminal.
568 571 * Send the initialization strings to the terminal.
569 572 */
570 573
571 574 static void
572 575 initterm()
573 576 {
574 577 register int filedes; /* File descriptor for ioctl's. */
575 578 #if defined(SYSV) || defined(USG)
576 579 struct termio termmode; /* To hold terminal settings. */
577 580 struct termios termmodes; /* To hold terminal settings. */
578 581 int i;
579 582 int istermios = -1;
580 583 #define GTTY(fd, mode) ioctl(fd, TCGETA, mode)
581 584 #define GTTYS(fd, mode) \
582 585 (istermios = ioctl(fd, TCGETS, mode))
583 586 #define STTY(fd, mode) ioctl(fd, TCSETAW, mode)
584 587 #define STTYS(fd, mode) ioctl(fd, TCSETSW, mode)
585 588 #define SPEED(mode) (mode.c_cflag & CBAUD)
586 589 #define SPEEDS(mode) (cfgetospeed(&mode))
587 590 #define OFLAG(mode) mode.c_oflag
588 591 #else /* BSD */
589 592 struct sgttyb termmode; /* To hold terminal settings. */
590 593 #define GTTY(fd, mode) gtty(fd, mode)
591 594 #define STTY(fd, mode) stty(fd, mode)
592 595 #define SPEED(mode) (mode.sg_ospeed & 017)
593 596 #define OFLAG(mode) mode.sg_flags
594 597 #define TAB3 XTABS
595 598 #endif
596 599
597 600 /* Get the terminal settings. */
598 601 /* First try standard output, then standard error, */
599 602 /* then standard input, then /dev/tty. */
600 603 #ifdef SYSV
601 604 if ((filedes = 1, GTTYS(filedes, &termmodes) < 0) ||
602 605 (filedes = 2, GTTYS(filedes, &termmodes) < 0) ||
603 606 (filedes = 0, GTTYS(filedes, &termmodes) < 0) ||
604 607 (filedes = open("/dev/tty", O_RDWR),
605 608 GTTYS(filedes, &termmodes) < 0)) {
606 609 #endif /* SYSV */
607 610 if ((filedes = 1, GTTY(filedes, &termmode) == -1) ||
608 611 (filedes = 2, GTTY(filedes, &termmode) == -1) ||
609 612 (filedes = 0, GTTY(filedes, &termmode) == -1) ||
610 613 (filedes = open("/dev/tty", O_RDWR),
611 614 GTTY(filedes, &termmode) == -1)) {
612 615 filedes = -1;
613 616 CurrentBaudRate = speeds[B1200];
614 617 } else
615 618 CurrentBaudRate = speeds[SPEED(termmode)];
616 619 #ifdef SYSV
617 620 termmodes.c_lflag = termmode.c_lflag;
618 621 termmodes.c_oflag = termmode.c_oflag;
619 622 termmodes.c_iflag = termmode.c_iflag;
620 623 termmodes.c_cflag = termmode.c_cflag;
621 624 for (i = 0; i < NCC; i++)
622 625 termmodes.c_cc[i] = termmode.c_cc[i];
623 626 } else
624 627 CurrentBaudRate = speeds[SPEEDS(termmodes)];
625 628 #endif /* SYSV */
626 629
627 630 if (xon_xoff) {
628 631 #ifdef SYSV
629 632 OFLAG(termmodes) &=
630 633 ~(NLbits | CRbits | BSbits | FFbits | TBbits);
631 634 #else /* SYSV */
632 635 OFLAG(termmode) &=
633 636 ~(NLbits | CRbits | BSbits | FFbits | TBbits);
634 637 #endif /* SYSV */
635 638 } else {
636 639 #ifdef SYSV
637 640 setdelay(getpad(carriage_return),
638 641 CRdelay, CRbits, &OFLAG(termmodes));
639 642 setdelay(getpad(scroll_forward),
640 643 NLdelay, NLbits, &OFLAG(termmodes));
641 644 setdelay(getpad(cursor_left),
642 645 BSdelay, BSbits, &OFLAG(termmodes));
643 646 setdelay(getpad(form_feed),
644 647 FFdelay, FFbits, &OFLAG(termmodes));
645 648 setdelay(getpad(tab),
646 649 TBdelay, TBbits, &OFLAG(termmodes));
647 650 #else /* SYSV */
648 651 setdelay(getpad(carriage_return),
649 652 CRdelay, CRbits, &OFLAG(termmode));
650 653 setdelay(getpad(scroll_forward),
651 654 NLdelay, NLbits, &OFLAG(termmode));
652 655 setdelay(getpad(cursor_left),
653 656 BSdelay, BSbits, &OFLAG(termmode));
654 657 setdelay(getpad(form_feed),
655 658 FFdelay, FFbits, &OFLAG(termmode));
656 659 setdelay(getpad(tab),
657 660 TBdelay, TBbits, &OFLAG(termmode));
658 661 #endif /* SYSV */
659 662 }
660 663
661 664 /* If tabs can be sent to the tty, turn off their expansion. */
662 665 if (tab && set_tab || init_tabs == 8) {
663 666 #ifdef SYSV
664 667 OFLAG(termmodes) &= ~(TAB3);
665 668 #else /* SYSV */
666 669 OFLAG(termmode) &= ~(TAB3);
667 670 #endif /* SYSV */
668 671 } else {
669 672 #ifdef SYSV
670 673 OFLAG(termmodes) |= TAB3;
671 674 #else /* SYSV */
672 675 OFLAG(termmode) |= TAB3;
673 676 #endif /* SYSV */
674 677 }
675 678
676 679 /* Do the changes to the terminal settings */
677 680 #ifdef SYSV
678 681 if (istermios < 0) {
679 682 int i;
680 683
681 684 termmode.c_lflag = termmodes.c_lflag;
682 685 termmode.c_oflag = termmodes.c_oflag;
683 686 termmode.c_iflag = termmodes.c_iflag;
684 687 termmode.c_cflag = termmodes.c_cflag;
685 688 for (i = 0; i < NCC; i++)
686 689 termmode.c_cc[i] = termmodes.c_cc[i];
687 690 (void) STTY(filedes, &termmode);
688 691 } else
689 692 (void) STTYS(filedes, &termmodes);
690 693
691 694 #else /* SYSV */
692 695 (void) STTY(filedes, &termmode);
693 696 #endif /* SYSV */
694 697
695 698 /* Send first initialization strings. */
696 699 if (init_prog)
697 700 (void) system(init_prog);
698 701
699 702 if (reset && reset_1string) {
700 703 putp(reset_1string);
701 704 } else if (init_1string) {
702 705 putp(init_1string);
703 706 }
704 707
705 708 if (reset && reset_2string) {
706 709 putp(reset_2string);
707 710 } else if (init_2string) {
708 711 putp(init_2string);
709 712 }
710 713
711 714 /* Set up the tabs stops. */
712 715 settabs();
713 716
714 717 /* Send out initializing file. */
715 718 if (reset && reset_file) {
716 719 cat(reset_file);
717 720 } else if (init_file) {
718 721 cat(init_file);
719 722 }
720 723
721 724 /* Send final initialization strings. */
722 725 if (reset && reset_3string) {
723 726 putp(reset_3string);
724 727 } else if (init_3string) {
725 728 putp(init_3string);
726 729 }
727 730
728 731 if (carriage_return) {
729 732 putp(carriage_return);
730 733 } else {
731 734 (void) putchar('\r');
732 735 }
733 736
734 737 /* Send color initialization strings */
735 738
736 739 if (orig_colors)
737 740 putp(orig_colors);
738 741
739 742 if (orig_pair)
740 743 putp(orig_pair);
741 744
742 745 /* Let the terminal settle down. */
743 746 (void) fflush(stdout);
744 747 (void) sleep(1);
745 748 }
746 749
747 750 static void
748 751 reset_term()
749 752 {
750 753 reset++;
751 754 initterm();
752 755 }
↓ open down ↓ |
562 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX