nrelease - fix/improve livecd
[dragonfly.git] / usr.bin / getconf / progenv.gperf
1 %{
2 /*
3  * Copyright is disclaimed as to the contents of this file.
4  *
5  * $FreeBSD: head/usr.bin/getconf/progenv.gperf 142066 2005-02-18 21:53:05Z wollman $
6  */
7
8 #include <sys/types.h>
9
10 #include <string.h>
11 #include <unistd.h>
12
13 #include "getconf.h"
14
15 /*
16  * Override gperf's built-in external scope.
17  */
18 static const struct map *in_word_set(const char *str);
19
20 /*
21  * The Standard seems a bit ambiguous over whether the POSIX_V6_*
22  * are specified with or without a leading underscore, so we just
23  * use both.
24  */
25 /*
26  * The alt_path member gives the path containing another `getconf'
27  * executable which was compiled using the specified programming
28  * environment.  If it is NULL, the current executable is good enough.
29  * If we ever support multiple environments, this table will need to
30  * be updated.  (We cheat here and define the supported environments
31  * statically.)
32  */
33 #if defined(__x86_64__)
34 #define have_LP64_OFF64         NULL
35 #else
36 #error platform not handled in progenv.gperf
37 #endif
38
39 %}
40 struct map { const char *name; const char *alt_path; int valid; };
41 %%
42 POSIX_V6_ILP32_OFF32, notdef
43 POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
44 POSIX_V6_LP64_OFF64, have_LP64_OFF64
45 POSIX_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 _POSIX_V7_ILP32_OFF32, notdef
51 _POSIX_V7_ILP32_OFFBIG, have_ILP32_OFFBIG
52 _POSIX_V7_LP64_OFF64, have_LP64_OFF64
53 _POSIX_V7_LPBIG_OFFBIG, notdef
54 %%
55 int
56 find_progenv(const char *name, const char **alt_path)
57 {
58         const struct map *rv;
59
60         rv = in_word_set(name);
61         if (rv != NULL) {
62                 if (rv->valid) {
63                         *alt_path = rv->alt_path;
64                         return 1;
65                 }
66                 return -1;
67         }
68         return 0;
69 }