simple/errno/errno.c

48 lines
760 B
C
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2003-02-14 12:59:43 +01:00
#include "errno_list.h"
char *cmnd;
static void usage(void) {
fprintf(stderr, "Usage: %s errno ...\n", cmnd);
exit(1);
}
int main(int argc, char **argv) {
int i;
cmnd = argv[0];
if (argc <= 1) {
2003-02-14 12:59:43 +01:00
int i;
for (i = 0; i < wke_nr; i++) {
int e = wke[i].number;
char *d = wke[i].define;
printf("%d\t%s\t%s\n", e, d, strerror(e));
}
} else {
for (i = 1; i < argc; i++) {
int e = strtoul(argv[i], NULL, 0);
2003-02-14 12:59:43 +01:00
char *d = "(unknown)";
int j;
for (j = 0; j < wke_nr; j++) {
if (wke[j].number == e) {
d = wke[j].define;
break;
}
}
2003-02-14 12:59:43 +01:00
printf("%d\t%s\t%s\n", e, d, strerror(e));
}
}
return 0;
}
/*
* vim:sw=4
*/