2 .\" Japanese Version Copyright (c) 1999 ishikawa, keisuke
3 .\" all rights reserved.
4 .\" Translated Thu Jan 7 00:03:12 JST 1999
5 .\" by ishikawa, keisuke <ishikawa@sgk.gr.jp>
6 .\" Updated Sat May 19 JST 2001 by Kentaro Shirakata <argrath@ub32.org>
7 .\" Updated & Modified Sun Jul 1 15:48:32 JST 2001
8 .\" by Yuichi SATO <ysato@h4.dion.ne.jp>
10 .\" Copyright (c) 1980, 1991 Regents of the University of California.
11 .\" All rights reserved.
13 .\" This code is derived from software contributed to Berkeley by
14 .\" the American National Standards Committee X3, on Information
15 .\" Processing Systems.
17 .\" Redistribution and use in source and binary forms, with or without
18 .\" modification, are permitted provided that the following conditions
20 .\" 1. Redistributions of source code must retain the above copyright
21 .\" notice, this list of conditions and the following disclaimer.
22 .\" 2. Redistributions in binary form must reproduce the above copyright
23 .\" notice, this list of conditions and the following disclaimer in the
24 .\" documentation and/or other materials provided with the distribution.
25 .\" 3. All advertising materials mentioning features or use of this software
26 .\" must display the following acknowledgement:
27 .\" This product includes software developed by the University of
28 .\" California, Berkeley and its contributors.
29 .\" 4. Neither the name of the University nor the names of its contributors
30 .\" may be used to endorse or promote products derived from this software
31 .\" without specific prior written permission.
33 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
34 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
35 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
36 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
37 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
41 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
42 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 .\" @(#)setbuf.3 6.10 (Berkeley) 6/29/91
47 .\" Converted for Linux, Mon Nov 29 14:55:24 1993, faith@cs.unc.edu
48 .\" Added section to BUGS, Sun Mar 12 22:28:33 MET 1995,
49 .\" Thomas.Koenig@ciw.uni-karlsruhe.de
50 .\" Correction, Sun, 11 Apr 1999 15:55:18,
51 .\" Martin Vicente <martin@netadmin.dgac.fr>
52 .\" Correction, 2000-03-03, Andreas Jaeger <aj@suse.de>
53 .\" Added return value for setvbuf, aeb,
55 .TH SETBUF 3 2008-06-26 "Linux" "Linux Programmer's Manual"
57 .\"O setbuf, setbuffer, setlinebuf, setvbuf \- stream buffering operations
59 setbuf, setbuffer, setlinebuf, setvbuf \- ストリームのバッファリングの操作
65 .BI "void setbuf(FILE *" stream ", char *" buf );
67 .BI "void setbuffer(FILE *" stream ", char *" buf ", size_t " size );
69 .BI "void setlinebuf(FILE *" stream );
71 .BI "int setvbuf(FILE *" stream ", char *" buf ", int " mode \
76 .\"O Feature Test Macro Requirements for glibc (see
77 .\"O .BR feature_test_macros (7)):
79 .RB ( feature_test_macros (7)
87 .\"O The three types of buffering available are unbuffered, block buffered, and
89 .\"O When an output stream is unbuffered, information appears on
90 .\"O the destination file or terminal as soon as written; when it is block
91 .\"O buffered many characters are saved up and written as a block; when it is
92 .\"O line buffered characters are saved up until a newline is output or input is
93 .\"O read from any stream attached to a terminal device (typically \fIstdin\fP).
96 .\"O may be used to force the block out early.
99 .\"O Normally all files are block buffered.
100 .\"O When the first I/O operation occurs
103 .\"O is called, and a buffer is obtained.
104 .\"O If a stream refers to a terminal (as
106 .\"O normally does) it is line buffered.
107 .\"O The standard error stream
109 .\"O is always unbuffered by default.
111 バッファリングには unbuffered, block buffered, line buffered の3つのタイプが
112 ある。出力ストリームのタイプが unbuffered の場合、データを書き込むとすぐに出
113 力先ファイルに書き込まれるかターミナルに表示される。block buffered の場合、文
114 字の読み書きはブロック単位でいっぺんに行われる。line buffered の場合、
115 新しい行が出力されるか、ターミナルデバイスに接続しているストリーム
116 (通常、\fIstdin\fP) から新しい行が入力されるまで文字がたくわえられる。
121 を参照のこと) 通常、ファイルはすべて block buffered である。ファイルに対して
124 が呼び出されバッファが獲得される。もし ストリームが (通常、
126 がそうであるように) ターミナルを参照する場合には、ファイルは line buffered と
129 はデフォルトでは常に unbuffered である。
133 .\"O function may be used on any open stream to change its buffer.
135 関数は、オープンしている任意のストリームに対してバッファを変更できる。
138 .\"O argument must be one of the following three macros:
141 は、次の 3 つのマクロのうちいずれかである:
154 .\"O Except for unbuffered files, the
156 .\"O argument should point to a buffer at least
158 .\"O bytes long; this buffer will be used instead of the current buffer.
162 .\"O only the mode is affected; a new buffer will be allocated on the next read
163 .\"O or write operation.
166 .\"O function may only be used after opening a stream and before any other
167 .\"O operations have been performed on it.
172 バイト以上の大きさのバッファを指していなければならない。このバッファは現在の
175 が NULL ならば、モードだけが変更される。
176 新しいバッファは次に読み書きした際に割り当てられる。
179 そのストリームに対して何らかの操作をする前にのみ使用できる。
181 .\"O The other three calls are, in effect, simply aliases for calls to
185 .\"O function is exactly equivalent to the call
188 .\"O setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
192 .\"O .BR setbuffer ()
193 .\"O function is the same, except that the size of the buffer is up to the
194 .\"O caller, rather than being determined by the default
197 .\"O .BR setlinebuf ()
198 .\"O function is exactly equivalent to the call:
201 .\"O setvbuf(stream, (char *) NULL, _IOLBF, 0);
205 の呼び出しに単純に置き換えることができる。
210 setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
217 ではなく引数で与えられる点以外は同じである。
222 setvbuf(stream, (char *) NULL, _IOLBF, 0);
226 .\"O .SH "RETURN VALUE"
230 .\"O returns 0 on success.
231 .\"O It returns nonzero on failure
233 .\"O is invalid or the request cannot be honored).
242 が不正な場合またはリクエストが条件を満たさない場合である)。
248 .\"O The other functions do not return a value.
250 .\"O .SH "CONFORMING TO"
256 .\"O functions conform to C89 and C99.
260 関数は C89 と C99 に準拠している。
264 .\"O .BR setbuffer ()
266 .\"O .BR setlinebuf ()
267 .\"O functions are not portable to versions of BSD before 4.2BSD, and may not be
268 .\"O available under Linux.
269 .\"O On 4.2BSD and 4.3BSD systems,
271 .\"O always uses a suboptimal buffer size and should be avoided.
275 関数は 4.2BSD より前の BSD とは互換性がない。また Linux でも(古いバージョン
276 では)利用できないかもしれない。4.2BSD および 4.3BSD のシステムでは
278 は必ず追加のバッファーのサイズを使用するので、これも使うべきでない。
280 .\"O You must make sure that the space that
282 .\"O points to still exist by the time
284 .\"O is closed, which also happens at program termination.
285 .\"O For example, the following is invalid:
287 を閉じる時 (プログラムを終了する際にもこれは起きる) には、
289 が指し示す空間とが存在していることを保証しなければならない。
300 printf("Hello, world!\\n");