]>
Commit | Line | Data |
---|---|---|
83f6dbe8 A |
1 | %{ |
2 | /* | |
3 | * Copyright is disclaimed as to the contents of this file. | |
4 | * | |
5 | * $FreeBSD: src/usr.bin/getconf/progenv.gperf,v 1.2 2003/08/22 17:32:07 markm Exp $ | |
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(__alpha__) || defined(__sparc64__) | |
34 | #define have_LP64_OFF64 NULL | |
34d340d7 A |
35 | #elif defined(__APPLE__) |
36 | #define have_LP64_OFF64 NULL | |
37 | #define have_LPBIG_OFFBIG NULL | |
83f6dbe8 A |
38 | #endif |
39 | ||
ef8ad44b | 40 | #if defined(__i386__) || defined(__powerpc__) || defined(__x86_64__) |
83f6dbe8 A |
41 | #define have_ILP32_OFFBIG NULL |
42 | #endif | |
43 | ||
44 | %} | |
45 | struct map { const char *name; const char *alt_path; int valid; }; | |
46 | %% | |
47 | POSIX_V6_ILP32_OFF32, notdef | |
48 | POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG | |
49 | POSIX_V6_LP64_OFF64, have_LP64_OFF64 | |
34d340d7 | 50 | POSIX_V6_LPBIG_OFFBIG, have_LPBIG_OFFBIG |
83f6dbe8 A |
51 | _POSIX_V6_ILP32_OFF32, notdef |
52 | _POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG | |
53 | _POSIX_V6_LP64_OFF64, have_LP64_OFF64 | |
34d340d7 | 54 | _POSIX_V6_LPBIG_OFFBIG, have_LPBIG_OFFBIG |
83f6dbe8 A |
55 | %% |
56 | int | |
57 | find_progenv(const char *name, const char **alt_path) | |
58 | { | |
59 | const struct map *rv; | |
60 | ||
61 | rv = in_word_set(name); | |
62 | if (rv != NULL) { | |
63 | if (rv->valid) { | |
64 | *alt_path = rv->alt_path; | |
65 | return 1; | |
66 | } | |
67 | return -1; | |
68 | } | |
69 | return 0; | |
70 | } |