summaryrefslogtreecommitdiffstats
path: root/usr.bin/getconf/pathconf.gperf
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>2002-09-19 03:39:03 +0000
committerwollman <wollman@FreeBSD.org>2002-09-19 03:39:03 +0000
commitcb45d14fee8f6330b3fbc791aea9eaa571b019f9 (patch)
treeab1f0dc71db78e794da3665ed9b795e82d90c7aa /usr.bin/getconf/pathconf.gperf
parenta059a58a99b6e22aecf174427806403adc8d6cf6 (diff)
downloadFreeBSD-src-cb45d14fee8f6330b3fbc791aea9eaa571b019f9.zip
FreeBSD-src-cb45d14fee8f6330b3fbc791aea9eaa571b019f9.tar.gz
Completely revamp the way getconf(1) works, for better adherence to the
intent of the Standard. - Make getconf able to distinguish between configuration variables which are entirely unknown and those which are merely not defined in the compilation environment. The latter now get a more appropriate "undefined\n" result rather than a diagnostic. This may not be exactly right, but it's closer to the intent of the Standard than the previous behavior. - Support ``programming environments'' by validating that the environment requested with the `-v' flag is the one-and-only execution environment. (If more environments are supported for some platforms in the future, multiple getconf(1) executables will be required, but a simple edit in progenv.gperf will enable automatic support for it.) Document POSIX standard programming environments. - Add all of the 1003.1-2001 configuration variables. FreeBSD does not support all of these (including some that are mandatory); getconf will later be fixed to break the world should a required variable not be defined. As a result of all these changes, gperf is no longer adequate. Keep the overall format and names of the files for now, to preserve revision history. Use an awk script to process the .gperf files into C source, which does a few things that gperf, as a more general tool, cannot do. The keyword recognition function is no longer a perfect hash function. This may obviate the need for gperf in the source tree. - Add a small compile-time regression test to break the build if any of the .gperf files declare conflicting token sets. (gperf itself would have done this for the simple case of duplicate tokens in the same input file.)
Diffstat (limited to 'usr.bin/getconf/pathconf.gperf')
-rw-r--r--usr.bin/getconf/pathconf.gperf27
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.bin/getconf/pathconf.gperf b/usr.bin/getconf/pathconf.gperf
index 17ca458..b44e824 100644
--- a/usr.bin/getconf/pathconf.gperf
+++ b/usr.bin/getconf/pathconf.gperf
@@ -14,20 +14,12 @@
#include "getconf.h"
/*
- * Stuff that isn't defined right now -- we want this file to work
- * unmodified once it is defined.
- */
-#ifndef _PC_FILESIZEBITS
-#define _PC_FILESIZEBITS -1
-#endif
-
-/*
* Override gperf's built-in external scope.
*/
static const struct map *in_word_set(const char *str, unsigned int len);
%}
-struct map { char *name; int key; };
+struct map { char *name; int key; int valid; };
%%
FILESIZEBITS, _PC_FILESIZEBITS
LINK_MAX, _PC_LINK_MAX
@@ -36,6 +28,11 @@ MAX_INPUT, _PC_MAX_INPUT
NAME_MAX, _PC_NAME_MAX
PATH_MAX, _PC_PATH_MAX
PIPE_BUF, _PC_PIPE_BUF
+POSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN
+POSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE
+POSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE
+POSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE
+POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED
_POSIX_NO_TRUNC, _PC_NO_TRUNC
_POSIX_VDISABLE, _PC_VDISABLE
@@ -44,13 +41,17 @@ _POSIX_PRIO_IO, _PC_PRIO_IO
_POSIX_SYNC_IO, _PC_SYNC_IO
%%
int
-find_pathconf(const char *name)
+find_pathconf(const char *name, int *key)
{
const struct map *rv;
rv = in_word_set(name, strlen(name));
- if (rv != 0)
- return rv->key;
- else
+ if (rv != NULL) {
+ if (rv->valid) {
+ *key = rv->key;
+ return 1;
+ }
return -1;
+ }
+ return 0;
}
OpenPOWER on IntegriCloud