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