Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man3c / strerror.3c
blob1694c42617f3bab680a760ee8188cbf6ac124a6d
1 '\" te
2 .\" Copyright 2015, Joyent, Inc.
3 .\" Copyright (c) 2005, Sun Microsystems, Inc.  All Rights Reserved.
4 .\" Copyright 1989 AT&T
5 .\" Portions Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
6 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
7 .\" http://www.opengroup.org/bookstore/.
8 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
9 .\"  This notice shall appear on any product containing this material.
10 .\" 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.
11 .\" 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.
12 .\" 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]
13 .TH STRERROR 3C "Aug 17, 2015"
14 .SH NAME
15 strerror, strerror_r, strerror_l \- get error message string
16 .SH SYNOPSIS
17 .LP
18 .nf
19 #include <string.h>
21 \fBchar *\fR\fBstrerror\fR(\fBint\fR \fIerrnum\fR);
22 .fi
24 .LP
25 .nf
26 \fBint\fR \fBstrerror_r\fR(\fBint\fR \fIerrnum\fR, \fBchar *\fR\fIstrerrbuf\fR, \fBsize_t\fR  \fIbuflen\fR);
27 .fi
29 .LP
30 .nf
31 \fBchar *\fR\fBstrerror_l\fR(\fBint\fR \fIerrnum\fR, \fBlocale_t\fR \fIloc\fR);
33 .SH DESCRIPTION
34 .LP
35 The \fBstrerror()\fR function maps the error number in \fIerrnum\fR to an error
36 message string, and returns a pointer to that string. It uses the same set of
37 error messages as \fBperror\fR(3C). The returned string should not be
38 overwritten.
39 .sp
40 .LP
41 The \fBstrerror_r()\fR function maps the error number in \fIerrnum\fR to
42 an error message string and returns the string in the buffer pointed to by
43 \fIstrerrbuf\fR with length \fIbuflen\fR.
44 .sp
45 .LP
46 The \fBstrerror_l()\fR function maps the error number in \fIerrnum\fR to
47 an error message string in the locale indicated by \fIloc\fR.  The
48 returned string should not be overwritten. If \fIloc\fR is passed the
49 \fBNULL\fR pointer, then the locale of the calling thread's current locale
50 will be used instead.
51 .sp
52 .LP
53 Because the \fBstrerror()\fR and \fBstrerror_l()\fR functions, return localized
54 strings in the event of an unknown error, one must use the value of \fBerrno\fR
55 to detect an error. Callers should first set \fBerrno\fR to \fB0\fR before the
56 call to either function and then check the value of \fBerrno\fR after the call.
57 If the value of \fBerrno\fR is non-zero then an error has occurred.
58 .SH RETURN VALUES
59 .LP
60 Upon successful completion, \fBstrerror()\fR and \fBstrerror_l()\fR return a
61 pointer to the generated message string. Otherwise, they set \fBerrno\fR and
62 returns a pointer to an error message string. They return the localized string
63 "Unknown error" if \fIerrnum\fR is not a valid error number.
64 .sp
65 .LP
66 Upon successful completion, \fBstrerror_r()\fR returns 0.  Otherwise it sets
67 \fBerrno\fR and returns the value of \fBerrno\fR to indicate the error. It
68 returns the localized string "Unknown error" in the buffer pointed to by
69 \fIstrerrbuf\fR if \fIerrnum\fR is not a valid error number.
70 .SH ERRORS
71 .LP
72 These functions may fail if:
73 .sp
74 .ne 2
75 .na
76 \fB\fBEINVAL\fR\fR
77 .ad
78 .RS 10n
79 The value of \fIerrnum\fR is not a valid error number.
80 .RE
82 .sp
83 .LP
84 The \fBstrerror_r()\fR function may fail if:
85 .sp
86 .ne 2
87 .na
88 \fB\fBERANGE\fR\fR
89 .ad
90 .RS 10n
91 The \fIbuflen\fR argument specifies insufficient storage to contain the
92 generated message string.
93 .RE
95 .SH USAGE
96 .LP
97 Messages returned from these functions are in the native language specified by
98 the \fBLC_MESSAGES\fR locale category. See \fBsetlocale\fR(3C) and
99 \fBuselocale\fR(3C).
100 .SH ATTRIBUTES
102 See \fBattributes\fR(5) for descriptions of the following attributes:
107 box;
108 c | c
109 l | l .
110 ATTRIBUTE TYPE  ATTRIBUTE VALUE
112 Interface Stability     Standard
114 MT-Level        Safe
117 .SH SEE ALSO
119 \fBgettext\fR(3C), \fBperror\fR(3C), \fBsetlocale\fR(3C), \fBuselocale\fR(3C),
120 \fBattributes\fR(5), \fBstandards\fR(5)