OSDN Git Service

(split) LDP: draft snapshot generated from latest ja.po files.
[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 2009\-03\-30 "" "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 可能であるならば、適切な言語を選択するために、 現在のロケールの \fBLC_MESSAGES\fP を使う。
70 この文字列は、アプリケーションで変更してはならないが、 その後に起こる \fBperror\fP(3)  や \fBstrerror\fP()  の呼び出しで
71 変更されても構わない。 この文字列を変更するライブラリ関数はない。
72
73 \fBstrerror_r\fP()  関数は \fBstrerror\fP()  と似ているが、 スレッドセーフである。 この関数には二種類のバージョンが存在し、
74 POSIX.1\-2001 で規定された XSI 準拠のバージョン (glibc 2.3.4 以降で利用可能) と、 GNU 仕様のバージョン
75 (glibc 2.0 以降で利用可能) である。 「書式」の節に記載された機能検査マクロの場合には、 XSI 準拠のバージョンが提供される。
76 それ以外の場合には GNU 仕様のバージョンが提供される。 機能検査マクロが一つも明示的に定義されない場合、 (glibc 2.4 以降では)
77 デフォルトで \fB_POSIX_SOURCE\fP は値 200112l で定義され、その結果 XSI 準拠のバージョンの \fBstrerror_r\fP()
78 がデフォルトで提供される。
79
80 移植性が必要なアプリケーションでは、 XSI 準拠の \fBstrerror_r\fP()  を使う方がよい。 この関数は、ユーザーから提供される長さ
81 \fIbuflen\fP のバッファ \fIbuf\fP にエラー文字列を返す。
82
83 GNU 仕様の \fBstrerror_r\fP()  は、エラーメッセージを格納した文字列へのポインタを返す。 返り値は、この関数が \fIbuf\fP
84 に格納した文字列へのポインタか、 何らかの (不変な) 静的な文字列へのポインタ、のいずれかとなる (後者の場合は \fIbuf\fP は使用されない)。
85 \fIbuf\fP に文字列が格納される場合は、 最大で \fIbuflen\fP バイトが格納され (\fIbuflen\fP
86 が小さ過ぎたときには文字列は切り詰められる)、 文字列には必ず終端ヌル文字が含まれる。
87 .SH 返り値
88 \fBstrerror\fP()  と \fBstrerror_r\fP()  はエラー内容を説明する 文字列を返す。エラー番号が未知の場合は "Unknown
89 error nnn" という メッセージを返す。
90
91 XSI 準拠の \fBstrerror_r\fP()  関数は成功すると 0 を返す。 エラーの場合には、 \-1 を返し、 \fIerrno\fP
92 にエラー内容を示す値をセットする。
93 .SH エラー
94 .TP 
95 \fBEINVAL\fP
96 \fIerrnum\fP の値が有効なエラー番号ではない。
97 .TP 
98 \fBERANGE\fP
99 エラーコードを説明する文字列のために、充分な領域が確保できなかった。
100 .SH 準拠
101 \fBstrerror\fP()  は POSIX.1\-2001, C89, C99 で規定されている。 \fBstrerror_r\fP()  は
102 POSIX.1\-2001 で規定されている。
103
104 GNU 仕様の \fBstrerror_r\fP()  関数は非標準の拡張である。
105
106 .\" e.g., Solaris 8, HP-UX 11
107 .\" e.g., FreeBSD 5.4, Tru64 5.1B
108 POSIX.1\-2001 は、 \fBstrerror\fP()  がエラーに遭遇した場合に \fIerrno\fP
109 をセットすることを認めているが、エラー発生時に関数の結果として どんな値を返すべきかを規定してない。 あるシステムでは、 エラー番号が未知の場合、
110 \fBstrerror\fP()  は NULL を返す。 他のシステムでは、 エラー番号が未知の場合、 \fBstrerror\fP()  は "Error
111 nnn occurred" といった文字列を返し、 \fIerrno\fP に \fBEINVAL\fP をセットする。
112 .SH 関連項目
113 \fBerr\fP(3), \fBerrno\fP(3), \fBerror\fP(3), \fBperror\fP(3), \fBstrsignal\fP(3)