summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/__fpending.3
blob: c0a58ddd6e8151f1ded4c463acefb6aa9b077b33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.\"	$OpenBSD: __fpending.3,v 1.1 2024/08/12 20:56:55 guenther Exp $
.\"
.\" Copyright (c) 2024 Philip Guenther <guenther@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: August 12 2024 $
.Dt __FPENDING 3
.Os
.Sh NAME
.Nm __fpending ,
.Nm __freadahead ,
.Nm __freading ,
.Nm __freadptr ,
.Nm __freadptrinc ,
.Nm __fseterr ,
.Nm __fwriting
.Nd stream extension functions
.Sh SYNOPSIS
.In stdio_ext.h
.Ft size_t
.Fn __fpending "FILE *stream"
.Ft size_t
.Fn __freadahead "FILE *stream"
.Ft int
.Fn __freading "FILE *stream"
.Ft "const char *"
.Fn __freadptr "FILE *stream" "size_t *sizep"
.Ft void
.Fn __freadptrinc "FILE *stream" "size_t increment"
.Ft void
.Fn __fseterr "FILE *stream"
.Ft int
.Fn __fwriting "FILE *stream"
.Sh DESCRIPTION
The
.Fn __fpending
function returns the number of bytes of output data currently
buffered on
.Fa stream .
.Pp
The
.Fn __freadahead
function returns the number of bytes of input data currently
buffered on
.Fa stream .
.Pp
The
.Fn __freading
function returns non-zero if
.Fa stream
either was opened read-only or if the last operation on the stream
was a read or push-back operation.
.Pp
The
.Fn __freadptr
function returns either a pointer to the next byte of buffered input
data on
.Fa stream
and stores the number of consecutive bytes of buffered data available
to the location pointed to by
.Fa sizep ,
or return
.Dv NULL
if there's no buffered input data.
The value returned via
.Fa sizep
may differ from the value that would be returned by
.Fn __freadahead .
.Pp
The
.Fn __freadptrinc
function consumes
.Fa increment
bytes of buffered input data on
.Fa stream .
This is only valid immediately after a non-NULL return from
.Fn __freadptr
and
.Fa increment
must not be greater than the size value from that call.
.Pp
The
.Fn __fseterr
function sets the error indicator for
.Fa stream .
.Pp
The
.Fn __fwriting
function returns non-zero if
.Fa stream
either was opened write-only or append-only or if the last operation
on the stream was a write operation.
.Sh ERRORS
These functions should not fail and do not set the external
variable
.Va errno .
.Sh SEE ALSO
.Xr fflush 3
.Sh HISTORY
The
.Fn __fpending ,
.Fn __freadahead ,
.Fn __freading ,
.Fn __freadptr ,
.Fn __freadptrinc ,
.Fn __fseterr ,
.Fn __fwriting
and
functions appeared in
.Ox 7.6 .
.Sh BUGS
These functions are under-specified and non-portable.
They exist to permit a particular
.Dq portability
library to function without direct manipulation of stdio structures;
everyone else should either implement their own stdio layer,
do the work of defining and standardizing the required functionality,
or reconsider their life decisions.