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 setbuf, setbuffer, setlinebuf, setvbuf \- ストリームのバッファリングの操作
62 .BI "void setbuf(FILE *" stream ", char *" buf );
64 .BI "void setbuffer(FILE *" stream ", char *" buf ", size_t " size );
66 .BI "void setlinebuf(FILE *" stream );
68 .BI "int setvbuf(FILE *" stream ", char *" buf ", int " mode \
74 .RB ( feature_test_macros (7)
82 バッファリングには unbuffered, block buffered, line buffered の3つのタイプが
83 ある。出力ストリームのタイプが unbuffered の場合、データを書き込むとすぐに出
84 力先ファイルに書き込まれるかターミナルに表示される。block buffered の場合、文
85 字の読み書きはブロック単位でいっぺんに行われる。line buffered の場合、
86 新しい行が出力されるか、ターミナルデバイスに接続しているストリーム
87 (通常、\fIstdin\fP) から新しい行が入力されるまで文字がたくわえられる。
92 を参照のこと) 通常、ファイルはすべて block buffered である。ファイルに対して
95 が呼び出されバッファが獲得される。もし ストリームが (通常、
97 がそうであるように) ターミナルを参照する場合には、ファイルは line buffered と
100 はデフォルトでは常に unbuffered である。
103 関数は、オープンしている任意のストリームに対してバッファを変更できる。
106 は、次の 3 つのマクロのうちいずれかである:
123 バイト以上の大きさのバッファを指していなければならない。このバッファは現在の
126 が NULL ならば、モードだけが変更される。
127 新しいバッファは次に読み書きした際に割り当てられる。
130 そのストリームに対して何らかの操作をする前にのみ使用できる。
134 の呼び出しに単純に置き換えることができる。
139 setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
146 ではなく引数で与えられる点以外は同じである。
151 setvbuf(stream, (char *) NULL, _IOLBF, 0);
161 が不正な場合またはリクエストが条件を満たさない場合である)。
172 関数は C89 と C99 に準拠している。
177 関数は 4.2BSD より前の BSD とは互換性がない。また Linux でも(古いバージョン
178 では)利用できないかもしれない。4.2BSD および 4.3BSD のシステムでは
180 は必ず追加のバッファーのサイズを使用するので、これも使うべきでない。
183 を閉じる時 (プログラムを終了する際にもこれは起きる) には、
185 が指し示す空間とが存在していることを保証しなければならない。
196 printf("Hello, world!\\n");