Print list of all error codes if no argument given.

This commit is contained in:
hjp 1999-07-09 21:04:43 +00:00
parent 20cad3f629
commit f0ceda7117
1 changed files with 14 additions and 6 deletions

View File

@ -4,7 +4,7 @@
char *cmnd; char *cmnd;
void usage(void) { static void usage(void) {
fprintf(stderr, "Usage: %s errno ...\n", cmnd); fprintf(stderr, "Usage: %s errno ...\n", cmnd);
exit(1); exit(1);
} }
@ -15,12 +15,20 @@ int main(int argc, char **argv) {
cmnd = argv[0]; cmnd = argv[0];
if (argc <= 1) usage(); if (argc <= 1) {
int e;
for (e = 0;; e++) {
printf("%d\t%s\n", e, strerror(e));
}
} else {
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
int e = strtoul(argv[i], NULL, 0); int e = strtoul(argv[i], NULL, 0);
printf("%d\t%s\n", e, strerror(e)); printf("%d\t%s\n", e, strerror(e));
} }
}
return 0; return 0;
} }
/*
* vim:sw=4
*/