xref: /dragonfly/usr.bin/getconf/progenv.gperf (revision 36a3d1d6)
1%{
2/*
3 * Copyright is disclaimed as to the contents of this file.
4 *
5 * $FreeBSD: src/usr.bin/getconf/progenv.gperf,v 1.1.2.1 2002/10/27 04:18:40 wollman Exp $
6 * $DragonFly: src/usr.bin/getconf/progenv.gperf,v 1.3 2006/08/25 22:37:09 swildner Exp $
7 */
8
9#include <sys/types.h>
10
11#include <string.h>
12#include <unistd.h>
13
14#include "getconf.h"
15
16/*
17 * Override gperf's built-in external scope.
18 */
19static const struct map *in_word_set(const char *str, unsigned int len);
20
21/*
22 * The Standard seems a bit ambiguous over whether the POSIX_V6_*
23 * are specified with or without a leading underscore, so we just
24 * use both.
25 */
26/*
27 * The alt_path member gives the path containing another `getconf'
28 * executable which was compiled using the specified programming
29 * environment.  If it is NULL, the current executable is good enough.
30 * If we ever support multiple environments, this table will need to
31 * be updated.  (We cheat here and define the supported environments
32 * statically.)
33 */
34#if defined(__sparc64__)
35#define	have_LP64_OFF64		NULL
36#endif
37
38#if defined(__i386__) || defined(__powerpc__)
39#define	have_ILP32_OFFBIG	NULL
40#endif
41
42%}
43struct map { const char *name; const char *alt_path; int valid; };
44%%
45POSIX_V6_ILP32_OFF32, notdef
46POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
47POSIX_V6_LP64_OFF64, have_LP64_OFF64
48POSIX_V6_LPBIG_OFFBIG, notdef
49_POSIX_V6_ILP32_OFF32, notdef
50_POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
51_POSIX_V6_LP64_OFF64, have_LP64_OFF64
52_POSIX_V6_LPBIG_OFFBIG, notdef
53%%
54int
55find_progenv(const char *name, const char **alt_path)
56{
57	const struct map *rv;
58
59	rv = in_word_set(name, strlen(name));
60	if (rv != NULL) {
61		if (rv->valid) {
62			*alt_path = rv->alt_path;
63			return 1;
64		}
65		return -1;
66	}
67	return 0;
68}
69