9103 opengroup acknowledgement should be properly formatted in man pages
[unleashed.git] / usr / src / man / man3c / strerror.3c
blob4a79a8aca0b16410e41967aa457565d6206ee8df
1 .\"
2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group.  In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document.  The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
30 .\"
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
35 .\"
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
41 .\"
42 .\"
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 2001, The IEEE and The Open Group.  All Rights Reserved.
45 .\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
46 .\" Copyright 2015, Joyent, Inc.
47 .\"
48 .TH STRERROR 3C "Aug 17, 2015"
49 .SH NAME
50 strerror, strerror_r, strerror_l \- get error message string
51 .SH SYNOPSIS
52 .LP
53 .nf
54 #include <string.h>
56 \fBchar *\fR\fBstrerror\fR(\fBint\fR \fIerrnum\fR);
57 .fi
59 .LP
60 .nf
61 \fBint\fR \fBstrerror_r\fR(\fBint\fR \fIerrnum\fR, \fBchar *\fR\fIstrerrbuf\fR, \fBsize_t\fR  \fIbuflen\fR);
62 .fi
64 .LP
65 .nf
66 \fBchar *\fR\fBstrerror_l\fR(\fBint\fR \fIerrnum\fR, \fBlocale_t\fR \fIloc\fR);
68 .SH DESCRIPTION
69 .LP
70 The \fBstrerror()\fR function maps the error number in \fIerrnum\fR to an error
71 message string, and returns a pointer to that string. It uses the same set of
72 error messages as \fBperror\fR(3C). The returned string should not be
73 overwritten.
74 .sp
75 .LP
76 The \fBstrerror_r()\fR function maps the error number in \fIerrnum\fR to
77 an error message string and returns the string in the buffer pointed to by
78 \fIstrerrbuf\fR with length \fIbuflen\fR.
79 .sp
80 .LP
81 The \fBstrerror_l()\fR function maps the error number in \fIerrnum\fR to
82 an error message string in the locale indicated by \fIloc\fR.  The
83 returned string should not be overwritten. If \fIloc\fR is passed the
84 \fBNULL\fR pointer, then the locale of the calling thread's current locale
85 will be used instead.
86 .sp
87 .LP
88 Because the \fBstrerror()\fR and \fBstrerror_l()\fR functions, return localized
89 strings in the event of an unknown error, one must use the value of \fBerrno\fR
90 to detect an error. Callers should first set \fBerrno\fR to \fB0\fR before the
91 call to either function and then check the value of \fBerrno\fR after the call.
92 If the value of \fBerrno\fR is non-zero then an error has occurred.
93 .SH RETURN VALUES
94 .LP
95 Upon successful completion, \fBstrerror()\fR and \fBstrerror_l()\fR return a
96 pointer to the generated message string. Otherwise, they set \fBerrno\fR and
97 returns a pointer to an error message string. They return the localized string
98 "Unknown error" if \fIerrnum\fR is not a valid error number.
99 .sp
101 Upon successful completion, \fBstrerror_r()\fR returns 0.  Otherwise it sets
102 \fBerrno\fR and returns the value of \fBerrno\fR to indicate the error. It
103 returns the localized string "Unknown error" in the buffer pointed to by
104 \fIstrerrbuf\fR if \fIerrnum\fR is not a valid error number.
105 .SH ERRORS
107 These functions may fail if:
109 .ne 2
111 \fB\fBEINVAL\fR\fR
113 .RS 10n
114 The value of \fIerrnum\fR is not a valid error number.
119 The \fBstrerror_r()\fR function may fail if:
121 .ne 2
123 \fB\fBERANGE\fR\fR
125 .RS 10n
126 The \fIbuflen\fR argument specifies insufficient storage to contain the
127 generated message string.
130 .SH USAGE
132 Messages returned from these functions are in the native language specified by
133 the \fBLC_MESSAGES\fR locale category. See \fBsetlocale\fR(3C) and
134 \fBuselocale\fR(3C).
135 .SH ATTRIBUTES
137 See \fBattributes\fR(5) for descriptions of the following attributes:
142 box;
143 c | c
144 l | l .
145 ATTRIBUTE TYPE  ATTRIBUTE VALUE
147 Interface Stability     Standard
149 MT-Level        Safe
152 .SH SEE ALSO
154 \fBgettext\fR(3C), \fBperror\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C),
155 \fBattributes\fR(5), \fBstandards\fR(5)