Loading...
Searching...
No Matches
stream.h
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
* Copyright (C) 2013 Frediano Ziglio
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _tdsguard_a5iqP6Ed7kDGP9L1OvOL7W_
#define _tdsguard_a5iqP6Ed7kDGP9L1OvOL7W_
#ifndef _tdsguard_hfOrWb5znoUCWdBPoNQvqN_
#error Include tds.h first
#endif
#include <freetds/pushvis.h>
typedef struct tds_input_stream {
int (*read)(struct tds_input_stream *stream, void *ptr, size_t len);
} TDSINSTREAM;
typedef struct tds_output_stream {
int (*write)(struct tds_output_stream *stream, size_t len);
char *buffer;
size_t buf_len;
} TDSOUTSTREAM;
TDSRET tds_convert_stream(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION direction,
TDSINSTREAM * istream, TDSOUTSTREAM *ostream);
TDSRET tds_copy_stream(TDSINSTREAM * istream, TDSOUTSTREAM * ostream);
/* Additional streams */
typedef struct tds_datain_stream {
TDSINSTREAM stream;
size_t wire_size;
TDSSOCKET *tds;
} TDSDATAINSTREAM;
void tds_datain_stream_init(TDSDATAINSTREAM * stream, TDSSOCKET * tds, size_t wire_size);
typedef struct tds_dataout_stream {
TDSOUTSTREAM stream;
TDSSOCKET *tds;
size_t written;
} TDSDATAOUTSTREAM;
void tds_dataout_stream_init(TDSDATAOUTSTREAM * stream, TDSSOCKET * tds);
typedef struct tds_staticin_stream {
TDSINSTREAM stream;
const char *buffer;
size_t buf_left;
} TDSSTATICINSTREAM;
void tds_staticin_stream_init(TDSSTATICINSTREAM * stream, const void *ptr, size_t len);
typedef struct tds_staticout_stream {
TDSOUTSTREAM stream;
} TDSSTATICOUTSTREAM;
void tds_staticout_stream_init(TDSSTATICOUTSTREAM * stream, void *ptr, size_t len);
typedef struct tds_dynamic_stream {
TDSOUTSTREAM stream;
void **buf;
size_t allocated;
size_t size;
} TDSDYNAMICSTREAM;
TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM * stream, void **ptr, size_t allocated);
#include <freetds/popvis.h>
#endif
tds_input_stream
define a stream of data used for input
Definition stream.h:30
tds_input_stream::read
int(* read)(struct tds_input_stream *stream, void *ptr, size_t len)
read some data Return 0 if end of stream Return <0 if error (actually not defined)
Definition stream.h:35
tds_output_stream
define a stream of data used for output
Definition stream.h:39
tds_output_stream::buffer
char * buffer
write buffer.
Definition stream.h:50
tds_output_stream::write
int(* write)(struct tds_output_stream *stream, size_t len)
write len bytes from buffer, return <0 if error or len
Definition stream.h:41
tds_datain_stream
input stream to read data from tds protocol
Definition stream.h:63
tds_datain_stream::wire_size
size_t wire_size
bytes still to read
Definition stream.h:65
tds_dataout_stream
output stream to write data to tds protocol
Definition stream.h:72
tds_staticin_stream
input stream to read data from a static buffer
Definition stream.h:81
tds_staticout_stream
output stream to write data to a static buffer.
Definition stream.h:92
tds_dynamic_stream
output stream to write data to a dynamic buffer
Definition stream.h:99
tds_dynamic_stream::buf
void ** buf
where is stored the pointer
Definition stream.h:102
tds_dynamic_stream::size
size_t size
size of data inside buffer
Definition stream.h:106
tds_dynamic_stream::allocated
size_t allocated
currently allocated buffer
Definition stream.h:104
tds_dynamic_stream_init
TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM *stream, void **ptr, size_t allocated)
Initialize a dynamic output stream.
Definition stream.c:354
tds_copy_stream
TDSRET tds_copy_stream(TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream to another.
Definition stream.c:163
tds_convert_stream
TDSRET tds_convert_stream(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION direction, TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream converting characters.
Definition stream.c:71
tds_staticout_stream_init
void tds_staticout_stream_init(TDSSTATICOUTSTREAM *stream, void *ptr, size_t len)
Initialize an output stream for write into a static allocated buffer.
Definition stream.c:313
tds_dataout_stream_init
void tds_dataout_stream_init(TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
Initialize a data output stream.
Definition stream.c:244
tds_staticin_stream_init
void tds_staticin_stream_init(TDSSTATICINSTREAM *stream, const void *ptr, size_t len)
Initialize an input stream for read from a static allocated buffer.
Definition stream.c:286
tds_datain_stream_init
void tds_datain_stream_init(TDSDATAINSTREAM *stream, TDSSOCKET *tds, size_t wire_size)
Initialize a data input stream.
Definition stream.c:204