]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/getconf/unsigned_limits.gperf
THIS BRANCH IS OBSOLETE, PLEASE READ:
[FreeBSD/FreeBSD.git] / usr.bin / getconf / unsigned_limits.gperf
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 <limits.h>
12
13 #include "getconf.h"
14
15 /*
16  * Override gperf's built-in external scope.
17  */
18 static const struct map *in_word_set(const char *str);
19
20 %}
21 struct map { const char *name; uintmax_t value; int valid; };
22 %%
23 UCHAR_MAX, UCHAR_MAX
24 UINT_MAX, UINT_MAX
25 ULLONG_MAX, ULLONG_MAX
26 ULONG_MAX, ULONG_MAX
27 USHRT_MAX, USHRT_MAX
28 %%
29 int
30 find_unsigned_limit(const char *name, uintmax_t *value)
31 {
32         const struct map *rv;
33
34         rv = in_word_set(name);
35         if (rv != NULL) {
36                 if (rv->valid) {
37                         *value = rv->value;
38                         return 1;
39                 }
40                 return -1;
41         }
42         return 0;
43 }