Deleted Added
full compact
term.c (50477) term.c (87701)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/usr.bin/tset/term.c 87701 2001-12-11 23:29:45Z markm $");
37
34#ifndef lint
38#ifndef lint
35#if 0
36static char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/9/93";
39static const char sccsid[] = "@(#)term.c 8.1 (Berkeley) 6/9/93";
37#endif
40#endif
38static const char rcsid[] =
39 "$FreeBSD: head/usr.bin/tset/term.c 50477 1999-08-28 01:08:13Z peter $";
40#endif /* not lint */
41
42#include <sys/types.h>
43#include <err.h>
44#include <errno.h>
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>
48#include <unistd.h>
49#include <ttyent.h>
50#include "extern.h"
51
52char tbuf[1024]; /* Termcap entry. */
53
41
42#include <sys/types.h>
43#include <err.h>
44#include <errno.h>
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>
48#include <unistd.h>
49#include <ttyent.h>
50#include "extern.h"
51
52char tbuf[1024]; /* Termcap entry. */
53
54char *askuser __P((char *));
54const char *askuser __P((const char *));
55char *ttys __P((char *));
56
57/*
58 * Figure out what kind of terminal we're dealing with, and then read in
59 * its termcap entry.
60 */
55char *ttys __P((char *));
56
57/*
58 * Figure out what kind of terminal we're dealing with, and then read in
59 * its termcap entry.
60 */
61char *
61const char *
62get_termcap_entry(userarg, tcapbufp)
63 char *userarg, **tcapbufp;
64{
65 struct ttyent *t;
66 int rval;
62get_termcap_entry(userarg, tcapbufp)
63 char *userarg, **tcapbufp;
64{
65 struct ttyent *t;
66 int rval;
67 char *p, *ttype, *ttypath;
67 char *p, *ttypath;
68 const char *ttype;
68
69 if (userarg) {
70 ttype = userarg;
71 goto found;
72 }
73
74 /* Try the environment. */
75 if ((ttype = getenv("TERM")))

--- 42 unchanged lines hidden (view full) ---

118 }
119 if (rval == -1)
120 errx(1, "termcap: %s", strerror(errno ? errno : ENOENT));
121 *tcapbufp = tbuf;
122 return (ttype);
123}
124
125/* Prompt the user for a terminal type. */
69
70 if (userarg) {
71 ttype = userarg;
72 goto found;
73 }
74
75 /* Try the environment. */
76 if ((ttype = getenv("TERM")))

--- 42 unchanged lines hidden (view full) ---

119 }
120 if (rval == -1)
121 errx(1, "termcap: %s", strerror(errno ? errno : ENOENT));
122 *tcapbufp = tbuf;
123 return (ttype);
124}
125
126/* Prompt the user for a terminal type. */
126char *
127const char *
127askuser(dflt)
128askuser(dflt)
128 char *dflt;
129 const char *dflt;
129{
130 static char answer[256];
131 char *p;
132
133 /* We can get recalled; if so, don't continue uselessly. */
134 if (feof(stdin) || ferror(stdin)) {
135 (void)fprintf(stderr, "\n");
136 exit(1);

--- 24 unchanged lines hidden ---
130{
131 static char answer[256];
132 char *p;
133
134 /* We can get recalled; if so, don't continue uselessly. */
135 if (feof(stdin) || ferror(stdin)) {
136 (void)fprintf(stderr, "\n");
137 exit(1);

--- 24 unchanged lines hidden ---