This file is indexed.

/usr/include/fstrm/rdwr.h is in libfstrm-dev 0.2.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/*
 * Copyright (c) 2014 by Farsight Security, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef FSTRM_RDWR_H
#define FSTRM_RDWR_H

/**
 * \defgroup fstrm_rdwr fstrm_rdwr
 *
 * `fstrm_rdwr` is an interface for abstracting the process of reading and
 * writing data to byte streams. It allows extending the `fstrm` library to
 * support reading and writing Frame Streams data to new kinds of byte stream
 * transports. (It also allows building mock interfaces for testing the correct
 * functioning of the library.)
 *
 * `fstrm_rdwr` is a low-level interface that is used in conjunction with the
 * higher level \ref fstrm_reader and \ref fstrm_writer interfaces. The
 * following methods need to be defined for `fstrm_rdwr` implementations:
 *
 * Method name  | Method type                   | Method description
 * ------------ | ----------------------------- | ------------------
 * `destroy`    | #fstrm_rdwr_destroy_func      | Destroys the instance.
 * `open`       | #fstrm_rdwr_open_func         | Opens the stream.
 * `close`      | #fstrm_rdwr_close_func        | Closes the stream.
 * `read`       | #fstrm_rdwr_read_func         | Reads bytes from the stream.
 * `write`      | #fstrm_rdwr_write_func        | Writes bytes to the stream.
 *
 * The `destroy` method is optional. It cleans up any remaining resources
 * associated with the instance.
 *
 * The `open` method is required. It should perform the actual opening of the
 * byte stream and prepare it to read or write data.
 *
 * The `close` method is required. It should perform the actual closing of the
 * byte stream.
 *
 * If the `fstrm_rdwr` object is to be used in an `fstrm_reader` object, it must
 * have a `read` method. If the `fstrm_rdwr` object embedded in an
 * `fstrm_reader` object also has a `write` method, the stream will be
 * considered bi-directional (that is, it supports both reading and writing) and
 * handshaking will be performed. If a `read` method is supplied but a `write`
 * method is not, the reader's stream will instead be considered
 * uni-directional. See \ref fstrm_reader for details.
 *
 * If the `fstrm_rdwr` object is to be used in an `fstrm_writer` object, it must
 * have a `write` method. If the `fstrm_rdwr` object embedded in an
 * `fstrm_writer` object also has a `read` method, the stream will be considered
 * bi-directional and shaking will be performed. If a `write` method is supplied
 * but a `read` method is not, the writer's stream will instead be considered
 * uni-directional. See \ref fstrm_writer for details.
 *
 * An `fstrm_rdwr` instance is created with a call to `fstrm_rdwr_init()`,
 * optionally passing a pointer to some state object associated with the
 * instance. This pointer will be passed as the first argument to each of the
 * methods described above. Then, the various `fstrm_rdwr_set_*()` functions
 * should be used to configure the functions to be used to invoke the methods
 * required for the `fstrm_rdwr` object.
 *
 * @{
 */

/**
 * `destroy` method function type. This method is invoked to deallocate any
 * per-stream resources used by an `fstrm_rdwr` implementation.
 *
 * \see fstrm_rdwr_set_destroy()
 *
 * \param obj
 *      The `obj` value passed to `fstrm_rdwr_init()`.
 *
 * \retval #fstrm_res_success
 * \retval #fstrm_res_failure
 */
typedef fstrm_res
(*fstrm_rdwr_destroy_func)(void *obj);

/**
 * `open` method function type. This method is invoked to open the stream and
 * prepare it for reading or writing. For example, if an `fstrm_rdwr`
 * implementation is backed by file I/O, this method might be responsible for
 * opening a file descriptor.
 *
 * \see fstrm_rdwr_set_open()
 *
 * \param obj
 *      The `obj` value passed to `fstrm_rdwr_init()`.
 *
 * \retval #fstrm_res_success
 * \retval #fstrm_res_failure
 */
typedef fstrm_res
(*fstrm_rdwr_open_func)(void *obj);

/**
 * `close` method function type. This method is invoked to close the stream. For
 * example, if an `fstrm_rdwr` implementation is backed by file I/O, this method
 * might be responsible for closing a file descriptor.
 *
 * \see fstrm_rdwr_set_close()
 *
 * \param obj
 *      The `obj` value passed to `fstrm_rdwr_init()`.
 *
 * \retval #fstrm_res_success
 * \retval #fstrm_res_failure
 */
typedef fstrm_res
(*fstrm_rdwr_close_func)(void *obj);

/**
 * `read` method function type. This method is used to read data from a stream.
 * It must satisfy the full amount of data requested, unless the stream has
 * ended.
 *
 * \see fstrm_rdwr_set_read()
 *
 * \param obj
 *      The `obj` value passed to `fstrm_rdwr_init()`.
 * \param data
 *      The buffer in which to place the data read.
 * \param count
 *      The number of bytes requested.
 *
 * \retval #fstrm_res_success
 *      The data was read successfully.
 * \retval #fstrm_res_failure
 *      An unexpected failure occurred.
 * \retval #fstrm_res_stop
 *      The end of the stream has occurred.
 */
typedef fstrm_res
(*fstrm_rdwr_read_func)(void *obj, void *data, size_t count);

/**
 * `write` method function type. This method is used to write data to a stream.
 * It must perform the full write of all data, unless an error has occurred.
 *
 * \see fstrm_rdwr_set_write()
 *
 * \param obj
 *      The `obj` value passed to `fstrm_rdwr_init()`.
 * \param iov
 *      Array of `struct iovec` objects.
 * \param iovcnt
 *      Number of `struct iovec` objects in `iov`.
 *
 * \return #fstrm_res_success
 * \return #fstrm_res_failure
 */
typedef fstrm_res
(*fstrm_rdwr_write_func)(void *obj, const struct iovec *iov, int iovcnt);

/**
 * Initialize a new `fstrm_rdwr` object.
 *
 * \param obj
 *      Per-object state.
 *
 * \return
 *      `fstrm_rdwr` object.
 * \retval
 *      NULL on failure.
 */
struct fstrm_rdwr *
fstrm_rdwr_init(void *obj);

/**
 * Destroy an `fstrm_rdwr` object. This invokes the underlying `destroy` method
 * as well.
 *
 * \param rdwr
 *      Pointer to an `fstrm_rdwr` object.
 *
 * \return #fstrm_res_success
 * \return #fstrm_res_failure
 */
fstrm_res
fstrm_rdwr_destroy(struct fstrm_rdwr **rdwr);

/**
 * Invoke the `open` method on an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 *
 * \return #fstrm_res_success
 * \return #fstrm_res_failure
 */
fstrm_res
fstrm_rdwr_open(struct fstrm_rdwr *rdwr);

/**
 * Invoke the `close` method on an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 *
 * \return #fstrm_res_success
 * \return #fstrm_res_failure
 */
fstrm_res
fstrm_rdwr_close(struct fstrm_rdwr *rdwr);

/**
 * Invoke the `read` method on an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param data
 *      The buffer in which to place the data read.
 * \param count
 *      The number of bytes to read.
 *
 * \return #fstrm_res_success
 * \return #fstrm_res_failure
 * \return #fstrm_res_stop
 */
fstrm_res
fstrm_rdwr_read(struct fstrm_rdwr *rdwr, void *data, size_t count);

/**
 * Invoke the `write` method on an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param iov
 *      Array of `struct iovec` objects.
 * \param iovcnt
 *      Number of `struct iovec` objects in `iov`.
 *
 * \return #fstrm_res_success
 * \return #fstrm_res_failure
 */
fstrm_res
fstrm_rdwr_write(struct fstrm_rdwr *rdwr, const struct iovec *iov, int iovcnt);

/**
 * Set the `destroy` method for an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param fn
 *      Function to use.
 */
void
fstrm_rdwr_set_destroy(
	struct fstrm_rdwr *rdwr,
	fstrm_rdwr_destroy_func fn);

/**
 * Set the `open` method for an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param fn
 *      Function to use.
 */
void
fstrm_rdwr_set_open(
	struct fstrm_rdwr *rdwr,
	fstrm_rdwr_open_func fn);

/**
 * Set the `close` method for an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param fn
 *      Function to use.
 */
void
fstrm_rdwr_set_close(
	struct fstrm_rdwr *rdwr,
	fstrm_rdwr_close_func fn);

/**
 * Set the `read` method for an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param fn
 *      Function to use.
 */
void
fstrm_rdwr_set_read(
	struct fstrm_rdwr *rdwr,
	fstrm_rdwr_read_func fn);

/**
 * Set the `write` method for an `fstrm_rdwr` object.
 *
 * \param rdwr
 *      The `fstrm_rdwr` object.
 * \param fn
 *      Function to use.
 */
void
fstrm_rdwr_set_write(
	struct fstrm_rdwr *rdwr,
	fstrm_rdwr_write_func fn);

/**@}*/

#endif /* FSTRM_RDWR_H */