OSDN Git Service

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