xref: /csrg-svn/lib/libc/string/strerror.3 (revision 56414)
148351Scael.\" Copyright (c) 1980, 1991 Regents of the University of California.
248351Scael.\" All rights reserved.
320436Smckusick.\"
450314Sbostic.\" This code is derived from software contributed to Berkeley by
550314Sbostic.\" the American National Standards Committee X3, on Information
650314Sbostic.\" Processing Systems.
750314Sbostic.\"
848351Scael.\" %sccs.include.redist.man%
920436Smckusick.\"
10*56414Sbostic.\"     @(#)strerror.3	6.10 (Berkeley) 10/04/92
1148351Scael.\"
1248351Scael.Dd
1348351Scael.Dt STRERROR 3
1448351Scael.Os BSD 4
1548351Scael.Sh NAME
1648351Scael.Nm perror ,
1748351Scael.Nm strerror ,
1848351Scael.Nm sys_errlist ,
1948351Scael.Nm sys_nerr
2048351Scael.Nd system error messages
2148351Scael.Sh SYNOPSIS
22*56414Sbostic.Fd #include <errno.h>
2348351Scael.Vt extern int errno;
24*56414Sbostic.Fd #include <stdio.h>
25*56414Sbostic.Vt extern int sys_nerr;
2648351Scael.Vt extern char *sys_errlist[];
2748351Scael.Fd #include <stdio.h>
2848351Scael.Ft void
2948351Scael.Fn perror "const char *string"
30*56414Sbostic.Fd #include <errno.h>
31*56414Sbostic.Fd #include <string.h>
3248351Scael.Ft char *
3348351Scael.Fn strerror "int errnum"
3448351Scael.Sh DESCRIPTION
3548351ScaelThe
3648351Scael.Fn strerror
3748351Scaeland
3848351Scael.Fn perror
3948351Scaelfunctions lookup the error message string affiliated with an
4048351Scaelerror number.
4148351Scael.Pp
4248351ScaelThe
4348351Scael.Fn sterror
4448351Scaelfunction accepts an error number argument
4548351Scael.Fa errnum
4648351Scaeland
4748351Scaelreturns a pointer to the corresponding
4848351Scaelmessage string.
4948351Scael.Pp
5048351ScaelThe
5148351Scael.Fn perror
5248351Scaelfunction finds the error message corresponding to the current
5348351Scaelvalue of the global variable
5448351Scael.Va errno
5548351Scaeland writes it, followed by a new-line, to the
5648351Scael.Em stderr .
5748351ScaelIf the argument
5848351Scael.Fa string
5948351Scaelis
6048351Scael.Pf non- Dv NULL
6148351Scaelit is pre-appended to the message
6248351Scaelstring and separated from it by
6348351Scaela colon and space
6448351Scael.Pq Ql \&:\ \& .
6548351ScaelIf
6648351Scael.Fa string
6748351Scaelis
6848351Scael.Dv NULL
6948351Scaelonly the error message string is printed.
7048351Scael.Pp
7136225SbosticThe message strings can be accessed directly using the external
7236225Sbosticcharacter array
7348351Scael.Fa sys_errlist .
7448351ScaelThe external value
7548351Scael.Fa sys_nerr
7648351Scaelcontains a count of the messages in
7748351Scael.Fa sys_errlist .
7847016SbosticThe use of these variables is deprecated;
7948351Scael.Fn strerror
8036225Sbosticshould be used instead.
8148351Scael.Sh SEE ALSO
8248351Scael.Xr intro 2 ,
8348351Scael.Xr psignal 3
8448351Scael.Sh HISTORY
8548351ScaelThe
8648351Scael.Fn strerror
8748351Scaeland
8848351Scael.Fn perror
8948351Scaelfunctions are
9048351Scael.Ud .
91