'\" te .\" Copyright 1989 AT&T Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH ELF_ERRMSG 3ELF "Jul 11, 2001" .SH NAME elf_errmsg, elf_errno \- error handling .SH SYNOPSIS .LP .nf cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lelf\fR [ \fIlibrary\fR ... ] #include \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 \fB(void)elf_errno(\|); /* processing \|.\|.\|. */ while (more_to_do) { if ((err = elf_errno(\|)) != 0) { /* print msg */ msg = elf_errmsg(err); } }\fR .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Stable _ MT-Level MT-Safe .TE .SH SEE ALSO .sp .LP .BR elf (3ELF), .BR libelf (3LIB), .BR attributes (7)