521fa314e2
Change-Id: Ib970c8647409196902ed53d6e9631a1673a4ab2e
29 lines
710 B
Awk
29 lines
710 B
Awk
# 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 && err < sizeof(errors) / sizeof(errors[0]) &&\n");
|
|
printf("\t errors[err] != NULL)\n");
|
|
printf("\t\treturn errors[err];\n");
|
|
printf("\telse\n");
|
|
printf("\t\treturn NULL;\n");
|
|
printf("}\n");
|
|
}
|