summaryrefslogtreecommitdiff
path: root/minix/usr.bin/trace/error.awk
blob: f6a404615e27be91f0813e6a5e6918ce0c708b69 (plain)
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
# Derived from libc errlist.awk

BEGIN {
	printf("/* This file is automatically generated by error.awk */\n\n");
	printf("#include \"inc.h\"\n\n");
	printf("static const char *const errors[] = {\n");
}
/^#define/ {
	name = $2;
	if (name == "ELAST")
		next;
	number = $3;
	if (number == "(_SIGN")
		number = $4;
	if (number < 0 || number == "EAGAIN")
		next;
	printf("\t[%s] = \"%s\",\n", name, name);
}
END {
	printf("};\n\n");
	printf("const char *\nget_error_name(int err)\n{\n\n");
	printf("\tif (err >= 0 && (unsigned int)err < __arraycount(errors) &&\n");
	printf("\t    errors[err] != NULL)\n");
	printf("\t\treturn errors[err];\n");
	printf("\telse\n");
	printf("\t\treturn NULL;\n");
	printf("}\n");
}