ostream.c revision 3a30e5e6ca0473fbaf5eb243fd1cccb1e227c630
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz ostream.c : Output stream handling
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz Copyright (c) 2002 Timo Sirainen
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz Permission is hereby granted, free of charge, to any person obtaining
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz a copy of this software and associated documentation files (the
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz "Software"), to deal in the Software without restriction, including
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz without limitation the rights to use, copy, modify, merge, publish,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz distribute, sublicense, and/or sell copies of the Software, and to
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz permit persons to whom the Software is furnished to do so, subject to
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz the following conditions:
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz The above copyright notice and this permission notice shall be
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz included in all copies or substantial portions of the Software.
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzvoid o_stream_unref(struct ostream *stream)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzvoid o_stream_set_max_buffer_size(struct ostream *stream, size_t max_size)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz _io_stream_set_max_buffer_size(stream->real_stream, max_size);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzvoid o_stream_set_blocking(struct ostream *stream, int timeout_msecs,
e7e9ca33af09b6ab77633bcafe27d751adf09c93Michael Slusarz void (*timeout_func)(void *), void *context)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz _io_stream_set_blocking(stream->real_stream, timeout_msecs,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct _ostream *_stream = stream->real_stream;
f6fb60c7dcfc88895c8c45514c3fc424d3126336Michael Slusarz struct _ostream *_stream = stream->real_stream;
f6fb60c7dcfc88895c8c45514c3fc424d3126336Michael Slusarzint o_stream_have_space(struct ostream *stream, size_t size)
f6fb60c7dcfc88895c8c45514c3fc424d3126336Michael Slusarz struct _ostream *_stream = stream->real_stream;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzint o_stream_seek(struct ostream *stream, uoff_t offset)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct _ostream *_stream = stream->real_stream;
f6fb60c7dcfc88895c8c45514c3fc424d3126336Michael Slusarzssize_t o_stream_send(struct ostream *stream, const void *data, size_t size)
f6fb60c7dcfc88895c8c45514c3fc424d3126336Michael Slusarz struct _ostream *_stream = stream->real_stream;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz return _stream->send(_stream, data, size);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzssize_t o_stream_send_str(struct ostream *stream, const char *str)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz return o_stream_send(stream, str, strlen(str));
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzoff_t o_stream_send_istream(struct ostream *outstream,
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz struct _ostream *_outstream = outstream->real_stream;
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz if (outstream->closed || instream->closed)
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarz return _outstream->send_istream(_outstream, instream);
51ed197520dd9ea534fbc3bc1790ebe3cb5421e2Michael M Slusarzstruct ostream *_o_stream_create(struct _ostream *_stream, pool_t pool)