Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

elf_errmsg(3) [freebsd man page]

ELF_ERRMSG(3)						   BSD Library Functions Manual 					     ELF_ERRMSG(3)

NAME
elf_errmsg, elf_errno -- ELF library error message handling LIBRARY
ELF Access Library (libelf, -lelf) SYNOPSIS
#include <libelf.h> int elf_errno(void); const char * elf_errmsg(int error); DESCRIPTION
When an error occurs during an ELF library API call, the library encodes the error using an error number and stores the error number inter- nally for retrieval by the application at a later point of time. Error numbers may contain an OS supplied error code in addition to an ELF API specific error code. An error number value of zero indicates no error. Function elf_errno() is used to retrieve the last error recorded by the ELF library. Invoking this function has the side-effect of resetting the ELF library's recorded error number to zero. The function elf_errmsg() returns a null-terminated string with a human readable description of the error specified in argument error. A zero value for argument error retrieves the most recent error encountered by the ELF library. An argument value of -1 behaves identically, except that it guarantees a non-NULL return from elf_errmsg(). RETURN VALUES
Function elf_errno() returns a non-zero value encoding the last error encountered by the ELF library, or zero if no error was encountered. Function elf_errmsg() returns a pointer to library local storage for non-zero values of argument error. With a zero argument, the function will return a NULL pointer if no error had been encountered by the library, or will return a pointer to library local storage containing an appropriate message otherwise. EXAMPLES
Clearing the ELF library's recorded error number can be accomplished by invoking elf_errno() and discarding its return value. /* clear error */ (void) elf_errno(); Retrieving a human-readable description of the current error number can be done with the following snippet: int err; const char *errmsg; ... err = elf_errno(); if (err != 0) errmsg = elf_errmsg(err); SEE ALSO
elf(3), gelf(3) BUGS
Function elf_errmsg() is not localized. BSD
June 11, 2006 BSD

Check Out this Related Man Page

elf_errmsg(3ELF)					       ELF Library Functions						  elf_errmsg(3ELF)

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) SunOS 5.10 11 Jul 2001 elf_errmsg(3ELF)
Man Page

Featured Tech Videos