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