OSDN Git Service

62a2621720e5a2065e6ad2a047d8537d23f29633
[linuxjm/LDP_man-pages.git] / draft / man3 / err.3
1 .\" Copyright (c) 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     From: @(#)err.3 8.1 (Berkeley) 6/9/93
33 .\" $FreeBSD: src/lib/libc/gen/err.3,v 1.11.2.5 2001/08/17 15:42:32 ru Exp $
34 .\"
35 .\" 2011-09-10, mtk, Converted from mdoc to man macros
36 .\"
37 .\"*******************************************************************
38 .\"
39 .\" This file was generated with po4a. Translate the source file.
40 .\"
41 .\"*******************************************************************
42 .TH ERR 3 2012\-03\-15 Linux "Linux Programmer's Manual"
43 .SH 名前
44 err, verr, errx, verrx, warn, vwarn, warnx, vwarnx \- エラーメッセージを整形する
45 .SH 書式
46 .nf
47 \fB#include <err.h>\fP
48 .sp
49 \fBvoid err(int \fP\fIeval\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fP
50 .sp
51 \fBvoid errx(int \fP\fIeval\fP\fB, const char *\fP\fIfmt\fP\fB, ...);\fP
52 .sp
53 \fBvoid warn(const char *\fP\fIfmt\fP\fB, ...);\fP
54 .sp
55 \fBvoid warnx(const char *\fP\fIfmt\fP\fB, ...);\fP
56 .sp
57 \fB#include <stdarg.h>\fP
58 .sp
59 \fBvoid verr(int \fP\fIeval\fP\fB, const char *\fP\fIfmt\fP\fB, va_list \fP\fIargs\fP\fB);\fP
60 .sp
61 \fBvoid verrx(int \fP\fIeval\fP\fB, const char *\fP\fIfmt\fP\fB, va_list \fP\fIargs\fP\fB);\fP
62 .sp
63 \fBvoid vwarn(const char *\fP\fIfmt\fP\fB, va_list \fP\fIargs\fP\fB);\fP
64 .sp
65 \fBvoid vwarnx(const char *\fP\fIfmt\fP\fB, va_list \fP\fIargs\fP\fB);\fP
66 .fi
67 .SH 説明
68 \fBerr\fP()  関数群と \fBwarn\fP()  関数群は、エラーメッセージを整形して標準エラー出力に表示する。
69 どの関数の場合も、(ディレクトリ部分を省いた)プログラム名、 コロン 1個、スペース 1個が出力される。 \fIfmt\fP 引き数が NULL でない場合、
70 \fBprintf\fP(3)  と同様に整形が行われ、エラーメッセージが出力される。 出力は改行文字で終わる。
71 .PP
72 関数 \fBerr\fP(), \fBverr\fP(), \fBwarn\fP(), \fBvwarn\fP()  は、グローバル変数 \fIerrno\fP に基づいて
73 \fBstrerror\fP(3)  から得たエラーメッセージを出力する。 \fIfmt\fP 引き数が NULL
74 でない場合は、一個ずつのコロンとスペースに続けて出力する。
75 .PP
76 関数 \fBerrx\fP(), \fBwarnx\fP()  はエラーメッセージを付け加えない。
77 .PP
78 関数 \fBerr\fP(), \fBverr\fP(), \fBerrx\fP(), \fBverrx\fP()  は返り値を返さないが、引き数 \fIeval\fP の値を
79 exit status に設定し終了する。
80 .SH 準拠
81 .\" .SH HISTORY
82 .\" The
83 .\" .BR err ()
84 .\" and
85 .\" .BR warn ()
86 .\" functions first appeared in
87 .\" 4.4BSD.
88 これらの関数は非標準の BSD 拡張である。
89 .SH 例
90 現在の \fIerrno\fP の情報を表示し、終了する:
91 .in +4n
92 .nf
93
94 if ((p = malloc(size)) == NULL)
95     err(1, NULL);
96 if ((fd = open(file_name, O_RDONLY, 0)) == \-1)
97     err(1, "%s", file_name);
98 .fi
99 .in
100 .PP
101 エラーメッセージを表示し、終了する:
102 .in +4n
103 .nf
104
105 if (tm.tm_hour < START_TIME)
106     errx(1, "too early, wait until %s", start_time_string);
107 .fi
108 .in
109 .PP
110 エラーを警告表示する:
111 .in +4n
112 .nf
113
114 if ((fd = open(raw_device, O_RDONLY, 0)) == \-1)
115     warnx("%s: %s: trying the block device",
116             raw_device, strerror(errno));
117 if ((fd = open(block_device, O_RDONLY, 0)) == \-1)
118     err(1, "%s", block_device);
119 .fi
120 .in
121 .SH 関連項目
122 \fBerror\fP(3), \fBexit\fP(3), \fBperror\fP(3), \fBprintf\fP(3), \fBstrerror\fP(3)