xref: /freebsd/usr.bin/getconf/pathconf.gperf (revision 1c05a6ea6b849ff95e539c31adea887c644a6a01)
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
27FILESIZEBITS, _PC_FILESIZEBITS
28INF_PRESENT, _PC_INF_PRESENT
29LINK_MAX, _PC_LINK_MAX
30MAC_PRESENT, _PC_MAC_PRESENT
31MAX_CANON, _PC_MAX_CANON
32MAX_INPUT, _PC_MAX_INPUT
33MIN_HOLE_SIZE, _PC_MIN_HOLE_SIZE
34NAME_MAX, _PC_NAME_MAX
35PATH_MAX, _PC_PATH_MAX
36PIPE_BUF, _PC_PIPE_BUF
37POSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN
38POSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE
39POSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE
40POSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE
41POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
42SYMLINK_MAX, _PC_SYMLINK_MAX
43TRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED
44TRUSTEDBSD_ACL_NFS4, _PC_ACL_NFS4
45TRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX
46TRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT
47TRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT
48TRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT
49_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED
50_POSIX_NO_TRUNC, _PC_NO_TRUNC
51_POSIX_VDISABLE, _PC_VDISABLE
52_POSIX_ASYNC_IO, _PC_ASYNC_IO
53_POSIX_PRIO_IO, _PC_PRIO_IO
54_POSIX_SYNC_IO, _PC_SYNC_IO
55%%
56int
57find_pathconf(const char *name, int *key)
58{
59	const struct map *rv;
60
61	rv = in_word_set(name);
62	if (rv != NULL) {
63		if (rv->valid) {
64			*key = rv->key;
65			return 1;
66		}
67		return -1;
68	}
69	return 0;
70}
71
72void
73foreach_pathconf(void (*func)(const char *, int, const char *),
74    const char *path)
75{
76	const struct map *mp;
77
78	for (mp = wordlist; mp->name != NULL; mp++) {
79		if (mp->valid)
80			func(mp->name, mp->key, path);
81	}
82}
83