13
13
incompatible with our later declaration, perhaps by using const
14
14
attributes. So we hide the declaration in errno.h (if any) using a
16
#define sys_nerr sys_nerr__
16
17
#define sys_errlist sys_errlist__
22
23
#ifdef HAVE_SYS_ERRLIST
26
28
/* Routines imported from standard C runtime libraries. */
30
extern void *malloc (size_t size); /* 4.10.3.3 */
31
extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
33
extern char *malloc (); /* Standard memory allocater */
34
extern char *memset ();
38
43
# define MAX(a,b) ((a) > (b) ? (a) : (b))
56
int value; /* The numeric value from <errno.h> */
57
const char *name; /* The equivalent symbolic value */
61
const int value; /* The numeric value from <errno.h> */
62
const char *const name; /* The equivalent symbolic value */
58
63
#ifndef HAVE_SYS_ERRLIST
59
const char *msg; /* Short message about this value */
64
const char *const msg; /* Short message about this value */
562
errno_max -- return the max errno value
570
Returns the maximum errno value for which a corresponding symbolic
571
name or message is available. Note that in the case where
572
we use the sys_errlist supplied by the system, it is possible for
573
there to be more symbolic names than messages, or vice versa.
574
In fact, the manual page for perror(3C) explicitly warns that one
575
should check the size of the table (sys_nerr) before indexing it,
576
since new error codes may be added to the system before they are
577
added to the table. Thus sys_nerr might be smaller than value
578
implied by the largest errno value defined in <errno.h>.
580
We return the maximum value that can be used to obtain a meaningful
581
symbolic name or message.
567
@deftypefn Extension int errno_max (void)
569
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>}.
579
We return the maximum value that can be used to obtain a meaningful
580
symbolic name or message.
604
strerror -- map an error number to an error message string
608
char *strerror (int errnoval)
612
Maps an errno number to an error message string, the contents of
613
which are implementation defined. On systems which have the external
614
variables sys_nerr and sys_errlist, these strings will be the same
615
as the ones used by perror().
617
If the supplied error number is within the valid range of indices
618
for the sys_errlist, but no message is available for the particular
619
error number, then returns the string "Error NUM", where NUM is the
622
If the supplied error number is not a valid index into sys_errlist,
625
The returned string is only guaranteed to be valid only until the
626
next call to strerror.
603
@deftypefn Supplemental char* strerror (int @var{errnoval})
605
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}.
610
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.
615
If the supplied error number is not a valid index into
616
@code{sys_errlist}, returns @code{NULL}.
618
The returned string is only guaranteed to be valid only until the
619
next call to @code{strerror}.
678
strerrno -- map an error number to a symbolic name string
682
const char *strerrno (int errnoval)
686
Given an error number returned from a system call (typically
687
returned in errno), returns a pointer to a string containing the
688
symbolic name of that error number, as found in <errno.h>.
690
If the supplied error number is within the valid range of indices
691
for symbolic names, but no name is available for the particular
692
error number, then returns the string "Error NUM", where NUM is
695
If the supplied error number is not within the range of valid
696
indices, then returns NULL.
700
The contents of the location pointed to are only guaranteed to be
701
valid until the next call to strerrno.
671
@deftypefn Replacement {const char*} strerrno (int @var{errnum})
673
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>}.
677
If the supplied error number is within the valid range of indices for
678
symbolic names, but no name is available for the particular error
679
number, then returns the string @samp{Error @var{num}}, where @var{num}
682
If the supplied error number is not within the range of valid
683
indices, then returns @code{NULL}.
685
The contents of the location pointed to are only guaranteed to be
686
valid until the next call to @code{strerrno}.
746
strtoerrno -- map a symbolic errno name to a numeric value
750
int strtoerrno (char *name)
754
Given the symbolic name of a error number, map it to an errno value.
755
If no translation is found, returns 0.
731
@deftypefn Extension int strtoerrno (const char *@var{name})
733
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.