FreeTDS API
Loading...
Searching...
No Matches
dblib.h
1/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#ifndef _dblib_h_
21#define _dblib_h_
22
23#include <freetds/pushvis.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#if 0
29}
30#endif
31#endif
32
33typedef enum
34{
35 _DB_RES_INIT
36 , _DB_RES_RESULTSET_EMPTY
37 , _DB_RES_RESULTSET_ROWS
38 , _DB_RES_NEXT_RESULT
39 , _DB_RES_NO_MORE_RESULTS
40 , _DB_RES_SUCCEED
41} DB_RESULT_STATE;
42
44{
46 bool network_auth;
47};
48
49struct dblib_buffer_row;
50
51typedef struct
52{
53 int received; /* how many rows have been received for this result set */
54 int head; /* queue insertion point */
55 int tail; /* oldest item in queue */
56 int current; /* dbnextrow() reads this row */
57 int capacity; /* how many elements the queue can hold */
58 struct dblib_buffer_row *rows; /* pointer to the row storage */
60
61typedef struct
62{
63 int host_column;
64 TDS_SERVER_TYPE datatype;
65 int prefix_len;
66 DBINT column_len;
67 BYTE *terminator;
68 int term_len;
69 int tab_colnum;
70 int column_error;
72
73typedef struct
74{
75 TDS_CHAR *hostfile;
76 TDS_CHAR *errorfile;
77 FILE *bcp_errfileptr;
78 TDS_INT host_colcount;
79 BCP_HOSTCOLINFO **host_columns;
80 TDS_INT firstrow;
81 TDS_INT lastrow;
82 TDS_INT maxerrs;
83 TDS_INT batch;
85
86/* linked list of rpc parameters */
87
88typedef struct DBREMOTE_PROC_PARAM
89{
90 struct DBREMOTE_PROC_PARAM *next;
91
92 char *name;
93 BYTE status;
94 TDS_SERVER_TYPE type;
95 DBINT maxlen;
96 DBINT datalen;
97 BYTE *value;
99
100typedef struct DBREMOTE_PROC
101{
102 struct DBREMOTE_PROC *next;
103
104 char *name;
105 DBSMALLINT options;
106 DBREMOTE_PROC_PARAM *param_list;
108
109typedef struct dboption
110{
111 const char *text;
112 DBSTRING *param;
113 DBBOOL factive;
114} DBOPTION;
115
116typedef struct
117{
118 const BYTE *bindval;
119 size_t len;
120} NULLREP;
121
123{
125
126 STATUS row_type;
127 DBPROC_ROWBUF row_buf;
128
129 int noautofree;
130 int more_results; /* boolean. Are we expecting results? */
131 DB_RESULT_STATE dbresults_state;
132 int dbresults_retcode;
133 BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata() */
134 unsigned char *dbbuf; /* is dynamic! */
135 int dbbufsz;
136 int command_state;
137 TDS_INT text_size;
138 TDS_INT text_sent;
139 DBTYPEINFO typeinfo;
140 unsigned char avail_flag;
141 DBOPTION *dbopts;
142 DBSTRING *dboptcmd;
143 BCP_HOSTFILEINFO *hostfileinfo;
144 TDSBCPINFO *bcpinfo;
145 DBREMOTE_PROC *rpc;
146 DBUSMALLINT envchange_rcv;
147 char dbcurdb[DBMAXNAME + 1];
148 char servcharset[DBMAXNAME + 1];
149 FILE *ftos;
150 DB_DBCHKINTR_FUNC chkintr;
151 DB_DBHNDLINTR_FUNC hndlintr;
152
155
156 int ntimeouts;
157
159 NULLREP nullreps[MAXBINDTYPES];
160};
161
162enum {
163#if MSDBLIB
164 dblib_msdblib = 1
165#else
166 dblib_msdblib = 0
167#endif
168};
169
170/*
171 * internal prototypes
172 */
173RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr);
174void copy_data_to_host_var(DBPROCESS * dbproc, TDS_SERVER_TYPE srctype, const BYTE * src, DBINT srclen,
175 BYTE * dest, DBINT destlen,
176 int bindtype, DBINT *indicator);
177
178int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
179int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
180int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
181int _dblib_check_and_handle_interrupt(void * vdbproc);
182
183void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
184void _dblib_convert_err(DBPROCESS * dbproc, TDS_INT len);
185
186DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
187DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
188
189RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
190RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
191
192extern MHANDLEFUNC _dblib_msg_handler;
193extern EHANDLEFUNC _dblib_err_handler;
194
195#define CHECK_PARAMETER(x, msg, ret) if (!(x)) { dbperror(dbproc, (msg), 0); return ret; }
196#define CHECK_NULP(x, func, param_num, ret) if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; }
197#define CHECK_PARAMETER_NOPROC(x, msg) if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; }
198#define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; }
199#define DBPERROR_RETURN3(x, msg, a, b, c) if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; }
200#define CHECK_CONN(ret) do { CHECK_PARAMETER(dbproc, SYBENULL, (ret)); \
201 if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(dbproc, SYBEDDNE, 0); return (ret); } } while(0)
202
203
204#ifdef __cplusplus
205#if 0
206{
207#endif
208}
209#endif
210
211#include <freetds/popvis.h>
212
213#endif
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
Definition dblib.c:529
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
Call client-installed error handler.
Definition dblib.c:8154
int _dblib_check_and_handle_interrupt(void *vdbproc)
check interrupts for libtds.
Definition dbutil.c:192
Definition buffering.h:1
Definition dblib.h:44
Definition dblib.h:52
Definition dblib.h:62
Definition dblib.h:74
Definition dblib.h:89
Definition dblib.h:101
Definition dblib.h:110
Definition dblib.h:117
Definition dblib.h:123
NULLREP nullreps[MAXBINDTYPES]
default null values
Definition dblib.h:159
int msdblib
boolean use ms behaviour
Definition dblib.h:154
Definition tds.h:518
Definition tds.h:880
Definition tds.h:1033
Information for a server connection.
Definition tds.h:1180
Definition tds.h:1700
Definition sybdb.h:336
Definition sybdb.h:342