Deleted Added
full compact
map.c (50638) map.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/map.c 87701 2001-12-11 23:29:45Z markm $");
37
34#ifndef lint
38#ifndef lint
35#if 0
36static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93";
39static const char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93";
37#endif
40#endif
38static const char rcsid[] =
39 "$FreeBSD: head/usr.bin/tset/map.c 50638 1999-08-30 08:27:31Z peter $";
40#endif /* not lint */
41
42#include <sys/types.h>
41
42#include <sys/types.h>
43
43#include <err.h>
44#include <stdlib.h>
45#include <string.h>
46#include <termios.h>
44#include <err.h>
45#include <stdlib.h>
46#include <string.h>
47#include <termios.h>
48
47#include "extern.h"
48
49extern speed_t Ospeed;
50speed_t tset_baudrate __P((char *));
51
52/* Baud rate conditionals for mapping. */
53#define GT 0x01
54#define EQ 0x02

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

69
70/*
71 * Syntax for -m:
72 * [port-type][test baudrate]:terminal-type
73 * The baud rate tests are: >, <, @, =, !
74 */
75void
76add_mapping(port, arg)
49#include "extern.h"
50
51extern speed_t Ospeed;
52speed_t tset_baudrate __P((char *));
53
54/* Baud rate conditionals for mapping. */
55#define GT 0x01
56#define EQ 0x02

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

71
72/*
73 * Syntax for -m:
74 * [port-type][test baudrate]:terminal-type
75 * The baud rate tests are: >, <, @, =, !
76 */
77void
78add_mapping(port, arg)
77 char *port, *arg;
79 const char *port;
80 char *arg;
78{
79 MAP *mapp;
80 char *copy, *p, *termp;
81
82 copy = strdup(arg);
83 mapp = malloc((u_int)sizeof(MAP));
84 if (copy == NULL || mapp == NULL)
85 errx(1, "malloc");

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

154 /* If a NOT conditional, reverse the test. */
155 if (mapp->conditional & NOT)
156 mapp->conditional = ~mapp->conditional & (EQ | GT | LT);
157
158 /* If user specified a port with an option flag, set it. */
159done: if (port) {
160 if (mapp->porttype)
161badmopt: errx(1, "illegal -m option format: %s", copy);
81{
82 MAP *mapp;
83 char *copy, *p, *termp;
84
85 copy = strdup(arg);
86 mapp = malloc((u_int)sizeof(MAP));
87 if (copy == NULL || mapp == NULL)
88 errx(1, "malloc");

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

157 /* If a NOT conditional, reverse the test. */
158 if (mapp->conditional & NOT)
159 mapp->conditional = ~mapp->conditional & (EQ | GT | LT);
160
161 /* If user specified a port with an option flag, set it. */
162done: if (port) {
163 if (mapp->porttype)
164badmopt: errx(1, "illegal -m option format: %s", copy);
162 mapp->porttype = port;
165 mapp->porttype = strdup(port);
163 }
164
165#ifdef MAPDEBUG
166 (void)printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY");
167 (void)printf("type: %s\n", mapp->type);
168 (void)printf("conditional: ");
169 p = "";
170 if (mapp->conditional & GT) {

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

181#endif
182}
183
184/*
185 * Return the type of terminal to use for a port of type 'type', as specified
186 * by the first applicable mapping in 'map'. If no mappings apply, return
187 * 'type'.
188 */
166 }
167
168#ifdef MAPDEBUG
169 (void)printf("port: %s\n", mapp->porttype ? mapp->porttype : "ANY");
170 (void)printf("type: %s\n", mapp->type);
171 (void)printf("conditional: ");
172 p = "";
173 if (mapp->conditional & GT) {

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

184#endif
185}
186
187/*
188 * Return the type of terminal to use for a port of type 'type', as specified
189 * by the first applicable mapping in 'map'. If no mappings apply, return
190 * 'type'.
191 */
189char *
192const char *
190mapped(type)
193mapped(type)
191 char *type;
194 const char *type;
192{
193 MAP *mapp;
194 int match;
195
196 for (mapp = maplist; mapp; mapp = mapp->next)
197 if (mapp->porttype == NULL || !strcmp(mapp->porttype, type)) {
198 switch (mapp->conditional) {
199 case 0: /* No test specified. */

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

218 if (match)
219 return (mapp->type);
220 }
221 /* No match found; return given type. */
222 return (type);
223}
224
225typedef struct speeds {
195{
196 MAP *mapp;
197 int match;
198
199 for (mapp = maplist; mapp; mapp = mapp->next)
200 if (mapp->porttype == NULL || !strcmp(mapp->porttype, type)) {
201 switch (mapp->conditional) {
202 case 0: /* No test specified. */

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

221 if (match)
222 return (mapp->type);
223 }
224 /* No match found; return given type. */
225 return (type);
226}
227
228typedef struct speeds {
226 char *string;
229 const char *string;
227 speed_t speed;
228} SPEEDS;
229
230SPEEDS speeds[] = {
230 speed_t speed;
231} SPEEDS;
232
233SPEEDS speeds[] = {
231 "0", B0,
232 "134.5", B134,
233 "exta", B19200,
234 "extb", B38400,
235 NULL
234 { "0", B0 },
235 { "134.5", B134 },
236 { "exta", B19200 },
237 { "extb", B38400 },
238 { NULL, 0 }
236};
237
238speed_t
239tset_baudrate(rate)
240 char *rate;
241{
242 SPEEDS *sp;
243 speed_t speed;

--- 13 unchanged lines hidden ---
239};
240
241speed_t
242tset_baudrate(rate)
243 char *rate;
244{
245 SPEEDS *sp;
246 speed_t speed;

--- 13 unchanged lines hidden ---