Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/fstrm
File: rdwr.h
/*
[0] Fix | Delete
* Copyright (c) 2014 by Farsight Security, Inc.
[1] Fix | Delete
*
[2] Fix | Delete
* Permission is hereby granted, free of charge, to any person obtaining
[3] Fix | Delete
* a copy of this software and associated documentation files (the
[4] Fix | Delete
* "Software"), to deal in the Software without restriction, including
[5] Fix | Delete
* without limitation the rights to use, copy, modify, merge, publish,
[6] Fix | Delete
* distribute, sublicense, and/or sell copies of the Software, and to
[7] Fix | Delete
* permit persons to whom the Software is furnished to do so, subject to
[8] Fix | Delete
* the following conditions:
[9] Fix | Delete
*
[10] Fix | Delete
* The above copyright notice and this permission notice shall be included
[11] Fix | Delete
* in all copies or substantial portions of the Software.
[12] Fix | Delete
*
[13] Fix | Delete
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
[14] Fix | Delete
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
[15] Fix | Delete
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
[16] Fix | Delete
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
[17] Fix | Delete
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
[18] Fix | Delete
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
[19] Fix | Delete
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[20] Fix | Delete
*
[21] Fix | Delete
*/
[22] Fix | Delete
[23] Fix | Delete
#ifndef FSTRM_RDWR_H
[24] Fix | Delete
#define FSTRM_RDWR_H
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* \defgroup fstrm_rdwr fstrm_rdwr
[28] Fix | Delete
*
[29] Fix | Delete
* `fstrm_rdwr` is an interface for abstracting the process of reading and
[30] Fix | Delete
* writing data to byte streams. It allows extending the `fstrm` library to
[31] Fix | Delete
* support reading and writing Frame Streams data to new kinds of byte stream
[32] Fix | Delete
* transports. (It also allows building mock interfaces for testing the correct
[33] Fix | Delete
* functioning of the library.)
[34] Fix | Delete
*
[35] Fix | Delete
* `fstrm_rdwr` is a low-level interface that is used in conjunction with the
[36] Fix | Delete
* higher level \ref fstrm_reader and \ref fstrm_writer interfaces. The
[37] Fix | Delete
* following methods need to be defined for `fstrm_rdwr` implementations:
[38] Fix | Delete
*
[39] Fix | Delete
* Method name | Method type | Method description
[40] Fix | Delete
* ------------ | ----------------------------- | ------------------
[41] Fix | Delete
* `destroy` | #fstrm_rdwr_destroy_func | Destroys the instance.
[42] Fix | Delete
* `open` | #fstrm_rdwr_open_func | Opens the stream.
[43] Fix | Delete
* `close` | #fstrm_rdwr_close_func | Closes the stream.
[44] Fix | Delete
* `read` | #fstrm_rdwr_read_func | Reads bytes from the stream.
[45] Fix | Delete
* `write` | #fstrm_rdwr_write_func | Writes bytes to the stream.
[46] Fix | Delete
*
[47] Fix | Delete
* The `destroy` method is optional. It cleans up any remaining resources
[48] Fix | Delete
* associated with the instance.
[49] Fix | Delete
*
[50] Fix | Delete
* The `open` method is required. It should perform the actual opening of the
[51] Fix | Delete
* byte stream and prepare it to read or write data.
[52] Fix | Delete
*
[53] Fix | Delete
* The `close` method is required. It should perform the actual closing of the
[54] Fix | Delete
* byte stream.
[55] Fix | Delete
*
[56] Fix | Delete
* If the `fstrm_rdwr` object is to be used in an `fstrm_reader` object, it must
[57] Fix | Delete
* have a `read` method. If the `fstrm_rdwr` object embedded in an
[58] Fix | Delete
* `fstrm_reader` object also has a `write` method, the stream will be
[59] Fix | Delete
* considered bi-directional (that is, it supports both reading and writing) and
[60] Fix | Delete
* handshaking will be performed. If a `read` method is supplied but a `write`
[61] Fix | Delete
* method is not, the reader's stream will instead be considered
[62] Fix | Delete
* uni-directional. See \ref fstrm_reader for details.
[63] Fix | Delete
*
[64] Fix | Delete
* If the `fstrm_rdwr` object is to be used in an `fstrm_writer` object, it must
[65] Fix | Delete
* have a `write` method. If the `fstrm_rdwr` object embedded in an
[66] Fix | Delete
* `fstrm_writer` object also has a `read` method, the stream will be considered
[67] Fix | Delete
* bi-directional and shaking will be performed. If a `write` method is supplied
[68] Fix | Delete
* but a `read` method is not, the writer's stream will instead be considered
[69] Fix | Delete
* uni-directional. See \ref fstrm_writer for details.
[70] Fix | Delete
*
[71] Fix | Delete
* An `fstrm_rdwr` instance is created with a call to `fstrm_rdwr_init()`,
[72] Fix | Delete
* optionally passing a pointer to some state object associated with the
[73] Fix | Delete
* instance. This pointer will be passed as the first argument to each of the
[74] Fix | Delete
* methods described above. Then, the various `fstrm_rdwr_set_*()` functions
[75] Fix | Delete
* should be used to configure the functions to be used to invoke the methods
[76] Fix | Delete
* required for the `fstrm_rdwr` object.
[77] Fix | Delete
*
[78] Fix | Delete
* @{
[79] Fix | Delete
*/
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* `destroy` method function type. This method is invoked to deallocate any
[83] Fix | Delete
* per-stream resources used by an `fstrm_rdwr` implementation.
[84] Fix | Delete
*
[85] Fix | Delete
* \see fstrm_rdwr_set_destroy()
[86] Fix | Delete
*
[87] Fix | Delete
* \param obj
[88] Fix | Delete
* The `obj` value passed to `fstrm_rdwr_init()`.
[89] Fix | Delete
*
[90] Fix | Delete
* \retval #fstrm_res_success
[91] Fix | Delete
* \retval #fstrm_res_failure
[92] Fix | Delete
*/
[93] Fix | Delete
typedef fstrm_res
[94] Fix | Delete
(*fstrm_rdwr_destroy_func)(void *obj);
[95] Fix | Delete
[96] Fix | Delete
/**
[97] Fix | Delete
* `open` method function type. This method is invoked to open the stream and
[98] Fix | Delete
* prepare it for reading or writing. For example, if an `fstrm_rdwr`
[99] Fix | Delete
* implementation is backed by file I/O, this method might be responsible for
[100] Fix | Delete
* opening a file descriptor.
[101] Fix | Delete
*
[102] Fix | Delete
* \see fstrm_rdwr_set_open()
[103] Fix | Delete
*
[104] Fix | Delete
* \param obj
[105] Fix | Delete
* The `obj` value passed to `fstrm_rdwr_init()`.
[106] Fix | Delete
*
[107] Fix | Delete
* \retval #fstrm_res_success
[108] Fix | Delete
* \retval #fstrm_res_failure
[109] Fix | Delete
*/
[110] Fix | Delete
typedef fstrm_res
[111] Fix | Delete
(*fstrm_rdwr_open_func)(void *obj);
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* `close` method function type. This method is invoked to close the stream. For
[115] Fix | Delete
* example, if an `fstrm_rdwr` implementation is backed by file I/O, this method
[116] Fix | Delete
* might be responsible for closing a file descriptor.
[117] Fix | Delete
*
[118] Fix | Delete
* \see fstrm_rdwr_set_close()
[119] Fix | Delete
*
[120] Fix | Delete
* \param obj
[121] Fix | Delete
* The `obj` value passed to `fstrm_rdwr_init()`.
[122] Fix | Delete
*
[123] Fix | Delete
* \retval #fstrm_res_success
[124] Fix | Delete
* \retval #fstrm_res_failure
[125] Fix | Delete
*/
[126] Fix | Delete
typedef fstrm_res
[127] Fix | Delete
(*fstrm_rdwr_close_func)(void *obj);
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* `read` method function type. This method is used to read data from a stream.
[131] Fix | Delete
* It must satisfy the full amount of data requested, unless the stream has
[132] Fix | Delete
* ended.
[133] Fix | Delete
*
[134] Fix | Delete
* \see fstrm_rdwr_set_read()
[135] Fix | Delete
*
[136] Fix | Delete
* \param obj
[137] Fix | Delete
* The `obj` value passed to `fstrm_rdwr_init()`.
[138] Fix | Delete
* \param data
[139] Fix | Delete
* The buffer in which to place the data read.
[140] Fix | Delete
* \param count
[141] Fix | Delete
* The number of bytes requested.
[142] Fix | Delete
*
[143] Fix | Delete
* \retval #fstrm_res_success
[144] Fix | Delete
* The data was read successfully.
[145] Fix | Delete
* \retval #fstrm_res_failure
[146] Fix | Delete
* An unexpected failure occurred.
[147] Fix | Delete
* \retval #fstrm_res_stop
[148] Fix | Delete
* The end of the stream has occurred.
[149] Fix | Delete
*/
[150] Fix | Delete
typedef fstrm_res
[151] Fix | Delete
(*fstrm_rdwr_read_func)(void *obj, void *data, size_t count);
[152] Fix | Delete
[153] Fix | Delete
/**
[154] Fix | Delete
* `write` method function type. This method is used to write data to a stream.
[155] Fix | Delete
* It must perform the full write of all data, unless an error has occurred.
[156] Fix | Delete
*
[157] Fix | Delete
* \see fstrm_rdwr_set_write()
[158] Fix | Delete
*
[159] Fix | Delete
* \param obj
[160] Fix | Delete
* The `obj` value passed to `fstrm_rdwr_init()`.
[161] Fix | Delete
* \param iov
[162] Fix | Delete
* Array of `struct iovec` objects.
[163] Fix | Delete
* \param iovcnt
[164] Fix | Delete
* Number of `struct iovec` objects in `iov`.
[165] Fix | Delete
*
[166] Fix | Delete
* \return #fstrm_res_success
[167] Fix | Delete
* \return #fstrm_res_failure
[168] Fix | Delete
*/
[169] Fix | Delete
typedef fstrm_res
[170] Fix | Delete
(*fstrm_rdwr_write_func)(void *obj, const struct iovec *iov, int iovcnt);
[171] Fix | Delete
[172] Fix | Delete
/**
[173] Fix | Delete
* Initialize a new `fstrm_rdwr` object.
[174] Fix | Delete
*
[175] Fix | Delete
* \param obj
[176] Fix | Delete
* Per-object state.
[177] Fix | Delete
*
[178] Fix | Delete
* \return
[179] Fix | Delete
* `fstrm_rdwr` object.
[180] Fix | Delete
* \retval
[181] Fix | Delete
* NULL on failure.
[182] Fix | Delete
*/
[183] Fix | Delete
struct fstrm_rdwr *
[184] Fix | Delete
fstrm_rdwr_init(void *obj);
[185] Fix | Delete
[186] Fix | Delete
/**
[187] Fix | Delete
* Destroy an `fstrm_rdwr` object. This invokes the underlying `destroy` method
[188] Fix | Delete
* as well.
[189] Fix | Delete
*
[190] Fix | Delete
* \param rdwr
[191] Fix | Delete
* Pointer to an `fstrm_rdwr` object.
[192] Fix | Delete
*
[193] Fix | Delete
* \return #fstrm_res_success
[194] Fix | Delete
* \return #fstrm_res_failure
[195] Fix | Delete
*/
[196] Fix | Delete
fstrm_res
[197] Fix | Delete
fstrm_rdwr_destroy(struct fstrm_rdwr **rdwr);
[198] Fix | Delete
[199] Fix | Delete
/**
[200] Fix | Delete
* Invoke the `open` method on an `fstrm_rdwr` object.
[201] Fix | Delete
*
[202] Fix | Delete
* \param rdwr
[203] Fix | Delete
* The `fstrm_rdwr` object.
[204] Fix | Delete
*
[205] Fix | Delete
* \return #fstrm_res_success
[206] Fix | Delete
* \return #fstrm_res_failure
[207] Fix | Delete
*/
[208] Fix | Delete
fstrm_res
[209] Fix | Delete
fstrm_rdwr_open(struct fstrm_rdwr *rdwr);
[210] Fix | Delete
[211] Fix | Delete
/**
[212] Fix | Delete
* Invoke the `close` method on an `fstrm_rdwr` object.
[213] Fix | Delete
*
[214] Fix | Delete
* \param rdwr
[215] Fix | Delete
* The `fstrm_rdwr` object.
[216] Fix | Delete
*
[217] Fix | Delete
* \return #fstrm_res_success
[218] Fix | Delete
* \return #fstrm_res_failure
[219] Fix | Delete
*/
[220] Fix | Delete
fstrm_res
[221] Fix | Delete
fstrm_rdwr_close(struct fstrm_rdwr *rdwr);
[222] Fix | Delete
[223] Fix | Delete
/**
[224] Fix | Delete
* Invoke the `read` method on an `fstrm_rdwr` object.
[225] Fix | Delete
*
[226] Fix | Delete
* \param rdwr
[227] Fix | Delete
* The `fstrm_rdwr` object.
[228] Fix | Delete
* \param data
[229] Fix | Delete
* The buffer in which to place the data read.
[230] Fix | Delete
* \param count
[231] Fix | Delete
* The number of bytes to read.
[232] Fix | Delete
*
[233] Fix | Delete
* \return #fstrm_res_success
[234] Fix | Delete
* \return #fstrm_res_failure
[235] Fix | Delete
* \return #fstrm_res_stop
[236] Fix | Delete
*/
[237] Fix | Delete
fstrm_res
[238] Fix | Delete
fstrm_rdwr_read(struct fstrm_rdwr *rdwr, void *data, size_t count);
[239] Fix | Delete
[240] Fix | Delete
/**
[241] Fix | Delete
* Invoke the `write` method on an `fstrm_rdwr` object.
[242] Fix | Delete
*
[243] Fix | Delete
* \param rdwr
[244] Fix | Delete
* The `fstrm_rdwr` object.
[245] Fix | Delete
* \param iov
[246] Fix | Delete
* Array of `struct iovec` objects.
[247] Fix | Delete
* \param iovcnt
[248] Fix | Delete
* Number of `struct iovec` objects in `iov`.
[249] Fix | Delete
*
[250] Fix | Delete
* \return #fstrm_res_success
[251] Fix | Delete
* \return #fstrm_res_failure
[252] Fix | Delete
*/
[253] Fix | Delete
fstrm_res
[254] Fix | Delete
fstrm_rdwr_write(struct fstrm_rdwr *rdwr, const struct iovec *iov, int iovcnt);
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Set the `destroy` method for an `fstrm_rdwr` object.
[258] Fix | Delete
*
[259] Fix | Delete
* \param rdwr
[260] Fix | Delete
* The `fstrm_rdwr` object.
[261] Fix | Delete
* \param fn
[262] Fix | Delete
* Function to use.
[263] Fix | Delete
*/
[264] Fix | Delete
void
[265] Fix | Delete
fstrm_rdwr_set_destroy(
[266] Fix | Delete
struct fstrm_rdwr *rdwr,
[267] Fix | Delete
fstrm_rdwr_destroy_func fn);
[268] Fix | Delete
[269] Fix | Delete
/**
[270] Fix | Delete
* Set the `open` method for an `fstrm_rdwr` object.
[271] Fix | Delete
*
[272] Fix | Delete
* \param rdwr
[273] Fix | Delete
* The `fstrm_rdwr` object.
[274] Fix | Delete
* \param fn
[275] Fix | Delete
* Function to use.
[276] Fix | Delete
*/
[277] Fix | Delete
void
[278] Fix | Delete
fstrm_rdwr_set_open(
[279] Fix | Delete
struct fstrm_rdwr *rdwr,
[280] Fix | Delete
fstrm_rdwr_open_func fn);
[281] Fix | Delete
[282] Fix | Delete
/**
[283] Fix | Delete
* Set the `close` method for an `fstrm_rdwr` object.
[284] Fix | Delete
*
[285] Fix | Delete
* \param rdwr
[286] Fix | Delete
* The `fstrm_rdwr` object.
[287] Fix | Delete
* \param fn
[288] Fix | Delete
* Function to use.
[289] Fix | Delete
*/
[290] Fix | Delete
void
[291] Fix | Delete
fstrm_rdwr_set_close(
[292] Fix | Delete
struct fstrm_rdwr *rdwr,
[293] Fix | Delete
fstrm_rdwr_close_func fn);
[294] Fix | Delete
[295] Fix | Delete
/**
[296] Fix | Delete
* Set the `read` method for an `fstrm_rdwr` object.
[297] Fix | Delete
*
[298] Fix | Delete
* \param rdwr
[299] Fix | Delete
* The `fstrm_rdwr` object.
[300] Fix | Delete
* \param fn
[301] Fix | Delete
* Function to use.
[302] Fix | Delete
*/
[303] Fix | Delete
void
[304] Fix | Delete
fstrm_rdwr_set_read(
[305] Fix | Delete
struct fstrm_rdwr *rdwr,
[306] Fix | Delete
fstrm_rdwr_read_func fn);
[307] Fix | Delete
[308] Fix | Delete
/**
[309] Fix | Delete
* Set the `write` method for an `fstrm_rdwr` object.
[310] Fix | Delete
*
[311] Fix | Delete
* \param rdwr
[312] Fix | Delete
* The `fstrm_rdwr` object.
[313] Fix | Delete
* \param fn
[314] Fix | Delete
* Function to use.
[315] Fix | Delete
*/
[316] Fix | Delete
void
[317] Fix | Delete
fstrm_rdwr_set_write(
[318] Fix | Delete
struct fstrm_rdwr *rdwr,
[319] Fix | Delete
fstrm_rdwr_write_func fn);
[320] Fix | Delete
[321] Fix | Delete
/**@}*/
[322] Fix | Delete
[323] Fix | Delete
#endif /* FSTRM_RDWR_H */
[324] Fix | Delete
[325] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function