1 /* xstrerror.c -- jacket routine for more robust strerror() usage.
2 Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
3 This code is in the public domain. */
12 #if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
13 extern char *strerror PARAMS ((int,...));
14 #define DONT_DECLARE_STRERROR
18 #ifndef DONT_DECLARE_STRERROR
19 extern char *strerror PARAMS ((int));
22 /* If strerror returns NULL, we'll format the number into a static buffer. */
24 #define ERRSTR_FMT "undocumented error #%d"
25 static char xstrerror_buf[sizeof ERRSTR_FMT + 20];
27 /* Like strerror, but result is never a null pointer. */
35 char *(*vmslib_strerror) PARAMS ((int,...));
37 /* Override any possibly-conflicting declaration from system header. */
38 vmslib_strerror = (char *(*) PARAMS ((int,...))) strerror;
39 /* Second argument matters iff first is EVMSERR, but it's simpler to
40 pass it unconditionally. `vaxc$errno' is declared in <errno.h>
41 and maintained by the run-time library in parallel to `errno'.
42 We assume that `errnum' corresponds to the last value assigned to
43 errno by the run-time library, hence vaxc$errno will be relevant. */
44 errstr = (*vmslib_strerror) (errnum, vaxc$errno);
46 errstr = strerror (errnum);
49 /* If `errnum' is out of range, result might be NULL. We'll fix that. */
52 sprintf (xstrerror_buf, ERRSTR_FMT, errnum);
53 errstr = xstrerror_buf;