DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

elf_error(S)


elf_error: elf_errmsg, elf_errno -- error handling

Syntax

cc [flag . . . ] file . . . -lelf [library] . . .

#include <libelf.h>

const char *elf_errmsg(int err); int elf_errno(void);

Description

elf_errmsg- get a specified error message

elf_errno- retrieve an internal error number


elf_errno

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

elf_errmsg

elf_errmsg(S) 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; however, it guarantees a non-null return value even when no error has occurred. If no message is available for the number, elf_errmsg( ) returns a pointer to a message.

elf_errmsg( ) does not clear the internal error number.

Examples

The following fragment clears the internal error number and checks it later for errors. The next call returns zero unless an error occurs after the first call to elf_errno( ).

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

See also

elf(S), elf_version(S)

Standards conformance

elf_errmsg(S) and elf_errno(S) are not part of any currently supported standard; they were developed by UNIX System Laboratories, Inc. and are maintained by The SCO Group.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003