OSDN Git Service

848f382b1bc0e571290b6542d1d09112c8cac6c7
[linuxjm/LDP_man-pages.git] / release / man3 / strerror.3
1 .\" Copyright (C) 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (C) 2005, 2014 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" References consulted:
27 .\"     Linux libc source code
28 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
29 .\"     386BSD man pages
30 .\" Modified Sat Jul 24 18:05:30 1993 by Rik Faith <faith@cs.unc.edu>
31 .\" Modified Fri Feb 16 14:25:17 1996 by Andries Brouwer <aeb@cwi.nl>
32 .\" Modified Sun Jul 21 20:55:44 1996 by Andries Brouwer <aeb@cwi.nl>
33 .\" Modified Mon Oct 15 21:16:25 2001 by John Levon <moz@compsoc.man.ac.uk>
34 .\" Modified Tue Oct 16 00:04:43 2001 by Andries Brouwer <aeb@cwi.nl>
35 .\" Modified Fri Jun 20 03:04:30 2003 by Andries Brouwer <aeb@cwi.nl>
36 .\" 2005-12-13, mtk, Substantial rewrite of strerror_r() description
37 .\"         Addition of extra material on portability and standards.
38 .\"
39 .\"*******************************************************************
40 .\"
41 .\" This file was generated with po4a. Translate the source file.
42 .\"
43 .\"*******************************************************************
44 .\"
45 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
46 .\"       all rights reserved.
47 .\" Translated 1997-01-20, YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
48 .\" Updated & Modified 2001-11-03, Yuichi SATO <ysato@h4.dion.ne.jp>
49 .\" Updated 2005-12-26, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
50 .\" Updated 2007-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.64
51 .\" Updated 2012-05-02, Akihiro MOTOKI <amotoki@gmail.com>
52 .\" Updated 2013-07-22, Akihiro MOTOKI <amotoki@gmail.com>
53 .\"
54 .TH STRERROR 3 2014\-03\-18 "" "Linux Programmer's Manual"
55 .SH 名前
56 strerror, strerror_r, strerror_l \- エラー番号を説明する文字列を返す。
57 .SH 書式
58 .nf
59 \fB#include <string.h>\fP
60 .sp
61 \fBchar *strerror(int \fP\fIerrnum\fP\fB);\fP
62 .sp
63 \fBint strerror_r(int \fP\fIerrnum\fP\fB, char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB);\fP
64             /* XSI\-compliant */
65 .sp
66 \fBchar *strerror_r(int \fP\fIerrnum\fP\fB, char *\fP\fIbuf\fP\fB, size_t \fP\fIbuflen\fP\fB);\fP
67             /* GNU\-specific */
68
69 \fBchar *strerror_l(int \fP\fIerrnum\fP\fB, locale_t \fP\fIlocale\fP\fB);\fP
70 .fi
71 .sp
72 .in -4n
73 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
74 .in
75 .ad l
76 .sp
77 \fBstrerror_r\fP():
78 .RS 4
79 次の場合には XSI 準拠のバージョンが提供される:
80 .br
81 (_POSIX_C_SOURCE\ >=\ 200112L || _XOPEN_SOURCE\ >=\ 600) && !\ _GNU_SOURCE
82 .br
83 それ以外の場合、GNU バージョンが提供される。
84 .RE
85 .ad
86 .SH 説明
87 .\"
88 \fBstrerror\fP() 関数は、引き数 \fIerrnum\fP で渡されたエラーコードについての説明が入った文字列へのポインタを返す。
89 可能であるならば、適切な言語を選択するために、 現在のロケールの \fBLC_MESSAGES\fP を使う。(例えば、 \fIerrnum\fP が
90 \fBEINVAL\fP の場合、説明として "Invalid argument" が返される。) この文字列は、アプリケーションで変更してはならないが、
91 これ以降に行われる \fBstrerror\fP() や \fBstrerror_l\fP() の呼び出しで変更されても構わない。 \fBperror\fP(3)
92 などの、これ以外のライブラリ関数ではこの文字列は変更されない。
93 .SS strerror_r()
94 \fBstrerror_r\fP() 関数は \fBstrerror\fP() と似ているが、スレッドセーフである。
95 この関数には二種類のバージョンが存在し、 POSIX.1\-2001 で規定された XSI
96 準拠のバージョン (glibc 2.3.4 以降で利用可能だが、glibc 2.13 までは
97 POSIX 準拠ではない) と、 GNU 仕様のバージョン (glibc 2.0 以降で利用可能)
98 である。 「書式」の節に記載された機能検査マクロの場合には、 XSI 準拠の
99 バージョンが提供される。それ以外の場合には GNU 仕様のバージョンが提供さ
100 れる。機能検査マクロが一つも明示的に定義されない場合、 (glibc 2.4 以降
101 では) デフォルトで \fB_POSIX_SOURCE\fP は値 200112l で定義され、その結果
102 XSI 準拠のバージョンの \fBstrerror_r\fP() がデフォルトで提供される。
103
104 移植性が必要なアプリケーションでは、 XSI 準拠の \fBstrerror_r\fP()  を使う方がよい。 この関数は、ユーザーから提供される長さ
105 \fIbuflen\fP のバッファ \fIbuf\fP にエラー文字列を返す。
106
107 .\"
108 GNU 仕様の \fBstrerror_r\fP() は、 エラーメッセージを格納した文字列へのポインタを返す。 返り値は、 この関数が \fIbuf\fP
109 に格納した文字列へのポインタか、 何らかの (不変な) 静的な文字列へのポインタ、 のいずれかとなる (後者の場合は \fIbuf\fP は使用されない)。
110 \fIbuf\fP に文字列が格納される場合は、 最大で \fIbuflen\fP バイトが格納される (\fIbuflen\fP
111 が小さ過ぎたときには文字列は切り詰められ、 \fIerrnum\fP は不定である)。 文字列には必ず終端ヌル文字 (\(aq\e0\(aq) が含まれる。
112 .SS strerror_l()
113 \fBstrerror_l\fP() は \fBstrerror\fP() と同様だが、 \fIerrnum\fP を \fIlocale\fP
114 で指定されたロケールのロケール依存のエラーメッセージにマッピングする。 \fIlocale\fP が特別なロケールオブジェクト
115 \fBLC_GLOBAL_LOCALE\fP の場合、もしくは \fIlocale\fP が有効なロケールオブジェクトハンドルでない場合は、
116 \fBstrerror_l\fP() の動作は未定義である。
117 .SH 返り値
118 関数 \fBstrerror\fP(), \fBstrerror_l\fP() と GNU 固有の関数 \fBstrerror_r\fP()
119 はエラー内容を説明する文字列を返す。 エラー番号が未知の場合は "Unknown error nnn" という メッセージを返す。
120
121 XSI 準拠の \fBstrerror_r\fP() 関数は成功すると 0 を返す。エラーの場合には、
122 (glibc 2.13 以降では) (正の) エラー番号が返され、(バージョン 2.13 より前
123 の glibc では) \-1 が返され、 \fIerrno\fP にエラーを示す値がセットされる。
124
125 POSIX.1\-2001 と POSIX.1\-2008 では、 \fBstrerror\fP() や \fBstrerror_l\fP() が成功した場合は
126 \fIerrno\fP
127 を変更せずに元のままにしなければならないとされている。関数のどの返り値もエラーを示すために予約されていないので、エラーをチェックしたいアプリケーションは呼び出しを行う前に
128 \fIerrno\fP を 0 に初期化し、呼び出しの後で \fIerrno\fP をチェックすべき点に注意すること。
129 .SH エラー
130 .TP 
131 \fBEINVAL\fP
132 \fIerrnum\fP の値が有効なエラー番号ではない。
133 .TP 
134 \fBERANGE\fP
135 エラーコードを説明する文字列のために、充分な領域が確保できなかった。
136 .SH 属性
137 .SS "マルチスレッディング (pthreads(7) 参照)"
138 \fBstrerror\fP() 関数はスレッドセーフではない。
139 .LP
140 .\" FIXME Need a thread-safety statement about strerror_l()
141 \fBstrerror_r\fP() 関数はスレッドセーフである。
142 .SH バージョン
143 \fBstrerror_l\fP() 関数は glibc 2.6 で初めて登場した。
144 .SH 準拠
145 \fBstrerror\fP()  は POSIX.1\-2001, POSIX.1\-2008, C89, C99 で規定されている。
146 \fBstrerror_r\fP()  は POSIX.1\-2001 と POSIX.1\-2008 で規定されている。
147
148 \fBstrerror_l\fP() は POSIX.1\-2008 で規定されている。
149
150 GNU 仕様の \fBstrerror_r\fP()  関数は非標準の拡張である。
151
152 .\" e.g., Solaris 8, HP-UX 11
153 .\" e.g., FreeBSD 5.4, Tru64 5.1B
154 POSIX.1\-2001 は、 \fBstrerror\fP() がエラーに遭遇した場合に \fIerrno\fP をセッ
155 トすることを認めているが、エラー発生時に関数の結果として どんな値を返す
156 べきかを規定してない。 あるシステムでは、 エラー番号が未知の場合、
157 \fBstrerror\fP() は NULL を返す。 他のシステムでは、 エラー番号が未知の場
158 合、 \fBstrerror\fP() は "Error nnn occurred" といった文字列を返し、
159 \fIerrno\fP に \fBEINVAL\fP をセットする。 C99 と POSIX.1\-2008 では、返り値が
160 NULL 以外になることが求められている。
161 .SH 関連項目
162 \fBerr\fP(3), \fBerrno\fP(3), \fBerror\fP(3), \fBperror\fP(3), \fBstrsignal\fP(3),
163 \fBlocale\fP(7)
164 .SH この文書について
165 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部
166 である。プロジェクトの説明とバグ報告に関する情報は
167 http://www.kernel.org/doc/man\-pages/ に書かれている。