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