FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32 
33 /* $Id: dblib.h,v 1.49 2011-12-05 02:26:31 jklowden Exp $ */
34 
35 typedef enum tag_DB_RESULT_STATE {
36  _DB_RES_INIT
37  , _DB_RES_RESULTSET_EMPTY
38  , _DB_RES_RESULTSET_ROWS
39  , _DB_RES_NEXT_RESULT
40  , _DB_RES_NO_MORE_RESULTS
41  , _DB_RES_SUCCEED
42 } DB_RESULT_STATE;
43 
45 {
47 };
48 
49 struct dblib_buffer_row;
50 
51 typedef struct tag_DBPROC_ROWBUF
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 
61 typedef struct
62 {
63  int host_column;
64  int 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 
73 typedef 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 
88 typedef struct _DBREMOTE_PROC_PARAM
89 {
90  struct _DBREMOTE_PROC_PARAM *next;
91 
92  char *name;
93  BYTE status;
94  int type;
95  DBINT maxlen;
96  DBINT datalen;
97  BYTE *value;
99 
100 typedef struct _DBREMOTE_PROC
101 {
102  struct _DBREMOTE_PROC *next;
103 
104  char *name;
105  DBSMALLINT options;
106  DBREMOTE_PROC_PARAM *param_list;
107 } DBREMOTE_PROC;
108 
109 #define MAXOPTTEXT 32
110 
111 struct dboption
112 {
113  char text[MAXOPTTEXT];
114  DBSTRING *param;
115  DBBOOL factive;
116 };
117 typedef struct dboption DBOPTION;
118 
119 typedef struct _null_representation
120 {
121  const BYTE *bindval;
122  size_t len;
123 } NULLREP;
124 
126 {
128 
129  STATUS row_type;
130  DBPROC_ROWBUF row_buf;
131 
132  int noautofree;
133  int more_results; /* boolean. Are we expecting results? */
134  DB_RESULT_STATE dbresults_state;
135  int dbresults_retcode;
136  BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata() */
137  unsigned char *dbbuf; /* is dynamic! */
138  int dbbufsz;
139  int command_state;
140  TDS_INT text_size;
141  TDS_INT text_sent;
142  DBTYPEINFO typeinfo;
143  unsigned char avail_flag;
144  DBOPTION *dbopts;
145  DBSTRING *dboptcmd;
146  BCP_HOSTFILEINFO *hostfileinfo;
147  TDSBCPINFO *bcpinfo;
148  DBREMOTE_PROC *rpc;
149  DBUSMALLINT envchange_rcv;
150  char dbcurdb[DBMAXNAME + 1];
151  char servcharset[DBMAXNAME + 1];
152  FILE *ftos;
153  DB_DBCHKINTR_FUNC chkintr;
154  DB_DBHNDLINTR_FUNC hndlintr;
155 
157  int msdblib;
158 
159  int ntimeouts;
160 
162  NULLREP nullreps[MAXBINDTYPES];
163 };
164 
165 /*
166  * internal prototypes
167  */
168 RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr);
169 void copy_data_to_host_var(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen,
170  BYTE * dest, DBINT destlen,
171  int bindtype, DBINT *indicator);
172 
173 int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
174 int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
175 int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
176 int _dblib_check_and_handle_interrupt(void * vdbproc);
177 
178 void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
179 void _dblib_convert_err(DBPROCESS * dbproc, TDS_INT len);
180 
181 DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
182 DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
183 
184 RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
185 RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
186 
187 extern MHANDLEFUNC _dblib_msg_handler;
188 extern EHANDLEFUNC _dblib_err_handler;
189 
190 #define CHECK_PARAMETER(x, msg, ret) if (!(x)) { dbperror(dbproc, (msg), 0); return ret; }
191 #define CHECK_NULP(x, func, param_num, ret) if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; }
192 #define CHECK_PARAMETER_NOPROC(x, msg) if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; }
193 #define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; }
194 #define DBPERROR_RETURN3(x, msg, a, b, c) if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; }
195 #define CHECK_CONN(ret) do { CHECK_PARAMETER(dbproc, SYBENULL, (ret)); \
196  if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(NULL, SYBEDDNE, 0); return (ret); } } while(0)
197 
198 
199 #ifdef __cplusplus
200 #if 0
201 {
202 #endif
203 }
204 #endif
205 
206 #include <freetds/popvis.h>
207 
208 #endif
Definition: dblib.h:51
Definition: dblib.h:125
Definition: dblib.h:73
NULLREP nullreps[MAXBINDTYPES]
default null values
Definition: dblib.h:162
int _dblib_check_and_handle_interrupt(void *vdbproc)
check interrupts for libtds.
Definition: dbutil.c:193
Definition: sybdb.h:304
Definition: tds.h:996
Definition: tds.h:1491
Definition: dblib.h:88
Definition: tds.h:519
Definition: dblib.h:61
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
Call client-installed error handler.
Definition: dblib.c:7884
int msdblib
boolean use ms behaviour
Definition: dblib.h:157
Definition: sybdb.h:310
Definition: dblib.h:119
Definition: buffering.h:1
Definition: tds.h:846
Definition: dblib.h:111
Definition: dblib.h:100
Definition: dblib.h:44
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
Definition: dblib.c:535
Information for a server connection.
Definition: tds.h:1098