version 1.14, 2004/05/09 22:14:15 |
version 1.15, 2004/06/27 00:48:22 |
|
|
#define ERRMAX 20 |
#define ERRMAX 20 |
|
|
struct errs { /* structure for a system-call error */ |
struct errs { /* structure for a system-call error */ |
int errno; /* value of errno (that is, the actual error) */ |
int err; /* value of errno (that is, the actual error) */ |
char *arg; /* argument that caused the error */ |
char *arg; /* argument that caused the error */ |
}; |
}; |
|
|
|
|
return(err_toomany); \ |
return(err_toomany); \ |
} else { \ |
} else { \ |
errs[errcnt].arg = (p); \ |
errs[errcnt].arg = (p); \ |
errs[errcnt++].errno = (e); \ |
errs[errcnt++].err = (e); \ |
} |
} |
|
|
#define STRMAX 80 |
#define STRMAX 80 |
|
|
/* loop thru the sorted list, building an error string */ |
/* loop thru the sorted list, building an error string */ |
while (cnt < errcnt) { |
while (cnt < errcnt) { |
errp = &(errs[cnt++]); |
errp = &(errs[cnt++]); |
if (errp->errno != currerr) { |
if (errp->err != currerr) { |
if (currerr != -1) { |
if (currerr != -1) { |
if (str_adderr(string, sizeof string, currerr) > |
if (str_adderr(string, sizeof string, currerr) > |
sizeof string - 2) |
sizeof string - 2) |
|
|
/* we know there's more */ |
/* we know there's more */ |
(void) strlcat(string, "; ", sizeof string); |
(void) strlcat(string, "; ", sizeof string); |
} |
} |
currerr = errp->errno; |
currerr = errp->err; |
first = Yes; |
first = Yes; |
} |
} |
if (str_addarg(string, sizeof string, errp->arg, first) >= |
if (str_addarg(string, sizeof string, errp->arg, first) >= |
|
|
const struct errs *p2 = (struct errs *) e2; |
const struct errs *p2 = (struct errs *) e2; |
int result; |
int result; |
|
|
if ((result = p1->errno - p2->errno) == 0) |
if ((result = p1->err - p2->err) == 0) |
return (strcmp(p1->arg, p2->arg)); |
return (strcmp(p1->arg, p2->arg)); |
return (result); |
return (result); |
} |
} |
|
|
printf("%d error%s:\n\n", errcnt, errcnt == 1 ? "" : "s"); |
printf("%d error%s:\n\n", errcnt, errcnt == 1 ? "" : "s"); |
while (cnt++ < errcnt) { |
while (cnt++ < errcnt) { |
printf("%5s: %s\n", errp->arg, |
printf("%5s: %s\n", errp->arg, |
errp->errno == 0 ? "Not a number" : strerror(errp->errno)); |
errp->err == 0 ? "Not a number" : strerror(errp->err)); |
errp++; |
errp++; |
} |
} |
} |
} |