Command line argument can now be a defined error code (e.g., EPERM)

instead of an error number.

Added Linux specific error codes
This commit is contained in:
hjp 2003-02-14 15:45:28 +00:00
parent a1822cb42c
commit 9f7f0f7b9e
2 changed files with 52 additions and 14 deletions

View File

@ -6,12 +6,6 @@
char *cmnd;
static void usage(void) {
fprintf(stderr, "Usage: %s errno ...\n", cmnd);
exit(1);
}
int main(int argc, char **argv) {
int i;
@ -26,7 +20,24 @@ int main(int argc, char **argv) {
}
} else {
for (i = 1; i < argc; i++) {
int e = strtoul(argv[i], NULL, 0);
char *p;
int e = strtoul(argv[i], &p, 0);
if (*p) {
/* This is not a number, so we assume it is a define */
char *d = argv[i];
int j;
for (j = 0; j < wke_nr; j++) {
if (strcmp(wke[j].define, d) == 0) {
e = wke[j].number;
printf("%d\t%s\t%s\n", e, d, strerror(e));
break;
}
}
} else {
/* it is a number */
char *d = "(unknown)";
int j;
@ -39,6 +50,8 @@ int main(int argc, char **argv) {
printf("%d\t%s\t%s\n", e, d, strerror(e));
}
}
}
return 0;
}

View File

@ -6,9 +6,15 @@ EADV
EAFNOSUPPORT
EAGAIN
EALREADY
EBADE
EBADF
EBADFD
EBADMSG
EBADR
EBADRQC
EBADSLT
EBADVER
EBFONT
EBUSY
ECANCELED
ECHILD
@ -19,6 +25,7 @@ ECONNABORTED
ECONNREFUSED
ECONNRESET
EDEADLK
EDEADLOCK
EDESTADDRREQ
EDOM
EDOTDOT
@ -36,21 +43,30 @@ EINVAL
EIO
EISCONN
EISDIR
EISNAM
EL2HLT
EL2NSYNC
EL3HLT
EL3RST
ELIBACC
ELIBBAD
ELIBEXEC
ELIBMAX
ELIBSCN
ELNRNG
ELOOP
EMEDIUMTYPE
EMFILE
EMLINK
EMSGSIZE
EMULTIHOP
ENAMETOOLONG
ENAVAIL
ENETDOWN
ENETRESET
ENETUNREACH
ENFILE
ENOANO
ENOBUFS
ENOCSI
ENODATA
@ -61,6 +77,7 @@ ENOLCK
ENOLINK
ENOLOAD
ENOMATCH
ENOMEDIUM
ENOMEM
ENOMSG
ENONET
@ -76,9 +93,11 @@ ENOTBLK
ENOTCONN
ENOTDIR
ENOTEMPTY
ENOTNAM
ENOTSOCK
ENOTSUP
ENOTTY
ENOTUNIQ
ENOUNLD
ENOUNREG
ENXIO
@ -93,8 +112,11 @@ EPROTOTYPE
ERANGE
EREFUSED
ERELOC
EREMCHG
EREMOTE
EREMOTEIO
EREMOTERELEASE
ERESTART
EROFS
ESHUTDOWN
ESOCKTNOSUPPORT
@ -102,11 +124,14 @@ ESPIPE
ESRCH
ESRMNT
ESTALE
ESTRPIPE
ETIME
ETIMEDOUT
ETOOMANYREFS
ETXTBSY
EUCLEAN
EUNATCH
EUSERS
EWOULDBLOCK
EXDEV
EXFULL