]> git.saurik.com Git - apple/system_cmds.git/blame - getconf.tproj/limits.gperf
system_cmds-790.30.1.tar.gz
[apple/system_cmds.git] / getconf.tproj / limits.gperf
CommitLineData
83f6dbe8
A
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 */
21static const struct map *in_word_set(const char *str);
22
23%}
24struct map { const char *name; intmax_t value; int valid; };
25%%
83f6dbe8
A
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
2fc1e207 30_POSIX_CLOCKRES_MIN, _POSIX_CLOCKRES_MIN
83f6dbe8 31_POSIX_DELAYTIMER_MAX, _POSIX_DELAYTIMER_MAX
83f6dbe8
A
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
50f84f3e 43_POSIX_PIPE_BUF, _POSIX_PIPE_BUF
83f6dbe8
A
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
2fc1e207 70_POSIX2_EXPR_NEST_MAX, _POSIX2_EXPR_NEST_MAX
83f6dbe8
A
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
76CHAR_BIT, CHAR_BIT
77CHAR_MAX, CHAR_MAX
78CHAR_MIN, CHAR_MIN
79INT_MAX, INT_MAX
80INT_MIN, INT_MIN
81LLONG_MIN, LLONG_MIN
82LLONG_MAX, LLONG_MAX
83LONG_BIT, LONG_BIT
84LONG_MAX, LONG_MAX
85LONG_MIN, LONG_MIN
86MB_LEN_MAX, MB_LEN_MAX
87SCHAR_MAX, SCHAR_MAX
88SCHAR_MIN, SCHAR_MIN
89SHRT_MAX, SHRT_MAX
90SHRT_MIN, SHRT_MIN
91SSIZE_MAX, SSIZE_MAX
92UCHAR_MAX, UCHAR_MAX
93UINT_MAX, UINT_MAX
94ULLONG_MAX, ULLONG_MAX
95ULONG_MAX, ULONG_MAX
96USHRT_MAX, USHRT_MAX
97WORD_BIT, WORD_BIT
98CHARCLASS_NAME_MAX, CHARCLASS_NAME_MAX
99NL_ARGMAX, NL_ARGMAX
100ML_LANGMAX, NL_LANGMAX
101NL_MSGMAX, NL_MSGMAX
102NL_NMAX, NL_NMAX
103NL_SETMAX, NL_SETMAX
104NL_TEXTMAX, NL_TEXTMAX
105NZERO, NZERO
106%%
107int
108find_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 == '_')
34d340d7 125 alt = (char *)name + 1;
83f6dbe8
A
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}