xref: /titanic_50/usr/src/man/man3elf/elf_errmsg.3elf (revision 7b07063d906859b2be1e88791f801b3c96e432f6)
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]
ELF_ERRMSG 3ELF "Jul 11, 2001"
NAME
elf_errmsg, elf_errno - error handling
SYNOPSIS

cc [ flag ... ] file ... -lelf [ library ... ]
#include <libelf.h>

const char *elf_errmsg(int err);

int elf_errno(void);
DESCRIPTION

If an ELF library function fails, a program can call elf_errno() to retrieve the library's internal error number. As a side effect, this function resets the internal error number to 0, which indicates no error.

The elf_errmsg() function takes an error number, err, and returns a null-terminated error message (with no trailing new-line) that describes the problem. A zero err 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 err of -1 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, elf_errmsg() returns a pointer to an appropriate message. This function does not have the side effect of clearing the internal error number.

EXAMPLES

Example 1 A sample program of calling the elf_errmsg() function.

The following fragment clears the internal error number and checks it later for errors. Unless an error occurs after the first call to elf_errno(), the next call will return 0.

(void)elf_errno(\|);
/* processing \|.\|.\|. */
while (more_to_do)
{
 if ((err = elf_errno(\|)) != 0)
 {
 /* print msg */
 msg = elf_errmsg(err);
 }
}
ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Stable
MT-Level MT-Safe
SEE ALSO

elf(3ELF), libelf(3LIB), attributes(5)