aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/getconf/unsigned_limits.gperf
blob: 8950828ee176266bdc92e701ab236be150bd9f15 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%{
/*
 * Copyright is disclaimed as to the contents of this file.
 */

#include <sys/types.h>

#include <string.h>
#include <limits.h>

#include "getconf.h"

/*
 * Override gperf's built-in external scope.
 */
static const struct map *in_word_set(const char *str);

%}
struct map { const char *name; uintmax_t value; int valid; };
%%
UCHAR_MAX, UCHAR_MAX
UINT_MAX, UINT_MAX
ULLONG_MAX, ULLONG_MAX
ULONG_MAX, ULONG_MAX
USHRT_MAX, USHRT_MAX
%%
int
find_unsigned_limit(const char *name, uintmax_t *value)
{
	const struct map *rv;

	rv = in_word_set(name);
	if (rv != NULL) {
		if (rv->valid) {
			*value = rv->value;
			return 1;
		}
		return -1;
	}
	return 0;
}