]> git.saurik.com Git - apple/system_cmds.git/blob - system_cmds-597.1.1/getconf.tproj/limits.gperf
system_cmds-597.90.1.tar.gz
[apple/system_cmds.git] / system_cmds-597.1.1 / getconf.tproj / limits.gperf
1 %{
2 /*
3 * Copyright is disclaimed as to the contents of this file.
4 *
5 * $FreeBSD: src/usr.bin/getconf/limits.gperf,v 1.2 2003/08/22 17:32:07 markm Exp $
6 */
7
8 #include <sys/types.h>
9
10 #include <string.h>
11 #include <limits.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 */
21 static const struct map *in_word_set(const char *str);
22
23 %}
24 struct map { const char *name; intmax_t value; int valid; };
25 %%
26 _POSIX_AIO_LISTIO_MAX, _POSIX_AIO_LISTIO_MAX
27 _POSIX_AIO_MAX, _POSIX_AIO_MAX
28 _POSIX_ARG_MAX, _POSIX_ARG_MAX
29 _POSIX_CHILD_MAX, _POSIX_CHILD_MAX
30 _POSIX_CLOCKRES_MIN, _POSIX_CLOCKRES_MIN
31 _POSIX_DELAYTIMER_MAX, _POSIX_DELAYTIMER_MAX
32 _POSIX_HOST_NAME_MAX, _POSIX_HOST_NAME_MAX
33 _POSIX_LINK_MAX, _POSIX_LINK_MAX
34 _POSIX_LOGIN_NAME_MAX, _POSIX_LOGIN_NAME_MAX
35 _POSIX_MAX_CANON, _POSIX_MAX_CANON
36 _POSIX_MAX_INPUT, _POSIX_MAX_INPUT
37 _POSIX_MQ_OPEN_MAX, _POSIX_MQ_OPEN_MAX
38 _POSIX_MQ_PRIO_MAX, _POSIX_MQ_PRIO_MAX
39 _POSIX_NAME_MAX, _POSIX_NAME_MAX
40 _POSIX_NGROUPS_MAX, _POSIX_NGROUPS_MAX
41 _POSIX_OPEN_MAX, _POSIX_OPEN_MAX
42 _POSIX_PATH_MAX, _POSIX_PATH_MAX
43 _POSIX_PIPE_BUF, __POSIX_PIPE_BUF
44 _POSIX_RE_DUP_MAX, _POSIX_RE_DUP_MAX
45 _POSIX_RTSIG_MAX, _POSIX_RTSIG_MAX
46 _POSIX_SEM_NSEMS_MAX, _POSIX_SEM_NSEMS_MAX
47 _POSIX_SEM_VALUE_MAX, _POSIX_SEM_VALUE_MAX
48 _POSIX_SIGQUEUE_MAX, _POSIX_SIGQUEUE_MAX
49 _POSIX_SSIZE_MAX, _POSIX_SSIZE_MAX
50 _POSIX_STREAM_MAX, _POSIX_STREAM_MAX
51 _POSIX_SS_REPL_MAX, _POSIX_SS_REPL_MAX
52 _POSIX_SYMLINK_MAX, _POSIX_SYMLINK_MAX
53 _POSIX_SYMLOOP_MAX, _POSIX_SYMLOOP_MAX
54 _POSIX_THREAD_DESTRUCTOR_ITERATIONS, _POSIX_THREAD_DESTRUCTOR_ITERATIONS
55 _POSIX_THREAD_KEYS_MAX, _POSIX_THREAD_KEYS_MAX
56 _POSIX_THREAD_THREADS_MAX, _POSIX_THREAD_THREADS_MAX
57 _POSIX_TIMER_MAX, _POSIX_TIMER_MAX
58 _POSIX_TRACE_EVENT_NAME_MAX, _POSIX_TRACE_EVENT_NAME_MAX
59 _POSIX_TRACE_NAME_MAX, _POSIX_TRACE_NAME_MAX
60 _POSIX_TRACE_SYS_MAX, _POSIX_TRACE_SYS_MAX
61 _POSIX_TRACE_USER_EVENT_MAX, _POSIX_TRACE_USER_EVENT_MAX
62 _POSIX_TTY_NAME_MAX, _POSIX_TTY_NAME_MAX
63 _POSIX_TZNAME_MAX, _POSIX_TZNAME_MAX
64 _POSIX2_BC_BASE_MAX, _POSIX2_BC_BASE_MAX
65 _POSIX2_BC_DIM_MAX, _POSIX2_BC_DIM_MAX
66 _POSIX2_BC_SCALE_MAX, _POSIX2_BC_SCALE_MAX
67 _POSIX2_BC_STRING_MAX, _POSIX2_BC_STRING_MAX
68 _POSIX2_CHARCLASS_NAME_MAX, _POSIX2_CHARCLASS_NAME_MAX
69 _POSIX2_COLL_WEIGHTS_MAX, _POSIX2_COLL_WEIGHTS_MAX
70 _POSIX2_EXPR_NEST_MAX, _POSIX2_EXPR_NEST_MAX
71 _POSIX2_LINE_MAX, _POSIX2_LINE_MAX
72 _POSIX2_RE_DUP_MAX, _POSIX2_RE_DUP_MAX
73 _XOPEN_IOV_MAX, _XOPEN_IOV_MAX
74 _XOPEN_NAME_MAX, _XOPEN_NAME_MAX
75 _XOPEN_PATH_MAX, _XOPEN_PATH_MAX
76 CHAR_BIT, CHAR_BIT
77 CHAR_MAX, CHAR_MAX
78 CHAR_MIN, CHAR_MIN
79 INT_MAX, INT_MAX
80 INT_MIN, INT_MIN
81 LLONG_MIN, LLONG_MIN
82 LLONG_MAX, LLONG_MAX
83 LONG_BIT, LONG_BIT
84 LONG_MAX, LONG_MAX
85 LONG_MIN, LONG_MIN
86 MB_LEN_MAX, MB_LEN_MAX
87 SCHAR_MAX, SCHAR_MAX
88 SCHAR_MIN, SCHAR_MIN
89 SHRT_MAX, SHRT_MAX
90 SHRT_MIN, SHRT_MIN
91 SSIZE_MAX, SSIZE_MAX
92 UCHAR_MAX, UCHAR_MAX
93 UINT_MAX, UINT_MAX
94 ULLONG_MAX, ULLONG_MAX
95 ULONG_MAX, ULONG_MAX
96 USHRT_MAX, USHRT_MAX
97 WORD_BIT, WORD_BIT
98 CHARCLASS_NAME_MAX, CHARCLASS_NAME_MAX
99 NL_ARGMAX, NL_ARGMAX
100 ML_LANGMAX, NL_LANGMAX
101 NL_MSGMAX, NL_MSGMAX
102 NL_NMAX, NL_NMAX
103 NL_SETMAX, NL_SETMAX
104 NL_TEXTMAX, NL_TEXTMAX
105 NZERO, NZERO
106 %%
107 int
108 find_limit(const char *name, intmax_t *value)
109 {
110 const struct map *rv;
111 #ifdef APPLE_GETCONF_UNDERSCORE
112 char *alt;
113 #endif /* APPLE_GETCONF_UNDERSCORE */
114
115 rv = in_word_set(name);
116 if (rv != NULL) {
117 if (rv->valid) {
118 *value = rv->value;
119 return 1;
120 }
121 return -1;
122 }
123 #ifdef APPLE_GETCONF_UNDERSCORE
124 if(*name == '_')
125 alt = (char *)name + 1;
126 else {
127 if((alt = (char *)alloca(strlen(name) + 2)) == NULL)
128 return 0;
129 *alt = '_';
130 strcpy(alt + 1, name);
131 }
132 rv = in_word_set(alt);
133 if (rv != NULL) {
134 if (rv->valid) {
135 *value = rv->value;
136 return 1;
137 }
138 return -1;
139 }
140 #endif /* APPLE_GETCONF_UNDERSCORE */
141 return 0;
142 }