1*6167eca2Schristos /* Id: arch.c,v 1.14 2019/03/04 13:01:57 schwarze Exp */
2*6167eca2Schristos /*
3*6167eca2Schristos * Copyright (c) 2017, 2019 Ingo Schwarze <schwarze@openbsd.org>
4*6167eca2Schristos *
5*6167eca2Schristos * Permission to use, copy, modify, and distribute this software for any
6*6167eca2Schristos * purpose with or without fee is hereby granted, provided that the above
7*6167eca2Schristos * copyright notice and this permission notice appear in all copies.
8*6167eca2Schristos *
9*6167eca2Schristos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*6167eca2Schristos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*6167eca2Schristos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*6167eca2Schristos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*6167eca2Schristos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*6167eca2Schristos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*6167eca2Schristos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*6167eca2Schristos */
17*6167eca2Schristos #include "config.h"
18*6167eca2Schristos
19*6167eca2Schristos #include <string.h>
20*6167eca2Schristos
21*6167eca2Schristos #include "roff.h"
22*6167eca2Schristos
23*6167eca2Schristos int
arch_valid(const char * arch,enum mandoc_os os)24*6167eca2Schristos arch_valid(const char *arch, enum mandoc_os os)
25*6167eca2Schristos {
26*6167eca2Schristos const char *openbsd_arch[] = {
27*6167eca2Schristos "alpha", "amd64", "arm64", "armv7", "hppa", "i386",
28*6167eca2Schristos "landisk", "loongson", "luna88k", "macppc", "mips64",
29*6167eca2Schristos "octeon", "sgi", "socppc", "sparc64", NULL
30*6167eca2Schristos };
31*6167eca2Schristos const char *netbsd_arch[] = {
32*6167eca2Schristos "acorn26", "acorn32", "algor", "alpha", "amiga",
33*6167eca2Schristos "arc", "atari",
34*6167eca2Schristos "bebox", "cats", "cesfic", "cobalt", "dreamcast",
35*6167eca2Schristos "emips", "evbarm", "evbmips", "evbppc", "evbsh3", "evbsh5",
36*6167eca2Schristos "hp300", "hpcarm", "hpcmips", "hpcsh", "hppa",
37*6167eca2Schristos "i386", "ibmnws", "luna68k",
38*6167eca2Schristos "mac68k", "macppc", "mipsco", "mmeye", "mvme68k", "mvmeppc",
39*6167eca2Schristos "netwinder", "news68k", "newsmips", "next68k",
40*6167eca2Schristos "pc532", "playstation2", "pmax", "pmppc", "prep",
41*6167eca2Schristos "sandpoint", "sbmips", "sgimips", "shark",
42*6167eca2Schristos "sparc", "sparc64", "sun2", "sun3",
43*6167eca2Schristos "vax", "walnut", "x68k", "x86", "x86_64", "xen", NULL
44*6167eca2Schristos };
45*6167eca2Schristos const char **arches[] = { NULL, netbsd_arch, openbsd_arch };
46*6167eca2Schristos const char **arch_p;
47*6167eca2Schristos
48*6167eca2Schristos if ((arch_p = arches[os]) == NULL)
49*6167eca2Schristos return 1;
50*6167eca2Schristos for (; *arch_p != NULL; arch_p++)
51*6167eca2Schristos if (strcmp(*arch_p, arch) == 0)
52*6167eca2Schristos return 1;
53*6167eca2Schristos return 0;
54*6167eca2Schristos }
55