]> git.saurik.com Git - apple/system_cmds.git/blame - getconf.tproj/pathconf.gperf
system_cmds-336.10.tar.gz
[apple/system_cmds.git] / getconf.tproj / pathconf.gperf
CommitLineData
83f6dbe8
A
1%{
2/*
3 * Copyright is disclaimed as to the contents of this file.
4 *
5 * $FreeBSD: src/usr.bin/getconf/pathconf.gperf,v 1.4 2003/08/22 17:32:07 markm Exp $
6 */
7
8#include <sys/types.h>
9
10#include <string.h>
11#include <unistd.h>
12#ifdef APPLE_GETCONF_UNDERSCORE
13#include <alloca.h>
14#endif /* APPLE_GETCONF_UNDERSCORE */
15
16#include "getconf.h"
17
18/*
19 * Override gperf's built-in external scope.
20 */
21static const struct map *in_word_set(const char *str);
22
23%}
24struct map { const char *name; int key; int valid; };
25%%
26FILESIZEBITS, _PC_FILESIZEBITS
27LINK_MAX, _PC_LINK_MAX
28MAX_CANON, _PC_MAX_CANON
29MAX_INPUT, _PC_MAX_INPUT
30NAME_MAX, _PC_NAME_MAX
31PATH_MAX, _PC_PATH_MAX
32PIPE_BUF, _PC_PIPE_BUF
33POSIX_ALLOC_SIZE_MIN, _PC_ALLOC_SIZE_MIN
34POSIX_REC_INCR_XFER_SIZE, _PC_REC_INCR_XFER_SIZE
35POSIX_REC_MAX_XFER_SIZE, _PC_REC_MAX_XFER_SIZE
36POSIX_REC_MIN_XFER_SIZE, _PC_REC_MIN_XFER_SIZE
37POSIX_REC_XFER_ALIGN, _PC_REC_XFER_ALIGN
38SYMLINK_MAX, _PC_SYMLINK_MAX
39TRUSTEDBSD_ACL_EXTENDED, _PC_ACL_EXTENDED
40TRUSTEDBSD_ACL_PATH_MAX, _PC_ACL_PATH_MAX
41TRUSTEDBSD_CAP_PRESENT, _PC_CAP_PRESENT
42TRUSTEDBSD_INF_PRESENT, _PC_INF_PRESENT
43TRUSTEDBSD_MAC_PRESENT, _PC_MAC_PRESENT
2fc1e207 44_POSIX_ASYNC_IO, _PC_ASYNC_IO
83f6dbe8
A
45_POSIX_CHOWN_RESTRICTED, _PC_CHOWN_RESTRICTED
46_POSIX_NO_TRUNC, _PC_NO_TRUNC
2fc1e207 47_POSIX_PATH_MAX, _PC_PATH_MAX
83f6dbe8
A
48_POSIX_PRIO_IO, _PC_PRIO_IO
49_POSIX_SYNC_IO, _PC_SYNC_IO
2fc1e207 50_POSIX_VDISABLE, _PC_VDISABLE
83f6dbe8
A
51%%
52int
53find_pathconf(const char *name, int *key)
54{
55 const struct map *rv;
56#ifdef APPLE_GETCONF_UNDERSCORE
57 char *alt;
58#endif /* APPLE_GETCONF_UNDERSCORE */
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#ifdef APPLE_GETCONF_UNDERSCORE
69 if(*name == '_')
70 alt = name + 1;
71 else {
72 if((alt = (char *)alloca(strlen(name) + 2)) == NULL)
73 return 0;
74 *alt = '_';
75 strcpy(alt + 1, name);
76 }
77 rv = in_word_set(alt);
78 if (rv != NULL) {
79 if (rv->valid) {
80 *key = rv->key;
81 return 1;
82 }
83 return -1;
84 }
85#endif /* APPLE_GETCONF_UNDERSCORE */
86 return 0;
87}