20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40 #pragma ident "%Z%%M% %I% %E% SMI"
41
42 /*LINTLIBRARY*/
43
44 #include <stdio.h>
45 #include <sys/types.h>
46 #include <fcntl.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include <unistd.h>
50 #include <errno.h>
51 #include "curses_inc.h"
52
53 #define TERMPATH "/usr/share/lib/terminfo/"
54 #define TERMPATHLEN 512
55
56 extern bool _use_env; /* in curses.c */
57
58 chtype bit_attributes[NUM_ATTRIBUTES] = {
59 A_STANDOUT,
60 A_UNDERLINE,
61 A_ALTCHARSET,
62 A_REVERSE,
63 A_BLINK,
64 A_DIM,
65 A_BOLD,
66 A_INVIS,
67 A_PROTECT
68 };
69
70 char *Def_term = "unknown", /* default terminal type */
255 if (errret != 0)
256 *errret = -1;
257
258 if (((cp = getenv("TERMINFO")) != 0) && *cp) {
259 /* $TERMINFO/?/$TERM */
260 if (snprintf(fname, sizeof (fname),
261 "%s/%c/%s", cp, *term, term) >= sizeof (fname)) {
262 term_errno = TERMINFO_TOO_LONG;
263 goto out_err;
264 }
265
266 tfd = open(fname, 0);
267 #ifdef DUMPTI
268 printf("looking in file %s\n", fname);
269 #endif /* DUMPTI */
270 if ((tfd < 0) && (errno == EACCES))
271 goto cant_read;
272 }
273
274 if (tfd < 0) {
275 /* /usr/share/lib/terminfo/?/$TERM */
276 if (snprintf(fname, sizeof (fname),
277 "%s/%c/%s", TERMPATH, *term, term) >= sizeof (fname)) {
278 term_errno = TERMINFO_TOO_LONG;
279 goto out_err;
280 }
281
282 tfd = open(fname, 0);
283 #ifdef DUMPTI
284 printf("looking in file %s\n", fname);
285 #endif /* DUMPTI */
286
287 }
288
289 if (tfd < 0) {
290 if (errno == EACCES) {
291 cant_read:
292 term_errno = NOT_READABLE;
293 } else {
294 if (access(TERMPATH, 0) == -1)
295 term_errno = UNACCESSIBLE;
296 else {
297 term_errno = NO_TERMINAL;
|
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
29
30 /*
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
33 * All Rights Reserved
34 *
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
37 * contributors.
38 */
39
40 /*LINTLIBRARY*/
41
42 #include <stdio.h>
43 #include <sys/types.h>
44 #include <fcntl.h>
45 #include <stdlib.h>
46 #include <string.h>
47 #include <unistd.h>
48 #include <errno.h>
49 #include <zone.h>
50 #include "curses_inc.h"
51
52 #define TERMPATH "/usr/share/lib/terminfo/"
53 #define TERMPATHLEN 512
54
55 extern bool _use_env; /* in curses.c */
56
57 chtype bit_attributes[NUM_ATTRIBUTES] = {
58 A_STANDOUT,
59 A_UNDERLINE,
60 A_ALTCHARSET,
61 A_REVERSE,
62 A_BLINK,
63 A_DIM,
64 A_BOLD,
65 A_INVIS,
66 A_PROTECT
67 };
68
69 char *Def_term = "unknown", /* default terminal type */
254 if (errret != 0)
255 *errret = -1;
256
257 if (((cp = getenv("TERMINFO")) != 0) && *cp) {
258 /* $TERMINFO/?/$TERM */
259 if (snprintf(fname, sizeof (fname),
260 "%s/%c/%s", cp, *term, term) >= sizeof (fname)) {
261 term_errno = TERMINFO_TOO_LONG;
262 goto out_err;
263 }
264
265 tfd = open(fname, 0);
266 #ifdef DUMPTI
267 printf("looking in file %s\n", fname);
268 #endif /* DUMPTI */
269 if ((tfd < 0) && (errno == EACCES))
270 goto cant_read;
271 }
272
273 if (tfd < 0) {
274 const char *zroot = zone_get_nroot();
275 /* /usr/share/lib/terminfo/?/$TERM */
276 if (snprintf(fname, sizeof (fname),
277 "%s/%s/%c/%s", zroot == NULL ? "" : zroot, TERMPATH,
278 *term, term) >= sizeof (fname)) {
279 term_errno = TERMINFO_TOO_LONG;
280 goto out_err;
281 }
282
283 tfd = open(fname, 0);
284 #ifdef DUMPTI
285 printf("looking in file %s\n", fname);
286 #endif /* DUMPTI */
287
288 }
289
290 if (tfd < 0) {
291 if (errno == EACCES) {
292 cant_read:
293 term_errno = NOT_READABLE;
294 } else {
295 if (access(TERMPATH, 0) == -1)
296 term_errno = UNACCESSIBLE;
297 else {
298 term_errno = NO_TERMINAL;
|