NCBI C++ ToolKit
tds.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3  * Copyright (C) 2010, 2011 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _tds_h_
22 #define _tds_h_
23 
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <time.h>
27 #include <sys/types.h>
28 
29 #include <config.h>
30 
31 #ifdef HAVE_STDDEF_H
32 #include <stddef.h>
33 #endif
34 
35 #if HAVE_NETDB_H
36 #include <netdb.h>
37 #endif /* HAVE_NETDB_H */
38 
39 #if HAVE_NETINET_IN_H
40 #include <netinet/in.h>
41 #endif /* HAVE_NET_INET_IN_H */
42 #if HAVE_ARPA_INET_H
43 #include <arpa/inet.h>
44 #endif /* HAVE_ARPA_INET_H */
45 
46 /* forward declaration */
47 typedef struct tdsiconvinfo TDSICONV;
48 typedef struct tds_connection TDSCONNECTION;
49 typedef struct tds_socket TDSSOCKET;
50 typedef struct tds_column TDSCOLUMN;
51 typedef struct tds_bcpinfo TDSBCPINFO;
52 /* More, to address "declared with greater visibility" warnings. */
54 typedef struct tds_bcpcoldata BCPCOLDATA;
55 typedef struct tds_capabilities TDS_CAPABILITIES;
57 typedef struct tds_column_funcs TDSCOLUMNFUNCS;
58 typedef struct tds_context TDSCONTEXT;
59 typedef struct tds_cursor TDSCURSOR;
61 typedef struct tds_dstr *DSTR;
62 typedef struct tds_dynamic TDSDYNAMIC;
63 typedef struct tds_env TDSENV;
64 typedef struct tds_locale TDSLOCALE;
65 typedef struct tds_login TDSLOGIN;
66 typedef struct tds_packet TDSPACKET;
67 typedef struct tds_poll_wakeup TDSPOLLWAKEUP;
68 typedef struct tds_result_info TDSCOMPUTEINFO;
69 typedef struct tds_result_info TDSRESULTINFO;
71 
72 #include <freetds/version.h>
73 #include "tds_sysdep_public.h"
74 #include <freetds/sysdep_private.h>
75 #include <freetds/thread.h>
76 #include <freetds/bool.h>
77 #include "replacements.h"
78 
79 #include <freetds/pushvis.h>
80 
81 #ifdef __cplusplus
82 extern "C"
83 {
84 #if 0
85 }
86 #endif
87 #endif
88 
89 /**
90  * A structure to hold all the compile-time settings.
91  * This structure is returned by tds_get_compiletime_settings
92  */
93 
95 {
96  const char *freetds_version; /* release version of FreeTDS */
97  const char *sysconfdir; /* location of freetds.conf */
98  const char *last_update; /* latest software_version date among the modules */
99  int msdblib; /* for MS style dblib */
100  int sybase_compat; /* enable increased Open Client binary compatibility */
101  int threadsafe; /* compile for thread safety default=no */
102  int libiconv; /* search for libiconv in DIR/include and DIR/lib */
103  const char *tdsver; /* TDS protocol version (4.2/4.6/5.0/7.0/7.1) 5.0 */
104  int iodbc; /* build odbc driver against iODBC in DIR */
105  int unixodbc; /* build odbc driver against unixODBC in DIR */
106  int openssl; /* build against OpenSSL */
107  int gnutls; /* build against GnuTLS */
108  int mars; /* MARS enabled */
110 
111 /**
112  * Structure to hold a string.
113  * Use tds_dstr_* functions/macros, do not access members directly.
114  * There should be always a buffer.
115  */
116 struct tds_dstr {
117  size_t dstr_size;
118  char dstr_s[1];
119 } /* *DSTR */;
120 
121 /**
122  * @file tds.h
123  * Main include file for libtds
124  */
125 
126 /**
127  * \defgroup libtds LibTDS API
128  * Callable functions in \c libtds.
129  *
130  * The \c libtds library is for use internal to \em FreeTDS. It is not
131  * intended for use by applications. Although any use is \em permitted, you're
132  * encouraged to use one of the established public APIs instead, because their
133  * interfaces are stable and documented by the vendors.
134  */
135 
136 /*
137  * All references to data that touch the wire should use the following typedefs.
138  *
139  * If you have problems on 64-bit machines and the code is
140  * using a native datatype, please change it to use
141  * these. (In the TDS layer only, the API layers have their
142  * own typedefs which equate to these).
143  */
144 typedef char TDS_CHAR; /* 8-bit char */
145 typedef unsigned char TDS_UCHAR; /* 8-bit uchar */
146 typedef unsigned char TDS_TINYINT; /* 8-bit unsigned */
147 typedef tds_sysdep_int16_type TDS_SMALLINT; /* 16-bit int */
148 typedef tds_sysdep_uint16_type TDS_USMALLINT; /* 16-bit unsigned */
149 typedef tds_sysdep_int32_type TDS_INT; /* 32-bit int */
150 typedef tds_sysdep_uint32_type TDS_UINT; /* 32-bit unsigned */
151 typedef tds_sysdep_real32_type TDS_REAL; /* 32-bit real */
152 typedef tds_sysdep_real64_type TDS_FLOAT; /* 64-bit real */
153 typedef tds_sysdep_int64_type TDS_INT8; /* 64-bit integer */
154 typedef tds_sysdep_uint64_type TDS_UINT8; /* 64-bit unsigned */
157 
158 #include <freetds/proto.h>
159 
160 #define TDS_INVALID_TYPE ((TDS_SERVER_TYPE) 0)
161 
162 /**
163  * this structure is not directed connected to a TDS protocol but
164  * keeps any DATE/TIME information.
165  */
166 typedef struct
167 {
168  TDS_UINT8 time; /**< time, 7 digit precision */
169  TDS_INT date; /**< date, 0 = 1900-01-01 */
170  TDS_SMALLINT offset; /**< time offset */
177 
178 /** Used by tds_datecrack */
179 typedef struct tdsdaterec
180 {
181  TDS_INT year; /**< year */
182  TDS_INT quarter; /**< quarter (0-3) */
183  TDS_INT month; /**< month number (0-11) */
184  TDS_INT day; /**< day of month (1-31) */
185  TDS_INT dayofyear; /**< day of year (1-366) */
186  TDS_INT weekday; /**< day of week (0-6, 0 = sunday) */
187  TDS_INT hour; /**< 0-23 */
188  TDS_INT minute; /**< 0-59 */
189  TDS_INT second; /**< 0-59 */
190  TDS_INT decimicrosecond; /**< 0-9999999 */
191  TDS_INT timezone; /**< -840 - 840 minutes from UTC */
193 
194 /**
195  * The following little table is indexed by precision and will
196  * tell us the number of bytes required to store the specified
197  * precision.
198  */
199 extern const int tds_numeric_bytes_per_prec[];
200 
201 typedef int TDSRET;
202 #define TDS_NO_MORE_RESULTS ((TDSRET)1)
203 #define TDS_SUCCESS ((TDSRET)0)
204 #define TDS_FAIL ((TDSRET)-1)
205 #define TDS_CANCELLED ((TDSRET)-2)
206 #define TDS_FAILED(rc) ((rc)<0)
207 #define TDS_SUCCEED(rc) ((rc)>=0)
208 
209 #define TDS_INT_CONTINUE 1
210 #define TDS_INT_CANCEL 2
211 #define TDS_INT_TIMEOUT 3
212 
213 
214 #define TDS_NO_COUNT -1
215 
216 #define TDS_ROW_RESULT 4040
217 #define TDS_PARAM_RESULT 4042
218 #define TDS_STATUS_RESULT 4043
219 #define TDS_MSG_RESULT 4044
220 #define TDS_COMPUTE_RESULT 4045
221 #define TDS_CMD_DONE 4046
222 #define TDS_CMD_SUCCEED 4047
223 #define TDS_CMD_FAIL 4048
224 #define TDS_ROWFMT_RESULT 4049
225 #define TDS_COMPUTEFMT_RESULT 4050
226 #define TDS_DESCRIBE_RESULT 4051
227 #define TDS_DONE_RESULT 4052
228 #define TDS_DONEPROC_RESULT 4053
229 #define TDS_DONEINPROC_RESULT 4054
230 #define TDS_OTHERS_RESULT 4055
231 
233 {
244 };
245 
246 #define TDS_TOKEN_FLAG(flag) TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2))
247 
249 {
251  TDS_TOKEN_FLAG(OTHERS),
252  TDS_TOKEN_FLAG(ROWFMT),
253  TDS_TOKEN_FLAG(COMPUTEFMT),
254  TDS_TOKEN_FLAG(PARAMFMT),
257  TDS_TOKEN_FLAG(COMPUTE),
263 };
264 
265 /**
266  * Flags returned in TDS_DONE token
267  */
269 {
270  TDS_DONE_FINAL = 0x00 /**< final result set, command completed successfully. */
271  , TDS_DONE_MORE_RESULTS = 0x01 /**< more results follow */
272  , TDS_DONE_ERROR = 0x02 /**< error occurred */
273  , TDS_DONE_INXACT = 0x04 /**< transaction in progress */
274  , TDS_DONE_PROC = 0x08 /**< results are from a stored procedure */
275  , TDS_DONE_COUNT = 0x10 /**< count field in packet is valid */
276  , TDS_DONE_CANCELLED = 0x20 /**< acknowledging an attention command (usually a cancel) */
277  , TDS_DONE_EVENT = 0x40 /* part of an event notification. */
278  , TDS_DONE_SRVERROR = 0x100 /**< SQL server server error */
279 
280  /* after the above flags, a TDS_DONE packet has a field describing the state of the transaction */
281  , TDS_DONE_NO_TRAN = 0 /* No transaction in effect */
282  , TDS_DONE_TRAN_SUCCEED = 1 /* Transaction completed successfully */
283  , TDS_DONE_TRAN_PROGRESS= 2 /* Transaction in progress */
284  , TDS_DONE_STMT_ABORT = 3 /* A statement aborted */
285  , TDS_DONE_TRAN_ABORT = 4 /* Transaction aborted */
286 };
287 
288 
289 /*
290  * TDSERRNO is emitted by libtds to the client library's error handler
291  * (which may in turn call the client's error handler).
292  * These match the db-lib msgno, because the same values have the same meaning
293  * in db-lib and ODBC. ct-lib maps them to ct-lib numbers (todo).
294  */
295 typedef enum { TDSEOK = TDS_SUCCESS,
296  TDSEVERDOWN = 100,
297  TDSEICONVIU = 2400,
298  TDSEICONVAVAIL = 2401,
299  TDSEICONVO = 2402,
300  TDSEICONVI = 2403,
303  TDSESYNC = 20001,
304  TDSEFCON = 20002,
305  TDSETIME = 20003,
306  TDSEREAD = 20004,
307  TDSEWRIT = 20006,
308  TDSESOCK = 20008,
309  TDSECONN = 20009,
310  TDSEMEM = 20010,
311  TDSEINTF = 20012, /* Server name not found in interface file */
312  TDSEUHST = 20013, /* Unknown host machine name. */
313  TDSEPWD = 20014,
314  TDSESEOF = 20017,
315  TDSERPND = 20019,
316  TDSEBTOK = 20020,
317  TDSEOOB = 20022,
318  TDSECLOS = 20056,
319  TDSEUSCT = 20058,
320  TDSEUTDS = 20146,
321  TDSEEUNR = 20185,
322  TDSECAP = 20203,
323  TDSENEG = 20210,
324  TDSEUMSG = 20212,
325  TDSECAPTYP = 20213,
326  TDSECONF = 20214,
327  TDSEBPROBADTYP = 20250,
328  TDSECLOSEIN = 20292
330 
331 
332 enum {
340  TDS_CUR_ISTAT_DEALLOC = 0x40
341 };
342 
343 /* string types */
344 #define TDS_NULLTERM -9
345 
346 
347 typedef union tds_option_arg
348 {
353 
354 
355 typedef enum tds_encryption_level {
358 
359 #define TDS_ZERO_FREE(x) do {free((x)); (x) = NULL;} while(0)
360 #define TDS_VECTOR_SIZE(x) (sizeof(x)/sizeof(x[0]))
361 #ifdef offsetof
362 #define TDS_OFFSET(str, field) offsetof(str, field)
363 #else
364 #define TDS_OFFSET(str, field) (((char*)&((str*)0)->field)-((char*)0))
365 #endif
366 
367 #if defined(__GNUC__) && __GNUC__ >= 3
368 # define TDS_LIKELY(x) __builtin_expect(!!(x), 1)
369 # define TDS_UNLIKELY(x) __builtin_expect(!!(x), 0)
370 #else
371 # define TDS_LIKELY(x) (x)
372 # define TDS_UNLIKELY(x) (x)
373 #endif
374 
375 #if ENABLE_EXTRA_CHECKS
376 # if defined(__llvm__) \
377  || (defined(__GNUC__) \
378  && (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)))
379 # define TDS_COMPILE_CHECK(name,check) \
380  _Static_assert(check,#name)
381 # elif defined(__GNUC__) && __GNUC__ >= 2
382 # define TDS_COMPILE_CHECK(name,check) \
383  extern int name[(check)?1:-1] __attribute__ ((unused))
384 # else
385 # define TDS_COMPILE_CHECK(name,check) \
386  extern int name[(check)?1:-1]
387 # endif
388 # define TDS_EXTRA_CHECK(stmt) stmt
389 #else
390 # define TDS_COMPILE_CHECK(name,check) \
391  extern int disabled_check_##name
392 # define TDS_EXTRA_CHECK(stmt)
393 #endif
394 
395 #if ENABLE_EXTRA_CHECKS && defined(__GNUC__) && __GNUC__ >= 4
396 #define TDS_WUR __attribute__ ((__warn_unused_result__))
397 #else
398 #define TDS_WUR
399 #endif
400 
401 /*
402  * TODO use system macros for optimization
403  * See mcrypt for reference and linux kernel source for optimization
404  * check if unaligned access and use fast write/read when implemented
405  */
406 #define TDS_BYTE_SWAP16(value) \
407  (((((unsigned short)value)<<8) & 0xFF00) | \
408  ((((unsigned short)value)>>8) & 0x00FF))
409 
410 #define TDS_BYTE_SWAP32(value) \
411  (((((unsigned long)value)<<24) & 0xFF000000) | \
412  ((((unsigned long)value)<< 8) & 0x00FF0000) | \
413  ((((unsigned long)value)>> 8) & 0x0000FF00) | \
414  ((((unsigned long)value)>>24) & 0x000000FF))
415 
416 #define is_end_token(x) (x==TDS_DONE_TOKEN || \
417  x==TDS_DONEPROC_TOKEN || \
418  x==TDS_DONEINPROC_TOKEN)
419 
420 enum {
430 };
431 
432 extern const unsigned char tds_type_flags_ms[256];
433 #if 0
434 extern const unsigned char tds_type_flags_syb[256];
435 extern const char *const tds_type_names[256];
436 #endif
437 
438 #define is_fixed_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_FIXED) != 0)
439 #define is_nullable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_NULLABLE) != 0)
440 #define is_variable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIABLE) != 0)
441 
442 
443 #define is_blob_type(x) ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT)
444 #if 1
445 #define is_blob_col(x) (is_blob_type((x)->column_type) \
446  || ((x)->column_varint_size == 8) \
447  || ((x)->column_type == SYBVARIANT \
448  && (x)->column_varint_size == 4))
449 #else
450 #define is_blob_col(x) ((x)->column_varint_size > 2)
451 #endif
452 /* large type means it has a two byte size field */
453 /* define is_large_type(x) (x>128) */
454 #define is_numeric_type(x) ((x)==SYBNUMERIC || (x)==SYBDECIMAL)
455 /** return true if type is a datetime (but not date or time) */
456 #define is_datetime_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_DATETIME) != 0)
457 #define is_unicode_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_UNICODE) != 0)
458 #define is_collate_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_COLLATE) != 0)
459 #define is_ascii_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_ASCII) != 0)
460 #define is_char_type(x) ((tds_type_flags_ms[x] & (TDS_TYPEFLAG_ASCII|TDS_TYPEFLAG_UNICODE)) != 0)
461 #define is_similar_type(x, y) (is_char_type(x) && is_char_type(y))
462 static inline
464 {
465  return (unsigned) type < 256u && tds_type_flags_ms[type] != 0;
466 }
467 
468 
469 #define TDS_MAX_CAPABILITY 32
470 #define MAXPRECISION 77
471 #define TDS_MAX_CONN 4096
472 #define TDS_MAX_DYNID_LEN 30
473 
474 /* defaults to use if no others are found */
475 #define TDS_DEF_SERVER "SYBASE"
476 #define TDS_DEF_BLKSZ 512
477 #define TDS_DEF_CHARSET "iso_1"
478 #define TDS_DEF_LANG "us_english"
479 #if TDS42
480 #define TDS_DEFAULT_VERSION 0x402
481 #define TDS_DEF_PORT 1433
482 #elif TDS46
483 #define TDS_DEFAULT_VERSION 0x406
484 #define TDS_DEF_PORT 4000
485 #elif TDS50
486 #define TDS_DEFAULT_VERSION 0x500
487 #define TDS_DEF_PORT 4000
488 #elif TDS70
489 #define TDS_DEFAULT_VERSION 0x700
490 #define TDS_DEF_PORT 1433
491 #elif TDS71
492 #define TDS_DEFAULT_VERSION 0x701
493 #define TDS_DEF_PORT 1433
494 #elif TDS72
495 #define TDS_DEFAULT_VERSION 0x702
496 #define TDS_DEF_PORT 1433
497 #elif TDS73
498 #define TDS_DEFAULT_VERSION 0x703
499 #define TDS_DEF_PORT 1433
500 #elif TDS74
501 #define TDS_DEFAULT_VERSION 0x704
502 #define TDS_DEF_PORT 1433
503 #else
504 #define TDS_DEFAULT_VERSION 0x000
505 #define TDS_DEF_PORT 1433
506 #endif
507 
508 /* normalized strings from freetds.conf file */
509 #define TDS_STR_VERSION "tds version"
510 #define TDS_STR_BLKSZ "initial block size"
511 #define TDS_STR_SWAPDT "swap broken dates"
512 #define TDS_STR_DUMPFILE "dump file"
513 #define TDS_STR_DEBUGLVL "debug level"
514 #define TDS_STR_DEBUGFLAGS "debug flags"
515 #define TDS_STR_TIMEOUT "timeout"
516 #define TDS_STR_QUERY_TIMEOUT "query timeout"
517 #define TDS_STR_CONNTIMEOUT "connect timeout"
518 #define TDS_STR_HOSTNAME "hostname"
519 #define TDS_STR_HOST "host"
520 #define TDS_STR_PORT "port"
521 #define TDS_STR_TEXTSZ "text size"
522 /* for big endian hosts */
523 #define TDS_STR_EMUL_LE "emulate little endian"
524 #define TDS_STR_CHARSET "charset"
525 #define TDS_STR_CLCHARSET "client charset"
526 #define TDS_STR_USE_UTF_16 "use utf-16"
527 #define TDS_STR_LANGUAGE "language"
528 #define TDS_STR_APPENDMODE "dump file append"
529 #define TDS_STR_DATEFMT "date format"
530 #define TDS_STR_INSTANCE "instance"
531 #define TDS_STR_ASA_DATABASE "asa database"
532 #define TDS_STR_DATABASE "database"
533 #define TDS_STR_ENCRYPTION "encryption"
534 #define TDS_STR_USENTLMV2 "use ntlmv2"
535 #define TDS_STR_USELANMAN "use lanman"
536 /* conf values */
537 #define TDS_STR_ENCRYPTION_OFF "off"
538 #define TDS_STR_ENCRYPTION_REQUEST "request"
539 #define TDS_STR_ENCRYPTION_REQUIRE "require"
540 /* Defines to enable optional GSSAPI delegation */
541 #define TDS_GSSAPI_DELEGATION "enable gssapi delegation"
542 /* Kerberos realm name */
543 #define TDS_STR_REALM "realm"
544 /* Kerberos SPN */
545 #define TDS_STR_SPN "spn"
546 /* CA file */
547 #define TDS_STR_CAFILE "ca file"
548 /* CRL file */
549 #define TDS_STR_CRLFILE "crl file"
550 /* check SSL hostname */
551 #define TDS_STR_CHECKSSLHOSTNAME "check certificate hostname"
552 /* database filename to attach on login (MSSQL) */
553 #define TDS_STR_DBFILENAME "database filename"
554 /* Application Intent MSSQL 2012 support */
555 #define TDS_STR_READONLY_INTENT "read-only intent"
556 /* configurable cipher suite to send to openssl's SSL_set_cipher_list() function */
557 #define TLS_STR_OPENSSL_CIPHERS "openssl ciphers"
558 
559 
560 /* TODO do a better check for alignment than this */
561 typedef union
562 {
563  void *p;
564  int i;
567 
568 #define TDS_ALIGN_SIZE sizeof(tds_align_struct)
569 
571 {
572  unsigned char type;
573  unsigned char len; /* always sizeof(values) */
574  unsigned char values[TDS_MAX_CAPABILITY/2-2];
575 } /* TDS_CAPABILITY_TYPE */;
576 
578 {
580 } /* TDS_CAPABILITIES */;
581 
582 #define TDS_MAX_LOGIN_STR_SZ 128
583 struct tds_login
584 {
585  DSTR server_name; /**< server name (in freetds.conf) */
586  int port; /**< port of database service */
587  TDS_USMALLINT tds_version; /**< TDS version */
589  DSTR language; /* e.g. us-english */
590  DSTR server_charset; /**< charset of server e.g. iso_1 */
594  DSTR server_realm_name; /**< server realm name (in freetds.conf) */
595  DSTR server_spn; /**< server SPN (in freetds.conf) */
596  DSTR db_filename; /**< database filename to attach (MSSQL) */
597  DSTR cafile; /**< certificate authorities file */
598  DSTR crlfile; /**< certificate revocation file */
601  DSTR user_name; /**< account for login */
602  DSTR password; /**< password of account login */
603  DSTR new_password; /**< new password to set (TDS 7.2+) */
604 
605  DSTR library; /* Ct-Library, DB-Library, TDS-Library or ODBC */
607 
612 
613  struct addrinfo *ip_addrs; /**< ip(s) of server */
614  struct addrinfo *connected_addr; /* ip of connected server */
621 
622  unsigned char option_flag2;
623 
624  unsigned int bulk_copy:1; /**< if bulk copy should be enabled */
625  unsigned int suppress_language:1;
626  unsigned int emul_little_endian:1;
627  unsigned int gssapi_use_delegation:1;
628  unsigned int use_ntlmv2:1;
629  unsigned int use_lanman:1;
630  unsigned int mars:1;
631  unsigned int use_utf16:1;
632  unsigned int use_new_password:1;
633  unsigned int valid_configuration:1;
634  unsigned int check_ssl_hostname:1;
635  unsigned int readonly_intent:1;
636 } /* TDSLOGIN */;
637 
638 typedef struct tds_headers
639 {
640  const char *qn_options;
641  const char *qn_msgtext;
643  /* TDS 7.4+: trace activity ID char[20] */
645 
647 {
648  char *language;
650  char *date_fmt;
651 } /* TDSLOCALE */;
652 
653 /**
654  * Information about blobs (e.g. text or image).
655  * current_row contains this structure.
656  */
657 typedef struct tds_blob
658 {
662  unsigned char valid_ptr;
664 
665 /**
666  * Store variant informations
667  */
668 typedef struct tds_variant
669 {
670  /* this MUST have same position and place of textvalue in tds_blob */
677 
678 /**
679  * Information relevant to libiconv. The name is an iconv name, not
680  * the same as found in master..syslanguages.
681  */
682 typedef struct tds_encoding
683 {
684  /** name of the encoding (ie UTF-8) */
685  const char *name;
686  unsigned char min_bytes_per_char;
687  unsigned char max_bytes_per_char;
688  /** internal numeric index into array of all encodings */
689  unsigned char canonic;
691 
693 {
697 } /* BCPCOLDATA */;
698 
699 
703 typedef unsigned tds_func_put_info_len(TDSSOCKET *tds, TDSCOLUMN *col);
705 typedef TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7);
706 typedef int tds_func_check(const TDSCOLUMN *col);
707 
709 {
713  /**
714  * Returns metadata column information size.
715  * \tds
716  * \param col column to send
717  */
719  /**
720  * Send metadata column information to server.
721  * \tds
722  * \param col column to send
723  */
725  /**
726  * Send column data to server.
727  * Usually send parameters unless bcp7 is specified, in
728  * this case send BCP for TDS7+ (Sybase use a completely
729  * different format for BCP)
730  * \tds
731  * \param col column to send
732  * \param bcp7 1 to send BCP column on TDS7+
733  */
735 #if ENABLE_EXTRA_CHECKS
736  /**
737  * Check column is valid.
738  * Some things should be checked:
739  * - column_type and on_server.column_type;
740  * - column_size and on_server.column_size;
741  * - column_cur_size;
742  * - column_prec and column_scale;
743  * - is_XXXX_type macros/functions (nullable/fixed/blob/variable);
744  * - tds_get_size_by_type;
745  * - tds_get_conversion_type.
746  *
747  * \tds
748  * \param col column to check
749  */
751 #endif
752 #if 0
753  TDSRET (*convert)(TDSSOCKET *tds, TDSCOLUMN *col);
754 #endif
755 } /* TDSCOLUMNFUNCS */;
756 
757 /**
758  * Metadata about columns in regular and compute rows
759  */
761 {
765 
766  TDS_INT column_size; /**< maximun size of data. For fixed is the size. */
767 
768  TDS_SERVER_TYPE column_type; /**< This type can be different from wire type because
769  * conversion (e.g. UCS-2->Ascii) can be applied.
770  * I'm beginning to wonder about the wisdom of this, however.
771  * April 2003 jkl
772  */
773  TDS_TINYINT column_varint_size; /**< size of length when reading from wire (0, 1, 2 or 4) */
774 
775  TDS_TINYINT column_prec; /**< precision for decimal/numeric */
776  TDS_TINYINT column_scale; /**< scale for decimal/numeric */
777 
778  struct
779  {
780  TDS_SERVER_TYPE column_type; /**< type of data, saved from wire */
783 
784  TDSICONV *char_conv; /**< refers to previously allocated iconv information */
785 
789 
791  unsigned char* column_default;
792 
793  unsigned char *column_data;
795  unsigned int column_nullable:1;
796  unsigned int column_writeable:1;
797  unsigned int column_identity:1;
798  unsigned int column_key:1;
799  unsigned int column_hidden:1;
800  unsigned int column_output:1;
801  unsigned int column_timestamp:1;
802  unsigned int column_hasdefault:1;
804 
805  /* additional fields flags for compute results */
808 
809  /* FIXME this is data related, not column */
810  /** size written in variable (ie: char, text, binary). -1 if NULL. */
812 
813  /* related to binding or info stored by client libraries */
814  /* FIXME find a best place to store these data, some are unused */
824 
826  /**
827  * The length, in bytes, of any length prefix this column may have.
828  * For example, strings in some non-C programming languages are
829  * made up of a one-byte length prefix, followed by the string
830  * data itself.
831  * If the data do not have a length prefix, set prefixlen to 0.
832  * Currently not very used in code, however do not remove.
833  */
837 };
838 
839 
840 /** Hold information for any results */
842 {
843  /* TODO those fields can became a struct */
849  unsigned char *current_row;
850  void (*row_free)(struct tds_result_info* result, unsigned char *row);
852 
856  /* TODO remove ?? used only in dblib */
858 } /* TDSRESULTINFO */;
859 
860 /** values for tds->state */
861 typedef enum tds_states
862 {
863  TDS_IDLE, /**< no data expected */
864  TDS_WRITING, /**< client is writing data */
865  TDS_SENDING, /**< client would send data */
866  TDS_PENDING, /**< cilent is waiting for data */
867  TDS_READING, /**< client is reading data */
868  TDS_DEAD /**< no connection */
870 
871 typedef enum tds_operations
872 {
874 
875  /* mssql operations */
891 
892  /* sybase operations */
895 
896 #define TDS_DBG_LOGIN __FILE__, ((__LINE__ << 4) | 11)
897 #define TDS_DBG_HEADER __FILE__, ((__LINE__ << 4) | 10)
898 #define TDS_DBG_FUNC __FILE__, ((__LINE__ << 4) | 7)
899 #define TDS_DBG_INFO2 __FILE__, ((__LINE__ << 4) | 6)
900 #define TDS_DBG_INFO1 __FILE__, ((__LINE__ << 4) | 5)
901 #define TDS_DBG_NETWORK __FILE__, ((__LINE__ << 4) | 4)
902 #define TDS_DBG_WARN __FILE__, ((__LINE__ << 4) | 3)
903 #define TDS_DBG_ERROR __FILE__, ((__LINE__ << 4) | 2)
904 #define TDS_DBG_SEVERE __FILE__, ((__LINE__ << 4) | 1)
905 
906 #define TDS_DBGFLAG_FUNC 0x80
907 #define TDS_DBGFLAG_INFO2 0x40
908 #define TDS_DBGFLAG_INFO1 0x20
909 #define TDS_DBGFLAG_NETWORK 0x10
910 #define TDS_DBGFLAG_WARN 0x08
911 #define TDS_DBGFLAG_ERROR 0x04
912 #define TDS_DBGFLAG_SEVERE 0x02
913 #define TDS_DBGFLAG_ALL 0xfff
914 #define TDS_DBGFLAG_LOGIN 0x0800
915 #define TDS_DBGFLAG_HEADER 0x0400
916 #define TDS_DBGFLAG_PID 0x1000
917 #define TDS_DBGFLAG_TIME 0x2000
918 #define TDS_DBGFLAG_SOURCE 0x4000
919 #define TDS_DBGFLAG_THREAD 0x8000
920 
921 #if 0
922 /**
923  * An attempt at better logging.
924  * Using these bitmapped values, various logging features can be turned on and off.
925  * It can be especially helpful to turn packet data on/off for security reasons.
926  */
927 enum TDS_DBG_LOG_STATE
928 {
929  TDS_DBG_LOGIN = (1 << 0) /**< for diagnosing login problems;
930  otherwise the username/password information is suppressed. */
931  , TDS_DBG_API = (1 << 1) /**< Log calls to client libraries */
932  , TDS_DBG_ASYNC = (1 << 2) /**< Log asynchronous function starts or completes. */
933  , TDS_DBG_DIAG = (1 << 3) /**< Log client- and server-generated messages */
934  , TDS_DBG_error = (1 << 4)
935  /* TODO: ^^^^^ make upper case when old #defines (above) are removed */
936  /* Log FreeTDS runtime/logic error occurs. */
937  , TDS_DBG_PACKET = (1 << 5) /**< Log hex dump of packets to/from the server. */
938  , TDS_DBG_LIBTDS = (1 << 6) /**< Log calls to (and in) libtds */
939  , TDS_DBG_CONFIG = (1 << 7) /**< replaces TDSDUMPCONFIG */
940  , TDS_DBG_DEFAULT = 0xFE /**< all above except login packets */
941 };
942 #endif
943 
944 typedef struct tds_message
945 {
952  /* -1 .. 255 */
956  /* for library-generated errors */
957  int oserr;
960 
961 typedef struct tds_upd_col
962 {
963  struct tds_upd_col *next;
965  char * columnname;
967 
968 typedef enum {
969  TDS_CURSOR_STATE_UNACTIONED = 0 /* initial value */
970  , TDS_CURSOR_STATE_REQUESTED = 1 /* called by ct_cursor */
971  , TDS_CURSOR_STATE_SENT = 2 /* sent to server */
972  , TDS_CURSOR_STATE_ACTIONED = 3 /* acknowledged by server */
974 
976 {
983 } /* TDS_CURSOR_STATUS */;
984 
986 {
992 
993 typedef enum tds_cursor_fetch
994 {
1002 
1003 /**
1004  * Holds informations about a cursor
1005  */
1007 {
1008  struct tds_cursor *next; /**< next in linked list, keep first */
1009  TDS_INT ref_count; /**< reference counter so client can retain safely a pointer */
1010  char *cursor_name; /**< name of the cursor */
1011  TDS_INT cursor_id; /**< cursor id returned by the server after cursor declare */
1012  TDS_TINYINT options; /**< read only|updatable TODO use it */
1013  /**
1014  * true if cursor was marker to be closed when connection is idle
1015  */
1017  char *query; /**< SQL query */
1018  /* TODO for updatable columns */
1019  /* TDS_TINYINT number_upd_cols; */ /**< number of updatable columns */
1020  /* TDSUPDCOL *cur_col_list; */ /**< updatable column list */
1021  TDS_INT cursor_rows; /**< number of cursor rows to fetch */
1022  /* TDSPARAMINFO *params; */ /** cursor parameter */
1025  TDSRESULTINFO *res_info; /** row fetched from this cursor */
1027 } /* TDSCURSOR */;
1028 
1029 /**
1030  * Current environment as reported by the server
1031  */
1032 struct tds_env
1033 {
1034  /** packet size (512-65535) */
1036  char *language;
1037  /** character set encoding */
1038  char *charset;
1039  /** database name */
1040  char *database;
1041 } /* TDSENV */;
1042 
1043 /**
1044  * Holds information for a dynamic (also called prepared) query.
1045  */
1047 {
1048  struct tds_dynamic *next; /**< next in linked list, keep first */
1049  TDS_INT ref_count; /**< reference counter so client can retain safely a pointer */
1050  /** numeric id for mssql7+*/
1052  /**
1053  * id of dynamic.
1054  * Usually this id correspond to server one but if not specified
1055  * is generated automatically by libTDS
1056  */
1057  char id[30];
1058  /**
1059  * this dynamic query cannot be prepared so libTDS have to construct a simple query.
1060  * This can happen for instance is tds protocol doesn't support dynamics or trying
1061  * to prepare query under Sybase that have BLOBs as parameters.
1062  */
1064  /**
1065  * true if dynamic was marker to be closed when connection is idle
1066  */
1068  /* int dyn_state; */ /* TODO use it */
1069  TDSPARAMINFO *res_info; /**< query results */
1070  /**
1071  * query parameters.
1072  * Mostly used executing query however is a good idea to prepare query
1073  * again if parameter type change in an incompatible way (ie different
1074  * types or larger size). Is also better to prepare a query knowing
1075  * parameter types earlier.
1076  */
1078  /** saved query, we need to know original query if prepare is impossible */
1079  char *query;
1080 } /* TDSDYNAMIC */;
1081 
1082 typedef enum {
1087 
1088 typedef struct tds_multiple
1089 {
1091  unsigned int flags;
1093 
1094 /* forward declaration */
1095 typedef int (*err_handler_t) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1096 
1098 {
1100  void *parent;
1101  /* handlers */
1104  int (*int_handler) (void *);
1105 };
1106 
1108 {
1109  client2ucs2
1111  , initial_char_conv_count /* keep last */
1112 };
1113 
1115 {
1119  TDSRET (*handle_next)(TDSSOCKET * tds, struct tds_authentication * auth, size_t len);
1120 } /* TDSAUTHENTICATION */;
1121 
1123 {
1124  struct tds_packet *next;
1125  short sid;
1126  unsigned len, capacity;
1127  unsigned char buf[1];
1128 } /* TDSPACKET */;
1129 
1131 {
1133 } /* TDSPOLLWAKEUP */;
1134 
1135 /* field related to connection */
1137 {
1139  TDS_UINT product_version; /**< version of product (Sybase/MS and full version) */
1141 
1142  TDS_SYS_SOCKET s; /**< tcp socket, INVALID_SOCKET if not connected */
1145 
1146  /** environment is shared between all sessions */
1148 
1149  /**
1150  * linked list of cursors allocated for this connection
1151  * contains only cursors allocated on the server
1152  */
1154  /**
1155  * list of dynamic allocated for this connection
1156  * contains only dynamic allocated on the server
1157  */
1159 
1162 
1165 
1167  unsigned int emul_little_endian:1;
1168  unsigned int use_iconv:1;
1169  unsigned int tds71rev1:1;
1170  unsigned int pending_close:1; /**< true is connection has pending closing (cursors or dynamic) */
1171  unsigned int encrypt_single_packet:1;
1172 #if ENABLE_ODBC_MARS
1173  unsigned int mars:1;
1174 
1175  TDSSOCKET *in_net_tds;
1176  TDSPACKET *packets;
1177  TDSPACKET *recv_packet;
1178  TDSPACKET *send_packets;
1179  unsigned send_pos, recv_pos;
1180 
1181 #ifdef TDS_HAVE_MUTEX
1183 #endif
1184 #define BUSY_SOCKET ((TDSSOCKET*)(TDS_UINTPTR)1)
1185 #define TDSSOCKET_VALID(tds) (((TDS_UINTPTR)(tds)) > 1)
1186  struct tds_socket **sessions;
1187  unsigned num_sessions;
1188  unsigned num_cached_packets;
1190 #endif
1191 
1192  int spid;
1194 
1196 #if defined(HAVE_GNUTLS)
1197  void *tls_credentials;
1198 #elif defined(HAVE_OPENSSL)
1199  void *tls_ctx;
1200 #else
1201  void *tls_dummy;
1202 #endif
1204  char *server;
1205 };
1206 
1207 /**
1208  * Information for a server connection
1209  */
1211 {
1212 #if ENABLE_ODBC_MARS
1214 #else
1216 #endif
1217 
1218  /** Input buffer.
1219  * Points to receiving packet buffer.
1220  * As input buffer contains just the raw packet actually this pointer
1221  * is the address of recv_packet->buf.
1222  */
1223  unsigned char *in_buf;
1224 
1225  /** Output buffer.
1226  * Points to sending packet buffer.
1227  * Output buffer can contain additional data before the raw TDS packet
1228  * so this buffer can point some bytes after send_packet->buf.
1229  */
1230  unsigned char *out_buf;
1231 
1232  /** Maximum size of packet pointed by out_buf.
1233  * The buffer is actually a bit larger to make possible to do some
1234  * optimizations (at least TDS_ADDITIONAL_SPACE bytes).
1235  */
1236  unsigned int out_buf_max;
1237  unsigned in_pos; /**< current position in in_buf */
1238  unsigned out_pos; /**< current position in out_buf */
1239  unsigned in_len; /**< input buffer length */
1240  unsigned char in_flag; /**< input buffer type */
1241  unsigned char out_flag; /**< output buffer type */
1242 
1243  void *parent;
1244 
1245 #if ENABLE_ODBC_MARS
1246  short sid;
1247  tds_condition packet_cond;
1248  TDS_UINT recv_seq;
1249  TDS_UINT send_seq;
1250  TDS_UINT recv_wnd;
1251  TDS_UINT send_wnd;
1252 #endif
1253  /* packet we received */
1255  /** packet we are preparing to send */
1257 
1258  /**
1259  * Current query information.
1260  * Contains information in process, both normal and compute results.
1261  * This pointer shouldn't be freed; it's just an alias to another structure.
1262  */
1268  TDSCURSOR *cur_cursor; /**< cursor in use */
1269  TDS_TINYINT bulk_query; /**< true is query sent was a bulk query so we need to switch state to QUERYING */
1270  TDS_TINYINT has_status; /**< true is ret_status is valid */
1271  bool in_row; /**< true if we are getting rows */
1272  TDS_INT ret_status; /**< return status from store procedure */
1274  volatile
1275  unsigned char in_cancel; /**< indicate we are waiting a cancel reply; discard tokens till acknowledge;
1276  1 mean we have to send cancel packet, 2 already sent. */
1277 
1278  TDS_INT8 rows_affected; /**< rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid */
1280 
1281  TDSDYNAMIC *cur_dyn; /**< dynamic structure in use */
1282 
1283  TDSLOGIN *login; /**< config for login stuff. After login this field is NULL */
1284 
1285  void (*env_chg_func) (TDSSOCKET * tds, int type, char *oldval, char *newval);
1287 
1289 #ifdef TDS_HAVE_MUTEX
1291 #endif
1292 };
1293 
1294 #define tds_get_ctx(tds) ((tds)->conn->tds_ctx)
1295 #define tds_set_ctx(tds, val) do { ((tds)->conn->tds_ctx) = (val); } while(0)
1296 #define tds_get_parent(tds) ((tds)->parent)
1297 #define tds_set_parent(tds, val) do { ((tds)->parent) = (val); } while(0)
1298 #define tds_get_s(tds) ((tds)->conn->s)
1299 #define tds_set_s(tds, val) do { ((tds)->conn->s) = (val); } while(0)
1300 
1301 
1302 /* config.c */
1304 typedef void (*TDSCONFPARSE) (const char *option, const char *value, void *param);
1305 int tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param);
1306 int tds_read_conf_file(TDSLOGIN * login, const char *server);
1307 void tds_parse_conf_section(const char *option, const char *value, void *param);
1310 TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN* login);
1311 struct addrinfo *tds_lookup_host(const char *servername);
1312 TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr);
1313 const char *tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax);
1314 
1315 TDSRET tds_set_interfaces_file_loc(const char *interfloc);
1316 extern const char STD_DATETIME_FMT[];
1317 int tds_parse_boolean(const char *value, int default_value);
1318 int tds_config_boolean(const char *option, const char *value, TDSLOGIN * login);
1319 
1320 TDSLOCALE *tds_get_locale(void);
1321 TDSRET tds_alloc_row(TDSRESULTINFO * res_info);
1323 BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size);
1324 TDSDYNAMIC *tds_lookup_dynamic(TDSCONNECTION * conn, const char *id);
1325 /*@observer@*/ const char *tds_prtype(int token);
1326 int tds_get_varint_size(TDSCONNECTION * conn, int datatype);
1327 TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype);
1328 
1329 
1330 /* iconv.c */
1331 TDSRET tds_iconv_open(TDSCONNECTION * conn, const char *charset, int use_utf16);
1333 void tds_srv_charset_changed(TDSCONNECTION * conn, const char *charset);
1334 void tds7_srv_charset_changed(TDSCONNECTION * conn, int sql_collate, int lcid);
1338 
1339 
1340 /* threadsafe.c */
1341 char *tds_timestamp_str(char *str, int maxlen);
1342 struct tm *tds_localtime_r(const time_t *timep, struct tm *result);
1343 struct hostent *tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop);
1344 int tds_getservice(const char *name);
1345 char *tds_get_homedir(void);
1346 
1347 
1348 /* mem.c */
1349 void tds_free_socket(TDSSOCKET * tds);
1351 void tds_free_results(TDSRESULTINFO * res_info);
1352 void tds_free_param_results(TDSPARAMINFO * param_info);
1353 void tds_free_param_result(TDSPARAMINFO * param_info);
1354 void tds_free_msg(TDSMESSAGE * message);
1356 void tds_release_cursor(TDSCURSOR **pcursor);
1357 void tds_free_bcp_column_data(BCPCOLDATA * coldata);
1360 TDSCONTEXT *tds_alloc_context(void * parent);
1363 void tds_free_input_params(TDSDYNAMIC * dyn);
1364 void tds_release_dynamic(TDSDYNAMIC ** dyn);
1365 static inline
1367 {
1369 }
1373 char *tds_alloc_client_sqlstate(int msgno);
1374 char *tds_alloc_lookup_sqlstate(TDSSOCKET * tds, int msgno);
1375 TDSLOGIN *tds_alloc_login(int use_environment);
1376 TDSDYNAMIC *tds_alloc_dynamic(TDSCONNECTION * conn, const char *id);
1377 void tds_free_login(TDSLOGIN * login);
1380 void *tds_alloc_param_data(TDSCOLUMN * curparam);
1382 TDSCURSOR * tds_alloc_cursor(TDSSOCKET * tds, const char *name, size_t namelen,
1383  const char *query, size_t querylen);
1384 void tds_free_row(TDSRESULTINFO * res_info, unsigned char *row);
1389 void * tds_realloc(void **pp, size_t new_size);
1390 #define TDS_RESIZE(p, n_elem) \
1391  tds_realloc((void **) &(p), sizeof(*(p)) * (size_t) (n_elem))
1392 #define tds_new(type, n) ((type *) malloc(sizeof(type) * (n)))
1393 #define tds_new0(type, n) ((type *) calloc(n, sizeof(type)))
1394 
1395 TDSPACKET *tds_alloc_packet(void *buf, unsigned len);
1396 TDSPACKET *tds_realloc_packet(TDSPACKET *packet, unsigned len);
1397 void tds_free_packets(TDSPACKET *packet);
1399 void tds_free_bcpinfo(TDSBCPINFO *bcpinfo);
1400 void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo);
1401 
1402 
1403 /* login.c */
1404 void tds_set_packet(TDSLOGIN * tds_login, int packet_size);
1405 void tds_set_port(TDSLOGIN * tds_login, int port);
1406 bool tds_set_passwd(TDSLOGIN * tds_login, const char *password) TDS_WUR;
1407 void tds_set_bulk(TDSLOGIN * tds_login, TDS_TINYINT enabled);
1408 bool tds_set_user(TDSLOGIN * tds_login, const char *username) TDS_WUR;
1409 bool tds_set_app(TDSLOGIN * tds_login, const char *application) TDS_WUR;
1410 bool tds_set_host(TDSLOGIN * tds_login, const char *hostname) TDS_WUR;
1411 bool tds_set_library(TDSLOGIN * tds_login, const char *library) TDS_WUR;
1412 bool tds_set_server(TDSLOGIN * tds_login, const char *server) TDS_WUR;
1413 bool tds_set_client_charset(TDSLOGIN * tds_login, const char *charset) TDS_WUR;
1414 bool tds_set_language(TDSLOGIN * tds_login, const char *language) TDS_WUR;
1415 void tds_set_version(TDSLOGIN * tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver);
1417 
1418 
1419 /* query.c */
1420 void tds_start_query(TDSSOCKET *tds, unsigned char packet_type);
1421 
1422 TDSRET tds_submit_query(TDSSOCKET * tds, const char *query);
1424 TDSRET tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...);
1425 TDSRET tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params);
1427 TDSRET tds71_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params);
1430 const char *tds_next_placeholder(const char *start);
1431 int tds_count_placeholders(const char *query);
1435 TDSRET tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDSHEADERS * head);
1441 size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id,
1442  ssize_t idlen);
1443 size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str,
1444  ssize_t len);
1445 const char *tds_skip_comment(const char *s);
1446 const char *tds_skip_quoted(const char *s);
1447 size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol);
1448 const char *tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv,
1449  const char *s, ssize_t len, size_t *out_len);
1450 void tds_convert_string_free(const char *original, const char *converted);
1451 #if !ENABLE_EXTRA_CHECKS
1452 #define tds_convert_string_free(original, converted) \
1453  do { if (original != converted) free((char*) converted); } while(0)
1454 #endif
1456 
1457 TDSRET tds_cursor_declare(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send);
1458 TDSRET tds_cursor_setrows(TDSSOCKET * tds, TDSCURSOR * cursor, int *send);
1459 TDSRET tds_cursor_open(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send);
1460 TDSRET tds_cursor_fetch(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row);
1461 TDSRET tds_cursor_get_cursor_info(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_UINT * row_number, TDS_UINT * row_count);
1467 
1470 TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO * params);
1472 
1473 
1474 /* token.c */
1476 int tds_get_token_size(int marker);
1479 int tds5_send_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG * tds_argument,
1480  TDS_INT * tds_argsize);
1481 TDSRET tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@*/ int *done_flags, unsigned flag);
1482 int determine_adjusted_size(const TDSICONV * char_conv, int size);
1483 
1484 
1485 /* data.c */
1488 
1489 
1490 /* tds_convert.c */
1491 TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr);
1493 extern const char tds_hex_digits[];
1494 
1495 
1496 /* write.c */
1498 int tds_put_n(TDSSOCKET * tds, const void *buf, size_t n);
1499 int tds_put_string(TDSSOCKET * tds, const char *buf, int len);
1503 /** Output a tinyint value */
1504 #define tds_put_tinyint(tds, ti) tds_put_byte(tds,ti)
1505 int tds_put_byte(TDSSOCKET * tds, unsigned char c);
1507 int tds_put_buf(TDSSOCKET * tds, const unsigned char *buf, int dsize, int ssize);
1508 
1509 
1510 /* read.c */
1511 unsigned char tds_get_byte(TDSSOCKET * tds);
1512 void tds_unget_byte(TDSSOCKET * tds);
1513 unsigned char tds_peek(TDSSOCKET * tds);
1515 #define tds_get_smallint(tds) ((TDS_SMALLINT) tds_get_usmallint(tds))
1517 #define tds_get_int(tds) ((TDS_INT) tds_get_uint(tds))
1519 #define tds_get_int8(tds) ((TDS_INT8) tds_get_uint8(tds))
1520 size_t tds_get_string(TDSSOCKET * tds, size_t string_len, char *dest, size_t dest_size);
1521 TDSRET tds_get_char_data(TDSSOCKET * tds, char *dest, size_t wire_size, TDSCOLUMN * curcol);
1522 void *tds_get_n(TDSSOCKET * tds, /*@out@*/ /*@null@*/ void *dest, size_t n);
1523 int tds_get_size_by_type(TDS_SERVER_TYPE servertype);
1524 DSTR* tds_dstr_get(TDSSOCKET * tds, DSTR * s, size_t len);
1525 
1526 
1527 /* util.c */
1528 int tdserror (const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, int msgno, int errnum);
1530 void tds_swap_bytes(void *buf, int bytes);
1531 #ifdef ENABLE_DEVELOPING
1532 unsigned int tds_gettime_ms(void);
1533 #endif
1534 char *tds_strndup(const void *s, TDS_INTPTR len);
1535 
1536 
1537 /* log.c */
1538 void tdsdump_off(void);
1539 void tdsdump_on(void);
1540 int tdsdump_state(void);
1541 int tdsdump_isopen(void);
1542 #include <freetds/popvis.h>
1543 int tdsdump_open(const char *filename);
1544 #include <freetds/pushvis.h>
1545 void tdsdump_close(void);
1546 void tdsdump_do_dump_buf(const char* file, unsigned int level_line,
1547  const char *msg, const void *buf, size_t length);
1548 void tdsdump_col(const TDSCOLUMN *col);
1549 void tdsdump_do_log(const char* file, unsigned int level_line,
1550  const char *fmt, ...)
1551 #if defined(__GNUC__) && __GNUC__ >= 2
1552 #if defined(__MINGW32__)
1553  __attribute__ ((__format__ (ms_printf, 3, 4)))
1554 #else
1555  __attribute__ ((__format__ (__printf__, 3, 4)))
1556 #endif
1557 #endif
1558 ;
1559 #define TDSDUMP_LOG_FAST \
1560  if (TDS_UNLIKELY(tds_write_dump && !tdsdump_elided)) tdsdump_do_log
1561 #define tdsdump_log TDSDUMP_LOG_FAST
1562 #define TDSDUMP_BUF_FAST \
1563  if (TDS_UNLIKELY(tds_write_dump && !tdsdump_elided)) tdsdump_do_dump_buf
1564 #define tdsdump_dump_buf TDSDUMP_BUF_FAST
1565 
1566 extern int tds_write_dump;
1567 extern int tds_debug_flags;
1568 extern int tds_g_append_mode;
1569 extern
1570 #ifdef NCBI_TLS_VAR
1572 #endif
1573 int tdsdump_elided;
1574 
1575 
1576 /* net.c */
1577 TDSERRNO tds_open_socket(TDSSOCKET * tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr);
1579 int tds7_get_instance_ports(FILE *output, struct addrinfo *addr);
1580 int tds7_get_instance_port(struct addrinfo *addr, const char *instance);
1581 char *tds_prwsaerror(int erc);
1582 void tds_prwsaerror_free(char *s);
1583 ssize_t tds_connection_read(TDSSOCKET * tds, unsigned char *buf,
1584  size_t buflen);
1585 ssize_t tds_connection_write(TDSSOCKET *tds, const unsigned char *buf,
1586  size_t buflen, int final);
1587 #define TDSSELREAD POLLIN
1588 #define TDSSELWRITE POLLOUT
1589 int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds);
1591 ssize_t tds_goodread(TDSSOCKET * tds, unsigned char *buf, size_t buflen);
1592 ssize_t tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer,
1593  size_t buflen);
1594 void tds_socket_flush(TDS_SYS_SOCKET sock);
1596 int tds_wakeup_init(TDSPOLLWAKEUP *wakeup);
1597 void tds_wakeup_close(TDSPOLLWAKEUP *wakeup);
1598 void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel);
1599 static inline TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup)
1600 {
1601  return wakeup->s_signaled;
1602 }
1603 
1604 
1605 /* packet.c */
1607 TDSRET tds_write_packet(TDSSOCKET * tds, unsigned char final);
1608 #if ENABLE_ODBC_MARS
1611 #else
1613 #endif
1614 
1615 
1616 /* vstrbuild.c */
1617 TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen,
1618  va_list ap);
1619 
1620 
1621 /* numeric.c */
1622 char *tds_money_to_string(const TDS_MONEY * money, char *s);
1623 TDS_INT tds_numeric_to_string(const TDS_NUMERIC * numeric, char *s);
1624 TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC * numeric, unsigned char new_prec, unsigned char new_scale);
1625 
1626 
1627 /* getmac.c */
1628 void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6]);
1629 
1630 
1631 /* challenge.c */
1632 #ifndef HAVE_SSPI
1635 #else
1636 TDSAUTHENTICATION * tds_sspi_get_auth(TDSSOCKET * tds);
1637 #endif
1638 
1639 
1640 /* random.c */
1641 void tds_random_buffer(unsigned char *out, int len);
1642 
1643 
1644 /* sec_negotiate.c */
1646 void tds5_negotiate_set_msg_type(TDSSOCKET * tds, TDSAUTHENTICATION * auth, unsigned msg_type);
1647 
1648 
1649 /* bulk.c */
1650 
1651 /** bcp direction */
1653 {
1656  TDS_BCP_QUERYOUT = 3
1657 };
1658 
1660 {
1661  const char *hint;
1662  void *parent;
1673 };
1674 
1676 typedef TDSRET (*tds_bcp_get_col_data) (TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset);
1677 typedef void (*tds_bcp_null_error) (TDSBCPINFO *bulk, int index, int offset);
1679 TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied);
1682 
1683 TDSRET tds_bcp_fread(TDSSOCKET * tds, TDSICONV * conv, FILE * stream,
1684  const char *terminator, size_t term_len, char **outbuf, size_t * outbytes);
1685 
1686 TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size);
1689 
1690 
1691 static inline
1692 bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
1693 {
1694  return (cap->values[sizeof(cap->values)-1-(cap_num>>3)] >> (cap_num&7)) & 1;
1695 }
1696 #define tds_capability_has_req(conn, cap) \
1697  tds_capability_enabled(&conn->capabilities.types[0], cap)
1698 
1699 #define IS_TDS42(x) (x->tds_version==0x402)
1700 #define IS_TDS46(x) (x->tds_version==0x406)
1701 #define IS_TDS50(x) (x->tds_version==0x500)
1702 #define IS_TDS70(x) (x->tds_version==0x700)
1703 #define IS_TDS71(x) (x->tds_version==0x701)
1704 #define IS_TDS72(x) (x->tds_version==0x702)
1705 #define IS_TDS73(x) (x->tds_version==0x703)
1706 
1707 #define IS_TDS50_PLUS(x) ((x)->tds_version>=0x500)
1708 #define IS_TDS7_PLUS(x) ((x)->tds_version>=0x700)
1709 #define IS_TDS71_PLUS(x) ((x)->tds_version>=0x701)
1710 #define IS_TDS72_PLUS(x) ((x)->tds_version>=0x702)
1711 #define IS_TDS73_PLUS(x) ((x)->tds_version>=0x703)
1712 #define IS_TDS74_PLUS(x) ((x)->tds_version>=0x704)
1713 
1714 #define TDS_MAJOR(x) ((x)->tds_version >> 8)
1715 #define TDS_MINOR(x) ((x)->tds_version & 0xff)
1716 
1717 #define IS_TDSDEAD(x) (((x) == NULL) || (x)->state == TDS_DEAD)
1718 
1719 /** Check if product is Sybase (such as Adaptive Server Enterrprice). x should be a TDSSOCKET*. */
1720 #define TDS_IS_SYBASE(x) (!((x)->conn->product_version & 0x80000000u))
1721 /** Check if product is Microsft SQL Server. x should be a TDSSOCKET*. */
1722 #define TDS_IS_MSSQL(x) (((x)->conn->product_version & 0x80000000u)!=0)
1723 
1724 /** Calc a version number for mssql. Use with TDS_MS_VER(7,0,842).
1725  * For test for a range of version you can use check like
1726  * if (tds->product_version >= TDS_MS_VER(7,0,0) && tds->product_version < TDS_MS_VER(8,0,0)) */
1727 #define TDS_MS_VER(maj,min,x) (0x80000000u|((maj)<<24)|((min)<<16)|(x))
1728 
1729 /* TODO test if not similar to ms one*/
1730 /** Calc a version number for Sybase. */
1731 #define TDS_SYB_VER(maj,min,x) (((maj)<<24)|((min)<<16)|(x)<<8)
1732 
1733 #ifdef __cplusplus
1734 #if 0
1735 {
1736 #endif
1737 }
1738 #endif
1739 
1740 #include <freetds/popvis.h>
1741 
1742 #define TDS_PUT_INT(tds,v) tds_put_int((tds), ((TDS_INT)(v)))
1743 #define TDS_PUT_SMALLINT(tds,v) tds_put_smallint((tds), ((TDS_SMALLINT)(v)))
1744 #define TDS_PUT_BYTE(tds,v) tds_put_byte((tds), ((unsigned char)(v)))
1745 
1746 #endif /* _tds_h_ */
#define head
Definition: ct_nlmzip_i.h:138
static const char si[8][64]
Definition: des.c:146
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
static const int timeout_seconds
Definition: timeout.c:13
#define TDS_SP_CURSOROPEN
Definition: proto.h:140
#define TDS_SP_PREPEXEC
Definition: proto.h:151
TDS_OPTION_CMD
options that can be sent with a TDS_OPTIONCMD token
Definition: proto.h:263
#define TDS_SP_UNPREPARE
Definition: proto.h:153
#define TDS_SP_CURSORCLOSE
Definition: proto.h:147
TDS_SERVER_TYPE
Definition: proto.h:161
#define TDS_SP_CURSOREXECUTE
Definition: proto.h:142
#define TDS_SP_CURSOR
Definition: proto.h:139
#define TDS_SP_CURSORPREPARE
Definition: proto.h:141
#define TDS_SP_PREPEXECRPC
Definition: proto.h:152
TDS_OPTION
Definition: proto.h:271
#define TDS_SP_CURSORPREPEXEC
Definition: proto.h:143
#define TDS_SP_EXECUTE
Definition: proto.h:150
#define TDS_SP_PREPARE
Definition: proto.h:149
#define TDS_SP_CURSORUNPREPARE
Definition: proto.h:144
#define TDS_SP_CURSORFETCH
Definition: proto.h:145
#define TDS_SP_CURSOROPTION
Definition: proto.h:146
#define TDS_SP_EXECUTESQL
Definition: proto.h:148
int TDS_SYS_SOCKET
#define TDS_WUR
Definition: tds.h:398
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
Definition: iconv.c:286
TDSRET tds_func_get_data(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:701
TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize)
Return type suitable for conversions (convert all nullable types to fixed type)
Definition: tds_types.h:124
#define TDS_DBG_LOGIN
Definition: tds.h:896
#define TDS_TOKEN_FLAG(flag)
Definition: tds.h:246
TDSRET tds_func_put_info(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:704
struct tm * tds_localtime_r(const time_t *timep, struct tm *result)
Definition: threadsafe.c:78
int tdsdump_elided
Definition: log.c:61
bool tds_set_user(TDSLOGIN *tds_login, const char *username)
Definition: login.c:100
void tdsdump_on(void)
Turn logging back on.
Definition: log.c:93
bool tds_set_server(TDSLOGIN *tds_login, const char *server)
Set the servername in a TDSLOGIN structure.
Definition: login.c:129
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:414
tds_operations
Definition: tds.h:872
@ TDS_OP_CURSORPREPARE
Definition: tds.h:878
@ TDS_OP_CURSORFETCH
Definition: tds.h:882
@ TDS_OP_EXECUTESQL
Definition: tds.h:885
@ TDS_OP_DYN_DEALLOC
Definition: tds.h:893
@ TDS_OP_CURSOROPEN
Definition: tds.h:877
@ TDS_OP_PREPEXECRPC
Definition: tds.h:889
@ TDS_OP_PREPEXEC
Definition: tds.h:888
@ TDS_OP_UNPREPARE
Definition: tds.h:890
@ TDS_OP_CURSORCLOSE
Definition: tds.h:884
@ TDS_OP_CURSOREXECUTE
Definition: tds.h:879
@ TDS_OP_CURSOROPTION
Definition: tds.h:883
@ TDS_OP_CURSOR
Definition: tds.h:876
@ TDS_OP_CURSORPREPEXEC
Definition: tds.h:880
@ TDS_OP_CURSORUNPREPARE
Definition: tds.h:881
@ TDS_OP_NONE
Definition: tds.h:873
@ TDS_OP_PREPARE
Definition: tds.h:886
@ TDS_OP_EXECUTE
Definition: tds.h:887
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:65
enum tds_cursor_operation TDS_CURSOR_OPERATION
tds_sysdep_int32_type TDS_INT
Definition: tds.h:149
struct tds_compiletime_settings TDS_COMPILETIME_SETTINGS
A structure to hold all the compile-time settings.
int tds_g_append_mode
Definition: log.c:54
tds_token_flags
Definition: tds.h:249
@ TDS_RETURN_ROWFMT
Definition: tds.h:252
@ TDS_STOPAT_COMPUTEFMT
Definition: tds.h:253
@ TDS_STOPAT_ROW
Definition: tds.h:256
@ TDS_HANDLE_ALL
Definition: tds.h:250
@ TDS_TOKEN_TRAILING
Definition: tds.h:262
@ TDS_STOPAT_OTHERS
Definition: tds.h:251
@ TDS_STOPAT_MSG
Definition: tds.h:259
@ TDS_STOPAT_ROWFMT
Definition: tds.h:252
@ TDS_TOKEN_RESULTS
Definition: tds.h:261
@ TDS_RETURN_PROC
Definition: tds.h:258
@ TDS_RETURN_DONE
Definition: tds.h:255
@ TDS_RETURN_COMPUTEFMT
Definition: tds.h:253
@ TDS_STOPAT_COMPUTE
Definition: tds.h:257
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:126
struct tds_variant TDSVARIANT
Store variant informations.
bool tds_set_library(TDSLOGIN *tds_login, const char *library)
Definition: login.c:156
@ TDS_TYPEFLAG_UNICODE
Definition: tds.h:427
@ TDS_TYPEFLAG_INVALID
Definition: tds.h:421
@ TDS_TYPEFLAG_NULLABLE
Definition: tds.h:422
@ TDS_TYPEFLAG_FIXED
Definition: tds.h:423
@ TDS_TYPEFLAG_ASCII
Definition: tds.h:426
@ TDS_TYPEFLAG_VARIABLE
Definition: tds.h:424
@ TDS_TYPEFLAG_COLLATE
Definition: tds.h:425
@ TDS_TYPEFLAG_DATETIME
Definition: tds.h:429
@ TDS_TYPEFLAG_NUMERIC
Definition: tds.h:428
TDS_ICONV_ENTRY
Definition: tds.h:1108
@ client2server_chardata
Definition: tds.h:1110
@ client2ucs2
Definition: tds.h:1109
@ initial_char_conv_count
Definition: tds.h:1111
struct tds_message TDSMESSAGE
static bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
Definition: tds.h:1692
void tdsdump_close(void)
Close the TDS dump log file.
Definition: log.c:207
tds_cursor_operation
Definition: tds.h:986
@ TDS_CURSOR_DELETE
Definition: tds.h:989
@ TDS_CURSOR_INSERT
Definition: tds.h:990
@ TDS_CURSOR_POSITION
Definition: tds.h:987
@ TDS_CURSOR_UPDATE
Definition: tds.h:988
void tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:225
void tdsdump_do_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:270
char * tds_money_to_string(const TDS_MONEY *money, char *s)
Definition: numeric.c:64
struct tds_headers TDSHEADERS
int tds_getservice(const char *name)
Return service port given the name.
Definition: threadsafe.c:343
struct tdsdaterec TDSDATEREC
Used by tds_datecrack.
const char STD_DATETIME_FMT[]
Definition: config.c:93
static void tds_release_cur_dyn(TDSSOCKET *tds)
Definition: tds.h:1366
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:57
struct tds_blob TDSBLOB
Information about blobs (e.g.
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
Definition: tds_types.h:9
const int tds_numeric_bytes_per_prec[]
The following little table is indexed by precision and will tell us the number of bytes required to s...
Definition: numeric.c:41
char * tds_prwsaerror(int erc)
void(* tds_bcp_null_error)(TDSBCPINFO *bulk, int index, int offset)
Definition: tds.h:1677
static bool is_tds_type_valid(int type)
Definition: tds.h:463
struct tds_multiple TDSMULTIPLE
tds_sysdep_real64_type TDS_FLOAT
Definition: tds.h:152
TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start bulk copy to server \tds.
Definition: bulk.c:980
int tds_connect_and_login(TDSSOCKET *tds, TDSLOGIN *login)
Definition: login.c:657
TDSRESULTINFO TDSPARAMINFO
Definition: tds.h:70
tds_sysdep_int64_type TDS_INT8
Definition: tds.h:153
TDS_INT tds_numeric_to_string(const TDS_NUMERIC *numeric, char *s)
Definition: numeric.c:94
tds_sysdep_intptr_type TDS_INTPTR
Definition: tds.h:155
unsigned char TDS_UCHAR
Definition: tds.h:145
void(* TDSCONFPARSE)(const char *option, const char *value, void *param)
Definition: tds.h:1304
bool tds_set_app(TDSLOGIN *tds_login, const char *application)
Definition: login.c:112
int tds_get_varint_size(TDSCONNECTION *conn, int datatype)
tds_get_varint_size() returns the size of a variable length integer returned in a TDS 7....
Definition: tds_types.h:57
void tdsdump_do_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:370
void tds_set_packet(TDSLOGIN *tds_login, int packet_size)
Definition: login.c:73
char * tds_get_homedir(void)
Get user home directory.
Definition: threadsafe.c:414
union tds_option_arg TDS_OPTION_ARG
unsigned tds_func_put_info_len(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:703
tds_cursor_fetch
Definition: tds.h:994
@ TDS_CURSOR_FETCH_RELATIVE
Definition: tds.h:1000
@ TDS_CURSOR_FETCH_PREV
Definition: tds.h:996
@ TDS_CURSOR_FETCH_NEXT
Definition: tds.h:995
@ TDS_CURSOR_FETCH_FIRST
Definition: tds.h:997
@ TDS_CURSOR_FETCH_LAST
Definition: tds.h:998
@ TDS_CURSOR_FETCH_ABSOLUTE
Definition: tds.h:999
TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)
Start writing writetext request.
Definition: bulk.c:1211
int tds5_send_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG *tds_argument, TDS_INT *tds_argsize)
TDS_CURSOR_STATE
Definition: tds.h:968
@ TDS_CURSOR_STATE_UNACTIONED
Definition: tds.h:969
@ TDS_CURSOR_STATE_REQUESTED
Definition: tds.h:970
@ TDS_CURSOR_STATE_ACTIONED
Definition: tds.h:972
@ TDS_CURSOR_STATE_SENT
Definition: tds.h:971
tds_sysdep_real32_type TDS_REAL
Definition: tds.h:151
int tds_debug_flags
Definition: log.c:53
TDSRET tds_bcp_fread(TDSSOCKET *tds, TDSICONV *conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes)
Read a data file, passing the data through iconv().
Definition: bulk.c:1141
TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start sending BCP data to server.
Definition: bulk.c:928
int tdsdump_state(void)
Get the logging state.
Definition: log.c:105
bool tds_set_host(TDSLOGIN *tds_login, const char *hostname)
Definition: login.c:106
void tds_prwsaerror_free(char *s)
unsigned char TDS_TINYINT
Definition: tds.h:146
void tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:247
tds_states
values for tds->state
Definition: tds.h:862
@ TDS_PENDING
cilent is waiting for data
Definition: tds.h:866
@ TDS_SENDING
client would send data
Definition: tds.h:865
@ TDS_READING
client is reading data
Definition: tds.h:867
@ TDS_WRITING
client is writing data
Definition: tds.h:864
@ TDS_IDLE
no data expected
Definition: tds.h:863
@ TDS_DEAD
no connection
Definition: tds.h:868
TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype)
Definition: data.c:351
tds_sysdep_int16_type TDS_SMALLINT
Definition: tds.h:147
TDSERRNO
Definition: tds.h:295
@ TDSEICONVO
Definition: tds.h:299
@ TDSEOOB
Definition: tds.h:317
@ TDSEICONVI
Definition: tds.h:300
@ TDSEFCON
Definition: tds.h:304
@ TDSEICONV2BIG
Definition: tds.h:301
@ TDSESYNC
Definition: tds.h:303
@ TDSEUMSG
Definition: tds.h:324
@ TDSEICONVAVAIL
Definition: tds.h:298
@ TDSECAPTYP
Definition: tds.h:325
@ TDSEBTOK
Definition: tds.h:316
@ TDSEPORTINSTANCE
Definition: tds.h:302
@ TDSEVERDOWN
Definition: tds.h:296
@ TDSECONF
Definition: tds.h:326
@ TDSEPWD
Definition: tds.h:313
@ TDSEBPROBADTYP
Definition: tds.h:327
@ TDSESEOF
Definition: tds.h:314
@ TDSEUTDS
Definition: tds.h:320
@ TDSEEUNR
Definition: tds.h:321
@ TDSECONN
Definition: tds.h:309
@ TDSEREAD
Definition: tds.h:306
@ TDSECLOSEIN
Definition: tds.h:328
@ TDSECLOS
Definition: tds.h:318
@ TDSETIME
Definition: tds.h:305
@ TDSESOCK
Definition: tds.h:308
@ TDSEINTF
Definition: tds.h:311
@ TDSEICONVIU
Definition: tds.h:297
@ TDSEMEM
Definition: tds.h:310
@ TDSEOK
Definition: tds.h:295
@ TDSEUHST
Definition: tds.h:312
@ TDSEWRIT
Definition: tds.h:307
@ TDSECAP
Definition: tds.h:322
@ TDSENEG
Definition: tds.h:323
@ TDSEUSCT
Definition: tds.h:319
@ TDSERPND
Definition: tds.h:315
struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop)
Definition: getaddrinfo.c:57
char * tds_timestamp_str(char *str, int maxlen)
Definition: threadsafe.c:101
void tds_set_port(TDSLOGIN *tds_login, int port)
Definition: login.c:79
#define tds_convert_string_free(original, converted)
Definition: tds.h:1452
void tds_set_version(TDSLOGIN *tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver)
Definition: login.c:67
struct tds_upd_col TDSUPDCOL
TDSRET(* tds_bcp_get_col_data)(TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset)
Definition: tds.h:1676
char TDS_CHAR
Definition: tds.h:144
tds_end
Flags returned in TDS_DONE token.
Definition: tds.h:269
@ TDS_DONE_TRAN_ABORT
Definition: tds.h:285
@ TDS_DONE_CANCELLED
acknowledging an attention command (usually a cancel)
Definition: tds.h:276
@ TDS_DONE_STMT_ABORT
Definition: tds.h:284
@ TDS_DONE_TRAN_PROGRESS
Definition: tds.h:283
@ TDS_DONE_MORE_RESULTS
more results follow
Definition: tds.h:271
@ TDS_DONE_TRAN_SUCCEED
Definition: tds.h:282
@ TDS_DONE_NO_TRAN
Definition: tds.h:281
@ TDS_DONE_SRVERROR
SQL server server error.
Definition: tds.h:278
@ TDS_DONE_FINAL
final result set, command completed successfully.
Definition: tds.h:270
@ TDS_DONE_ERROR
error occurred
Definition: tds.h:272
@ TDS_DONE_EVENT
Definition: tds.h:277
@ TDS_DONE_INXACT
transaction in progress
Definition: tds.h:273
@ TDS_DONE_PROC
results are from a stored procedure
Definition: tds.h:274
@ TDS_DONE_COUNT
count field in packet is valid
Definition: tds.h:275
tds_sysdep_uint64_type TDS_UINT8
Definition: tds.h:154
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:424
TDSSOCKET * tds_alloc_additional_socket(TDSCONNECTION *conn)
TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)
Send some data in the writetext request started by tds_writetext_start.
Definition: bulk.c:1249
TDSRET tds_func_get_info(TDSSOCKET *tds, TDSCOLUMN *col)
Definition: tds.h:700
int(* err_handler_t)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
Definition: tds.h:1095
int TDSRET
Definition: tds.h:201
tds_encryption_level
Definition: tds.h:355
@ TDS_ENCRYPTION_REQUEST
Definition: tds.h:356
@ TDS_ENCRYPTION_OFF
Definition: tds.h:356
@ TDS_ENCRYPTION_REQUIRE
Definition: tds.h:356
tds_sysdep_uint16_type TDS_USMALLINT
Definition: tds.h:148
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:322
int tdsdump_isopen(void)
Definition: log.c:111
enum tds_states TDS_STATE
values for tds->state
TDSRET tds_writetext_end(TDSSOCKET *tds)
Finish sending writetext data.
Definition: bulk.c:1266
#define TDS_SUCCESS
Definition: tds.h:203
void tdsdump_off(void)
Temporarily turn off logging.
Definition: log.c:81
TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Initialize BCP information.
Definition: bulk.c:88
enum tds_cursor_fetch TDS_CURSOR_FETCH
const unsigned char tds_type_flags_ms[256]
Definition: tds_types.h:189
tds_sysdep_uintptr_type TDS_UINTPTR
Definition: tds.h:156
TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC *numeric, unsigned char new_prec, unsigned char new_scale)
Definition: numeric.c:241
TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
Definition: tds.h:705
TDSAUTHENTICATION * tds_gss_get_auth(TDSSOCKET *tds)
struct tds_dstr * DSTR
Definition: tds.h:61
TDS_MULTIPLE_TYPE
Definition: tds.h:1082
@ TDS_MULTIPLE_EXECUTE
Definition: tds.h:1084
@ TDS_MULTIPLE_RPC
Definition: tds.h:1085
@ TDS_MULTIPLE_QUERY
Definition: tds.h:1083
tds_bcp_directions
bcp direction
Definition: tds.h:1653
@ TDS_BCP_OUT
Definition: tds.h:1655
@ TDS_BCP_IN
Definition: tds.h:1654
@ TDS_BCP_QUERYOUT
Definition: tds.h:1656
TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen, va_list ap)
Definition: vstrbuild.c:80
TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)
Send one row of data to server \tds.
Definition: bulk.c:344
TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied)
Tell we finished sending BCP data to server \tds.
Definition: bulk.c:898
TDS_INT tds_func_row_len(TDSCOLUMN *col)
Definition: tds.h:702
struct tds_encoding TDS_ENCODING
Information relevant to libiconv.
tds_sysdep_uint32_type TDS_UINT
Definition: tds.h:150
void tds_random_buffer(unsigned char *out, int len)
Definition: random.c:40
#define TDS_MAX_CAPABILITY
Definition: tds.h:469
tds_token_results
Definition: tds.h:233
@ TDS_TOKEN_RES_COMPUTE
Definition: tds.h:240
@ TDS_TOKEN_RES_OTHERS
Definition: tds.h:234
@ TDS_TOKEN_RES_PARAMFMT
Definition: tds.h:237
@ TDS_TOKEN_RES_ROWFMT
Definition: tds.h:235
@ TDS_TOKEN_RES_PROC
Definition: tds.h:241
@ TDS_TOKEN_RES_ENV
Definition: tds.h:243
@ TDS_TOKEN_RES_COMPUTEFMT
Definition: tds.h:236
@ TDS_TOKEN_RES_DONE
Definition: tds.h:238
@ TDS_TOKEN_RES_MSG
Definition: tds.h:242
@ TDS_TOKEN_RES_ROW
Definition: tds.h:239
void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6])
Definition: getmac.c:45
static TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup)
Definition: tds.h:1599
int tds_func_check(const TDSCOLUMN *col)
Definition: tds.h:706
enum tds_operations TDS_OPERATION
bool tds_set_client_charset(TDSLOGIN *tds_login, const char *charset)
Definition: login.c:162
TDSLOCALE * tds_get_locale(void)
Get locale information.
Definition: locale.c:50
void tds_swap_bytes(void *buf, int bytes)
Definition: util.c:185
bool tds_set_language(TDSLOGIN *tds_login, const char *language)
Definition: login.c:168
void tds_set_bulk(TDSLOGIN *tds_login, TDS_TINYINT enabled)
Definition: login.c:94
bool tds_set_passwd(TDSLOGIN *tds_login, const char *password)
Definition: login.c:85
enum tds_encryption_level TDS_ENCRYPTION_LEVEL
@ TDS_CUR_ISTAT_ROWCNT
Definition: tds.h:339
@ TDS_CUR_ISTAT_UNUSED
Definition: tds.h:333
@ TDS_CUR_ISTAT_CLOSED
Definition: tds.h:336
@ TDS_CUR_ISTAT_DEALLOC
Definition: tds.h:340
@ TDS_CUR_ISTAT_UPDATABLE
Definition: tds.h:338
@ TDS_CUR_ISTAT_RDONLY
Definition: tds.h:337
@ TDS_CUR_ISTAT_OPEN
Definition: tds.h:335
@ TDS_CUR_ISTAT_DECLARED
Definition: tds.h:334
#define check(s)
Definition: describecol2.c:21
static int type
Definition: getdata.c:31
static SQLCHAR output[256]
Definition: print.c:5
static const char * str(char *buf, int n)
Definition: stats.c:84
static const char * column
Definition: stats.c:23
int offset
Definition: replacements.h:160
#define addrinfo
Definition: replacements.h:98
#define option
static TDSICONV * conv
Definition: charconv.c:168
static TDSRET convert(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION direction, const char *from, size_t from_len, char *dest, size_t *dest_len)
Definition: charconv.c:57
static TDSSOCKET * tds
Definition: collations.c:37
static TDSLOGIN * login
Definition: dataread.c:31
#define tds_sysdep_real32_type
#define tds_sysdep_int16_type
#define tds_sysdep_uintptr_type
#define tds_sysdep_uint16_type
#define tds_sysdep_int64_type
#define tds_sysdep_uint32_type
#define tds_sysdep_int32_type
#define tds_sysdep_uint64_type
#define tds_sysdep_intptr_type
#define tds_sysdep_real64_type
unsigned int tds_gettime_ms(void)
Definition: util.c:209
#define tds_mutex
Definition: thread.h:336
#define tds_append_cancel
#define tds_append_fin
TDSAUTHENTICATION * tds5_negotiate_get_auth(TDSSOCKET *tds)
void tds5_negotiate_set_msg_type(TDSSOCKET *tds, TDSAUTHENTICATION *auth, unsigned msg_type)
TDSAUTHENTICATION * tds_ntlm_get_auth(TDSSOCKET *tds)
Build a NTLMSPP packet to send to server.
Definition: challenge.c:726
int tds_read_conf_file(TDSLOGIN *login, const char *server)
Read configuration info for given server return 0 on error.
Definition: config.c:346
TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr)
Definition: config.c:1026
void tds_parse_conf_section(const char *option, const char *value, void *param)
Definition: config.c:593
TDSRET tds_set_interfaces_file_loc(const char *interfloc)
Set the full name of interface file.
Definition: config.c:968
int tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param)
Read a section of configuration file (INI style file)
Definition: config.c:503
const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings(void)
Return a structure capturing the compile-time settings provided to the configure script.
Definition: config.c:1310
TDSLOGIN * tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale)
tds_read_config_info() will fill the tds connection structure based on configuration information gath...
Definition: config.c:138
struct addrinfo * tds_lookup_host(const char *servername)
Get the IP address for a hostname.
Definition: config.c:994
int tds_config_boolean(const char *option, const char *value, TDSLOGIN *login)
Definition: config.c:460
int tds_parse_boolean(const char *value, int default_value)
Definition: config.c:448
void tds_fix_login(TDSLOGIN *login)
Fix configuration after reading it.
Definition: config.c:285
TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN *login)
Set TDS version from given string.
Definition: config.c:930
TDSRET tds_iconv_open(TDSCONNECTION *conn, const char *charset, int use_utf16)
Definition: iconv.c:364
void tds_iconv_close(TDSCONNECTION *conn)
Definition: iconv.c:535
void tds_srv_charset_changed(TDSCONNECTION *conn, const char *charset)
Definition: iconv.c:850
void tds7_srv_charset_changed(TDSCONNECTION *conn, int sql_collate, int lcid)
Definition: iconv.c:840
void tds_iconv_free(TDSCONNECTION *conn)
Definition: iconv.c:546
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:1256
TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr)
Convert from db date format to a structured date format.
Definition: convert.c:3195
const char tds_hex_digits[]
Definition: convert.c:155
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
TDSRESULTINFO * tds_alloc_results(TDS_USMALLINT num_cols)
Definition: mem.c:461
TDSRET tds_alloc_compute_row(TDSCOMPUTEINFO *res_info)
Definition: mem.c:575
void tds_free_bcp_column_data(BCPCOLDATA *coldata)
Definition: mem.c:1844
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:533
TDSLOGIN * tds_alloc_login(int use_environment)
Definition: mem.c:983
void tds_detach_results(TDSRESULTINFO *info)
Detach result info from it current socket.
Definition: mem.c:497
TDSPACKET * tds_realloc_packet(TDSPACKET *packet, unsigned len)
Definition: mem.c:1095
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:373
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
Definition: mem.c:809
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
Definition: mem.c:160
TDSSOCKET * tds_realloc_socket(TDSSOCKET *tds, unsigned int bufsize)
Definition: mem.c:1350
char * tds_alloc_lookup_sqlstate(TDSSOCKET *tds, int msgno)
Definition: mem.c:1528
TDSPACKET * tds_alloc_packet(void *buf, unsigned len)
Definition: mem.c:1077
TDSCONTEXT * tds_alloc_context(void *parent)
Definition: mem.c:719
void tds_free_param_results(TDSPARAMINFO *param_info)
Definition: mem.c:581
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:320
TDSLOCALE * tds_alloc_locale(void)
Definition: mem.c:741
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:284
void tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info)
Definition: mem.c:482
void tds_free_all_results(TDSSOCKET *tds)
Definition: mem.c:663
TDSBCPINFO * tds_alloc_bcpinfo(void)
Definition: mem.c:1783
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
Definition: mem.c:1908
void tds_free_context(TDSCONTEXT *locale)
Definition: mem.c:742
void tds_release_cursor(TDSCURSOR **pcursor)
Definition: mem.c:955
void tds_cursor_deallocated(TDSCONNECTION *conn, TDSCURSOR *cursor)
Definition: mem.c:927
TDSCURSOR * tds_alloc_cursor(TDSSOCKET *tds, const char *name, size_t namelen, const char *query, size_t querylen)
Definition: mem.c:888
void tds_free_row(TDSRESULTINFO *res_info, unsigned char *row)
Definition: mem.c:612
BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size)
Definition: mem.c:1827
TDSSOCKET * tds_alloc_socket(TDSCONTEXT *context, unsigned int bufsize)
Definition: mem.c:1332
void tds_free_input_params(TDSDYNAMIC *dyn)
Frees all allocated input parameters of a dynamic statement.
Definition: mem.c:206
void tds_release_dynamic(TDSDYNAMIC **dyn)
Frees dynamic statement.
Definition: mem.c:253
void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Definition: mem.c:221
void tds_free_bcpinfo(TDSBCPINFO *bcpinfo)
Definition: mem.c:1893
void tds_free_login(TDSLOGIN *login)
Definition: mem.c:1040
void tds_free_msg(TDSMESSAGE *message)
Definition: mem.c:1484
void tds_free_locale(TDSLOCALE *locale)
Definition: mem.c:1459
char * tds_alloc_client_sqlstate(int msgno)
Definition: mem.c:1502
void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo)
Definition: mem.c:1868
void tds_free_packets(TDSPACKET *packet)
Definition: mem.c:1106
void tds_free_results(TDSRESULTINFO *res_info)
Definition: mem.c:622
TDSCOMPUTEINFO ** tds_alloc_compute_results(TDSSOCKET *tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
Definition: mem.c:431
void tds_free_socket(TDSSOCKET *tds)
Definition: mem.c:1418
void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel)
Definition: net.c:850
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer \tds.
Definition: read.c:72
int tds_put_string(TDSSOCKET *tds, const char *buf, int len)
Output a string to wire automatic translate string to unicode if needed.
Definition: write.c:97
unsigned char tds_peek(TDSSOCKET *tds)
Reads a byte from the TDS stream without removing it \tds.
Definition: read.c:100
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:168
ssize_t tds_connection_read(TDSSOCKET *tds, unsigned char *buf, size_t buflen)
Definition: net.c:973
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:548
int tds_read_packet(TDSSOCKET *tds)
Read in one 'packet' from the server.
Definition: packet.c:527
ssize_t tds_goodread(TDSSOCKET *tds, unsigned char *buf, size_t buflen)
Loops until we have received some characters return -1 on failure.
Definition: net.c:923
int tds_put_int8(TDSSOCKET *tds, TDS_INT8 i)
Definition: write.c:161
void tds_wakeup_close(TDSPOLLWAKEUP *wakeup)
Definition: net.c:840
TDSRET tds_write_packet(TDSSOCKET *tds, unsigned char final)
Definition: packet.c:740
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:225
int tds_wakeup_init(TDSPOLLWAKEUP *wakeup)
Definition: net.c:809
int tds_put_buf(TDSSOCKET *tds, const unsigned char *buf, int dsize, int ssize)
Definition: write.c:149
int tds_put_n(TDSSOCKET *tds, const void *buf, size_t n)
Definition: write.c:63
TDS_UINT8 tds_get_uint8(TDSSOCKET *tds)
Get an uint64 from the server.
Definition: read.c:140
TDSRET tds_get_char_data(TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol)
Fetch character data the wire.
Definition: read.c:195
size_t tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
Fetch a string from the wire.
Definition: read.c:166
int tds7_get_instance_ports(FILE *output, struct addrinfo *addr)
Get port of all instances.
Definition: net.c:1102
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
Definition: read.c:127
ssize_t tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, size_t buflen, int final)
Definition: net.c:1060
void tds_socket_flush(TDS_SYS_SOCKET sock)
Definition: net.c:1048
int tds_put_cancel(TDSSOCKET *tds)
Definition: packet.c:815
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
Definition: net.c:1238
const char * tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax)
Definition: net.c:200
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
Definition: read.c:113
void tds_unget_byte(TDSSOCKET *tds)
Unget will always work as long as you don't call it twice in a row.
Definition: read.c:89
int tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
Select on a socket until it's available or the timeout expires.
Definition: net.c:610
int tds_init_write_buf(TDSSOCKET *tds)
Definition: write.c:213
void * tds_get_n(TDSSOCKET *tds, void *dest, size_t n)
Get N bytes from the buffer and return them in the already allocated space given to us.
Definition: read.c:232
ssize_t tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:995
int tds_put_smallint(TDSSOCKET *tds, TDS_SMALLINT si)
Definition: write.c:190
int tds_put_byte(TDSSOCKET *tds, unsigned char c)
Definition: write.c:204
int tds_put_int(TDSSOCKET *tds, TDS_INT i)
Definition: write.c:176
void tds_connection_close(TDSCONNECTION *conn)
Definition: net.c:578
TDSERRNO tds_open_socket(TDSSOCKET *tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr)
Definition: net.c:371
DSTR * tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len)
Reads a string from wire and put in a DSTR.
Definition: read.c:300
int tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Check if dynamic request must be unprepared.
Definition: query.c:1812
TDSRET tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
Creates a temporary stored procedure in the server and execute it.
Definition: query.c:1457
void tds_start_query(TDSSOCKET *tds, unsigned char packet_type)
Start query packet of a given type \tds.
Definition: query.c:335
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:2087
TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
Definition: query.c:3403
TDSRET tds_cursor_get_cursor_info(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *row_number, TDS_UINT *row_count)
Definition: query.c:2692
TDSRET tds_disconnect(TDSSOCKET *tds)
Definition: query.c:3809
TDSRET tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Sends a previously prepared dynamic statement to the server.
Definition: query.c:1690
size_t tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol)
Get column size for wire.
Definition: query.c:1547
TDSRET tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
Return declaration for column (like "varchar(20)").
Definition: query.c:743
TDSRET tds_submit_commit(TDSSOCKET *tds, int cont)
Send a commit request.
Definition: query.c:3797
TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor)
Deallocate cursor on idle.
Definition: query.c:3116
TDSRET tds_submit_query(TDSSOCKET *tds, const char *query)
Sends a language string to the database server for processing.
Definition: query.c:213
const char * tds_skip_quoted(const char *s)
Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd])
Definition: query.c:520
TDSRET tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
Calls a RPC from server.
Definition: query.c:1990
const char * tds_next_placeholder(const char *start)
Get position of next placeholder.
Definition: query.c:540
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, ssize_t idlen)
Quote an id.
Definition: query.c:2229
TDSRET tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
Creates a temporary stored procedure in the server.
Definition: query.c:1180
TDSRET tds_submit_begin_tran(TDSSOCKET *tds)
Send a rollback request.
Definition: query.c:3724
TDSRET tds_cursor_declare(TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
Definition: query.c:2320
size_t tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, ssize_t len)
Quote a string.
Definition: query.c:2299
TDSRET tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Sends a language string to the database server for processing.
Definition: query.c:353
TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont)
Send a rollback request.
Definition: query.c:3766
TDSRET tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Unprepare dynamic on idle.
Definition: query.c:1834
const char * tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, ssize_t len, size_t *out_len)
Convert a string in an allocated buffer.
Definition: query.c:126
int tds_count_placeholders(const char *query)
Count the number of placeholders ('?') in a query.
Definition: query.c:576
const char * tds_skip_comment(const char *s)
Skip a comment in a query.
Definition: query.c:495
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
Definition: query.c:3065
TDSRET tds_cursor_setrows(TDSSOCKET *tds, TDSCURSOR *cursor, int *send)
Definition: query.c:2510
TDSRET tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...)
Format and submit a query \tds.
Definition: query.c:472
TDSRET tds_cursor_setname(TDSSOCKET *tds, TDSCURSOR *cursor)
Definition: query.c:2867
TDSRET tds_cursor_close(TDSSOCKET *tds, TDSCURSOR *cursor)
Definition: query.c:2808
TDSRET tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
Definition: query.c:3415
TDSRET tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS *head)
Definition: query.c:3369
TDSRET tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Submit a prepared query with parameters.
Definition: query.c:1312
TDSRET tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple)
Definition: query.c:3395
TDSRET tds_cursor_update(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
Definition: query.c:2934
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
Definition: query.c:195
TDSRET tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
Send option commands to server.
Definition: query.c:3448
TDSRET tds_cursor_open(TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
Definition: query.c:2366
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
Definition: query.c:1857
const char * tds_prtype(int token)
Returns string representation of the given type.
Definition: token.c:3059
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2589
int determine_adjusted_size(const TDSICONV *char_conv, int size)
Allow for maximum possible size of converted data, while being careful about integer division truncat...
Definition: token.c:3280
TDSRET tds_process_login_tokens(TDSSOCKET *tds)
tds_process_login_tokens() is called after sending the login packet to the server.
Definition: token.c:413
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:2747
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:533
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:883
TDSRET tds_process_cancel(TDSSOCKET *tds)
Definition: token.c:2556
FILE * file
char * buf
int i
yy_size_t n
int len
static void text(MDB_val *v)
Definition: mdb_dump.c:62
static MDB_envinfo info
Definition: mdb_load.c:37
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define NCBI_TLS_VAR
Definition: ncbiconf_msvc.h:77
int ssize_t
Definition: ncbiconf_msvc.h:93
const char * command
static char terminator
Definition: njn_ioutil.cpp:56
std::istream & in(std::istream &in_, double &x_)
static const char * locale
Definition: pcre2grep.c:212
static PCRE2_SIZE bufsize
Definition: pcre2grep.c:237
static uint8_t * buffer
Definition: pcre2test.c:1016
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)
Definition: string_bind.c:73
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.
Definition: tds.h:167
TDS_USMALLINT has_date
Definition: tds.h:174
TDS_USMALLINT _tds_reserved
Definition: tds.h:172
TDS_INT date
date, 0 = 1900-01-01
Definition: tds.h:169
TDS_SMALLINT offset
time offset
Definition: tds.h:170
TDS_USMALLINT time_prec
Definition: tds.h:171
TDS_USMALLINT has_time
Definition: tds.h:173
TDS_USMALLINT has_offset
Definition: tds.h:175
TDS_UINT8 time
time, 7 digit precision
Definition: tds.h:168
static string query
TDS_UCHAR * packet
Definition: tds.h:1116
TDSRET(* free)(TDSCONNECTION *conn, struct tds_authentication *auth)
Definition: tds.h:1118
TDSRET(* handle_next)(TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
Definition: tds.h:1119
TDS_UCHAR * data
Definition: tds.h:694
TDS_INT is_null
Definition: tds.h:696
TDS_INT datalen
Definition: tds.h:695
const char * hint
Definition: tds.h:1661
TDSRESULTINFO * bindinfo
Definition: tds.h:1669
TDS_INT blob_cols
Definition: tds.h:1672
TDS_CHAR * insert_stmt
Definition: tds.h:1664
void * parent
Definition: tds.h:1662
TDS_INT text_sent
Definition: tds.h:1670
TDS_INT identity_insert_on
Definition: tds.h:1666
TDS_INT xfer_init
Definition: tds.h:1667
TDS_INT next_col
Definition: tds.h:1671
DSTR tablename
Definition: tds.h:1663
TDS_INT direction
Definition: tds.h:1665
TDS_INT bind_count
Definition: tds.h:1668
Information about blobs (e.g.
Definition: tds.h:658
unsigned char valid_ptr
Definition: tds.h:662
TDS_CHAR * textvalue
Definition: tds.h:659
TDS_CHAR textptr[16]
Definition: tds.h:660
TDS_CHAR timestamp[8]
Definition: tds.h:661
TDS_CAPABILITY_TYPE types[2]
Definition: tds.h:579
unsigned char type
Definition: tds.h:572
unsigned char len
Definition: tds.h:573
unsigned char values[32/2-2]
Definition: tds.h:574
tds_func_get_info * get_info
Definition: tds.h:710
tds_func_row_len * row_len
Definition: tds.h:712
tds_func_put_info * put_info
Send metadata column information to server.
Definition: tds.h:724
tds_func_put_info_len * put_info_len
Returns metadata column information size.
Definition: tds.h:718
tds_func_get_data * get_data
Definition: tds.h:711
tds_func_put_data * put_data
Send column data to server.
Definition: tds.h:734
Metadata about columns in regular and compute rows.
Definition: tds.h:761
TDS_INT bcp_prefix_len
The length, in bytes, of any length prefix this column may have.
Definition: tds.h:834
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
Definition: tds.h:773
TDS_INT bcp_term_len
Definition: tds.h:835
TDS_TINYINT column_operator
Definition: tds.h:806
TDS_INT column_textpos
Definition: tds.h:821
TDS_INT column_size
maximun size of data.
Definition: tds.h:766
TDS_SMALLINT column_operand
Definition: tds.h:807
unsigned int column_hasdefault
Definition: tds.h:802
TDS_SMALLINT * column_nullbind
Definition: tds.h:818
DSTR column_name
Definition: tds.h:787
unsigned int column_timestamp
Definition: tds.h:801
TDS_UINT column_bindlen
Definition: tds.h:817
BCPCOLDATA * bcp_column_data
Definition: tds.h:825
TDS_UCHAR column_collation[5]
Definition: tds.h:803
void(* column_data_free)(struct tds_column *column)
Definition: tds.h:794
const TDSCOLUMNFUNCS * funcs
Definition: tds.h:762
TDS_SMALLINT column_bindtype
Definition: tds.h:815
unsigned int column_writeable
Definition: tds.h:796
DSTR table_column_name
Definition: tds.h:788
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:775
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:768
unsigned int column_identity
Definition: tds.h:797
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:784
unsigned int column_key
Definition: tds.h:798
TDS_SMALLINT column_bindfmt
Definition: tds.h:816
TDS_CHAR column_text_sqlputdatainfo
Definition: tds.h:823
DSTR table_name
Definition: tds.h:786
unsigned int column_nullable
Definition: tds.h:795
TDS_INT column_def_size
Definition: tds.h:790
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:776
unsigned char * column_data
Definition: tds.h:793
TDS_INT * column_lenbind
Definition: tds.h:820
unsigned int column_output
Definition: tds.h:800
struct tds_column::@124 on_server
TDS_CHAR * column_varaddr
Definition: tds.h:819
unsigned char * column_default
Definition: tds.h:791
TDS_INT column_flags
Definition: tds.h:764
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:811
TDS_INT column_usertype
Definition: tds.h:763
TDS_CHAR * bcp_terminator
Definition: tds.h:836
TDS_INT column_text_sqlgetdatapos
Definition: tds.h:822
unsigned int column_hidden
Definition: tds.h:799
A structure to hold all the compile-time settings.
Definition: tds.h:95
const char * freetds_version
Definition: tds.h:96
const char * sysconfdir
Definition: tds.h:97
const char * tdsver
Definition: tds.h:103
const char * last_update
Definition: tds.h:98
int char_conv_count
Definition: tds.h:1160
TDSENV env
environment is shared between all sessions
Definition: tds.h:1147
unsigned int tds71rev1
Definition: tds.h:1169
int client_spid
Definition: tds.h:1193
char * server
Definition: tds.h:1204
tds_mutex list_mtx
Definition: tds.h:1168
TDSPOLLWAKEUP wakeup
Definition: tds.h:1143
char * product_name
Definition: tds.h:1140
TDS_SYS_SOCKET s
tcp socket, INVALID_SOCKET if not connected
Definition: tds.h:1142
TDS_UCHAR collation[5]
Definition: tds.h:1163
unsigned num_cached_packets
Definition: tds.h:1170
TDSICONV ** char_convs
Definition: tds.h:1161
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1139
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server
Definition: tds.h:1153
unsigned int encrypt_single_packet
Definition: tds.h:1171
unsigned int pending_close
true is connection has pending closing (cursors or dynamic)
Definition: tds.h:1170
TDS_UCHAR tds72_transaction[8]
Definition: tds.h:1164
const TDSCONTEXT * tds_ctx
Definition: tds.h:1144
int spid
Definition: tds.h:1192
void * tls_session
Definition: tds.h:1195
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server
Definition: tds.h:1158
TDS_USMALLINT tds_version
Definition: tds.h:1138
TDSPACKET * packet_cache
Definition: tds.h:1171
TDSAUTHENTICATION * authentication
Definition: tds.h:1203
TDS_CAPABILITIES capabilities
Definition: tds.h:1166
unsigned int emul_little_endian
Definition: tds.h:1167
void * tls_dummy
Definition: tds.h:1201
unsigned int use_iconv
Definition: tds.h:1168
void * parent
Definition: tds.h:1100
TDSLOCALE * locale
Definition: tds.h:1099
int(* msg_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
Definition: tds.h:1102
int(* err_handler)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
Definition: tds.h:1103
int(* int_handler)(void *)
Definition: tds.h:1104
TDS_CURSOR_STATE close
Definition: tds.h:981
TDS_CURSOR_STATE open
Definition: tds.h:979
TDS_CURSOR_STATE declare
Definition: tds.h:977
TDS_CURSOR_STATE dealloc
Definition: tds.h:982
TDS_CURSOR_STATE fetch
Definition: tds.h:980
TDS_CURSOR_STATE cursor_row
Definition: tds.h:978
Holds informations about a cursor.
Definition: tds.h:1007
char * query
SQL query.
Definition: tds.h:1017
TDS_TINYINT options
read only|updatable TODO use it
Definition: tds.h:1012
char * cursor_name
name of the cursor
Definition: tds.h:1010
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:1009
TDS_TINYINT defer_close
true if cursor was marker to be closed when connection is idle
Definition: tds.h:1016
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:1011
TDS_INT cursor_rows
< number of updatable columns
Definition: tds.h:1021
TDS_INT type
row fetched from this cursor
Definition: tds.h:1026
TDS_INT concurrency
Definition: tds.h:1026
TDS_CURSOR_STATUS status
cursor parameter
Definition: tds.h:1023
TDSRESULTINFO * res_info
Definition: tds.h:1025
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:1008
TDS_USMALLINT srv_status
Definition: tds.h:1024
Structure to hold a string.
Definition: tds.h:116
char dstr_s[1]
Definition: tds.h:118
size_t dstr_size
Definition: tds.h:117
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1047
TDS_TINYINT defer_close
true if dynamic was marker to be closed when connection is idle
Definition: tds.h:1067
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:1048
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:1049
char * query
saved query, we need to know original query if prepare is impossible
Definition: tds.h:1079
TDSPARAMINFO * params
query parameters.
Definition: tds.h:1077
TDSPARAMINFO * res_info
query results
Definition: tds.h:1069
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query.
Definition: tds.h:1063
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:1051
Information relevant to libiconv.
Definition: tds.h:683
unsigned char max_bytes_per_char
Definition: tds.h:687
const char * name
name of the encoding (ie UTF-8)
Definition: tds.h:685
unsigned char min_bytes_per_char
Definition: tds.h:686
unsigned char canonic
internal numeric index into array of all encodings
Definition: tds.h:689
Current environment as reported by the server.
Definition: tds.h:1033
char * charset
character set encoding
Definition: tds.h:1038
int block_size
packet size (512-65535)
Definition: tds.h:1035
char * database
database name
Definition: tds.h:1040
char * language
Definition: tds.h:1036
const char * qn_msgtext
Definition: tds.h:641
TDS_INT qn_timeout
Definition: tds.h:642
const char * qn_options
Definition: tds.h:640
char * date_fmt
Definition: tds.h:650
char * server_charset
Definition: tds.h:649
char * language
Definition: tds.h:648
Definition: tds.h:584
unsigned int use_ntlmv2
Definition: tds.h:628
unsigned int use_new_password
Definition: tds.h:632
TDS_INT query_timeout
Definition: tds.h:608
DSTR crlfile
certificate revocation file
Definition: tds.h:598
unsigned int check_ssl_hostname
Definition: tds.h:634
DSTR server_realm_name
server realm name (in freetds.conf)
Definition: tds.h:594
DSTR database
Definition: tds.h:611
DSTR client_charset
Definition: tds.h:610
DSTR user_name
account for login
Definition: tds.h:601
TDS_INT connect_timeout
Definition: tds.h:591
unsigned int gssapi_use_delegation
Definition: tds.h:627
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:613
DSTR password
password of account login
Definition: tds.h:602
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:596
TDS_CAPABILITIES capabilities
Definition: tds.h:609
DSTR routing_address
Definition: tds.h:619
unsigned int readonly_intent
Definition: tds.h:635
TDS_TINYINT encryption_level
Definition: tds.h:606
unsigned char option_flag2
Definition: tds.h:622
DSTR client_host_name
Definition: tds.h:592
DSTR dump_file
Definition: tds.h:616
unsigned int valid_configuration
Definition: tds.h:633
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:585
DSTR instance_name
Definition: tds.h:615
DSTR server_charset
charset of server e.g.
Definition: tds.h:590
DSTR language
Definition: tds.h:589
int debug_flags
Definition: tds.h:617
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:587
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:603
struct addrinfo * connected_addr
Definition: tds.h:614
unsigned int use_utf16
Definition: tds.h:631
unsigned int use_lanman
Definition: tds.h:629
unsigned int suppress_language
Definition: tds.h:625
int text_size
Definition: tds.h:618
DSTR server_host_name
Definition: tds.h:593
unsigned int emul_little_endian
Definition: tds.h:626
DSTR openssl_ciphers
Definition: tds.h:599
unsigned int bulk_copy
if bulk copy should be enabled
Definition: tds.h:624
DSTR cafile
certificate authorities file
Definition: tds.h:597
unsigned int mars
Definition: tds.h:630
DSTR server_spn
server SPN (in freetds.conf)
Definition: tds.h:595
TDS_USMALLINT routing_port
Definition: tds.h:620
int port
port of database service
Definition: tds.h:586
int block_size
Definition: tds.h:588
DSTR library
Definition: tds.h:605
DSTR app_name
Definition: tds.h:600
TDS_CHAR * sql_state
Definition: tds.h:949
TDS_CHAR * message
Definition: tds.h:947
TDS_INT msgno
Definition: tds.h:950
TDS_CHAR * proc_name
Definition: tds.h:948
TDS_CHAR * osstr
Definition: tds.h:958
TDS_INT line_number
Definition: tds.h:951
TDS_CHAR * server
Definition: tds.h:946
int oserr
Definition: tds.h:957
TDS_TINYINT priv_msg_type
Definition: tds.h:954
TDS_TINYINT severity
Definition: tds.h:955
TDS_SMALLINT state
Definition: tds.h:953
TDS_MULTIPLE_TYPE type
Definition: tds.h:1090
unsigned int flags
Definition: tds.h:1091
short sid
Definition: tds.h:1125
unsigned len
Definition: tds.h:1126
unsigned char buf[1]
Definition: tds.h:1127
struct tds_packet * next
Definition: tds.h:1124
unsigned capacity
Definition: tds.h:1126
TDS_SYS_SOCKET s_signaled
Definition: tds.h:1132
TDS_SYS_SOCKET s_signal
Definition: tds.h:1132
Hold information for any results.
Definition: tds.h:842
TDS_TINYINT rows_exist
Definition: tds.h:855
unsigned char * current_row
Definition: tds.h:849
TDS_SMALLINT * bycolumns
Definition: tds.h:853
TDS_USMALLINT computeid
Definition: tds.h:846
TDSCOLUMN ** columns
Definition: tds.h:844
TDS_USMALLINT num_cols
Definition: tds.h:845
TDS_INT ref_count
Definition: tds.h:847
TDS_TINYINT more_results
Definition: tds.h:857
TDS_USMALLINT by_cols
Definition: tds.h:854
void(* row_free)(struct tds_result_info *result, unsigned char *row)
Definition: tds.h:850
TDS_INT row_size
Definition: tds.h:851
TDSSOCKET * attached_to
Definition: tds.h:848
Information for a server connection.
Definition: tds.h:1211
void(* env_chg_func)(TDSSOCKET *tds, int type, char *oldval, char *newval)
Definition: tds.h:1285
unsigned in_len
input buffer length
Definition: tds.h:1239
TDSCOMPUTEINFO ** comp_info
Definition: tds.h:1266
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1272
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1283
unsigned out_pos
current position in out_buf
Definition: tds.h:1238
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1268
void * parent
Definition: tds.h:1243
unsigned char * out_buf
Output buffer.
Definition: tds.h:1230
TDS_TINYINT has_status
true is ret_status is valid
Definition: tds.h:1270
unsigned char in_flag
input buffer type
Definition: tds.h:1240
tds_mutex wire_mtx
Definition: tds.h:1306
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1278
TDSPACKET * send_packet
packet we are preparing to send
Definition: tds.h:1256
unsigned char * in_buf
Input buffer.
Definition: tds.h:1223
TDS_TINYINT bulk_query
true is query sent was a bulk query so we need to switch state to QUERYING
Definition: tds.h:1269
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1281
unsigned char out_flag
output buffer type
Definition: tds.h:1241
unsigned in_pos
current position in in_buf
Definition: tds.h:1237
TDS_STATE state
Definition: tds.h:1273
bool in_row
true if we are getting rows
Definition: tds.h:1271
TDSCONNECTION conn[1]
Definition: tds.h:1215
int option_value
Definition: tds.h:1288
TDSPACKET * recv_packet
Definition: tds.h:1254
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1263
TDSRESULTINFO * res_info
Definition: tds.h:1264
TDS_UINT num_comp_info
Definition: tds.h:1265
volatile unsigned char in_cancel
indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cance...
Definition: tds.h:1275
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1236
TDS_INT query_timeout
Definition: tds.h:1279
TDSPARAMINFO * param_info
Definition: tds.h:1267
TDS_OPERATION current_op
Definition: tds.h:1286
char * columnname
Definition: tds.h:965
struct tds_upd_col * next
Definition: tds.h:963
TDS_INT colnamelength
Definition: tds.h:964
Store variant informations.
Definition: tds.h:669
TDS_SERVER_TYPE type
Definition: tds.h:674
TDS_UCHAR collation[5]
Definition: tds.h:675
TDS_CHAR * data
Definition: tds.h:671
TDS_INT data_len
Definition: tds.h:673
TDS_INT size
Definition: tds.h:672
Used by tds_datecrack.
Definition: tds.h:180
TDS_INT dayofyear
day of year (1-366)
Definition: tds.h:185
TDS_INT weekday
day of week (0-6, 0 = sunday)
Definition: tds.h:186
TDS_INT year
year
Definition: tds.h:181
TDS_INT timezone
-840 - 840 minutes from UTC
Definition: tds.h:191
TDS_INT minute
0-59
Definition: tds.h:188
TDS_INT day
day of month (1-31)
Definition: tds.h:184
TDS_INT decimicrosecond
0-9999999
Definition: tds.h:190
TDS_INT second
0-59
Definition: tds.h:189
TDS_INT quarter
quarter (0-3)
Definition: tds.h:182
TDS_INT hour
0-23
Definition: tds.h:187
TDS_INT month
month number (0-11)
Definition: tds.h:183
Definition: type.c:6
else result
Definition: token2.c:20
void * p
Definition: tds.h:563
TDS_INT8 ui
Definition: tds.h:565
TDS_TINYINT ti
Definition: tds.h:349
TDS_CHAR * c
Definition: tds.h:351
TDS_INT i
Definition: tds.h:350
Definition: proto.h:39
uchar outbuf[(1000000+1000000)]
Definition: unzcrash.c:41
static CS_CONTEXT * context
Definition: will_convert.c:21
@ DONE
Definition: inflate.h:49
Modified on Fri Sep 20 14:58:18 2024 by modify_doxy.py rev. 669887