xref: /freebsd/usr.bin/getconf/pathconf.gperf (revision 01007472eaddcb3c9abb8edab5b01c21c57f1f26)
18c6bd995SGarrett Wollman%{
28c6bd995SGarrett Wollman/*
38c6bd995SGarrett Wollman * Copyright is disclaimed as to the contents of this file.
48c6bd995SGarrett Wollman *
58c6bd995SGarrett Wollman * $FreeBSD$
68c6bd995SGarrett Wollman */
78c6bd995SGarrett Wollman
88c6bd995SGarrett Wollman#include <sys/types.h>
98c6bd995SGarrett Wollman
108c6bd995SGarrett Wollman#include <string.h>
118c6bd995SGarrett Wollman#include <unistd.h>
128c6bd995SGarrett Wollman
138c6bd995SGarrett Wollman#include "getconf.h"
148c6bd995SGarrett Wollman
158c6bd995SGarrett Wollman/*
168c6bd995SGarrett Wollman * Override gperf's built-in external scope.
178c6bd995SGarrett Wollman */
18a272cd3aSMark Murraystatic const struct map *in_word_set(const char *str);
198c6bd995SGarrett Wollman
208c6bd995SGarrett Wollman%}
21a272cd3aSMark Murraystruct map { const char *name; int key; int valid; };
228c6bd995SGarrett Wollman%%
23b4b4b530SBaptiste DaroussinACL_EXTENDED, _PC_ACL_EXTENDED
24b4b4b530SBaptiste DaroussinACL_NFS4, _PC_ACL_NFS4
25b4b4b530SBaptiste DaroussinACL_PATH_MAX, _PC_ACL_PATH_MAX
26b4b4b530SBaptiste DaroussinCAP_PRESENT, _PC_CAP_PRESENT
27*01007472SYuri PankovDEALLOC_PRESENT, _PC_DEALLOC_PRESENT
288c6bd995SGarrett WollmanFILESIZEBITS, _PC_FILESIZEBITS
29b4b4b530SBaptiste DaroussinINF_PRESENT, _PC_INF_PRESENT
308c6bd995SGarrett WollmanLINK_MAX, _PC_LINK_MAX
31b4b4b530SBaptiste DaroussinMAC_PRESENT, _PC_MAC_PRESENT
328c6bd995SGarrett WollmanMAX_CANON, _PC_MAX_CANON
338c6bd995SGarrett WollmanMAX_INPUT, _PC_MAX_INPUT
34b4b4b530SBaptiste DaroussinMIN_HOLE_SIZE, _PC_MIN_HOLE_SIZE
358c6bd995SGarrett WollmanNAME_MAX, _PC_NAME_MAX
368c6bd995SGarrett WollmanPATH_MAX, _PC_PATH_MAX
378c6bd995SGarrett WollmanPIPE_BUF, _PC_PIPE_BUF
38e9cfb9aeSGarrett WollmanPOSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN
39e9cfb9aeSGarrett WollmanPOSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE
40e9cfb9aeSGarrett WollmanPOSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE
41e9cfb9aeSGarrett WollmanPOSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE
42e9cfb9aeSGarrett WollmanPOSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
4311e3dcb6SGarrett WollmanSYMLINK_MAX, _PC_SYMLINK_MAX
4411e3dcb6SGarrett WollmanTRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED
45b4b4b530SBaptiste DaroussinTRUSTEDBSD_ACL_NFS4, _PC_ACL_NFS4
4611e3dcb6SGarrett WollmanTRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX
4711e3dcb6SGarrett WollmanTRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT
4811e3dcb6SGarrett WollmanTRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT
4911e3dcb6SGarrett WollmanTRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT
508c6bd995SGarrett Wollman_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED
518c6bd995SGarrett Wollman_POSIX_NO_TRUNC, _PC_NO_TRUNC
52b4b4b530SBaptiste Daroussin_POSIX_VDISABLE, _PC_VDISABLE
53b4b4b530SBaptiste Daroussin_POSIX_ASYNC_IO, _PC_ASYNC_IO
548c6bd995SGarrett Wollman_POSIX_PRIO_IO, _PC_PRIO_IO
558c6bd995SGarrett Wollman_POSIX_SYNC_IO, _PC_SYNC_IO
568c6bd995SGarrett Wollman%%
578c6bd995SGarrett Wollmanint
58e9cfb9aeSGarrett Wollmanfind_pathconf(const char *name, int *key)
598c6bd995SGarrett Wollman{
608c6bd995SGarrett Wollman	const struct map *rv;
618c6bd995SGarrett Wollman
62a272cd3aSMark Murray	rv = in_word_set(name);
63e9cfb9aeSGarrett Wollman	if (rv != NULL) {
64e9cfb9aeSGarrett Wollman		if (rv->valid) {
65e9cfb9aeSGarrett Wollman			*key = rv->key;
66e9cfb9aeSGarrett Wollman			return 1;
67e9cfb9aeSGarrett Wollman		}
688c6bd995SGarrett Wollman		return -1;
698c6bd995SGarrett Wollman	}
70e9cfb9aeSGarrett Wollman	return 0;
71e9cfb9aeSGarrett Wollman}
72dda1cfcfSJohn Baldwin
73dda1cfcfSJohn Baldwinvoid
74dda1cfcfSJohn Baldwinforeach_pathconf(void (*func)(const char *, int, const char *),
75dda1cfcfSJohn Baldwin    const char *path)
76dda1cfcfSJohn Baldwin{
77dda1cfcfSJohn Baldwin	const struct map *mp;
78dda1cfcfSJohn Baldwin
79dda1cfcfSJohn Baldwin	for (mp = wordlist; mp->name != NULL; mp++) {
80dda1cfcfSJohn Baldwin		if (mp->valid)
81dda1cfcfSJohn Baldwin			func(mp->name, mp->key, path);
82dda1cfcfSJohn Baldwin	}
83dda1cfcfSJohn Baldwin}
84