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