logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

setvbuf.3p (3721B)


  1. '\" et
  2. .TH SETVBUF "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. setvbuf
  12. \(em assign buffering to a stream
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <stdio.h>
  17. .P
  18. int setvbuf(FILE *restrict \fIstream\fP, char *restrict \fIbuf\fP, int \fItype\fP,
  19. size_t \fIsize\fP);
  20. .fi
  21. .SH DESCRIPTION
  22. The functionality described on this reference page is aligned with the
  23. ISO\ C standard. Any conflict between the requirements described here and the
  24. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  25. .P
  26. The
  27. \fIsetvbuf\fR()
  28. function may be used after the stream pointed to by
  29. .IR stream
  30. is associated with an open file but before any other operation
  31. (other than an unsuccessful call to
  32. \fIsetvbuf\fR())
  33. is performed on the stream. The argument
  34. .IR type
  35. determines how
  36. .IR stream
  37. shall be buffered, as follows:
  38. .IP " *" 4
  39. {_IOFBF} shall cause input/output to be fully buffered.
  40. .IP " *" 4
  41. {_IOLBF} shall cause input/output to be line buffered.
  42. .IP " *" 4
  43. {_IONBF} shall cause input/output to be unbuffered.
  44. .P
  45. If
  46. .IR buf
  47. is not a null pointer, the array it points to may be used instead of a
  48. buffer allocated by
  49. \fIsetvbuf\fR()
  50. and the argument
  51. .IR size
  52. specifies the size of the array; otherwise,
  53. .IR size
  54. may determine the size of a buffer allocated by the
  55. \fIsetvbuf\fR()
  56. function. The contents of the array at any time are unspecified.
  57. .P
  58. For information about streams, see
  59. .IR "Section 2.5" ", " "Standard I/O Streams".
  60. .SH "RETURN VALUE"
  61. Upon successful completion,
  62. \fIsetvbuf\fR()
  63. shall return 0. Otherwise, it shall return a non-zero value if an
  64. invalid value is given for
  65. .IR type
  66. or if the request cannot be honored,
  67. and may set
  68. .IR errno
  69. to indicate the error.
  70. .SH ERRORS
  71. The
  72. \fIsetvbuf\fR()
  73. function may fail if:
  74. .TP
  75. .BR EBADF
  76. The file descriptor underlying
  77. .IR stream
  78. is not valid.
  79. .LP
  80. .IR "The following sections are informative."
  81. .SH EXAMPLES
  82. None.
  83. .SH "APPLICATION USAGE"
  84. A common source of error is allocating buffer space as an ``automatic''
  85. variable in a code block, and then failing to close the stream in the
  86. same block.
  87. .P
  88. With
  89. \fIsetvbuf\fR(),
  90. allocating a buffer of
  91. .IR size
  92. bytes does not necessarily imply that all of
  93. .IR size
  94. bytes are used for the buffer area.
  95. .P
  96. Applications should note that many implementations only provide line
  97. buffering on input from terminal devices.
  98. .SH RATIONALE
  99. None.
  100. .SH "FUTURE DIRECTIONS"
  101. None.
  102. .SH "SEE ALSO"
  103. .IR "Section 2.5" ", " "Standard I/O Streams",
  104. .IR "\fIfopen\fR\^(\|)",
  105. .IR "\fIsetbuf\fR\^(\|)"
  106. .P
  107. The Base Definitions volume of POSIX.1\(hy2017,
  108. .IR "\fB<stdio.h>\fP"
  109. .\"
  110. .SH COPYRIGHT
  111. Portions of this text are reprinted and reproduced in electronic form
  112. from IEEE Std 1003.1-2017, Standard for Information Technology
  113. -- Portable Operating System Interface (POSIX), The Open Group Base
  114. Specifications Issue 7, 2018 Edition,
  115. Copyright (C) 2018 by the Institute of
  116. Electrical and Electronics Engineers, Inc and The Open Group.
  117. In the event of any discrepancy between this version and the original IEEE and
  118. The Open Group Standard, the original IEEE and The Open Group Standard
  119. is the referee document. The original Standard can be obtained online at
  120. http://www.opengroup.org/unix/online.html .
  121. .PP
  122. Any typographical or formatting errors that appear
  123. in this page are most likely
  124. to have been introduced during the conversion of the source files to
  125. man page format. To report such errors, see
  126. https://www.kernel.org/doc/man-pages/reporting_bugs.html .