OSDN Git Service

3922197f07a9e9eeff300c895e0cb48e6442c460
[linuxjm/LDP_man-pages.git] / draft / man3 / error.3
1 .\" Copyright (C) 2006 Justin Pryzby <pryzbyj@justinpryzby.com>
2 .\" and Copyright (C) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is hereby granted, free of charge, to any person obtaining
5 .\" a copy of this software and associated documentation files (the
6 .\" "Software"), to deal in the Software without restriction, including
7 .\" without limitation the rights to use, copy, modify, merge, publish,
8 .\" distribute, sublicense, and/or sell copies of the Software, and to
9 .\" permit persons to whom the Software is furnished to do so, subject to
10 .\" the following conditions:
11 .\"
12 .\" The above copyright notice and this permission notice shall be
13 .\" included in all copies or substantial portions of the Software.
14 .\"
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 .\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 .\" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 .\" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 .\" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 .\" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 .\"
23 .\" References:
24 .\"   glibc manual and source
25 .\"
26 .\" Japanese Version Copyright (c) 2006 Yuichi SATO
27 .\"         all rights reserved.
28 .\" Translated 2006-08-04 by Yuichi SATO <ysato444@yahoo.co.jp>, LDP v2.36
29 .\"
30 .TH ERROR 3 2010-08-29 "GNU" "Linux Programmer's Manual"
31 .\"O .SH NAME
32 .SH 名前
33 .\"O error, error_at_line, error_message_count, error_on_per_line, \
34 .\"O error_print_progname \- glibc error reporting functions
35 error, error_at_line, error_message_count, error_on_per_line, error_print_progname \- glibc のエラー書き出し関数
36 .\"O .SH SYNOPSIS
37 .SH 書式
38 .nf
39 \fB#include <error.h>
40
41 \fBvoid error(int \fIstatus, \fBint\fI errnum, \
42 \fBconst char *\fIformat, \fB...);
43
44 \fBvoid error_at_line(int \fIstatus, \fBint \fIerrnum, \
45 \fBconst char *\fIfilename,
46                    \fBunsigned int \fIlinenum, \
47 \fBconst char *\fIformat, \fB...);
48
49 \fBextern unsigned int \fIerror_message_count\fP;
50
51 \fBextern int \fIerror_one_per_line\fP;
52
53 \fBextern void (* \fIerror_print_progname\fB) (void);
54 .fi
55 .\"O .SH DESCRIPTION
56 .SH 説明
57 .\"O .BR error ()
58 .\"O is a general error-reporting function.
59 .BR error ()
60 は汎用的なエラー書き出し関数である。
61 .\"O It flushes
62 .\"O .IR stdout ,
63 .\"O and then outputs to
64 .\"O .I stderr
65 .\"O the program name, a colon and a space, the message specified by the
66 .\"O .BR printf (3)-style
67 .\"O format string \fIformat\fP, and, if \fIerrnum\fP is
68 .\"O nonzero, a second colon and a space followed by the string given by
69 .\"O .IR strerror(errnum) .
70 この関数は標準出力
71 .RI ( stdout )
72 に書き出してから、標準エラー出力
73 .RI ( stderr )
74 に書き出す。
75 書き出す内容は、プログラム名・コロン・スペース・
76 .BR printf (3)
77 形式の
78 フォーマット文字列 \fIformat\fP で指定されたメッセージである。
79 \fIerrnum\fP が 0 以外の場合、2 つ目のコロンとスペースの後に
80 .I strerror(errnum)
81 で指定された文字列も書き出す。
82 .\"O Any arguments required for
83 .\"O .I format
84 .\"O should follow
85 .\"O .I format
86 .\"O in the argument list.
87 .I format
88 に必要な任意の引き数が、引き数リストの
89 .I format
90 の後に続く。
91 .\"O The output is terminated by a newline character.
92 出力の終端には改行文字が付く。
93
94 .\"O The program name printed by
95 .\"O .BR error ()
96 .\"O is the value of the global variable
97 .\"O .BR program_invocation_name (3).
98 .BR error ()
99 で出力されるプログラム名は、大域変数
100 .BR program_invocation_name (3)
101 の値である。
102 .\"O .I program_invocation_name
103 .\"O initially has the same value as
104 .\"O .IR main ()'s
105 .\"O .IR argv[0] .
106 .I program_invocation_name
107 の初期値は
108 .IR main ()
109
110 .I argv[0]
111 の値と等しい。
112 .\"O The value of this variable can be modified to change the output of
113 .\"O .BR error ().
114 この変数の値は変更可能であり、変更すると
115 .BR error ()
116 の出力が変わる。
117
118 .\"O If \fIstatus\fP has a nonzero value, then
119 .\"O .BR error ()
120 .\"O calls
121 .\"O .BR exit (3)
122 .\"O to terminate the program using the given value as the exit status.
123 \fIstatus\fP が 0 以外の場合、
124 .BR error ()
125
126 .BR exit (3)
127 を呼び出して、指定された終了ステータスでプログラムを終了させる。
128
129 .\"O The
130 .\"O .BR error_at_line ()
131 .\"O function is exactly the same as
132 .\"O .BR error (),
133 .\"O except for the addition of the arguments
134 .\"O .I filename
135 .\"O and
136 .\"O .IR linenum .
137 .BR error_at_line ()
138 関数は、引き数
139 .I filename
140
141 .I linenum
142 が追加されている以外は、
143 .BR error ()
144 と同じである。
145 .\"O The output produced is as for
146 .\"O .BR error (),
147 .\"O except that after the program name are written: a colon, the value of
148 .\"O .IR filename ,
149 .\"O a colon, and the value of
150 .\"O .IR linenum .
151 生成される出力は、プログラム名の後に
152 コロン・\fIfilename\fR の値・コロン・\fIlinenum\fR の値が書き出される以外は、
153 .BR error ()
154 と同じである。
155 .\"O The preprocessor values \fB__LINE__\fP and
156 .\"O \fB__FILE__\fP may be useful when calling
157 .\"O .BR error_at_line (),
158 .\"O but other values can also be used.
159 .\"O For example, these arguments could refer to a location in an input file.
160 プリプロセッサの値 \fB__LINE__\fP と \fB__FILE__\fP は、
161 .BR error_at_line ()
162 を呼び出すときに役に立つ。
163 その他のプリプロセッサの値も使うことができる。
164 例えば、これらの引き数で入力ファイルにおける位置を参照できる。
165
166 .\"O If the global variable \fIerror_one_per_line\fP is set nonzero,
167 .\"O a sequence of
168 .\"O .BR error_at_line ()
169 .\"O calls with the
170 .\"O same value of \fIfilename\fP and \fIlinenum\fP will result in only
171 .\"O one message (the first) being output.
172 大域変数 \fIerror_one_per_line\fP が 0 以外に設定されている場合、
173 \fIfilename\fP と \fIlinenum\fP の値が共に等しい
174 .BR error_at_line ()
175 の呼び出しは、
176 1 つの (最初の) メッセージの出力にまとめられる。
177
178 .\"O The global variable \fIerror_message_count\fP counts the number of
179 .\"O messages that have been output by
180 .\"O .BR error ()
181 .\"O and
182 .\"O .BR error_at_line ().
183 大域変数 \fIerror_message_count\fP は、
184 .BR error ()
185
186 .BR error_at_line ()
187 で出力されたメッセージの数を表す。
188
189 .\"O If the global variable \fIerror_print_progname\fP
190 .\"O is assigned the address of a function
191 .\"O (i.e., is not NULL), then that function is called
192 .\"O instead of prefixing the message with the program name and colon.
193 .\"O The function should print a suitable string to
194 .\"O .IR stderr .
195 大域変数 \fIerror_print_progname\fP に
196 関数のアドレスが割り当てられている場合 (つまり NULL ではない場合)、
197 メッセージの前にプログラム名とコロンを書き出すのではなく、
198 この関数を呼び出す。
199 この関数は標準エラー出力
200 .RI ( stderr )
201 に対しての適切な文字列を書き出さなければならない。
202 .\"O .SH "CONFORMING TO"
203 .SH 準拠
204 .\"O These functions and variables are GNU extensions, and should not be
205 .\"O used in programs intended to be portable.
206 これらの関数と変数は GNU による拡張であり、
207 移植性を考えたプログラムでは使用すべきではない。
208 .\"O .SH SEE ALSO
209 .SH 関連項目
210 .BR err (3),
211 .BR errno (3),
212 .BR exit (3),
213 .BR perror (3),
214 .BR program_invocation_name (3),
215 .BR strerror (3)