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