58 |
|
|
59 |
struct error_info |
struct error_info |
60 |
{ |
{ |
61 |
int value; /* The numeric value from <errno.h> */ |
const int value; /* The numeric value from <errno.h> */ |
62 |
const char *name; /* The equivalent symbolic value */ |
const char *const name; /* The equivalent symbolic value */ |
63 |
#ifndef HAVE_SYS_ERRLIST |
#ifndef HAVE_SYS_ERRLIST |
64 |
const char *msg; /* Short message about this value */ |
const char *const msg; /* Short message about this value */ |
65 |
#endif |
#endif |
66 |
}; |
}; |
67 |
|
|
462 |
|
|
463 |
#ifndef HAVE_SYS_ERRLIST |
#ifndef HAVE_SYS_ERRLIST |
464 |
|
|
465 |
|
#define sys_nerr sys_nerr__ |
466 |
|
#define sys_errlist sys_errlist__ |
467 |
static int sys_nerr; |
static int sys_nerr; |
468 |
static const char **sys_errlist; |
static const char **sys_errlist; |
469 |
|
|
474 |
|
|
475 |
#endif |
#endif |
476 |
|
|
|
|
|
477 |
/* |
/* |
478 |
|
|
479 |
NAME |
NAME |
563 |
|
|
564 |
/* |
/* |
565 |
|
|
|
NAME |
|
|
|
|
|
errno_max -- return the max errno value |
|
566 |
|
|
567 |
SYNOPSIS |
@deftypefn Extension int errno_max (void) |
|
|
|
|
int errno_max (); |
|
568 |
|
|
569 |
DESCRIPTION |
Returns the maximum @code{errno} value for which a corresponding |
570 |
|
symbolic name or message is available. Note that in the case where we |
571 |
|
use the @code{sys_errlist} supplied by the system, it is possible for |
572 |
|
there to be more symbolic names than messages, or vice versa. In |
573 |
|
fact, the manual page for @code{perror(3C)} explicitly warns that one |
574 |
|
should check the size of the table (@code{sys_nerr}) before indexing |
575 |
|
it, since new error codes may be added to the system before they are |
576 |
|
added to the table. Thus @code{sys_nerr} might be smaller than value |
577 |
|
implied by the largest @code{errno} value defined in @code{<errno.h>}. |
578 |
|
|
579 |
Returns the maximum errno value for which a corresponding symbolic |
We return the maximum value that can be used to obtain a meaningful |
580 |
name or message is available. Note that in the case where |
symbolic name or message. |
|
we use the sys_errlist supplied by the system, it is possible for |
|
|
there to be more symbolic names than messages, or vice versa. |
|
|
In fact, the manual page for perror(3C) explicitly warns that one |
|
|
should check the size of the table (sys_nerr) before indexing it, |
|
|
since new error codes may be added to the system before they are |
|
|
added to the table. Thus sys_nerr might be smaller than value |
|
|
implied by the largest errno value defined in <errno.h>. |
|
581 |
|
|
582 |
We return the maximum value that can be used to obtain a meaningful |
@end deftypefn |
|
symbolic name or message. |
|
583 |
|
|
584 |
*/ |
*/ |
585 |
|
|
600 |
|
|
601 |
/* |
/* |
602 |
|
|
603 |
NAME |
@deftypefn Supplemental char* strerror (int @var{errnoval}) |
|
|
|
|
strerror -- map an error number to an error message string |
|
|
|
|
|
SYNOPSIS |
|
604 |
|
|
605 |
char *strerror (int errnoval) |
Maps an @code{errno} number to an error message string, the contents |
606 |
|
of which are implementation defined. On systems which have the |
607 |
|
external variables @code{sys_nerr} and @code{sys_errlist}, these |
608 |
|
strings will be the same as the ones used by @code{perror}. |
609 |
|
|
610 |
DESCRIPTION |
If the supplied error number is within the valid range of indices for |
611 |
|
the @code{sys_errlist}, but no message is available for the particular |
612 |
|
error number, then returns the string @samp{Error @var{num}}, where |
613 |
|
@var{num} is the error number. |
614 |
|
|
615 |
Maps an errno number to an error message string, the contents of |
If the supplied error number is not a valid index into |
616 |
which are implementation defined. On systems which have the external |
@code{sys_errlist}, returns @code{NULL}. |
|
variables sys_nerr and sys_errlist, these strings will be the same |
|
|
as the ones used by perror(). |
|
|
|
|
|
If the supplied error number is within the valid range of indices |
|
|
for the sys_errlist, but no message is available for the particular |
|
|
error number, then returns the string "Error NUM", where NUM is the |
|
|
error number. |
|
617 |
|
|
618 |
If the supplied error number is not a valid index into sys_errlist, |
The returned string is only guaranteed to be valid only until the |
619 |
returns NULL. |
next call to @code{strerror}. |
620 |
|
|
621 |
The returned string is only guaranteed to be valid only until the |
@end deftypefn |
|
next call to strerror. |
|
622 |
|
|
623 |
*/ |
*/ |
624 |
|
|
626 |
strerror (errnoval) |
strerror (errnoval) |
627 |
int errnoval; |
int errnoval; |
628 |
{ |
{ |
629 |
char *msg; |
const char *msg; |
630 |
static char buf[32]; |
static char buf[32]; |
631 |
|
|
632 |
#ifndef HAVE_SYS_ERRLIST |
#ifndef HAVE_SYS_ERRLIST |
668 |
|
|
669 |
/* |
/* |
670 |
|
|
671 |
NAME |
@deftypefn Replacement {const char*} strerrno (int @var{errnum}) |
|
|
|
|
strerrno -- map an error number to a symbolic name string |
|
|
|
|
|
SYNOPSIS |
|
|
|
|
|
const char *strerrno (int errnoval) |
|
672 |
|
|
673 |
DESCRIPTION |
Given an error number returned from a system call (typically returned |
674 |
|
in @code{errno}), returns a pointer to a string containing the |
675 |
|
symbolic name of that error number, as found in @code{<errno.h>}. |
676 |
|
|
677 |
Given an error number returned from a system call (typically |
If the supplied error number is within the valid range of indices for |
678 |
returned in errno), returns a pointer to a string containing the |
symbolic names, but no name is available for the particular error |
679 |
symbolic name of that error number, as found in <errno.h>. |
number, then returns the string @samp{Error @var{num}}, where @var{num} |
680 |
|
is the error number. |
|
If the supplied error number is within the valid range of indices |
|
|
for symbolic names, but no name is available for the particular |
|
|
error number, then returns the string "Error NUM", where NUM is |
|
|
the error number. |
|
681 |
|
|
682 |
If the supplied error number is not within the range of valid |
If the supplied error number is not within the range of valid |
683 |
indices, then returns NULL. |
indices, then returns @code{NULL}. |
684 |
|
|
685 |
BUGS |
The contents of the location pointed to are only guaranteed to be |
686 |
|
valid until the next call to @code{strerrno}. |
687 |
|
|
688 |
The contents of the location pointed to are only guaranteed to be |
@end deftypefn |
|
valid until the next call to strerrno. |
|
689 |
|
|
690 |
*/ |
*/ |
691 |
|
|
728 |
|
|
729 |
/* |
/* |
730 |
|
|
731 |
NAME |
@deftypefn Extension int strtoerrno (const char *@var{name}) |
|
|
|
|
strtoerrno -- map a symbolic errno name to a numeric value |
|
|
|
|
|
SYNOPSIS |
|
|
|
|
|
int strtoerrno (char *name) |
|
732 |
|
|
733 |
DESCRIPTION |
Given the symbolic name of a error number (e.g., @code{EACCES}), map it |
734 |
|
to an errno value. If no translation is found, returns 0. |
735 |
|
|
736 |
Given the symbolic name of a error number, map it to an errno value. |
@end deftypefn |
|
If no translation is found, returns 0. |
|
737 |
|
|
738 |
*/ |
*/ |
739 |
|
|
784 |
int errn; |
int errn; |
785 |
int errnmax; |
int errnmax; |
786 |
const char *name; |
const char *name; |
787 |
char *msg; |
const char *msg; |
788 |
char *strerror (); |
char *strerror (); |
789 |
|
|
790 |
errnmax = errno_max (); |
errnmax = errno_max (); |