xref: /freebsd/usr.bin/getconf/pathconf.gperf (revision b3e7694832e81d7a904a10f525f8797b753bf0d3)
18c6bd995SGarrett Wollman%{
28c6bd995SGarrett Wollman/*
38c6bd995SGarrett Wollman * Copyright is disclaimed as to the contents of this file.
48c6bd995SGarrett Wollman */
58c6bd995SGarrett Wollman
68c6bd995SGarrett Wollman#include <sys/types.h>
78c6bd995SGarrett Wollman
88c6bd995SGarrett Wollman#include <string.h>
98c6bd995SGarrett Wollman#include <unistd.h>
108c6bd995SGarrett Wollman
118c6bd995SGarrett Wollman#include "getconf.h"
128c6bd995SGarrett Wollman
138c6bd995SGarrett Wollman/*
148c6bd995SGarrett Wollman * Override gperf's built-in external scope.
158c6bd995SGarrett Wollman */
16a272cd3aSMark Murraystatic const struct map *in_word_set(const char *str);
178c6bd995SGarrett Wollman
188c6bd995SGarrett Wollman%}
19a272cd3aSMark Murraystruct map { const char *name; int key; int valid; };
208c6bd995SGarrett Wollman%%
21b4b4b530SBaptiste DaroussinACL_EXTENDED, _PC_ACL_EXTENDED
22b4b4b530SBaptiste DaroussinACL_NFS4, _PC_ACL_NFS4
23b4b4b530SBaptiste DaroussinACL_PATH_MAX, _PC_ACL_PATH_MAX
24b4b4b530SBaptiste DaroussinCAP_PRESENT, _PC_CAP_PRESENT
25*01007472SYuri PankovDEALLOC_PRESENT, _PC_DEALLOC_PRESENT
268c6bd995SGarrett WollmanFILESIZEBITS, _PC_FILESIZEBITS
27b4b4b530SBaptiste DaroussinINF_PRESENT, _PC_INF_PRESENT
288c6bd995SGarrett WollmanLINK_MAX, _PC_LINK_MAX
29b4b4b530SBaptiste DaroussinMAC_PRESENT, _PC_MAC_PRESENT
308c6bd995SGarrett WollmanMAX_CANON, _PC_MAX_CANON
318c6bd995SGarrett WollmanMAX_INPUT, _PC_MAX_INPUT
32b4b4b530SBaptiste DaroussinMIN_HOLE_SIZE, _PC_MIN_HOLE_SIZE
338c6bd995SGarrett WollmanNAME_MAX, _PC_NAME_MAX
348c6bd995SGarrett WollmanPATH_MAX, _PC_PATH_MAX
358c6bd995SGarrett WollmanPIPE_BUF, _PC_PIPE_BUF
36e9cfb9aeSGarrett WollmanPOSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN
37e9cfb9aeSGarrett WollmanPOSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE
38e9cfb9aeSGarrett WollmanPOSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE
39e9cfb9aeSGarrett WollmanPOSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE
40e9cfb9aeSGarrett WollmanPOSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
4111e3dcb6SGarrett WollmanSYMLINK_MAX, _PC_SYMLINK_MAX
4211e3dcb6SGarrett WollmanTRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED
43b4b4b530SBaptiste DaroussinTRUSTEDBSD_ACL_NFS4, _PC_ACL_NFS4
4411e3dcb6SGarrett WollmanTRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX
4511e3dcb6SGarrett WollmanTRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT
4611e3dcb6SGarrett WollmanTRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT
4711e3dcb6SGarrett WollmanTRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT
488c6bd995SGarrett Wollman_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED
498c6bd995SGarrett Wollman_POSIX_NO_TRUNC, _PC_NO_TRUNC
50b4b4b530SBaptiste Daroussin_POSIX_VDISABLE, _PC_VDISABLE
51b4b4b530SBaptiste Daroussin_POSIX_ASYNC_IO, _PC_ASYNC_IO
528c6bd995SGarrett Wollman_POSIX_PRIO_IO, _PC_PRIO_IO
538c6bd995SGarrett Wollman_POSIX_SYNC_IO, _PC_SYNC_IO
548c6bd995SGarrett Wollman%%
558c6bd995SGarrett Wollmanint
56e9cfb9aeSGarrett Wollmanfind_pathconf(const char *name, int *key)
578c6bd995SGarrett Wollman{
588c6bd995SGarrett Wollman	const struct map *rv;
598c6bd995SGarrett Wollman
60a272cd3aSMark Murray	rv = in_word_set(name);
61e9cfb9aeSGarrett Wollman	if (rv != NULL) {
62e9cfb9aeSGarrett Wollman		if (rv->valid) {
63e9cfb9aeSGarrett Wollman			*key = rv->key;
64e9cfb9aeSGarrett Wollman			return 1;
65e9cfb9aeSGarrett Wollman		}
668c6bd995SGarrett Wollman		return -1;
678c6bd995SGarrett Wollman	}
68e9cfb9aeSGarrett Wollman	return 0;
69e9cfb9aeSGarrett Wollman}
70dda1cfcfSJohn Baldwin
71dda1cfcfSJohn Baldwinvoid
72dda1cfcfSJohn Baldwinforeach_pathconf(void (*func)(const char *, int, const char *),
73dda1cfcfSJohn Baldwin    const char *path)
74dda1cfcfSJohn Baldwin{
75dda1cfcfSJohn Baldwin	const struct map *mp;
76dda1cfcfSJohn Baldwin
77dda1cfcfSJohn Baldwin	for (mp = wordlist; mp->name != NULL; mp++) {
78dda1cfcfSJohn Baldwin		if (mp->valid)
79dda1cfcfSJohn Baldwin			func(mp->name, mp->key, path);
80dda1cfcfSJohn Baldwin	}
81dda1cfcfSJohn Baldwin}
82