162 lines
5.9 KiB
HTML
162 lines
5.9 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>setvbuf</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="setvbuf"></a> <a name="tag_03_672"></a><!-- setvbuf -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_672_01"></a>NAME</h4>
|
|
|
|
<blockquote>setvbuf - assign buffering to a stream</blockquote>
|
|
|
|
<h4><a name="tag_03_672_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>#include <<a href="../basedefs/stdio.h.html">stdio.h</a>><br>
|
|
<br>
|
|
int setvbuf(FILE *restrict</tt> <i>stream</i><tt>, char *restrict</tt> <i>buf</i><tt>, int</tt> <i>type</i><tt>,<br>
|
|
size_t</tt> <i>size</i><tt>);<br>
|
|
</tt></code></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"
|
|
border="0"> The functionality described on this reference page is aligned with the ISO C standard. Any conflict between the
|
|
requirements described here and the ISO C standard is unintentional. This volume of IEEE Std 1003.1-2001 defers to
|
|
the ISO C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div>
|
|
|
|
<p>The <i>setvbuf</i>() function may be used after the stream pointed to by <i>stream</i> is associated with an open file but
|
|
before any other operation (other than an unsuccessful call to <i>setvbuf</i>()) is performed on the stream. The argument
|
|
<i>type</i> determines how <i>stream</i> shall be buffered, as follows:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>{_IOFBF} shall cause input/output to be fully buffered.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>{_IOLBF} shall cause input/output to be line buffered.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>{_IONBF} shall cause input/output to be unbuffered.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>If <i>buf</i> is not a null pointer, the array it points to may be used instead of a buffer allocated by <i>setvbuf</i>() and
|
|
the argument <i>size</i> specifies the size of the array; otherwise, <i>size</i> may determine the size of a buffer allocated by
|
|
the <i>setvbuf</i>() function. The contents of the array at any time are unspecified.</p>
|
|
|
|
<p>For information about streams, see <a href="xsh_chap02_05.html#tag_02_05"><i>Standard I/O Streams</i></a> .</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>setvbuf</i>() shall return 0. Otherwise, it shall return a non-zero value if an invalid value is
|
|
given for <i>type</i> or if the request cannot be honored, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src=
|
|
"../images/opt-start.gif" alt="[Option Start]" border="0"> and may set <i>errno</i> to indicate the error. <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>setvbuf</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EBADF]</dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
The file descriptor underlying <i>stream</i> is not valid. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_672_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>A common source of error is allocating buffer space as an "automatic" variable in a code block, and then failing to close the
|
|
stream in the same block.</p>
|
|
|
|
<p>With <i>setvbuf</i>(), allocating a buffer of <i>size</i> bytes does not necessarily imply that all of <i>size</i> bytes are
|
|
used for the buffer area.</p>
|
|
|
|
<p>Applications should note that many implementations only provide line buffering on input from terminal devices.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="xsh_chap02_05.html#tag_02_05"><i>Standard I/O Streams</i></a> , <a href="fopen.html"><i>fopen</i>()</a> , <a href=
|
|
"setbuf.html"><i>setbuf</i>()</a> , the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/stdio.h.html"><i><stdio.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 1. Derived from Issue 1 of the SVID.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_672_12"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>Extensions beyond the ISO C standard are marked.</p>
|
|
|
|
<p>The <i>setvbuf</i>() prototype is updated for alignment with the ISO/IEC 9899:1999 standard.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|