Deleted Added
full compact
map.c (146752) map.c (200419)
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

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

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
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

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

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 146752 2005-05-29 15:49:53Z charnier $");
36__FBSDID("$FreeBSD: head/usr.bin/tset/map.c 200419 2009-12-11 23:30:22Z delphij $");
37
38#ifndef lint
39static const char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93";
40#endif
41
42#include <sys/types.h>
43
44#include <err.h>

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

70MAP *cur, *maplist;
71
72/*
73 * Syntax for -m:
74 * [port-type][test baudrate]:terminal-type
75 * The baud rate tests are: >, <, @, =, !
76 */
77void
37
38#ifndef lint
39static const char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/9/93";
40#endif
41
42#include <sys/types.h>
43
44#include <err.h>

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

70MAP *cur, *maplist;
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)
79 const char *port;
80 char *arg;
78add_mapping(const char *port, char *arg)
81{
82 MAP *mapp;
83 char *copy, *p, *termp;
84
85 copy = strdup(arg);
86 mapp = malloc(sizeof(MAP));
87 if (copy == NULL || mapp == NULL)
88 errx(1, "malloc");

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

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 */
192const char *
79{
80 MAP *mapp;
81 char *copy, *p, *termp;
82
83 copy = strdup(arg);
84 mapp = malloc(sizeof(MAP));
85 if (copy == NULL || mapp == NULL)
86 errx(1, "malloc");

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

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

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

235 { "0", B0 },
236 { "134.5", B134 },
237 { "exta", B19200 },
238 { "extb", B38400 },
239 { NULL, 0 }
240};
241
242speed_t
192{
193 MAP *mapp;
194 int match;
195
196 match = 0;
197 for (mapp = maplist; mapp; mapp = mapp->next)
198 if (mapp->porttype == NULL || !strcmp(mapp->porttype, type)) {
199 switch (mapp->conditional) {

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

232 { "0", B0 },
233 { "134.5", B134 },
234 { "exta", B19200 },
235 { "extb", B38400 },
236 { NULL, 0 }
237};
238
239speed_t
243tset_baudrate(rate)
244 char *rate;
240tset_baudrate(char *rate)
245{
246 SPEEDS *sp;
247 speed_t speed;
248
249 /* The baudrate number can be preceded by a 'B', which is ignored. */
250 if (*rate == 'B')
251 ++rate;
252
253 for (sp = speeds; sp->string; ++sp)
254 if (!strcasecmp(rate, sp->string))
255 return (sp->speed);
256 speed = atol(rate);
257 if (speed == 0)
258 errx(1, "unknown baud rate %s", rate);
259 return speed;
260}
241{
242 SPEEDS *sp;
243 speed_t speed;
244
245 /* The baudrate number can be preceded by a 'B', which is ignored. */
246 if (*rate == 'B')
247 ++rate;
248
249 for (sp = speeds; sp->string; ++sp)
250 if (!strcasecmp(rate, sp->string))
251 return (sp->speed);
252 speed = atol(rate);
253 if (speed == 0)
254 errx(1, "unknown baud rate %s", rate);
255 return speed;
256}