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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "tip.h"
/*
* Attributes to be gleened from remote host description
* data base.
*/
static char **caps[] = {
&AT, &DV, &CM, &CU, &EL, &IE, &OE, &PN, &PR, &DI,
&ES, &EX, &FO, &RC, &RE, &PA
};
static char *capstrings[] = {
"at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr",
"di", "es", "ex", "fo", "rc", "re", "pa", 0
};
extern char *rgetstr(char *, char **);
static void
getremcap(char *host)
{
int stat;
char tbuf[BUFSIZ];
static char buf[BUFSIZ/2];
char *bp = buf;
char **p, ***q;
if ((stat = rgetent(tbuf, host, sizeof (tbuf))) <= 0) {
if (DV ||
host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
/*
* If the user specifies a device on the commandline,
* don't trust it.
*/
if (host[0] == '/')
trusted_device = 0;
CU = DV;
HO = host;
HW = 1;
DU = 0;
if (!BR)
BR = DEFBR;
FS = DEFFS;
RE = (char *)"tip.record";
EX = (char *)"\t\n\b\f";
DL = 0;
CL = 0;
ET = 10;
return;
}
(void) fprintf(stderr, stat == 0 ?
"tip: unknown host %s\n" :
"tip: can't open host description file\n", host);
exit(3);
}
for (p = capstrings, q = caps; *p != NULL; p++, q++)
if (**q == NULL)
**q = rgetstr(*p, &bp);
if (!BR && (BR = rgetnum("br")) < 0)
BR = DEFBR;
if ((FS = rgetnum("fs")) < 0)
FS = DEFFS;
if (DU < 0)
DU = 0;
else
DU = rgetflag("du");
if (DV == NOSTR) {
(void) fprintf(stderr, "%s: missing device spec\n", host);
exit(3);
}
if (DU && CU == NOSTR)
CU = DV;
if (DU && PN == NOSTR) {
(void) fprintf(stderr, "%s: missing phone number\n", host);
exit(3);
}
DB = rgetflag("db");
/*
* This effectively eliminates the "hw" attribute
* from the description file
*/
if (!HW)
HW = (CU == NOSTR) || (DU && equal(DV, CU));
HO = host;
/*
* see if uppercase mode should be turned on initially
*/
if (rgetflag("ra"))
boolean(value(RAISE)) = 1;
if (rgetflag("ec"))
boolean(value(ECHOCHECK)) = 1;
if (rgetflag("be"))
boolean(value(BEAUTIFY)) = 1;
if (rgetflag("nb"))
boolean(value(BEAUTIFY)) = 0;
if (rgetflag("sc"))
boolean(value(SCRIPT)) = 1;
if (rgetflag("tb"))
boolean(value(TABEXPAND)) = 1;
if (rgetflag("vb"))
boolean(value(VERBOSE)) = 1;
if (rgetflag("nv"))
boolean(value(VERBOSE)) = 0;
if (rgetflag("ta"))
boolean(value(TAND)) = 1;
if (rgetflag("nt"))
boolean(value(TAND)) = 0;
if (rgetflag("rw"))
boolean(value(RAWFTP)) = 1;
if (rgetflag("hd"))
boolean(value(HALFDUPLEX)) = 1;
if (rgetflag("hf"))
boolean(value(HARDWAREFLOW)) = 1;
if (RE == NULL)
RE = (char *)"tip.record";
if (EX == NULL)
EX = (char *)"\t\n\b\f";
if (ES != NOSTR)
(void) vstring("es", ES);
if (FO != NOSTR)
(void) vstring("fo", FO);
if (PR != NOSTR)
(void) vstring("pr", PR);
if (RC != NOSTR)
(void) vstring("rc", RC);
if ((DL = rgetnum("dl")) < 0)
DL = 0;
if ((CL = rgetnum("cl")) < 0)
CL = 0;
if ((ET = rgetnum("et")) < 0)
ET = 10;
}
char *
getremote(char *host)
{
char *cp;
static char *next;
static int lookedup = 0;
if (!lookedup) {
if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
(void) fprintf(stderr, "tip: no host specified\n");
exit(3);
}
getremcap(host);
next = DV;
lookedup++;
}
/*
* We return a new device each time we're called (to allow
* a rotary action to be simulated)
*/
if (next == NOSTR)
return (NOSTR);
if ((cp = strchr(next, ',')) == NULL) {
DV = next;
next = NOSTR;
} else {
*cp++ = '\0';
DV = next;
next = cp;
}
return (DV);
}
|