Current File : //usr/man/man3elf/elf_errmsg.3elf
'\" te
.\"  Copyright 1989 AT&T  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
.TH elf_errmsg 3ELF "11 Jul 2001" "SunOS 5.11" "ELF Library Functions"
.SH NAME
elf_errmsg, elf_errno \- error handling
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lelf\fR [ \fIlibrary\fR ... ]
#include <libelf.h>

\fBconst char *\fR\fBelf_errmsg\fR(\fBint\fR \fIerr\fR);
.fi

.LP
.nf
\fBint\fR \fBelf_errno\fR(\fBvoid\fR);
.fi

.SH DESCRIPTION
.sp
.LP
If an \fBELF\fR library function fails, a program can call \fBelf_errno()\fR to retrieve the library's internal error number. As a side effect, this function resets the internal error number to \fB0\fR, which indicates no error.
.sp
.LP
The \fBelf_errmsg()\fR function takes an error number, \fIerr\fR, and returns a null-terminated error message (with no trailing new-line) that describes the problem. A zero \fIerr\fR retrieves a message for the most recent error. If no error has occurred, the return value is a null pointer (not a pointer to the null string). Using \fIerr\fR of \fB\(mi1\fR also retrieves the most recent error, except it guarantees a non-null return value, even when no error has occurred. If no message is available for the given number, \fBelf_errmsg()\fR returns a pointer to an appropriate message. This function does not have the side effect of clearing the internal error number.
.SH EXAMPLES
.LP
\fBExample 1 \fRA sample program of calling the \fBelf_errmsg()\fR function.
.sp
.LP
The following fragment clears the internal error number and checks it later for errors. Unless an error occurs after the first call to \fBelf_errno()\fR, the next call will return \fB0\fR.

.sp
.in +2
.nf
(void)elf_errno(\|);
/* processing \|.\|.\|. */
while (more_to_do)
{
	if ((err = elf_errno(\|)) != 0)
	{
		/* print msg */
		msg = elf_errmsg(err);
	}
}
.fi
.in -2

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
tab() box;
cw(2.75i) |cw(2.75i) 
lw(2.75i) |lw(2.75i) 
.
ATTRIBUTE TYPEATTRIBUTE VALUE
_
Interface StabilityCommitted
_
MT-LevelMT-Safe
.TE

.SH SEE ALSO
.sp
.LP
\fBelf\fR(3ELF), \fBlibelf\fR(3LIB), \fBattributes\fR(5)