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

fgetc.3p (5119B)


  1. '\" et
  2. .TH FGETC "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. fgetc
  12. \(em get a byte from a stream
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <stdio.h>
  17. .P
  18. int fgetc(FILE *\fIstream\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The functionality described on this reference page is aligned with the
  22. ISO\ C standard. Any conflict between the requirements described here and the
  23. ISO\ C standard is unintentional. This volume of POSIX.1\(hy2017 defers to the ISO\ C standard.
  24. .P
  25. If the end-of-file indicator for the input stream pointed to by
  26. .IR stream
  27. is not set and a next byte is present, the
  28. \fIfgetc\fR()
  29. function shall obtain the next byte as an
  30. .BR "unsigned char"
  31. converted to an
  32. .BR int ,
  33. from the input stream pointed to by
  34. .IR stream ,
  35. and advance the associated file position indicator for the stream (if
  36. defined). Since
  37. \fIfgetc\fR()
  38. operates on bytes, reading a character consisting of multiple bytes (or
  39. ``a multi-byte character'') may require multiple calls to
  40. \fIfgetc\fR().
  41. .P
  42. The
  43. \fIfgetc\fR()
  44. function may mark the last data access timestamp of the file
  45. associated with
  46. .IR stream
  47. for update. The last data access timestamp shall be marked for
  48. update by the first successful execution of
  49. \fIfgetc\fR(),
  50. \fIfgets\fR(),
  51. \fIfread\fR(),
  52. \fIfscanf\fR(),
  53. \fIgetc\fR(),
  54. \fIgetchar\fR(),
  55. \fIgetdelim\fR(),
  56. \fIgetline\fR(),
  57. \fIgets\fR(),
  58. or
  59. \fIscanf\fR()
  60. using
  61. .IR stream
  62. that returns data not supplied by a prior call to
  63. \fIungetc\fR().
  64. .SH "RETURN VALUE"
  65. Upon successful completion,
  66. \fIfgetc\fR()
  67. shall return the next byte from the input stream pointed to by
  68. .IR stream .
  69. If the end-of-file indicator for the stream is set, or if the
  70. stream is at end-of-file, the end-of-file indicator for the
  71. stream shall be set and
  72. \fIfgetc\fR()
  73. shall return EOF. If a read error occurs, the error indicator for the
  74. stream shall be set,
  75. \fIfgetc\fR()
  76. shall return EOF,
  77. and shall set
  78. .IR errno
  79. to indicate the error.
  80. .SH ERRORS
  81. The
  82. \fIfgetc\fR()
  83. function shall fail if data needs to be read and:
  84. .TP
  85. .BR EAGAIN
  86. The O_NONBLOCK flag is set for the file descriptor underlying
  87. .IR stream
  88. and the thread would be delayed in the
  89. \fIfgetc\fR()
  90. operation.
  91. .TP
  92. .BR EBADF
  93. The file descriptor underlying
  94. .IR stream
  95. is not a valid file descriptor open for reading.
  96. .TP
  97. .BR EINTR
  98. The read operation was terminated due to the receipt of a signal, and
  99. no data was transferred.
  100. .TP
  101. .BR EIO
  102. A physical I/O error has occurred, or the process is in a background
  103. process group attempting to read from its controlling terminal, and
  104. either the calling thread is blocking SIGTTIN or the process is ignoring
  105. SIGTTIN or the process group of the process is orphaned.
  106. This error may also be generated for implementation-defined reasons.
  107. .TP
  108. .BR EOVERFLOW
  109. The file is a regular file and an attempt was made to read at or beyond
  110. the offset maximum associated with the corresponding stream.
  111. .P
  112. The
  113. \fIfgetc\fR()
  114. function may fail if:
  115. .TP
  116. .BR ENOMEM
  117. Insufficient storage space is available.
  118. .TP
  119. .BR ENXIO
  120. A request was made of a nonexistent device, or the request was outside
  121. the capabilities of the device.
  122. .LP
  123. .IR "The following sections are informative."
  124. .SH EXAMPLES
  125. None.
  126. .SH "APPLICATION USAGE"
  127. If the integer value returned by
  128. \fIfgetc\fR()
  129. is stored into a variable of type
  130. .BR char
  131. and then compared against the integer constant EOF, the comparison may
  132. never succeed, because sign-extension of a variable of type
  133. .BR char
  134. on widening to integer is implementation-defined.
  135. .P
  136. The
  137. \fIferror\fR()
  138. or
  139. \fIfeof\fR()
  140. functions must be used to distinguish between an error condition and an
  141. end-of-file condition.
  142. .SH RATIONALE
  143. None.
  144. .SH "FUTURE DIRECTIONS"
  145. None.
  146. .SH "SEE ALSO"
  147. .IR "Section 2.5" ", " "Standard I/O Streams",
  148. .IR "\fIfeof\fR\^(\|)",
  149. .IR "\fIferror\fR\^(\|)",
  150. .IR "\fIfgets\fR\^(\|)",
  151. .IR "\fIfread\fR\^(\|)",
  152. .IR "\fIfscanf\fR\^(\|)",
  153. .IR "\fIgetchar\fR\^(\|)",
  154. .IR "\fIgetc\fR\^(\|)",
  155. .IR "\fIgets\fR\^(\|)",
  156. .IR "\fIungetc\fR\^(\|)"
  157. .P
  158. The Base Definitions volume of POSIX.1\(hy2017,
  159. .IR "\fB<stdio.h>\fP"
  160. .\"
  161. .SH COPYRIGHT
  162. Portions of this text are reprinted and reproduced in electronic form
  163. from IEEE Std 1003.1-2017, Standard for Information Technology
  164. -- Portable Operating System Interface (POSIX), The Open Group Base
  165. Specifications Issue 7, 2018 Edition,
  166. Copyright (C) 2018 by the Institute of
  167. Electrical and Electronics Engineers, Inc and The Open Group.
  168. In the event of any discrepancy between this version and the original IEEE and
  169. The Open Group Standard, the original IEEE and The Open Group Standard
  170. is the referee document. The original Standard can be obtained online at
  171. http://www.opengroup.org/unix/online.html .
  172. .PP
  173. Any typographical or formatting errors that appear
  174. in this page are most likely
  175. to have been introduced during the conversion of the source files to
  176. man page format. To report such errors, see
  177. https://www.kernel.org/doc/man-pages/reporting_bugs.html .