NCBI C++ ToolKit
dblib.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  *
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
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32 
33 typedef enum tag_DB_RESULT_STATE {
41 
43 {
45 };
46 
47 struct dblib_buffer_row;
48 
49 typedef 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 */
58 
59 typedef struct
60 {
66  int term_len;
70 
71 typedef struct
72 {
83 
84 /* linked list of rpc parameters */
85 
86 typedef struct _DBREMOTE_PROC_PARAM
87 {
89 
90  char *name;
97 
98 typedef struct _DBREMOTE_PROC
99 {
101 
102  char *name;
106 
107 typedef struct dboption
108 {
109  const char *text;
113 
114 typedef struct _null_representation
115 {
116  const BYTE *bindval;
117  unsigned int len;
119 
121 {
123 
126 
128  int more_results; /* boolean. Are we expecting results? */
131  BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata() */
132  unsigned char *dbbuf; /* is dynamic! */
133  int dbbufsz;
138  unsigned char avail_flag;
145  char dbcurdb[DBMAXNAME + 1];
147  FILE *ftos;
150 
151  /** boolean use ms behaviour */
152  int msdblib;
153 
155 
156  /** default null values **/
158 };
159 
160 enum {
161 #if MSDBLIB
162  dblib_msdblib = 1
163 #else
164  dblib_msdblib = 0
165 #endif
166 };
167 
168 /*
169  * internal prototypes
170  */
171 RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr);
172 void 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 
176 int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
177 int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
178 int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
179 int _dblib_check_and_handle_interrupt(void * vdbproc);
180 
183 
184 DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
185 DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
186 
189 
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
static DBPROCESS * dbproc
Definition: done_handling.c:29
struct tag_DBPROC_ROWBUF DBPROC_ROWBUF
EHANDLEFUNC _dblib_err_handler
Definition: dblib.c:165
@ dblib_msdblib
Definition: dblib.h:164
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
Definition: dblib.c:8039
void _dblib_convert_err(DBPROCESS *dbproc, TDS_INT len)
Definition: dbutil.c:241
void copy_data_to_host_var(DBPROCESS *dbproc, TDS_SERVER_TYPE srctype, const BYTE *src, DBINT srclen, BYTE *dest, DBINT destlen, int bindtype, DBINT *indicator)
Definition: dblib.c:7339
struct _DBREMOTE_PROC DBREMOTE_PROC
struct _DBREMOTE_PROC_PARAM DBREMOTE_PROC_PARAM
struct dboption DBOPTION
DBINT _convert_char(int srctype, BYTE *src, int destype, BYTE *dest, DBINT destlen)
tag_DB_RESULT_STATE
Definition: dblib.h:33
@ _DB_RES_SUCCEED
Definition: dblib.h:39
@ _DB_RES_NO_MORE_RESULTS
Definition: dblib.h:38
@ _DB_RES_NEXT_RESULT
Definition: dblib.h:37
@ _DB_RES_INIT
Definition: dblib.h:34
@ _DB_RES_RESULTSET_EMPTY
Definition: dblib.h:35
@ _DB_RES_RESULTSET_ROWS
Definition: dblib.h:36
void _dblib_setTDS_version(TDSLOGIN *tds_login, DBINT version)
Definition: dbutil.c:225
RETCODE _bcp_get_prog_data(DBPROCESS *dbproc)
MHANDLEFUNC _dblib_msg_handler
Definition: dblib.c:164
DBINT _convert_intn(int srctype, BYTE *src, int destype, BYTE *dest, DBINT destlen)
int _dblib_handle_err_message(const TDSCONTEXT *ctxptr, TDSSOCKET *tdsptr, TDSMESSAGE *msgptr)
Definition: dbutil.c:127
int _dblib_handle_info_message(const TDSCONTEXT *ctxptr, TDSSOCKET *tdsptr, TDSMESSAGE *msgptr)
Definition: dbutil.c:70
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
Definition: dblib.c:543
RETCODE _bcp_clear_storage(DBPROCESS *dbproc)
struct _null_representation NULLREP
TDS_SERVER_TYPE
Definition: proto.h:161
tds_sysdep_int32_type TDS_INT
Definition: tds.h:149
char TDS_CHAR
Definition: tds.h:144
unsigned char DBBOOL
Definition: sybdb.h:250
int STATUS
Definition: sybdb.h:148
Uint2 DBUSMALLINT
Definition: sybdb.h:260
#define DBMAXNAME
Definition: sybdb.h:67
#define MAXBINDTYPES
Definition: sybdb.h:573
int RETCODE
Definition: sybdb.h:121
unsigned char BYTE
Definition: sybdb.h:334
int(* DB_DBCHKINTR_FUNC)(void *dbproc)
Definition: sybdb.h:134
Int2 DBSMALLINT
Definition: sybdb.h:254
int(* EHANDLEFUNC)(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
Definition: sybdb.h:532
int(* DB_DBHNDLINTR_FUNC)(void *dbproc)
Definition: sybdb.h:135
int(* MHANDLEFUNC)(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *proc, int line)
Definition: sybdb.h:534
Int4 DBINT
Definition: sybdb.h:255
DB_RESULT_STATE
Definition: dblib.h:34
int _dblib_check_and_handle_interrupt(void *vdbproc)
check interrupts for libtds.
Definition: dbutil.c:192
int len
static int version
Definition: mdb_load.c:29
int tab_colnum
Definition: dblib.h:67
TDS_SERVER_TYPE datatype
Definition: dblib.h:62
int prefix_len
Definition: dblib.h:63
int host_column
Definition: dblib.h:61
int term_len
Definition: dblib.h:66
BYTE * terminator
Definition: dblib.h:65
int column_error
Definition: dblib.h:68
DBINT column_len
Definition: dblib.h:64
TDS_INT firstrow
Definition: dblib.h:78
TDS_INT batch
Definition: dblib.h:81
BCP_HOSTCOLINFO ** host_columns
Definition: dblib.h:77
TDS_CHAR * hostfile
Definition: dblib.h:73
TDS_INT lastrow
Definition: dblib.h:79
FILE * bcp_errfileptr
Definition: dblib.h:75
TDS_CHAR * errorfile
Definition: dblib.h:74
TDS_INT host_colcount
Definition: dblib.h:76
TDS_INT maxerrs
Definition: dblib.h:80
Definition: dblib.h:117
TDS_SERVER_TYPE type
Definition: dblib.h:92
struct _DBREMOTE_PROC_PARAM * next
Definition: dblib.h:88
DBSMALLINT options
Definition: dblib.h:103
struct _DBREMOTE_PROC * next
Definition: dblib.h:100
char * name
Definition: dblib.h:102
DBREMOTE_PROC_PARAM * param_list
Definition: dblib.h:104
unsigned int len
Definition: dblib.h:117
const BYTE * bindval
Definition: dblib.h:116
const char * text
Definition: dblib.h:109
DBSTRING * param
Definition: dblib.h:110
DBBOOL factive
Definition: dblib.h:111
struct dblib_buffer_row * rows
Definition: dblib.h:56
NULLREP nullreps[MAXBINDTYPES]
default null values
Definition: dblib.h:157
TDSBCPINFO * bcpinfo
Definition: dblib.h:142
char dbcurdb[DBMAXNAME+1]
Definition: dblib.h:145
TDS_INT text_size
Definition: dblib.h:135
STATUS row_type
Definition: dblib.h:124
DBSTRING * dboptcmd
Definition: dblib.h:140
DBPROC_ROWBUF row_buf
Definition: dblib.h:125
BCP_HOSTFILEINFO * hostfileinfo
Definition: dblib.h:141
DBTYPEINFO typeinfo
Definition: dblib.h:137
DB_DBCHKINTR_FUNC chkintr
Definition: dblib.h:148
TDSSOCKET * tds_socket
Definition: dblib.h:122
DB_DBHNDLINTR_FUNC hndlintr
Definition: dblib.h:149
char servcharset[DBMAXNAME+1]
Definition: dblib.h:146
int dbresults_retcode
Definition: dblib.h:130
unsigned char * dbbuf
Definition: dblib.h:132
DBREMOTE_PROC * rpc
Definition: dblib.h:143
DB_RESULT_STATE dbresults_state
Definition: dblib.h:129
DBUSMALLINT envchange_rcv
Definition: dblib.h:144
TDS_INT text_sent
Definition: dblib.h:136
BYTE * user_data
Definition: dblib.h:131
int msdblib
boolean use ms behaviour
Definition: dblib.h:152
unsigned char avail_flag
Definition: dblib.h:138
DBOPTION * dbopts
Definition: dblib.h:139
TDSLOGIN * tds_login
Definition: dblib.h:44
Definition: tds.h:584
Information for a server connection.
Definition: tds.h:1211
Modified on Tue May 28 05:52:04 2024 by modify_doxy.py rev. 669887