File: jose_io.3

package info (click to toggle)
jose 10-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 2,772 kB
  • sloc: ansic: 9,696; sh: 4,816; makefile: 157
file content (219 lines) | stat: -rw-r--r-- 5,982 bytes parent folder | download | duplicates (4)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
.TH "jose_io" 3 "Tue May 30 2017" "José" \" -*- nroff -*-
.ad l
.nh
.SH NAME
jose_io \- IO Chaining\&.  

.SH SYNOPSIS
.br
.PP
.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBjose_io_t\fP"
.br
.RI "The interface for chained IO\&. "
.in -1c
.SS "Typedefs"

.in +1c
.ti -1c
.RI "typedef \fBjose_io_t\fP \fBjose_io_auto_t\fP"
.br
.RI "Defines a \fBjose_io_t\fP which calls \fBjose_io_decref()\fP at end of scope\&. "
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "\fBjose_io_t\fP * \fBjose_io_incref\fP (\fBjose_io_t\fP *io)"
.br
.RI "Increases the reference count of an IO object\&. "
.ti -1c
.RI "void \fBjose_io_decref\fP (\fBjose_io_t\fP *io)"
.br
.RI "Decreases the reference count of an IO object\&. "
.ti -1c
.RI "\fBjose_io_t\fP * \fBjose_io_malloc\fP (jose_cfg_t *cfg, void **buf, size_t *len)"
.br
.RI "Creates a new IO object which collects data into a dynamic buffer\&. "
.ti -1c
.RI "void * \fBjose_io_malloc_steal\fP (void **buf)"
.br
.RI "Steals the buffer created by the \fBjose_io_malloc()\fP IO object\&. "
.ti -1c
.RI "\fBjose_io_t\fP * \fBjose_io_buffer\fP (jose_cfg_t *cfg, void *buf, size_t *len)"
.br
.RI "Creates a new IO object which collects data into a static buffer\&. "
.ti -1c
.RI "\fBjose_io_t\fP * \fBjose_io_file\fP (jose_cfg_t *cfg, FILE *file)"
.br
.RI "Creates a new IO object which writes data into a FILE\&. "
.ti -1c
.RI "\fBjose_io_t\fP * \fBjose_io_multiplex\fP (jose_cfg_t *cfg, \fBjose_io_t\fP **nexts, bool all)"
.br
.RI "Creates a new IO object which multiplexes data into multiple IO objects\&. "
.in -1c
.SH "Detailed Description"
.PP 
IO Chaining\&. 


.SH "Typedef Documentation"
.PP 
.SS "typedef \fBjose_io_t\fP \fBjose_io_auto_t\fP"

.PP
Defines a \fBjose_io_t\fP which calls \fBjose_io_decref()\fP at end of scope\&. For example: 
.PP
.nf
void foo() {
    uint8_t *buf = NULL;
    size_t len = 0;
    jose_io_auto_t *io = jose_io_malloc(NULL, &buf, &len);
    // jose_io_decref() implicitly called
}
.fi
.PP
 
.SH "Function Documentation"
.PP 
.SS "\fBjose_io_t\fP* jose_io_incref (\fBjose_io_t\fP * io)"

.PP
Increases the reference count of an IO object\&. This function always succeeds\&.
.PP
\fBParameters:\fP
.RS 4
\fIio\fP The \fBjose_io_t\fP entity you are using\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
The value of \fCio\fP (for convenience)\&. 
.RE
.PP

.SS "void jose_io_decref (\fBjose_io_t\fP * io)"

.PP
Decreases the reference count of an IO object\&. When the reference count reaches zero, io->free() is called\&.
.PP
\fBParameters:\fP
.RS 4
\fIio\fP The \fBjose_io_t\fP entity you are using\&. 
.RE
.PP

.SS "\fBjose_io_t\fP* jose_io_malloc (jose_cfg_t * cfg, void ** buf, size_t * len)"

.PP
Creates a new IO object which collects data into a dynamic buffer\&. The dynamic buffer is allocated into the \fCbuf\fP pointer you provided and the length of the buffer is stored in \fClen\fP\&. The pointer referenced by \fCbuf\fP must remain valid for the entire duration of the returned IO object\&.
.PP
The default behavior is for the IO object to zero and free the buffer when it is freed\&. This means that, by default, you own the buffer pointer but the buffer itself is owned by the IO object\&. You can, however, steal the buffer by setting the buffer pointer to NULL\&.
.PP
\fBSee also:\fP
.RS 4
\fBjose_io_malloc_steal()\fP 
.RE
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP The configuration context (optional)\&. 
.br
\fIbuf\fP A buffer pointer pointer\&. 
.br
\fIlen\fP A pointer to the length of the buffer\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
The new IO object or NULL on error\&. 
.RE
.PP

.SS "void* jose_io_malloc_steal (void ** buf)"

.PP
Steals the buffer created by the \fBjose_io_malloc()\fP IO object\&. This convenience function simply returns the value of \fC*buf\fP and then sets \fC*buf\fP to NULL\&.
.PP
\fBSee also:\fP
.RS 4
\fBjose_io_malloc()\fP 
.RE
.PP
\fBParameters:\fP
.RS 4
\fIbuf\fP A pointer to the buffer pointer\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
The value of \fC*buf\fP before it is set to NULL\&. 
.RE
.PP

.SS "\fBjose_io_t\fP* jose_io_buffer (jose_cfg_t * cfg, void * buf, size_t * len)"

.PP
Creates a new IO object which collects data into a static buffer\&. The size of \fCbuf\fP MUST be specified in the variable pointed to by \fClen\fP\&. This will be the maximum data written\&. However, after the function returns, the variable pointed to by \fClen\fP will contain the current length of data in the buffer\&.
.PP
Unlike \fBjose_io_malloc()\fP, you own the buffer and it is not zeroed or freed when the IO object is freed\&.
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP The configuration context (optional)\&. 
.br
\fIbuf\fP A buffer pointer\&. 
.br
\fIlen\fP A pointer to the length of the buffer\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
The new IO object or NULL on error\&. 
.RE
.PP

.SS "\fBjose_io_t\fP* jose_io_file (jose_cfg_t * cfg, FILE * file)"

.PP
Creates a new IO object which writes data into a FILE\&. This function DOES NOT take ownership of the FILE\&. You are still responsible for calling fclose() at the appropriate time\&.
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP The configuration context (optional)\&. 
.br
\fIfile\fP The output file which MUST be opened for writing or appending\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
The new IO object or NULL on error\&. 
.RE
.PP

.SS "\fBjose_io_t\fP* jose_io_multiplex (jose_cfg_t * cfg, \fBjose_io_t\fP ** nexts, bool all)"

.PP
Creates a new IO object which multiplexes data into multiple IO objects\&. If \fCall\fP is true, the success of all \fCnexts\fP is required\&. Otherwise, all but one of the \fCnexts\fP can fail before the error is propagated upward\&.
.PP
\fBParameters:\fP
.RS 4
\fIcfg\fP The configuration context (optional)\&. 
.br
\fInexts\fP A NULL-terminated array of IO object pointers\&. 
.br
\fIall\fP Whether or not the success of all \fCnexts\fP is required\&. 
.RE
.PP
\fBReturns:\fP
.RS 4
The new IO object or NULL on error\&. 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for José from the source code\&.