minix/external/bsd/libelf/dist/elf_errmsg.3
Lionel Sambuc 84d9c625bf Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)
- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
2014-07-28 17:05:06 +02:00

109 lines
3.6 KiB
Groff

.\" $NetBSD: elf_errmsg.3,v 1.1.1.1 2009/12/19 05:43:39 thorpej Exp $
.\"
.\" Copyright (c) 2006 Joseph Koshy. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" This software is provided by Joseph Koshy ``as is'' and
.\" any express or implied warranties, including, but not limited to, the
.\" implied warranties of merchantability and fitness for a particular purpose
.\" are disclaimed. in no event shall Joseph Koshy be liable
.\" for any direct, indirect, incidental, special, exemplary, or consequential
.\" damages (including, but not limited to, procurement of substitute goods
.\" or services; loss of use, data, or profits; or business interruption)
.\" however caused and on any theory of liability, whether in contract, strict
.\" liability, or tort (including negligence or otherwise) arising in any way
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
.\" $FreeBSD: src/lib/libelf/elf_errmsg.3,v 1.2.10.1.2.1 2009/10/25 01:10:29 kensmith Exp $
.\"
.Dd June 11, 2006
.Os
.Dt ELF_ERRMSG 3
.Sh NAME
.Nm elf_errmsg ,
.Nm elf_errno
.Nd ELF library error message handling
.Sh LIBRARY
.Lb libelf
.Sh SYNOPSIS
.In libelf.h
.Ft int
.Fn elf_errno "void"
.Ft "const char *"
.Fn elf_errmsg "int error"
.Sh 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
internally 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.
.Pp
Function
.Fn 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.
.Pp
The function
.Fn elf_errmsg
returns a null-terminated string with a human readable
description of the error specified in argument
.Ar error .
A zero value for argument
.Ar 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
.Fn elf_errmsg .
.Sh RETURN VALUES
Function
.Fn elf_errno
returns a non-zero value encoding the last error encountered
by the ELF library, or zero if no error was encountered.
.Pp
Function
.Fn elf_errmsg
returns a pointer to library local storage for non-zero values
of argument
.Ar 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.
.Sh EXAMPLES
Clearing the ELF library's recorded error number can be accomplished
by invoking
.Fn elf_errno
and discarding its return value.
.Bd -literal -offset indent
/* clear error */
(void) elf_errno();
.Ed
.Pp
Retrieving a human-readable description of the current error number
can be done with the following snippet:
.Bd -literal -offset indent
int err;
const char *errmsg;
\&...
err = elf_errno();
if (err != 0)
errmsg = elf_errmsg(err);
.Ed
.Sh SEE ALSO
.Xr elf 3 ,
.Xr gelf 3
.Sh BUGS
Function
.Fn elf_errmsg
is not localized.