#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include "tdsver.h"
#include "tds_sysdep_public.h"
Go to the source code of this file.
Classes | |
struct | _tds_bcpcoldata |
struct | _tds_compiletime_settings |
A structure to hold all the compile-time settings. More... | |
struct | _tds_cursor |
struct | _tds_cursor_status |
struct | _tds_encoding |
Information relevant to libiconv. More... | |
struct | DSTR_STRUCT |
struct | TDS8_COLLATION |
TDS 8.0 collation information. More... | |
union | tds_align_struct |
struct | tds_answer |
struct | tds_blob |
Information about blobs (e.g. More... | |
struct | tds_column |
Metadata about columns in regular and compute rows. More... | |
struct | tds_connection |
struct | tds_context |
struct | tds_dynamic |
struct | tds_env |
struct | tds_locale |
struct | tds_login |
struct | tds_message |
struct | tds_multiple |
union | tds_option_arg |
struct | tds_result_info |
Hold information for any results. More... | |
struct | tds_socket |
struct | tds_upd_col |
struct | tdsdaterec |
information on data, used by tds_datecrack More... | |
struct | tdsdatetime |
struct | tdsdatetime4 |
union | tdsmoney |
struct | tdsmoney4 |
struct | tdsnumeric |
struct | tdsoldmoney |
struct | tdsunique |
struct | tdsvarbinary |
struct | tdsvarchar |
Defines | |
#define | CANCEL_PROCESS 2 |
#define | GOTO_1ST_ROW 3 |
#define | is_ascii_type(x) ( x==XSYBCHAR || x==XSYBVARCHAR || x==SYBTEXT || x==SYBCHAR || x==SYBVARCHAR) |
#define | is_binary_type(x) (x==SYBLONGBINARY) |
#define | is_blob_type(x) (x==SYBTEXT || x==SYBIMAGE || x==SYBNTEXT) |
#define | is_char_type(x) (is_unicode_type(x) || is_ascii_type(x)) |
#define | IS_CLOSE 400 |
#define | is_collate_type(x) (x==XSYBVARCHAR || x==XSYBCHAR || x==SYBTEXT || x==XSYBNVARCHAR || x==XSYBNCHAR || x==SYBNTEXT) |
#define | IS_CURROW 200 |
#define | IS_DECLARE 100 |
#define | is_end_token(x) |
#define | is_fixed_type(x) |
#define | is_hard_end_token(x) |
#define | is_msg_token(x) |
#define | is_nullable_type(x) |
#define | is_numeric_type(x) (x==SYBNUMERIC || x==SYBDECIMAL) |
#define | IS_OPEN 300 |
#define | is_result_token(x) |
#define | is_similar_type(x, y) ((is_char_type(x) && is_char_type(y)) || ((is_unicode_type(x) && is_unicode_type(y)))) |
#define | IS_TDS42(x) (x->major_version==4 && x->minor_version==2) |
#define | IS_TDS46(x) (x->major_version==4 && x->minor_version==6) |
#define | IS_TDS50(x) (x->major_version==5 && x->minor_version==0) |
#define | IS_TDS70(x) (x->major_version==7 && x->minor_version==0) |
#define | IS_TDS7_PLUS(x) ( IS_TDS70(x) || IS_TDS80(x) ) |
#define | IS_TDS80(x) (x->major_version==8 && x->minor_version==0) |
#define | IS_TDSDEAD(x) (((x) == NULL) || TDS_IS_SOCKET_INVALID((x)->s)) |
#define | is_unicode_type(x) (x==XSYBNVARCHAR || x==XSYBNCHAR || x==SYBNTEXT) |
#define | LOGIN 4 |
#define | MAXPRECISION 80 |
#define | PROCESS_RESULTS 1 |
#define | PROCESS_ROWS 0 |
#define | SYBAOPAVG 0x4f |
#define | SYBAOPAVGU 0x50 |
#define | SYBAOPCHECKSUM_AGG 0x72 |
#define | SYBAOPCNT 0x4b |
#define | SYBAOPCNT_BIG 0x09 |
#define | SYBAOPCNTU 0x4c |
#define | SYBAOPMAX 0x52 |
#define | SYBAOPMIN 0x51 |
#define | SYBAOPSTDEV 0x30 |
#define | SYBAOPSTDEVP 0x31 |
#define | SYBAOPSUM 0x4d |
#define | SYBAOPSUMU 0x4e |
#define | SYBAOPVAR 0x32 |
#define | SYBAOPVARP 0x33 |
#define | SYBBINARY SYBBINARY |
#define | SYBBIT SYBBIT |
#define | SYBBITN SYBBITN |
#define | SYBCHAR SYBCHAR |
#define | SYBDATETIME SYBDATETIME |
#define | SYBDATETIME4 SYBDATETIME4 |
#define | SYBDATETIMN SYBDATETIMN |
#define | SYBDECIMAL SYBDECIMAL |
#define | SYBFLT8 SYBFLT8 |
#define | SYBFLTN SYBFLTN |
#define | SYBIMAGE SYBIMAGE |
#define | SYBINT1 SYBINT1 |
#define | SYBINT2 SYBINT2 |
#define | SYBINT4 SYBINT4 |
#define | SYBINT8 SYBINT8 |
#define | SYBINTN SYBINTN |
#define | SYBLONGBINARY SYBLONGBINARY |
#define | SYBMONEY SYBMONEY |
#define | SYBMONEY4 SYBMONEY4 |
#define | SYBMONEYN SYBMONEYN |
#define | SYBNTEXT SYBNTEXT |
#define | SYBNUMERIC SYBNUMERIC |
#define | SYBNVARCHAR SYBNVARCHAR |
#define | SYBREAL SYBREAL |
#define | SYBSINT1 SYBSINT1 |
#define | SYBTEXT SYBTEXT |
#define | SYBUINT2 SYBUINT2 |
#define | SYBUINT4 SYBUINT4 |
#define | SYBUINT8 SYBUINT8 |
#define | SYBUNIQUE SYBUNIQUE |
#define | SYBVARBINARY SYBVARBINARY |
#define | SYBVARCHAR SYBVARCHAR |
#define | SYBVARIANT SYBVARIANT |
#define | SYBVOID SYBVOID |
#define | TDS5_DYNAMIC_TOKEN 231 |
#define | TDS5_PARAMFMT2_TOKEN 32 |
#define | TDS5_PARAMFMT_TOKEN 236 |
#define | TDS5_PARAMS_TOKEN 215 |
#define | TDS7_COMPUTE_RESULT_TOKEN 136 |
#define | TDS7_RESULT_TOKEN 129 |
#define | TDS_ALIGN_SIZE sizeof(tds_align_struct) |
#define | TDS_AUTH_TOKEN 237 |
#define | TDS_BYTE_SWAP16(value) |
#define | TDS_BYTE_SWAP32(value) |
#define | TDS_CANCELLED 3 |
#define | TDS_CAPABILITY_TOKEN 226 |
#define | TDS_CMD_DONE 4046 |
#define | TDS_CMD_FAIL 4048 |
#define | TDS_CMD_SUCCEED 4047 |
#define | TDS_CMP_ROW_TOKEN 211 |
#define | TDS_COLFMT_TOKEN 161 |
#define | TDS_COLINFO_TOKEN 165 |
#define | TDS_COLNAME_TOKEN 160 |
#define | TDS_COMPUTE_NAMES_TOKEN 167 |
#define | TDS_COMPUTE_RESULT 4045 |
#define | TDS_COMPUTE_RESULT_TOKEN 168 |
#define | TDS_COMPUTEFMT_RESULT 4050 |
#define | TDS_CONTROL_TOKEN 174 |
#define | TDS_CURCLOSE_TOKEN 128 |
#define | TDS_CURDECLARE_TOKEN 134 |
#define | TDS_CURFETCH_TOKEN 130 |
#define | TDS_CURINFO_TOKEN 131 |
#define | TDS_CUROPEN_TOKEN 132 |
#define | TDS_DBG_ERROR __FILE__, ((__LINE__ << 4) | 2) |
#define | TDS_DBG_FUNC __FILE__, ((__LINE__ << 4) | 7) |
#define | TDS_DBG_INFO1 __FILE__, ((__LINE__ << 4) | 5) |
#define | TDS_DBG_INFO2 __FILE__, ((__LINE__ << 4) | 6) |
#define | TDS_DBG_NETWORK __FILE__, ((__LINE__ << 4) | 4) |
#define | TDS_DBG_SEVERE __FILE__, ((__LINE__ << 4) | 1) |
#define | TDS_DBG_WARN __FILE__, ((__LINE__ << 4) | 3) |
#define | TDS_DBGFLAG_ALLLVL 0xfff |
#define | TDS_DBGFLAG_ERROR 0x04 |
#define | TDS_DBGFLAG_FUNC 0x80 |
#define | TDS_DBGFLAG_INFO1 0x20 |
#define | TDS_DBGFLAG_INFO2 0x40 |
#define | TDS_DBGFLAG_NETWORK 0x10 |
#define | TDS_DBGFLAG_PID 0x1000 |
#define | TDS_DBGFLAG_SEVERE 0x02 |
#define | TDS_DBGFLAG_SOURCE 0x4000 |
#define | TDS_DBGFLAG_THREAD 0x8000 |
#define | TDS_DBGFLAG_TIME 0x2000 |
#define | TDS_DBGFLAG_WARN 0x08 |
#define | TDS_DBRPC_TOKEN 230 |
#define | TDS_DEF_BLKSZ 512 |
#define | TDS_DEF_CHARSET "iso_1" |
#define | TDS_DEF_LANG "us_english" |
#define | TDS_DEF_MAJOR 5 |
#define | TDS_DEF_MINOR 0 |
#define | TDS_DEF_PORT 4000 |
#define | TDS_DEF_SERVER "SYBASE" |
#define | TDS_DESCRIBE_RESULT 4051 |
#define | TDS_DONE_RESULT 4052 |
#define | TDS_DONE_TOKEN 253 |
#define | TDS_DONEINPROC_RESULT 4054 |
#define | TDS_DONEINPROC_TOKEN 255 |
#define | TDS_DONEPROC_RESULT 4053 |
#define | TDS_DONEPROC_TOKEN 254 |
#define | TDS_DONT_RETURN 42 |
#define | TDS_DYNAMIC2_TOKEN 163 |
#define | TDS_EED_TOKEN 229 |
#define | TDS_ENV_CHARSET 3 |
#define | TDS_ENV_DATABASE 1 |
#define | TDS_ENV_LANG 2 |
#define | TDS_ENV_LCID 5 |
#define | TDS_ENV_PACKSIZE 4 |
#define | TDS_ENV_SQLCOLLATION 7 |
#define | TDS_ENVCHANGE_TOKEN 227 |
#define | TDS_ERROR 3 |
#define | TDS_ERROR_TOKEN 170 |
#define | TDS_FAIL 0 |
#define | TDS_INFO_TOKEN 171 |
#define | TDS_INT_CANCEL 2 |
#define | TDS_INT_CONTINUE 1 |
#define | TDS_INT_EXIT 0 |
#define | TDS_INT_TIMEOUT 3 |
#define | TDS_IS_MSSQL(x) ((x->product_version & 0x80000000u)!=0) |
Check if product is Microsft SQL Server. | |
#define | TDS_IS_SYBASE(x) (!(x->product_version & 0x80000000u)) |
Check if product is Sybase (such as Adaptive Server Enterrprice). | |
#define | TDS_LANGUAGE_TOKEN 33 |
#define | TDS_LOGINACK_TOKEN 173 |
#define | TDS_LOGOUT_TOKEN 113 |
#define | TDS_MAX_CAPABILITY 22 |
#define | TDS_MAX_CONN 4096 |
#define | TDS_MAX_DYNID_LEN 30 |
#define | TDS_MAX_LOGIN_STR_SZ 30 |
#define | TDS_MS_VER(maj, min, x) (0x80000000u|((maj)<<24)|((min)<<16)|(x)) |
Calc a version number for mssql. | |
#define | TDS_MSG_RESULT 4044 |
#define | TDS_NO_COUNT -1 |
#define | TDS_NO_MORE_RESULTS 2 |
#define | TDS_NULLTERM -9 |
#define | TDS_OPTIONCMD_TOKEN 166 |
#define | TDS_ORDERBY2_TOKEN 34 |
#define | TDS_ORDERBY_TOKEN 169 |
#define | TDS_OTHERS_RESULT 4055 |
#define | TDS_PARAM_RESULT 4042 |
#define | TDS_PARAM_TOKEN 172 |
#define | TDS_PROCID_TOKEN 124 |
#define | tds_put_tinyint(tds, ti) tds_put_byte(tds,ti) |
Output a tinyint value. | |
#define | TDS_RESULT_TOKEN 238 |
#define | TDS_RETURNSTATUS_TOKEN 121 |
#define | TDS_ROW_RESULT 4040 |
#define | TDS_ROW_TOKEN 209 |
#define | TDS_ROWFMT2_TOKEN 97 |
#define | TDS_ROWFMT_RESULT 4049 |
#define | TDS_SF_ACCENT_SENSITIVE (TDS_USMALLINT) 0x020 |
#define | TDS_SF_BIN (TDS_USMALLINT) 0x100 |
#define | TDS_SF_CASE_INSENSITIVE (TDS_USMALLINT) 0x010 |
#define | TDS_SF_KATATYPE_INSENSITIVE (TDS_USMALLINT) 0x040 |
#define | TDS_SF_WIDTH_INSENSITIVE (TDS_USMALLINT) 0x080 |
#define | TDS_SP_CURSOR 1 |
#define | TDS_SP_CURSORCLOSE 9 |
#define | TDS_SP_CURSOREXECUTE 4 |
#define | TDS_SP_CURSORFETCH 7 |
#define | TDS_SP_CURSOROPEN 2 |
#define | TDS_SP_CURSOROPTION 8 |
#define | TDS_SP_CURSORPREPARE 3 |
#define | TDS_SP_CURSORPREPEXEC 5 |
#define | TDS_SP_CURSORUNPREPARE 6 |
#define | TDS_SP_EXECUTE 12 |
#define | TDS_SP_EXECUTESQL 10 |
#define | TDS_SP_PREPARE 11 |
#define | TDS_SP_PREPEXEC 13 |
#define | TDS_SP_PREPEXECRPC 14 |
#define | TDS_SP_UNPREPARE 15 |
#define | TDS_STATUS_RESULT 4043 |
#define | TDS_STR_APPENDMODE "dump file append" |
#define | TDS_STR_BLKSZ "initial block size" |
#define | TDS_STR_CHARSET "charset" |
#define | TDS_STR_CLCHARSET "client charset" |
#define | TDS_STR_CONNTIMEOUT "connect timeout" |
#define | TDS_STR_DATEFMT "date format" |
#define | TDS_STR_DEBUGFLAGS "debug flags" |
#define | TDS_STR_DEBUGLVL "debug level" |
#define | TDS_STR_DUMPFILE "dump file" |
#define | TDS_STR_EMUL_LE "emulate little endian" |
#define | TDS_STR_HOST "host" |
#define | TDS_STR_HOSTNAME "hostname" |
#define | TDS_STR_INSTANCE "instance" |
#define | TDS_STR_LANGUAGE "language" |
#define | TDS_STR_PORT "port" |
#define | TDS_STR_QUERY_TIMEOUT "query timeout" |
#define | TDS_STR_SWAPDT "swap broken dates" |
#define | TDS_STR_SWAPMNY "swap broken money" |
#define | TDS_STR_TEXTSZ "text size" |
#define | TDS_STR_TIMEOUT "timeout" |
#define | TDS_STR_VERSION "tds version" |
#define | TDS_SUCCEED 1 |
#define | TDS_SYB_VER(maj, min, x) (((maj)<<24)|((min)<<16)|(x)<<8) |
Calc a version number for Sybase. | |
#define | TDS_TABNAME_TOKEN 164 |
#define | TDS_TOKEN_FLAG(flag) TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2)) |
#define | TDS_UT_TIMESTAMP 80 |
#define | TDS_VECTOR_SIZE(x) (sizeof(x)/sizeof(x[0])) |
#define | TDS_ZERO_FREE(x) do {free((x)); (x) = NULL;} while(0) |
#define | XSYBBINARY XSYBBINARY |
#define | XSYBCHAR XSYBCHAR |
#define | XSYBNCHAR XSYBNCHAR |
#define | XSYBNVARCHAR XSYBNVARCHAR |
#define | XSYBVARBINARY XSYBVARBINARY |
#define | XSYBVARCHAR XSYBVARCHAR |
Typedefs | |
typedef _tds_bcpcoldata | BCPCOLDATA |
typedef DSTR_STRUCT * | DSTR |
typedef char | TDS_CHAR |
typedef _tds_compiletime_settings | TDS_COMPILETIME_SETTINGS |
A structure to hold all the compile-time settings. | |
typedef _tds_cursor_status | TDS_CURSOR_STATUS |
typedef tdsdatetime | TDS_DATETIME |
typedef tdsdatetime4 | TDS_DATETIME4 |
typedef _tds_encoding | TDS_ENCODING |
Information relevant to libiconv. | |
typedef tds_sysdep_real64_type | TDS_FLOAT |
typedef tds_sysdep_int32_type | TDS_INT |
typedef tds_sysdep_int64_type | TDS_INT8 |
typedef tds_sysdep_intptr_type | TDS_INTPTR |
typedef tdsmoney | TDS_MONEY |
typedef tdsmoney4 | TDS_MONEY4 |
typedef tdsnumeric | TDS_NUMERIC |
typedef tdsoldmoney | TDS_OLD_MONEY |
typedef tds_option_arg | TDS_OPTION_ARG |
typedef enum tds_packet_type | TDS_PACKET_TYPE |
typedef tds_sysdep_real32_type | TDS_REAL |
typedef tds_sysdep_int16_type | TDS_SMALLINT |
typedef enum _TDS_STATE | TDS_STATE |
typedef unsigned char | TDS_TINYINT |
typedef unsigned char | TDS_UCHAR |
typedef unsigned tds_sysdep_int32_type | TDS_UINT |
typedef unsigned tds_sysdep_int64_type | TDS_UINT8 |
typedef tdsunique | TDS_UNIQUE |
typedef unsigned tds_sysdep_int16_type | TDS_USMALLINT |
typedef tdsvarbinary | TDS_VARBINARY |
typedef tdsvarchar | TDS_VARCHAR |
typedef tds_answer | TDSANSWER |
typedef tds_blob | TDSBLOB |
Information about blobs (e.g. | |
typedef tds_column | TDSCOLUMN |
Metadata about columns in regular and compute rows. | |
typedef tds_result_info | TDSCOMPUTEINFO |
typedef void(*) | TDSCONFPARSE (const char *option, const char *value, void *param) |
typedef tds_connection | TDSCONNECTION |
typedef tds_context | TDSCONTEXT |
typedef _tds_cursor | TDSCURSOR |
typedef tdsdaterec | TDSDATEREC |
information on data, used by tds_datecrack | |
typedef tds_dynamic | TDSDYNAMIC |
typedef tds_env | TDSENV |
typedef tdsiconvinfo | TDSICONV |
typedef tds_locale | TDSLOCALE |
typedef tds_login | TDSLOGIN |
typedef tds_message | TDSMESSAGE |
typedef tds_multiple | TDSMULTIPLE |
typedef TDSRESULTINFO | TDSPARAMINFO |
typedef tds_result_info | TDSRESULTINFO |
Hold information for any results. | |
typedef tds_socket | TDSSOCKET |
typedef tds_upd_col | TDSUPDCOL |
Enumerations | |
enum | { TDS_CUR_ISTAT_UNUSED = 0x00, TDS_CUR_ISTAT_DECLARED = 0x01, TDS_CUR_ISTAT_OPEN = 0x02, TDS_CUR_ISTAT_CLOSED = 0x04, TDS_CUR_ISTAT_RDONLY = 0x08, TDS_CUR_ISTAT_UPDATABLE = 0x10, TDS_CUR_ISTAT_ROWCNT = 0x20, TDS_CUR_ISTAT_DEALLOC = 0x40 } |
enum | { TDS_OPT_ARITHOVERFLOW = 0x01, TDS_OPT_NUMERICTRUNC = 0x02 } |
enum | { TDS_SYSNAME_SIZE = 512 } |
enum | _TDS_STATE { TDS_IDLE, TDS_QUERYING, TDS_PENDING, TDS_READING, TDS_DEAD } |
enum | TDS_CURSOR_STATE { TDS_CURSOR_STATE_UNACTIONED = 0, TDS_CURSOR_STATE_REQUESTED = 1, TDS_CURSOR_STATE_SENT = 2, TDS_CURSOR_STATE_ACTIONED = 3 } |
enum | TDS_DBG_LOG_STATE { TDS_DBG_LOGIN = 1, TDS_DBG_API = (1 << 1), TDS_DBG_ASYNC = (1 << 2), TDS_DBG_DIAG = (1 << 3), TDS_DBG_error = (1 << 4), TDS_DBG_PACKET = (1 << 5), TDS_DBG_LIBTDS = (1 << 6), TDS_DBG_CONFIG = (1 << 7), TDS_DBG_DEFAULT = 0xFE } |
An attempt at better logging. More... | |
enum | tds_end { TDS_DONE_FINAL = 0x00, TDS_DONE_MORE_RESULTS = 0x01, TDS_DONE_ERROR = 0x02, TDS_DONE_INXACT = 0x04, TDS_DONE_PROC = 0x08, TDS_DONE_COUNT = 0x10, TDS_DONE_CANCELLED = 0x20, TDS_DONE_EVENT = 0x40, TDS_DONE_SRVERROR = 0x100, TDS_DONE_NO_TRAN = 0, TDS_DONE_TRAN_SUCCEED = 1, TDS_DONE_TRAN_PROGRESS = 2, TDS_DONE_STMT_ABORT = 3, TDS_DONE_TRAN_ABORT = 4 } |
enum | TDS_ICONV_ENTRY { client2ucs2, client2server_chardata, iso2server_metadata, initial_char_conv_count } |
enum | TDS_MULTIPLE_TYPE { TDS_MULTIPLE_QUERY, TDS_MULTIPLE_EXECUTE, TDS_MULTIPLE_RPC } |
enum | TDS_OPT_DATEFIRST_CHOICE { TDS_OPT_MONDAY = 1, TDS_OPT_TUESDAY = 2, TDS_OPT_WEDNESDAY = 3, TDS_OPT_THURSDAY = 4, TDS_OPT_FRIDAY = 5, TDS_OPT_SATURDAY, TDS_OPT_SUNDAY = 7 } |
enum | TDS_OPT_DATEFORMAT_CHOICE { TDS_OPT_FMTMDY = 1, TDS_OPT_FMTDMY = 2, TDS_OPT_FMTYMD = 3, TDS_OPT_FMTYDM = 4, TDS_OPT_FMTMYD = 5, TDS_OPT_FMTDYM = 6 } |
enum | TDS_OPT_ISOLATION_CHOICE { TDS_OPT_LEVEL1 = 1, TDS_OPT_LEVEL3 = 3 } |
enum | TDS_OPTION { TDS_OPT_DATEFIRST = 1, TDS_OPT_TEXTSIZE = 2, TDS_OPT_STAT_TIME = 3, TDS_OPT_STAT_IO = 4, TDS_OPT_ROWCOUNT = 5, TDS_OPT_NATLANG = 6, TDS_OPT_DATEFORMAT = 7, TDS_OPT_ISOLATION = 8, TDS_OPT_AUTHON = 9, TDS_OPT_CHARSET = 10, TDS_OPT_SHOWPLAN = 13, TDS_OPT_NOEXEC = 14, TDS_OPT_ARITHIGNOREON = 15, TDS_OPT_ARITHABORTON = 17, TDS_OPT_PARSEONLY = 18, TDS_OPT_GETDATA = 20, TDS_OPT_NOCOUNT = 21, TDS_OPT_FORCEPLAN = 23, TDS_OPT_FORMATONLY = 24, TDS_OPT_CHAINXACTS = 25, TDS_OPT_CURCLOSEONXACT = 26, TDS_OPT_FIPSFLAG = 27, TDS_OPT_RESTREES = 28, TDS_OPT_IDENTITYON = 29, TDS_OPT_CURREAD = 30, TDS_OPT_CURWRITE = 31, TDS_OPT_IDENTITYOFF = 32, TDS_OPT_AUTHOFF = 33, TDS_OPT_ANSINULL = 34, TDS_OPT_QUOTED_IDENT = 35, TDS_OPT_ARITHIGNOREOFF = 36, TDS_OPT_ARITHABORTOFF = 37, TDS_OPT_TRUNCABORT = 38 } |
enum | TDS_OPTION_CMD { TDS_OPT_SET = 1, TDS_OPT_DEFAULT = 2, TDS_OPT_LIST = 3, TDS_OPT_INFO = 4 } |
options that can be sent with a TDS_OPTIONCMD token | |
enum | tds_packet_type { TDS_QUERY = 1, TDS_RPC = 3, TDS_CANCEL = 6, TDS_BULK = 7, TDS_NORMAL = 15 } |
enum | TDS_SERVER_TYPE { SYBCHAR = 47, SYBVARCHAR = 39, SYBINTN = 38, SYBINT1 = 48, SYBINT2 = 52, SYBINT4 = 56, SYBINT8 = 127, SYBFLT8 = 62, SYBDATETIME = 61, SYBBIT = 50, SYBTEXT = 35, SYBNTEXT = 99, SYBIMAGE = 34, SYBMONEY4 = 122, SYBMONEY = 60, SYBDATETIME4 = 58, SYBREAL = 59, SYBBINARY = 45, SYBVOID = 31, SYBVARBINARY = 37, SYBNVARCHAR = 103, SYBBITN = 104, SYBNUMERIC = 108, SYBDECIMAL = 106, SYBFLTN = 109, SYBMONEYN = 110, SYBDATETIMN = 111, XSYBCHAR = 175, XSYBVARCHAR = 167, XSYBNVARCHAR = 231, XSYBNCHAR = 239, XSYBVARBINARY = 165, XSYBBINARY = 173, SYBLONGBINARY = 225, SYBSINT1 = 64, SYBUINT2 = 65, SYBUINT4 = 66, SYBUINT8 = 67, SYBUNIQUE = 36, SYBVARIANT } |
enum | tds_token_flags { TDS_HANDLE_ALL = 0, OTHERS, ROWFMT, COMPUTEFMT, PARAMFMT, DONE, ROW, COMPUTE, PROC, MSG, TDS_TOKEN_RESULTS = TDS_RETURN_ROWFMT|TDS_RETURN_COMPUTEFMT|TDS_RETURN_DONE|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_RETURN_PROC, TDS_TOKEN_TRAILING = TDS_STOPAT_ROWFMT|TDS_STOPAT_COMPUTEFMT|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_STOPAT_MSG|TDS_STOPAT_OTHERS } |
enum | tds_token_results { TDS_TOKEN_RES_OTHERS, TDS_TOKEN_RES_ROWFMT, TDS_TOKEN_RES_COMPUTEFMT, TDS_TOKEN_RES_PARAMFMT, TDS_TOKEN_RES_DONE, TDS_TOKEN_RES_ROW, TDS_TOKEN_RES_COMPUTE, TDS_TOKEN_RES_PROC, TDS_TOKEN_RES_MSG } |
enum | TDS_USER_TYPE { USER_UNICHAR_TYPE = 34, USER_UNIVARCHAR_TYPE = 35 } |
Functions | |
int | tds5_send_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG *tds_argument, TDS_INT *tds_argsize) |
unsigned char * | tds7_crypt_pass (const unsigned char *clear_pass, int len, unsigned char *crypt_pass) |
tds7_crypt_pass() -- 'encrypt' TDS 7.0 style passwords. | |
int | tds7_get_instance_port (const char *ip_addr, const char *instance) |
Get port of given instance. | |
int | tds7_send_auth (TDSSOCKET *tds, const unsigned char *challenge) |
void | tds7_srv_charset_changed (TDSSOCKET *tds, int sql_collate, int lcid) |
void | tds_add_row_column_size (TDSRESULTINFO *info, TDSCOLUMN *curcol) |
Add a column size to result info row size and calc offset into row. | |
BCPCOLDATA * | tds_alloc_bcp_column_data (int column_size) |
char * | tds_alloc_client_sqlstate (int msgno) |
TDSCOMPUTEINFO ** | tds_alloc_compute_results (TDSSOCKET *tds, int num_cols, int by_cols) |
unsigned char * | tds_alloc_compute_row (TDSCOMPUTEINFO *res_info) |
TDSCONNECTION * | tds_alloc_connection (TDSLOCALE *locale) |
Allocate space for configure structure and initialize with default values. | |
TDSCONTEXT * | tds_alloc_context (void *parent) |
TDSCURSOR * | tds_alloc_cursor (TDSSOCKET *tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen) |
TDSDYNAMIC * | tds_alloc_dynamic (TDSSOCKET *tds, const char *id) |
Allocate a dynamic statement. | |
int | tds_alloc_get_string (TDSSOCKET *tds, char **string, int len) |
Read a string from wire in a new allocated buffer. | |
TDSLOCALE * | tds_alloc_locale (void) |
TDSLOGIN * | tds_alloc_login (void) |
char * | tds_alloc_lookup_sqlstate (TDSSOCKET *tds, int msgno) |
TDSPARAMINFO * | tds_alloc_param_result (TDSPARAMINFO *old_param) |
Adds a output parameter to TDSPARAMINFO. | |
unsigned char * | tds_alloc_param_row (TDSPARAMINFO *info, TDSCOLUMN *curparam) |
Add another field to row. | |
TDSRESULTINFO * | tds_alloc_results (int num_cols) |
unsigned char * | tds_alloc_row (TDSRESULTINFO *res_info) |
Allocate space for row store return NULL on out of memory. | |
TDSSOCKET * | tds_alloc_socket (TDSCONTEXT *context, int bufsize) |
void | tds_answer_challenge (const char *passwd, const unsigned char *challenge, TDSANSWER *answer) |
Crypt a given password using schema required for NTLMv1 authentication. | |
int | tds_client_msg (const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int severity, int state, int line, const char *message) |
tds_client_msg() sends a message to the client application from the CLI or TDS layer. | |
int | tds_close_socket (TDSSOCKET *tds) |
void | tds_config_verstr (const char *tdsver, TDSCONNECTION *connection) |
Set TDS version from given string. | |
int | tds_connect (TDSSOCKET *tds, TDSCONNECTION *connection) |
Do a connection to socket. | |
int | tds_count_placeholders (const char *query) |
Count the number of placeholders in query. | |
int | tds_cursor_close (TDSSOCKET *tds, TDSCURSOR *cursor) |
int | tds_cursor_dealloc (TDSSOCKET *tds, TDSCURSOR *cursor) |
int | tds_cursor_declare (TDSSOCKET *tds, TDSCURSOR *cursor, int *send) |
int | tds_cursor_fetch (TDSSOCKET *tds, TDSCURSOR *cursor) |
int | tds_cursor_open (TDSSOCKET *tds, TDSCURSOR *cursor, int *send) |
int | tds_cursor_setrows (TDSSOCKET *tds, TDSCURSOR *cursor, int *send) |
TDS_INT | tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr) |
Convert from db date format to a structured date format. | |
void | tds_fix_connection (TDSCONNECTION *connection) |
Fix configuration after reading it. | |
int | tds_flush_packet (TDSSOCKET *tds) |
Flush packet to server. | |
void | tds_free_all_results (TDSSOCKET *tds) |
void | tds_free_bcp_column_data (BCPCOLDATA *coldata) |
void | tds_free_connection (TDSCONNECTION *connection) |
void | tds_free_context (TDSCONTEXT *locale) |
void | tds_free_cursor (TDSSOCKET *tds, TDSCURSOR *cursor) |
void | tds_free_dynamic (TDSSOCKET *tds, TDSDYNAMIC *dyn) |
Frees dynamic statement and remove from TDS. | |
void | tds_free_input_params (TDSDYNAMIC *dyn) |
Frees all allocated input parameters of a dynamic statement. | |
void | tds_free_locale (TDSLOCALE *locale) |
void | tds_free_login (TDSLOGIN *login) |
void | tds_free_msg (TDSMESSAGE *message) |
void | tds_free_param_result (TDSPARAMINFO *param_info) |
Delete latest parameter. | |
void | tds_free_param_results (TDSPARAMINFO *param_info) |
void | tds_free_result_info (TDSRESULTINFO *info) |
void | tds_free_results (TDSRESULTINFO *res_info) |
void | tds_free_row (const TDSRESULTINFO *res_info, unsigned char *row) |
void | tds_free_socket (TDSSOCKET *tds) |
unsigned char | tds_get_byte (TDSSOCKET *tds) |
int | tds_get_char_data (TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol) |
Fetch character data the wire. | |
const TDS_COMPILETIME_SETTINGS * | tds_get_compiletime_settings (void) |
Return a structure capturing the compile-time settings provided to the configure script. | |
int | tds_get_conversion_type (int srctype, int colsize) |
Return type suitable for conversions (convert all nullable types to fixed type). | |
int | tds_get_dynid (TDSSOCKET *tds, char **id) |
Get an id for dynamic query based on TDS information. | |
char * | tds_get_homedir (void) |
Get user home directory. | |
TDS_INT | tds_get_int (TDSSOCKET *tds) |
Get an int32 from the server. | |
TDSLOCALE * | tds_get_locale (void) |
Get locale information. | |
void * | tds_get_n (TDSSOCKET *tds, void *dest, int n) |
Get N bytes from the buffer and return them in the already allocated space given to us. | |
void * | tds_get_parent (TDSSOCKET *tds) |
int | tds_get_size_by_type (int servertype) |
Return the number of bytes needed by specified type. | |
TDS_SMALLINT | tds_get_smallint (TDSSOCKET *tds) |
Get an int16 from the server. | |
int | tds_get_string (TDSSOCKET *tds, int string_len, char *dest, size_t dest_size) |
Fetch a string from the wire. | |
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 determine how to read past a token | |
hostent * | tds_gethostbyaddr_r (const char *addr, int len, int type, struct hostent *result, char *buffer, int buflen, int *h_errnop) |
hostent * | tds_gethostbyname_r (const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) |
void | tds_getmac (int s, unsigned char mac[6]) |
servent * | tds_getservbyname_r (const char *name, const char *proto, struct servent *result, char *buffer, int buflen) |
int | tds_iconv_alloc (TDSSOCKET *tds) |
Allocate iconv stuff. | |
void | tds_iconv_close (TDSSOCKET *tds) |
void | tds_iconv_free (TDSSOCKET *tds) |
TDSICONV * | tds_iconv_from_collate (TDSSOCKET *tds, int sql_collate, int lcid) |
Get iconv information from a LCID (to support different column encoding under MSSQL2K). | |
void | tds_iconv_open (TDSSOCKET *tds, const char *charset) |
int | tds_init_write_buf (TDSSOCKET *tds) |
TDSDYNAMIC * | tds_lookup_dynamic (TDSSOCKET *tds, char *id) |
Find a dynamic given string id. | |
void | tds_lookup_host (const char *servername, char *ip) |
Given a servername and port name or number, lookup the hostname and service. | |
char * | tds_money_to_string (const TDS_MONEY *money, char *s) |
int | tds_multiple_done (TDSSOCKET *tds, TDSMULTIPLE *multiple) |
int | tds_multiple_execute (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn) |
int | tds_multiple_init (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type) |
int | tds_multiple_query (TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params) |
const char * | tds_next_placeholder (const char *start) |
Get position of next placeholder. | |
TDS_INT | tds_numeric_change_prec_scale (TDS_NUMERIC *numeric, unsigned char new_prec, unsigned char new_scale) |
TDS_INT | tds_numeric_to_string (const TDS_NUMERIC *numeric, char *s) |
int | tds_open_socket (TDSSOCKET *tds, const char *ip_addr, unsigned int port, int timeout) |
unsigned char | tds_peek (TDSSOCKET *tds) |
int | tds_process_cancel (TDSSOCKET *tds) |
tds_process_cancel() processes the incoming token stream until it finds an end token (DONE, DONEPROC, DONEINPROC) with the cancel flag set. | |
int | tds_process_login_tokens (TDSSOCKET *tds) |
tds_process_login_tokens() is called after sending the login packet to the server. | |
int | tds_process_simple_query (TDSSOCKET *tds) |
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded. | |
int | tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag) |
process all streams. | |
const char * | tds_prtype (int token) |
int | tds_put_buf (TDSSOCKET *tds, const unsigned char *buf, int dsize, int ssize) |
int | tds_put_byte (TDSSOCKET *tds, unsigned char c) |
int | tds_put_int (TDSSOCKET *tds, TDS_INT i) |
int | tds_put_int8 (TDSSOCKET *tds, TDS_INT8 i) |
int | tds_put_n (TDSSOCKET *tds, const void *buf, int n) |
int | tds_put_smallint (TDSSOCKET *tds, TDS_SMALLINT si) |
int | tds_put_string (TDSSOCKET *tds, const char *buf, int len) |
Output a string to wire automatic translate string to unicode if needed. | |
int | tds_quote_id (TDSSOCKET *tds, char *buffer, const char *id, int idlen) |
Quote an id. | |
int | tds_quote_string (TDSSOCKET *tds, char *buffer, const char *str, int len) |
Quote a string. | |
int | tds_read_conf_file (TDSCONNECTION *connection, const char *server) |
Read configuration info for given server return 0 on error. | |
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). | |
TDSCONNECTION * | tds_read_config_info (TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale) |
tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values | |
int | tds_read_packet (TDSSOCKET *tds) |
Read in one 'packet' from the server. | |
TDSSOCKET * | tds_realloc_socket (TDSSOCKET *tds, int bufsize) |
int | tds_send_cancel (TDSSOCKET *tds) |
tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called directly after this. | |
void | tds_set_app (TDSLOGIN *tds_login, const char *application) |
void | tds_set_bulk (TDSLOGIN *tds_login, TDS_TINYINT enabled) |
void | tds_set_capabilities (TDSLOGIN *tds_login, unsigned char *capabilities, int size) |
void | tds_set_client_charset (TDSLOGIN *tds_login, const char *charset) |
void | tds_set_column_type (TDSCOLUMN *curcol, int type) |
Set type of column initializing all dependency. | |
void | tds_set_host (TDSLOGIN *tds_login, const char *hostname) |
int | tds_set_interfaces_file_loc (const char *interfloc) |
Set the full name of interface file. | |
void | tds_set_language (TDSLOGIN *tds_login, const char *language) |
void | tds_set_library (TDSLOGIN *tds_login, const char *library) |
void | tds_set_packet (TDSLOGIN *tds_login, int packet_size) |
void | tds_set_param_type (TDSSOCKET *tds, TDSCOLUMN *curcol, TDS_SERVER_TYPE type) |
Set type of column initializing all dependency. | |
void | tds_set_parent (TDSSOCKET *tds, void *the_parent) |
void | tds_set_passwd (TDSLOGIN *tds_login, const char *password) |
void | tds_set_port (TDSLOGIN *tds_login, int port) |
void | tds_set_server (TDSLOGIN *tds_login, const char *server) |
void | tds_set_server_addr (TDSLOGIN *tds_login, const char *server_addr) |
TDS_STATE | tds_set_state (TDSSOCKET *tds, TDS_STATE state) |
Set state of TDS connection, with logging and checking. | |
void | tds_set_user (TDSLOGIN *tds_login, const char *username) |
void | tds_set_version (TDSLOGIN *tds_login, short major_ver, short minor_ver) |
const char * | tds_skip_quoted (const char *s) |
Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]). | |
void | tds_srv_charset_changed (TDSSOCKET *tds, const char *charset) |
void | tds_ssl_deinit (TDSSOCKET *tds) |
int | tds_ssl_init (TDSSOCKET *tds) |
int | tds_submit_execdirect (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params) |
Submit a prepared query with parameters. | |
int | tds_submit_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn) |
tds_submit_execute() sends a previously prepared dynamic statement to the server. | |
int | tds_submit_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size) |
int | tds_submit_prepare (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params) |
tds_submit_prepare() creates a temporary stored procedure in the server. | |
int | tds_submit_query (TDSSOCKET *tds, const char *query) |
tds_submit_query() sends a language string to the database server for processing. | |
int | tds_submit_query_params (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params) |
tds_submit_query_params() sends a language string to the database server for processing. | |
int | tds_submit_queryf (TDSSOCKET *tds, const char *queryf,...) |
int | tds_submit_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params) |
tds_submit_rpc() call a RPC from server. | |
int | tds_submit_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn) |
Send a unprepare request for a prepared query. | |
int | tds_swap_bytes (unsigned char *buf, int bytes) |
void | tds_swap_datatype (int coltype, unsigned char *buf) |
void | tds_swap_numeric (TDS_NUMERIC *num) |
char * | tds_timestamp_str (char *str, int maxlen) |
void | tds_unget_byte (TDSSOCKET *tds) |
Unget will always work as long as you don't call it twice in a row. | |
int | tds_version (TDSSOCKET *tds_socket, char *pversion_string) |
Returns the version of the TDS protocol in effect for the link as a decimal integer. | |
int | tds_vstrbuild (char *buffer, int buflen, int *resultlen, char *text, int textlen, const char *formats, int formatlen, va_list ap) |
int | tds_write_packet (TDSSOCKET *tds, unsigned char final) |
void | tdsdump_close (void) |
Close the TDS dump log file. | |
void | tdsdump_dump_buf (const char *file, unsigned int level_line, const char *msg, const void *buf, int length) |
Dump the contents of data into the log file in a human readable format. | |
void | tdsdump_log (const char *file, unsigned int level_line, const char *fmt,...) |
This function write a message to the debug log. | |
void | tdsdump_off (void) |
Temporarily turn off logging. | |
void | tdsdump_on (void) |
Turn logging back on. | |
int | tdsdump_open (const char *filename) |
This creates and truncates a human readable dump file for the TDS traffic. | |
Variables | |
static const void *const | no_unused_tds_h_warn [] = { rcsid_tds_h, no_unused_tds_h_warn } |
static const char | rcsid_tds_h [] = "$Id: tds.h,v 1.245.2.1 2006/04/16 08:08:38 freddy77 Exp $" |
int | tds_debug_flags |
const char | tds_hex_digits [] |
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 store the specified precision. |
#define is_end_token | ( | x | ) |
Value:
(x==TDS_DONE_TOKEN || \ x==TDS_DONEPROC_TOKEN || \ x==TDS_DONEINPROC_TOKEN)
#define is_fixed_type | ( | x | ) |
Value:
(x==SYBINT1 || \ x==SYBINT2 || \ x==SYBINT4 || \ x==SYBINT8 || \ x==SYBREAL || \ x==SYBFLT8 || \ x==SYBDATETIME || \ x==SYBDATETIME4 || \ x==SYBBIT || \ x==SYBMONEY || \ x==SYBMONEY4 || \ x==SYBVOID || \ x==SYBUNIQUE)
#define is_hard_end_token | ( | x | ) |
Value:
(x==TDS_DONE_TOKEN || \ x==TDS_DONEPROC_TOKEN)
#define is_msg_token | ( | x | ) |
Value:
(x==TDS_INFO_TOKEN || \ x==TDS_ERROR_TOKEN || \ x==TDS_EED_TOKEN)
#define is_nullable_type | ( | x | ) |
Value:
( \ x==SYBBITN || \ x==SYBINTN || \ x==SYBFLTN || \ x==SYBMONEYN || \ x==SYBDATETIMN || \ x==SYBVARCHAR || \ x==SYBBINARY || \ x==SYBVARBINARY || \ x==SYBTEXT || \ x==SYBNTEXT || \ x==SYBIMAGE)
#define is_result_token | ( | x | ) |
Value:
(x==TDS_RESULT_TOKEN || \ x==TDS_ROWFMT2_TOKEN || \ x==TDS7_RESULT_TOKEN || \ x==TDS_COLFMT_TOKEN || \ x==TDS_COLNAME_TOKEN || \ x==TDS_RETURNSTATUS_TOKEN)
#define TDS_BYTE_SWAP16 | ( | value | ) |
Value:
(((((unsigned short)value)<<8) & 0xFF00) | \ ((((unsigned short)value)>>8) & 0x00FF))
#define TDS_BYTE_SWAP32 | ( | value | ) |
Value:
(((((unsigned long)value)<<24) & 0xFF000000) | \ ((((unsigned long)value)<< 8) & 0x00FF0000) | \ ((((unsigned long)value)>> 8) & 0x0000FF00) | \ ((((unsigned long)value)>>24) & 0x000000FF))
#define TDS_IS_MSSQL | ( | x | ) | ((x->product_version & 0x80000000u)!=0) |
Check if product is Microsft SQL Server.
x should be a TDS_SOCKET*.
#define TDS_IS_SYBASE | ( | x | ) | (!(x->product_version & 0x80000000u)) |
Check if product is Sybase (such as Adaptive Server Enterrprice).
x should be a TDS_SOCKET*.
#define TDS_MS_VER | ( | maj, | |||
min, | |||||
x | ) | (0x80000000u|((maj)<<24)|((min)<<16)|(x)) |
Calc a version number for mssql.
Use with TDS_MS_VER(7,0,842). For test for a range of version you can use check like if (tds->product_version >= TDS_MS_VER(7,0,0) && tds->product_version < TDS_MS_VER(8,0,0))
typedef struct _tds_compiletime_settings TDS_COMPILETIME_SETTINGS |
A structure to hold all the compile-time settings.
This structure is returned by tds_get_compiletime_settings
typedef struct _tds_encoding TDS_ENCODING |
Information relevant to libiconv.
The name is an iconv name, not the same as found in master..syslanguages.
Information about blobs (e.g.
text or image). current_row contains this structure.
enum TDS_DBG_LOG_STATE |
An attempt at better logging.
Using these bitmapped values, various logging features can be turned on and off. It can be especially helpful to turn packet data on/off for security reasons.
unsigned char* tds7_crypt_pass | ( | const unsigned char * | clear_pass, | |
int | len, | |||
unsigned char * | crypt_pass | |||
) |
tds7_crypt_pass() -- 'encrypt' TDS 7.0 style passwords.
the calling function is responsible for ensuring crypt_pass is at least 'len' characters
int tds7_get_instance_port | ( | const char * | ip_addr, | |
const char * | instance | |||
) |
Get port of given instance.
void tds_add_row_column_size | ( | TDSRESULTINFO * | info, | |
TDSCOLUMN * | curcol | |||
) |
Add a column size to result info row size and calc offset into row.
info | result where to add column | |
curcol | column to add |
TDSCONNECTION* tds_alloc_connection | ( | TDSLOCALE * | locale | ) |
Allocate space for configure structure and initialize with default values.
locale | locale information (copied to configuration information) |
TDSDYNAMIC* tds_alloc_dynamic | ( | TDSSOCKET * | tds, | |
const char * | id | |||
) |
Allocate a dynamic statement.
tds | the connection within which to allocate the statement. | |
id | a character label identifying the statement. |
int tds_alloc_get_string | ( | TDSSOCKET * | tds, | |
char ** | string, | |||
int | len | |||
) |
Read a string from wire in a new allocated buffer.
tds | state information for the socket and the TDS protocol | |
len | length of string to read |
TDSPARAMINFO* tds_alloc_param_result | ( | TDSPARAMINFO * | old_param | ) |
Adds a output parameter to TDSPARAMINFO.
old_param | a pointer to the TDSPARAMINFO structure containing the current set of output parameter, or NULL if none exists. |
unsigned char* tds_alloc_param_row | ( | TDSPARAMINFO * | info, | |
TDSCOLUMN * | curparam | |||
) |
Add another field to row.
Is assumed that last TDSCOLUMN contain information about this. Update also info structure.
info | parameters info where is contained row | |
curparam | parameter to retrieve size information |
void tds_answer_challenge | ( | const char * | passwd, | |
const unsigned char * | challenge, | |||
TDSANSWER * | answer | |||
) |
Crypt a given password using schema required for NTLMv1 authentication.
passwd | clear text domain password | |
challenge | challenge data given by server | |
answer | buffer where to store crypted password |
int tds_client_msg | ( | const TDSCONTEXT * | tds_ctx, | |
TDSSOCKET * | tds, | |||
int | msgno, | |||
int | severity, | |||
int | state, | |||
int | line, | |||
const char * | msg_text | |||
) |
tds_client_msg() sends a message to the client application from the CLI or TDS layer.
A client message is one that is generated from with the library and not from the server. The message is sent to the CLI (the err_handler) so that it may forward it to the client application or discard it if no msg handler has been by the application. tds->parent contains a void pointer to the parent of the tds socket. This can be cast back into DBPROCESS or CS_CONNECTION by the CLI and used to determine the proper recipient function for this message.
void tds_config_verstr | ( | const char * | tdsver, | |
TDSCONNECTION * | connection | |||
) |
Set TDS version from given string.
tdsver | tds string version | |
connection | where to store information |
int tds_connect | ( | TDSSOCKET * | tds, | |
TDSCONNECTION * | connection | |||
) |
Do a connection to socket.
tds | connection structure. This should be a non-connected connection. | |
connection | info for connection |
TDS_INT tds_datecrack | ( | TDS_INT | datetype, | |
const void * | di, | |||
TDSDATEREC * | dr | |||
) |
Convert from db date format to a structured date format.
datetype | source date type. SYBDATETIME or SYBDATETIME4 | |
di | source date | |
dr | destination date |
void tds_fix_connection | ( | TDSCONNECTION * | connection | ) |
Fix configuration after reading it.
Currently this read some environment variables and replace some options.
int tds_flush_packet | ( | TDSSOCKET * | tds | ) |
Flush packet to server.
void tds_free_dynamic | ( | TDSSOCKET * | tds, | |
TDSDYNAMIC * | dyn | |||
) |
Frees dynamic statement and remove from TDS.
tds | state information for the socket and the TDS protocol | |
dyn | dynamic statement to be freed. |
void tds_free_input_params | ( | TDSDYNAMIC * | dyn | ) |
Frees all allocated input parameters of a dynamic statement.
dyn | the dynamic statement whose input parameter are to be freed |
int tds_get_char_data | ( | TDSSOCKET * | tds, | |
char * | row_buffer, | |||
size_t | wire_size, | |||
TDSCOLUMN * | curcol | |||
) |
Fetch character data the wire.
Output is NOT null terminated. If char_conv is not NULL, convert data accordingly.
tds | state information for the socket and the TDS protocol | |
row_buffer | destination buffer in current_row. Can't be NULL | |
wire_size | size to read from wire (in bytes) | |
curcol | column information |
int tds_get_conversion_type | ( | int | srctype, | |
int | colsize | |||
) |
Return type suitable for conversions (convert all nullable types to fixed type).
srctype | type to convert | |
colsize | size of type |
int tds_get_dynid | ( | TDSSOCKET * | tds, | |
char ** | id | |||
) |
Get an id for dynamic query based on TDS information.
tds | state information for the socket and the TDS protocol |
char* tds_get_homedir | ( | void | ) |
Get user home directory.
TDSLOCALE* tds_get_locale | ( | void | ) |
Get locale information.
void* tds_get_n | ( | TDSSOCKET * | tds, | |
void * | dest, | |||
int | need | |||
) |
Get N bytes from the buffer and return them in the already allocated space given to us.
We ASSUME that the person calling this function has done the bounds checking for us since they know how many bytes they want here. dest of NULL means we just want to eat the bytes. (tetherow@nol.org)
int tds_get_string | ( | TDSSOCKET * | tds, | |
int | string_len, | |||
char * | dest, | |||
size_t | dest_size | |||
) |
Fetch a string from the wire.
Output string is NOT null terminated. If TDS version is 7 or 8 read unicode string and convert it. This function should be use to read server default encoding strings like columns name, table names, etc, not for data (use tds_get_char_data instead)
tds | connection information | |
string_len | length of string to read from wire (in server characters, bytes for tds4-tds5, ucs2 for tds7+) | |
dest | destination buffer, if NULL string is read and discarded | |
dest_size | destination buffer size, in bytes |
int tds_iconv_alloc | ( | TDSSOCKET * | tds | ) |
Allocate iconv stuff.
TDSDYNAMIC* tds_lookup_dynamic | ( | TDSSOCKET * | tds, | |
char * | id | |||
) |
Find a dynamic given string id.
tds | state information for the socket and the TDS protocol | |
id | dynamic id to search |
void tds_lookup_host | ( | const char * | servername, | |
char * | ip | |||
) |
Given a servername and port name or number, lookup the hostname and service.
The server ip will be stored in the string 'servername' in dotted-decimal notation. The service port number will be stored in string form in the 'port' parameter.
If we can't determine both the IP address and port number then 'ip' and 'port' will be set to empty strings.
const char* tds_next_placeholder | ( | const char * | start | ) |
Get position of next placeholder.
start | pointer to part of query to search |
int tds_process_cancel | ( | TDSSOCKET * | tds | ) |
tds_process_cancel() processes the incoming token stream until it finds an end token (DONE, DONEPROC, DONEINPROC) with the cancel flag set.
a that point the connetion should be ready to handle a new query.
int tds_process_login_tokens | ( | TDSSOCKET * | tds | ) |
tds_process_login_tokens() is called after sending the login packet to the server.
It returns the success or failure of the login dependent on the protocol version. 4.2 sends an ACK token only when successful, TDS 5.0 sends it always with a success byte within
int tds_process_simple_query | ( | TDSSOCKET * | tds | ) |
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded.
This function was written to avoid direct calls to tds_process_default_tokens (which caused problems such as ignoring query errors). Results are read until idle state or severe failure (do not stop for statement failure).
int tds_process_tokens | ( | TDSSOCKET * | tds, | |
TDS_INT * | result_type, | |||
int * | done_flags, | |||
unsigned | flag | |||
) |
process all streams.
tds_process_tokens() is called after submitting a query with tds_submit_query() and is responsible for calling the routines to populate tds->res_info if appropriate (some query have no result sets)
tds | A pointer to the TDSSOCKET structure managing a client/server operation. | |
result_type | A pointer to an integer variable which tds_process_tokens sets to indicate the current type of result. |
TDS_DONE_RESULT | The results of a command have been completely processed. This command return no rows. |
TDS_DONEPROC_RESULT | The results of a command have been completely processed. This command return rows. |
TDS_DONEINPROC_RESULT | The results of a command have been completely processed. This command return rows. |
TDS_ROWFMT_RESULT | Regular Data format information | tds->res_info now contains the result details ; tds->current_results now points to that data |
TDS_COMPUTEFMT_ RESULT | Compute data format information | tds->comp_info now contains the result data; tds->current_results now points to that data |
TDS_DESCRIBE_RESULT |
Value | Meaning | Information returned |
TDS_ROW_RESULT | Regular row results | 1 or more rows of regular data can now be retrieved |
TDS_COMPUTE_RESULT | Compute row results | A single row of compute data can now be retrieved |
TDS_PARAM_RESULT | Return parameter results | param_info or cur_dyn->params contain returned parameters |
TDS_STATUS_RESULT | Stored procedure status results | tds->ret_status contain the returned code |
flag | Flags to select token type to stop/return |
TDS_SUCCEED | if a result set is available for processing. | |
TDS_NO_MORE_RESULTS | if all results have been completely processed. |
int tds_put_string | ( | TDSSOCKET * | tds, | |
const char * | s, | |||
int | len | |||
) |
Output a string to wire automatic translate string to unicode if needed.
tds | state information for the socket and the TDS protocol | |
s | string to write | |
len | length of string in characters, or -1 for null terminated |
int tds_quote_id | ( | TDSSOCKET * | tds, | |
char * | buffer, | |||
const char * | id, | |||
int | idlen | |||
) |
Quote an id.
tds | state information for the socket and the TDS protocol | |
buffer | buffer to store quoted id. If NULL do not write anything (useful to compute quote length) | |
id | id to quote | |
idlen | id length |
int tds_quote_string | ( | TDSSOCKET * | tds, | |
char * | buffer, | |||
const char * | str, | |||
int | len | |||
) |
Quote a string.
tds | state information for the socket and the TDS protocol | |
buffer | buffer to store quoted id. If NULL do not write anything (useful to compute quote length) | |
str | string to quote (not necessary null-terminated) | |
len | length of string (-1 for null terminated) |
int tds_read_conf_file | ( | TDSCONNECTION * | connection, | |
const char * | server | |||
) |
Read configuration info for given server return 0 on error.
connection | where to store configuration | |
server | section of file configuration that hold configuration for a server |
int tds_read_conf_section | ( | FILE * | in, | |
const char * | section, | |||
TDSCONFPARSE | tds_conf_parse, | |||
void * | param | |||
) |
Read a section of configuration file (INI style file).
in | configuration file | |
section | section to read | |
tds_conf_parse | callback that receive every entry in section | |
param | parameter to pass to callback function |
TDSCONNECTION* tds_read_config_info | ( | TDSSOCKET * | tds, | |
TDSLOGIN * | login, | |||
TDSLOCALE * | locale | |||
) |
tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values
.tdsrc and freetds.conf have been added to make the package easier to integration with various Linux and *BSD distributions.
int tds_read_packet | ( | TDSSOCKET * | tds | ) |
Read in one 'packet' from the server.
This is a wrapped outer packet of the protocol (they bundle result packets into chunks and wrap them at what appears to be 512 bytes regardless of how that breaks internal packet up. (tetherow@nol.org)
int tds_send_cancel | ( | TDSSOCKET * | tds | ) |
tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called directly after this.
tds | state information for the socket and the TDS protocol |
void tds_set_column_type | ( | TDSCOLUMN * | curcol, | |
int | type | |||
) |
Set type of column initializing all dependency.
curcol | column to set | |
type | type to set |
int tds_set_interfaces_file_loc | ( | const char * | interf | ) |
Set the full name of interface file.
interf | file name |
void tds_set_param_type | ( | TDSSOCKET * | tds, | |
TDSCOLUMN * | curcol, | |||
TDS_SERVER_TYPE | type | |||
) |
Set type of column initializing all dependency.
tds | state information for the socket and the TDS protocol | |
curcol | column to set | |
type | type to set |
TDS_STATE tds_set_state | ( | TDSSOCKET * | tds, | |
TDS_STATE | state | |||
) |
Set state of TDS connection, with logging and checking.
tds | state information for the socket and the TDS protocol | |
state | the new state of the connection, cf. TDS_STATE. |
const char* tds_skip_quoted | ( | const char * | s | ) |
Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]).
s | pointer to first quoting character (should be '," or [) |
int tds_submit_execdirect | ( | TDSSOCKET * | tds, | |
const char * | query, | |||
TDSPARAMINFO * | params | |||
) |
Submit a prepared query with parameters.
tds | state information for the socket and the TDS protocol | |
query | language query with given placeholders (?) | |
params | parameters to send |
int tds_submit_execute | ( | TDSSOCKET * | tds, | |
TDSDYNAMIC * | dyn | |||
) |
tds_submit_execute() sends a previously prepared dynamic statement to the server.
tds | state information for the socket and the TDS protocol | |
dyn | dynamic proc to execute. Must build from same tds. |
int tds_submit_prepare | ( | TDSSOCKET * | tds, | |
const char * | query, | |||
const char * | id, | |||
TDSDYNAMIC ** | dyn_out, | |||
TDSPARAMINFO * | params | |||
) |
tds_submit_prepare() creates a temporary stored procedure in the server.
Under TDS 4.2 dynamic statements are emulated building sql command
tds | state information for the socket and the TDS protocol | |
query | language query with given placeholders (?) | |
id | string to identify the dynamic query. Pass NULL for automatic generation. | |
dyn_out | will receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL. | |
params | parameters to use. It can be NULL even if parameters are present. Used only for TDS7+ |
int tds_submit_query | ( | TDSSOCKET * | tds, | |
const char * | query | |||
) |
tds_submit_query() sends a language string to the database server for processing.
TDS 4.2 is a plain text message with a packet type of 0x01, TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f.
tds | state information for the socket and the TDS protocol | |
query | language query to submit |
int tds_submit_query_params | ( | TDSSOCKET * | tds, | |
const char * | query, | |||
TDSPARAMINFO * | params | |||
) |
tds_submit_query_params() sends a language string to the database server for processing.
TDS 4.2 is a plain text message with a packet type of 0x01, TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f.
tds | state information for the socket and the TDS protocol | |
query | language query to submit | |
params | parameters of query |
int tds_submit_rpc | ( | TDSSOCKET * | tds, | |
const char * | rpc_name, | |||
TDSPARAMINFO * | params | |||
) |
tds_submit_rpc() call a RPC from server.
Output parameters will be stored in tds->param_info
tds | state information for the socket and the TDS protocol | |
rpc_name | name of RPC | |
params | parameters informations. NULL for no parameters |
int tds_submit_unprepare | ( | TDSSOCKET * | tds, | |
TDSDYNAMIC * | dyn | |||
) |
Send a unprepare request for a prepared query.
tds | state information for the socket and the TDS protocol | |
dyn | dynamic query |
char* tds_timestamp_str | ( | char * | str, | |
int | maxlen | |||
) |
void tds_unget_byte | ( | TDSSOCKET * | tds | ) |
Unget will always work as long as you don't call it twice in a row.
It it may work if you call it multiple times as long as you don't backup over the beginning of network packet boundary which can occur anywhere in the token stream.
int tds_version | ( | TDSSOCKET * | tds_socket, | |
char * | pversion_string | |||
) |
Returns the version of the TDS protocol in effect for the link as a decimal integer.
Typical returned values are 42, 50, 70, 80. Also fills pversion_string unless it is null. Typical pversion_string values are "4.2" and "7.0".
void tdsdump_dump_buf | ( | const char * | file, | |
unsigned int | level_line, | |||
const char * | msg, | |||
const void * | buf, | |||
int | length | |||
) |
Dump the contents of data into the log file in a human readable format.
msg | message to print before dump | |
buf | buffer to dump | |
length | number of bytes in the buffer |
void tdsdump_log | ( | const char * | file, | |
unsigned int | level_line, | |||
const char * | fmt, | |||
... | ||||
) |
This function write a message to the debug log.
debug_lvl | level of debugging | |
fmt | printf-like format string |
void tdsdump_on | ( | void | ) |
Turn logging back on.
You must call tdsdump_open() before calling this routine.
int tdsdump_open | ( | const char * | filename | ) |
This creates and truncates a human readable dump file for the TDS traffic.
The name of the file is specified by the filename parameter. If that is given as NULL or an empty string, any existing log file will be closed.
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 store the specified precision.
Support precision up to 77 digits