xref: /freebsd/usr.bin/getconf/unsigned_limits.gperf (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
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 */
18static const struct map *in_word_set(const char *str);
19
20%}
21struct map { const char *name; uintmax_t value; int valid; };
22%%
23UCHAR_MAX, UCHAR_MAX
24UINT_MAX, UINT_MAX
25ULLONG_MAX, ULLONG_MAX
26ULONG_MAX, ULONG_MAX
27USHRT_MAX, USHRT_MAX
28%%
29int
30find_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}
44