xref: /freebsd/usr.bin/getconf/pathconf.gperf (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
1%{
2/*
3 * Copyright is disclaimed as to the contents of this file.
4 */
5
6#include <sys/types.h>
7
8#include <string.h>
9#include <unistd.h>
10
11#include "getconf.h"
12
13/*
14 * Override gperf's built-in external scope.
15 */
16static const struct map *in_word_set(const char *str);
17
18%}
19struct map { const char *name; int key; int valid; };
20%%
21ACL_EXTENDED, _PC_ACL_EXTENDED
22ACL_NFS4, _PC_ACL_NFS4
23ACL_PATH_MAX, _PC_ACL_PATH_MAX
24CAP_PRESENT, _PC_CAP_PRESENT
25DEALLOC_PRESENT, _PC_DEALLOC_PRESENT
26FILESIZEBITS, _PC_FILESIZEBITS
27INF_PRESENT, _PC_INF_PRESENT
28LINK_MAX, _PC_LINK_MAX
29MAC_PRESENT, _PC_MAC_PRESENT
30MAX_CANON, _PC_MAX_CANON
31MAX_INPUT, _PC_MAX_INPUT
32MIN_HOLE_SIZE, _PC_MIN_HOLE_SIZE
33NAME_MAX, _PC_NAME_MAX
34PATH_MAX, _PC_PATH_MAX
35PIPE_BUF, _PC_PIPE_BUF
36POSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN
37POSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE
38POSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE
39POSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE
40POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
41SYMLINK_MAX, _PC_SYMLINK_MAX
42TRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED
43TRUSTEDBSD_ACL_NFS4, _PC_ACL_NFS4
44TRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX
45TRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT
46TRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT
47TRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT
48_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED
49_POSIX_NO_TRUNC, _PC_NO_TRUNC
50_POSIX_VDISABLE, _PC_VDISABLE
51_POSIX_ASYNC_IO, _PC_ASYNC_IO
52_POSIX_PRIO_IO, _PC_PRIO_IO
53_POSIX_SYNC_IO, _PC_SYNC_IO
54%%
55int
56find_pathconf(const char *name, int *key)
57{
58	const struct map *rv;
59
60	rv = in_word_set(name);
61	if (rv != NULL) {
62		if (rv->valid) {
63			*key = rv->key;
64			return 1;
65		}
66		return -1;
67	}
68	return 0;
69}
70
71void
72foreach_pathconf(void (*func)(const char *, int, const char *),
73    const char *path)
74{
75	const struct map *mp;
76
77	for (mp = wordlist; mp->name != NULL; mp++) {
78		if (mp->valid)
79			func(mp->name, mp->key, path);
80	}
81}
82