Merge commit 'b31ca922c7346747131aed07c0c171ec2f573aac' into merges
[unleashed.git] / share / man / man3elf / elf_errmsg.3elf
bloba795b7d5ff69029be28269efe577f3038452e1b1
1 '\" te
2 .\"  Copyright 1989 AT&T  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH ELF_ERRMSG 3ELF "Jul 11, 2001"
7 .SH NAME
8 elf_errmsg, elf_errno \- error handling
9 .SH SYNOPSIS
10 .LP
11 .nf
12 cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lelf\fR [ \fIlibrary\fR ... ]
13 #include <libelf.h>
15 \fBconst char *\fR\fBelf_errmsg\fR(\fBint\fR \fIerr\fR);
16 .fi
18 .LP
19 .nf
20 \fBint\fR \fBelf_errno\fR(\fBvoid\fR);
21 .fi
23 .SH DESCRIPTION
24 .sp
25 .LP
26 If an \fBELF\fR library function fails, a program can call \fBelf_errno()\fR to
27 retrieve the library's internal error number. As a side effect, this function
28 resets the internal error number to \fB0\fR, which indicates no error.
29 .sp
30 .LP
31 The \fBelf_errmsg()\fR function takes an error number, \fIerr\fR, and returns a
32 null-terminated error message (with no trailing new-line) that describes the
33 problem. A zero \fIerr\fR retrieves a message for the most recent error. If no
34 error has occurred, the return value is a null pointer (not a pointer to the
35 null string). Using \fIerr\fR of \fB\(mi1\fR also retrieves the most recent
36 error, except it guarantees a non-null return value, even when no error has
37 occurred. If no message is available for the given number, \fBelf_errmsg()\fR
38 returns a pointer to an appropriate message. This function does not have the
39 side effect of clearing the internal error number.
40 .SH EXAMPLES
41 .LP
42 \fBExample 1 \fRA sample program of calling the \fBelf_errmsg()\fR function.
43 .sp
44 .LP
45 The following fragment clears the internal error number and checks it later for
46 errors. Unless an error occurs after the first call to \fBelf_errno()\fR, the
47 next call will return \fB0\fR.
49 .sp
50 .in +2
51 .nf
52 \fB(void)elf_errno(\|);
53 /* processing \|.\|.\|. */
54 while (more_to_do)
56         if ((err = elf_errno(\|)) != 0)
57         {
58                 /* print msg */
59                 msg = elf_errmsg(err);
60         }
61 }\fR
62 .fi
63 .in -2
65 .SH ATTRIBUTES
66 .sp
67 .LP
68 See \fBattributes\fR(5) for descriptions of the following attributes:
69 .sp
71 .sp
72 .TS
73 box;
74 c | c
75 l | l .
76 ATTRIBUTE TYPE  ATTRIBUTE VALUE
78 Interface Stability     Stable
80 MT-Level        MT-Safe
81 .TE
83 .SH SEE ALSO
84 .sp
85 .LP
86 \fBelf\fR(3ELF), \fBlibelf\fR(3LIB), \fBattributes\fR(5)