35 static const uint16_t cp1252_0080_00a0[] = {
70 TDS_COMPILE_CHECK(cp1252size,
sizeof(cp1252_0080_00a0) == 0x20*
sizeof(uint16_t));
output stream to write data to a static buffer.
Definition: stream.h:92
TDSPACKET * pkt
first packet frozen
Definition: tds.h:1575
static int tds_datain_stream_read(TDSINSTREAM *stream, void *ptr, size_t len)
Reads data from network for input stream.
Definition: stream.c:185
TDSPACKET * frozen_packets
list of packets frozen, points to first one.
Definition: tds.h:1203
char * charset
character set encoding
Definition: tds.h:968
static int tds_dynamic_stream_write(TDSOUTSTREAM *stream, size_t len)
Writes data to a dynamic allocated buffer.
Definition: stream.c:324
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:58
@ TDS_READING
client is reading data
Definition: tds.h:794
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
Definition: iconv.c:316
char * buffer
write buffer.
Definition: stream.h:50
static const char * tds_dstr_cstr(const DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition: string.h:78
DSTR password
password of account login
Definition: tds.h:535
unsigned in_pos
current position in in_buf
Definition: tds.h:1192
TDSICONV * tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5])
Get iconv information from a LCID (to support different column encoding under MSSQL2K)
Definition: iconv.c:1251
Main include file for libtds.
TDSENV env
environment is shared between all sessions
Definition: tds.h:1101
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
static int tds_dstr_isempty(const DSTR *s)
test if string is empty
Definition: string.h:60
static int tds_staticout_stream_write(TDSOUTSTREAM *stream, size_t len)
Writes data to a static allocated buffer.
Definition: stream.c:298
input stream to read data from a static buffer
Definition: stream.h:81
output stream to write data to tds protocol
Definition: stream.h:72
unsigned char canonic
internal numeric index into array of all encodings
Definition: tds.h:624
unsigned char * out_buf
Output buffer.
Definition: tds.h:1185
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:168
TDSRET tds_freeze_abort(TDSFREEZE *freeze)
Discard all data written after the freeze.
Definition: packet.c:961
enum tds_states TDS_STATE
values for tds->state
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1093
void tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:224
int tds_canonical_charset(const char *charset_name)
Determine canonical iconv character set.
Definition: iconv.c:976
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1254
unsigned char * in_buf
Input buffer.
Definition: tds.h:1177
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1243
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:524
TDSICONV * tds_iconv_get_info(TDSCONNECTION *conn, int canonic_client, int canonic_server)
Get a iconv info structure, allocate and initialize if needed.
Definition: iconv.c:764
unsigned size_len
length size (0, 1, 2 or 4)
Definition: tds.h:1579
void tds_datain_stream_init(TDSDATAINSTREAM *stream, TDSSOCKET *tds, size_t wire_size)
Initialize a data input stream.
Definition: stream.c:204
dlist_users waiters
users in wait state
Definition: pool.h:128
input stream to read data from tds protocol
Definition: stream.h:63
const char * tds_canonical_charset_name(const char *charset_name)
Determine canonical iconv character set name.
Definition: iconv.c:988
void ** buf
where is stored the pointer
Definition: stream.h:102
TDSRET tds_process_simple_query(TDSSOCKET *tds)
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results,...
Definition: token.c:881
int tds_get_token_size(int marker)
tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determi...
Definition: token.c:2754
static int tds_iconv_info_init(TDSICONV *char_conv, int client_canonic, int server_canonic)
Open iconv descriptors to convert between character sets (both directions).
Definition: iconv.c:450
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
define a stream of data used for input
Definition: stream.h:30
TDSRET tds_send_cancel(TDSSOCKET *tds)
tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called dire...
Definition: query.c:2026
Metadata about columns in regular and compute rows.
Definition: tds.h:689
const char * name
name of the encoding (ie UTF-8)
Definition: tds.h:620
size_t wire_size
bytes still to read
Definition: stream.h:65
unsigned char out_flag
output buffer type
Definition: tds.h:1196
static size_t skip_one_input_sequence(iconv_t cd, const TDS_ENCODING *charset, const char **input, size_t *input_size)
Move the input sequence pointer to the next valid position.
Definition: iconv.c:872
static const char * tds_set_iconv_name(int charset)
Get iconv name given canonic.
Definition: iconv.c:247
TDSRET tds_submit_query(TDSSOCKET *tds, const char *query)
Sends a language string to the database server for processing.
Definition: query.c:210
@ TDS_SENDING
client would send data
Definition: tds.h:792
TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM *stream, void **ptr, size_t allocated)
Initialize a dynamic output stream.
Definition: stream.c:354
Definition: replacements.h:88
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
Definition: packet.c:527
output stream to write data to a dynamic buffer
Definition: stream.h:99
Hold information for any results.
Definition: tds.h:769
@ TDS_WRITING
client is writing data
Definition: tds.h:791
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
Definition: tds_types.h:9
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:518
unsigned in_len
input buffer length
Definition: tds.h:1194
unsigned out_pos
current position in out_buf
Definition: tds.h:1193
TDS_INT column_size
maximun size of data.
Definition: tds.h:694
TDSRET tds_copy_stream(TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream to another.
Definition: stream.c:163
size_t allocated
currently allocated buffer
Definition: stream.h:104
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
iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode)
Inputs are FreeTDS canonical names, no other.
Definition: iconv.c:344
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
Definition: tds.h:701
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
int tdserror(const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
Call the client library's error handler (for library-generated errors only)
Definition: util.c:321
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen)
Quote an id.
Definition: query.c:2171
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
Definition: mem.c:1876
void tdsdump_dump_buf(const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
Dump the contents of data into the log file in a human readable format.
Definition: log.c:293
static bool tds_iconv_init(void)
Initialize charset searching for UTF-8, UCS-2 and ISO8859-1.
Definition: iconv.c:92
DSTR user_name
account for login
Definition: tds.h:534
size_t tds_iconv(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Wrapper around iconv(3).
Definition: iconv.c:598
@ TDS_DEAD
no connection
Definition: tds.h:795
char * tds_strndup(const void *s, TDS_INTPTR len)
Copy a string of length len to a new allocated buffer This function does not read more than len bytes...
Definition: util.c:406
TDSSOCKET * tds
which socket we refer to
Definition: tds.h:1573
bool tds_get_n(TDSSOCKET *tds, void *dest, size_t need)
Get N bytes from the buffer and return them in the already allocated space given to us.
Definition: read.c:230
@ TDS_IDLE
no data expected
Definition: tds.h:790
Information for a server connection.
Definition: tds.h:1163
unsigned char in_flag
input buffer type
Definition: tds.h:1195
Information relevant to libiconv.
Definition: tds.h:618
void tds_dataout_stream_init(TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
Initialize a data output stream.
Definition: stream.c:244
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1191
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:224
define a stream of data used for output
Definition: stream.h:39
unsigned pkt_pos
position in pkt
Definition: tds.h:1577
DSTR server_charset
charset of server e.g.
Definition: tds.h:523
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:793
int block_size
packet size (512-65535)
Definition: tds.h:965
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:696
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
size_t size
size of data inside buffer
Definition: stream.h:106
static int tds_staticin_stream_read(TDSINSTREAM *stream, void *ptr, size_t len)
Reads data from a static allocated buffer.
Definition: stream.c:268
Definition: charset_lookup.h:36
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:396
static int tds_dataout_stream_write(TDSOUTSTREAM *stream, size_t len)
Writes data to network for output stream.
Definition: stream.c:215