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

View File

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