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 tag_DB_RESULT_STATE {
34 _DB_RES_INIT
35 , _DB_RES_RESULTSET_EMPTY
36 , _DB_RES_RESULTSET_ROWS
37 , _DB_RES_NEXT_RESULT
38 , _DB_RES_NO_MORE_RESULTS
39 , _DB_RES_SUCCEED
40} DB_RESULT_STATE;
41
43{
44 TDSLOGIN *tds_login;
45};
46
47struct dblib_buffer_row;
48
49typedef struct tag_DBPROC_ROWBUF
50{
51 int received; /* how many rows have been received for this result set */
52 int head; /* queue insertion point */
53 int tail; /* oldest item in queue */
54 int current; /* dbnextrow() reads this row */
55 int capacity; /* how many elements the queue can hold */
56 struct dblib_buffer_row *rows; /* pointer to the row storage */
57} DBPROC_ROWBUF;
58
59typedef struct
60{
61 int host_column;
62 TDS_SERVER_TYPE datatype;
63 int prefix_len;
64 DBINT column_len;
65 BYTE *terminator;
66 int term_len;
67 int tab_colnum;
68 int column_error;
70
71typedef struct
72{
73 TDS_CHAR *hostfile;
74 TDS_CHAR *errorfile;
75 FILE *bcp_errfileptr;
76 TDS_INT host_colcount;
77 BCP_HOSTCOLINFO **host_columns;
78 TDS_INT firstrow;
79 TDS_INT lastrow;
80 TDS_INT maxerrs;
81 TDS_INT batch;
83
84/* linked list of rpc parameters */
85
87{
88 struct _DBREMOTE_PROC_PARAM *next;
89
90 char *name;
91 BYTE status;
92 TDS_SERVER_TYPE type;
93 DBINT maxlen;
94 DBINT datalen;
95 BYTE *value;
96} DBREMOTE_PROC_PARAM;
97
98typedef struct _DBREMOTE_PROC
99{
100 struct _DBREMOTE_PROC *next;
101
102 char *name;
103 DBSMALLINT options;
104 DBREMOTE_PROC_PARAM *param_list;
105} DBREMOTE_PROC;
106
107typedef struct dboption
108{
109 const char *text;
110 DBSTRING *param;
111 DBBOOL factive;
112} DBOPTION;
113
115{
116 const BYTE *bindval;
117 size_t len;
118} NULLREP;
119
121{
122 TDSSOCKET *tds_socket;
123
124 STATUS row_type;
125 DBPROC_ROWBUF row_buf;
126
127 int noautofree;
128 int more_results; /* boolean. Are we expecting results? */
129 DB_RESULT_STATE dbresults_state;
130 int dbresults_retcode;
131 BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata() */
132 unsigned char *dbbuf; /* is dynamic! */
133 int dbbufsz;
134 int command_state;
135 TDS_INT text_size;
136 TDS_INT text_sent;
137 DBTYPEINFO typeinfo;
138 unsigned char avail_flag;
139 DBOPTION *dbopts;
140 DBSTRING *dboptcmd;
141 BCP_HOSTFILEINFO *hostfileinfo;
142 TDSBCPINFO *bcpinfo;
143 DBREMOTE_PROC *rpc;
144 DBUSMALLINT envchange_rcv;
145 char dbcurdb[DBMAXNAME + 1];
146 char servcharset[DBMAXNAME + 1];
147 FILE *ftos;
148 DB_DBCHKINTR_FUNC chkintr;
149 DB_DBHNDLINTR_FUNC hndlintr;
150
153
154 int ntimeouts;
155
157 NULLREP nullreps[MAXBINDTYPES];
158};
159
160enum {
161#if MSDBLIB
162 dblib_msdblib = 1
163#else
164 dblib_msdblib = 0
165#endif
166};
167
168/*
169 * internal prototypes
170 */
171RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr);
172void copy_data_to_host_var(DBPROCESS * dbproc, TDS_SERVER_TYPE srctype, const BYTE * src, DBINT srclen,
173 BYTE * dest, DBINT destlen,
174 int bindtype, DBINT *indicator);
175
176int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
177int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
178int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
179int _dblib_check_and_handle_interrupt(void * vdbproc);
180
181void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
182void _dblib_convert_err(DBPROCESS * dbproc, TDS_INT len);
183
184DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
185DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
186
187RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
188RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
189
190extern MHANDLEFUNC _dblib_msg_handler;
191extern EHANDLEFUNC _dblib_err_handler;
192
193#define CHECK_PARAMETER(x, msg, ret) if (!(x)) { dbperror(dbproc, (msg), 0); return ret; }
194#define CHECK_NULP(x, func, param_num, ret) if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; }
195#define CHECK_PARAMETER_NOPROC(x, msg) if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; }
196#define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; }
197#define DBPERROR_RETURN3(x, msg, a, b, c) if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; }
198#define CHECK_CONN(ret) do { CHECK_PARAMETER(dbproc, SYBENULL, (ret)); \
199 if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(dbproc, SYBEDDNE, 0); return (ret); } } while(0)
200
201
202#ifdef __cplusplus
203#if 0
204{
205#endif
206}
207#endif
208
209#include <freetds/popvis.h>
210
211#endif
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
Definition dblib.c:534
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
Call client-installed error handler.
Definition dblib.c:8109
int _dblib_check_and_handle_interrupt(void *vdbproc)
check interrupts for libtds.
Definition dbutil.c:192
Definition buffering.h:1
Definition dblib.h:43
Definition dblib.h:50
Definition dblib.h:60
Definition dblib.h:72
Definition dblib.h:87
Definition dblib.h:99
Definition dblib.h:108
Definition dblib.h:115
Definition dblib.h:121
NULLREP nullreps[MAXBINDTYPES]
default null values
Definition dblib.h:157
int msdblib
boolean use ms behaviour
Definition dblib.h:152
Definition tds.h:512