20#ifndef _tdsguard_a5iqP6Ed7kDGP9L1OvOL7W_
21#define _tdsguard_a5iqP6Ed7kDGP9L1OvOL7W_
23#ifndef _tdsguard_hfOrWb5znoUCWdBPoNQvqN_
24#error Include tds.h first
28#include <freetds/tds/iconv.h>
29#include <freetds/pushvis.h>
33typedef off_t offset_type;
34#elif defined(_WIN32) || defined(_WIN64)
36typedef __int64 offset_type;
38#if defined(HAVE__FSEEKI64) && defined(HAVE__FTELLI64)
39#define fseeko(f,o,w) _fseeki64((f),o,w)
40#define ftello(f) _ftelli64((f))
42#define fseeko(f,o,w) (_lseeki64(fileno(f),o,w) == -1 ? -1 : 0)
43#define ftello(f) _telli64(fileno(f))
47#define fseeko(f,o,w) fseek(f,o,w)
48#define ftello(f) ftell(f)
49typedef long offset_type;
92void tds_fileout_stream_init(TDSFILEOUTSTREAM * s, FILE * fp,
int buff_mode);
94TDSRET tds_fileout_stream_flush(TDSFILEOUTSTREAM * s);
95TDSRET tds_fileout_stream_put(TDSFILEOUTSTREAM * s,
const void *src,
size_t n);
98TDSRET
tds_convert_stream(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION direction,
99 TDSINSTREAM * istream, TDSOUTSTREAM *ostream);
162{ TDSFILESTREAM_BLOCKSIZE = 512 };
184 char inbuf[TDSFILESTREAM_BLOCKSIZE];
190TDSRET tds_file_stream_init(TDSFILESTREAM * stream, FILE * f);
193size_t tds_file_stream_read_raw(TDSFILESTREAM * stream,
void *ptr,
size_t n);
194TDSRET tds_file_stream_seek_set(TDSFILESTREAM * stream, offset_type seek_to);
195offset_type tds_file_stream_tell(TDSFILESTREAM * stream);
196TDSRET tds_file_stream_close(TDSFILESTREAM * stream);
198#include <freetds/popvis.h>
define a stream of data used for input
Definition stream.h:55
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:60
define a stream of data used for output
Definition stream.h:64
char * buffer
write buffer.
Definition stream.h:75
int(* write)(struct tds_output_stream *stream, size_t len)
write len bytes from buffer, return <0 if error or len
Definition stream.h:66
Output stream that writes to file.
Definition stream.h:83
int buff_mode
How to buffer the data – _IONBF, _IOLBF or _IOFBF (default).
Definition stream.h:89
input stream to read data from tds protocol
Definition stream.h:106
size_t wire_size
bytes still to read
Definition stream.h:108
output stream to write data to tds protocol
Definition stream.h:115
input stream to read data from a static buffer
Definition stream.h:124
output stream to write data to a static buffer.
Definition stream.h:135
output stream to write data to a dynamic buffer
Definition stream.h:142
void ** buf
where is stored the pointer
Definition stream.h:145
size_t size
size of data inside buffer
Definition stream.h:149
size_t allocated
currently allocated buffer
Definition stream.h:147
char cbuf[50]
Circular buffer; assume nobody is going to use a gigantic terminator...
Definition stream.h:174
FILE * f
file to read from
Definition stream.h:170
const char * terminator
Terminator to compare against - Memory not owned by the TDSFILESTREAM; make sure to not leave danglin...
Definition stream.h:180
TDSINSTREAM stream
common fields, must be the first field
Definition stream.h:167
TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM *stream, void **ptr, size_t allocated)
Initialize a dynamic output stream.
Definition stream.c:354
TDSRET tds_copy_stream(TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream to another.
Definition stream.c:163
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
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
void tds_dataout_stream_init(TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
Initialize a data output stream.
Definition stream.c:244
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
void tds_datain_stream_init(TDSDATAINSTREAM *stream, TDSSOCKET *tds, size_t wire_size)
Initialize a data input stream.
Definition stream.c:204