xref: /minix/minix/usr.bin/trace/error.awk (revision 9f988b79)
1# Derived from libc errlist.awk
2
3BEGIN {
4	printf("/* This file is automatically generated by error.awk */\n\n");
5	printf("#include \"inc.h\"\n\n");
6	printf("static const char *const errors[] = {\n");
7}
8/^#define/ {
9	name = $2;
10	if (name == "ELAST")
11		next;
12	number = $3;
13	if (number == "(_SIGN")
14		number = $4;
15	if (number < 0 || number == "EAGAIN")
16		next;
17	printf("\t[%s] = \"%s\",\n", name, name);
18}
19END {
20	printf("};\n\n");
21	printf("const char *\nget_error_name(int err)\n{\n\n");
22	printf("\tif (err >= 0 && err < sizeof(errors) / sizeof(errors[0]) &&\n");
23	printf("\t    errors[err] != NULL)\n");
24	printf("\t\treturn errors[err];\n");
25	printf("\telse\n");
26	printf("\t\treturn NULL;\n");
27	printf("}\n");
28}
29