NCBI C++ ToolKit
ctlib.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 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 _ctlib_h_
21 #define _ctlib_h_
22 
23 #include <freetds/tds.h>
24 #include <freetds/convert.h>
25 #include <freetds/utils/string.h>
26 #include <freetds/bool.h>
27 
28 /*
29  * Internal (not part of the exposed API) prototypes and such.
30  */
31 
32 /* Forward declarations to fix "declared with greater visibility" warnings */
33 struct _cs_dynamic;
34 struct _cs_param;
35 struct _csremote_proc;
36 struct cs_diag_msg;
37 struct cs_diag_msg_client;
38 struct cs_diag_msg_svr;
40 struct cs_servermsg_large;
41 struct cs_servermsg_small;
43 
44 #include <freetds/pushvis.h>
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #if 0
50 }
51 #endif
52 #endif
53 
54 /* Fix a problem with Windows headers */
55 #undef small
56 
57 /*
58  * internal types
59  */
60 struct _cs_config
61 {
62  short cs_expose_formats;
63 };
64 
65 /* Code changed for error handling */
66 /* Code changes starts here - CT_DIAG - 01 */
67 
68 /* This structure is used in CT_DIAG */
69 
70 struct cs_diag_msg_client
71 {
72  struct cs_diag_msg_client *next;
74 };
75 
76 typedef struct cs_servermsg_small {
84  CS_CHAR proc[132];
91 
92 typedef struct cs_servermsg_large {
100  CS_CHAR proc[256];
107 
108 typedef struct cs_servermsg_common1 {
115 
116 typedef struct {
122 
124 {
130 
131 struct cs_diag_msg_svr
132 {
133  struct cs_diag_msg_svr *next;
135 };
136 
137 /* Code changes ends here - CT_DIAG - 01 */
138 
139 struct cs_diag_msg
140 {
141  CS_CLIENTMSG *msg;
142  struct cs_diag_msg *next;
143 };
144 
145 struct _cs_context
146 {
150 
151  /* added for storing the maximum messages limit CT_DIAG */
152  /* code changes starts here - CT_DIAG - 02 */
153 
158  struct cs_diag_msg_svr *svrstore;
159 
160  /* code changes ends here - CT_DIAG - 02 */
161 
162  struct cs_diag_msg *msgstore;
166  /* code changes start here - CS_CONFIG - 01*/
167  void *userdata;
168  int userdata_len;
169  /* code changes end here - CS_CONFIG - 01*/
172  int login_timeout; /**< not used unless positive */
173  int query_timeout; /**< not used unless positive */
174 
175  /** structures uses large identifiers */
177 };
178 
179 static inline size_t cs_servermsg_len(CS_CONTEXT *ctx)
180 {
182  return sizeof(CS_SERVERMSG_LARGE);
183  return sizeof(CS_SERVERMSG_SMALL);
184 }
185 
186 /*
187  * internal typedefs
188  */
189 typedef struct _ct_colinfo
190 {
192 }
194 
195 typedef struct _cs_dynamic CS_DYNAMIC;
196 
197 struct _cs_connection
198 {
199  CS_CONTEXT *ctx;
204  void *userdata;
205  int userdata_len;
206  CS_LOCALE *locale;
207  CS_COMMAND *cmds;
209  char *server_addr;
211 };
212 
213 /*
214  * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
215  * places, too.
216  */
217 
218 typedef struct _cs_param
219 {
220  struct _cs_param *next;
221  char *name;
222  int status;
223  int datatype;
224  CS_INT maxlen;
225  CS_INT scale;
227  CS_INT *datalen;
228  CS_SMALLINT *ind;
229  CS_BYTE *value;
230  int param_by_value;
234 
235 /*
236  * Code added for RPC functionality - SUHA
237  * RPC Code changes starts here
238  */
239 
241 
242 typedef struct _csremote_proc
243 {
244  char *name;
248 
249 /*
250  * Structure CS_COMMAND changed for RPC functionality -SUHA
251  * Added CSREMOTE_PROC *rpc to CS_COMMAND structure
252  */
253 
255 
256 struct _cs_dynamic
257 {
258  struct _cs_dynamic *next;
259  char *id;
260  char *stmt;
263 };
264 
265 /* specific FreeTDS commands */
266 #define CS_DYNAMIC_CMD 160
267 #define CS_CUR_CMD 161
268 
269 /* values for cs_command.results_state */
270 
271 #define _CS_RES_NONE -1
272 #define _CS_RES_INIT 0
273 #define _CS_RES_RESULTSET_EMPTY 1
274 #define _CS_RES_RESULTSET_ROWS 2
275 #define _CS_RES_STATUS 3
276 #define _CS_RES_CMD_DONE 4
277 #define _CS_RES_CMD_SUCCEED 5
278 #define _CS_RES_END_RESULTS 6
279 #define _CS_RES_DESCRIBE_RESULT 7
280 
281 /* values for cs_command.command_state */
282 
283 #define _CS_COMMAND_IDLE 0
284 #define _CS_COMMAND_BUILDING 1
285 #define _CS_COMMAND_READY 2
286 #define _CS_COMMAND_SENT 3
287 
288 /* values for cs_command.cancel_state */
289 #define _CS_CANCEL_NOCANCEL 0
290 #define _CS_CANCEL_PENDING 1
291 
292 struct _cs_command
293 {
294  struct _cs_command *next;
301  CS_CHAR *query;
302  short dynamic_cmd;
303  CS_DYNAMIC *dyn;
304  int row_prefetched;
305  int curr_result_type;
306  int bind_count;
307  int get_data_item;
309  CS_IODESC *iodesc;
314  TDSCURSOR *cursor;
315  void *userdata;
316  int userdata_len;
317 };
318 
319 struct _cs_blkdesc
320 {
322 };
323 
324 
325 #define _CS_ERRHAND_INLINE 1
326 #define _CS_ERRHAND_CB 2
327 
328 struct _cs_locale
329 {
330  char *language;
331  char *charset;
332  char *time;
333  char *collate;
334 };
335 
336 /* internal defines for cursor processing */
337 
338 #define _CS_CURS_TYPE_UNACTIONED TDS_CURSOR_STATE_UNACTIONED
339 #define _CS_CURS_TYPE_REQUESTED TDS_CURSOR_STATE_REQUESTED
340 #define _CS_CURS_TYPE_SENT TDS_CURSOR_STATE_SENT
341 
342 typedef struct {
343  CS_CHAR name[132];
355 
356 typedef struct {
357  CS_CHAR name[256];
369 
370 typedef struct {
381 
382 typedef union
383 {
388 
389 /*
390  * internal prototypes
391  */
392 TDSRET _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
393 int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
396 int _ct_get_client_type(const TDSCOLUMN *col, bool describe);
397 void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number,
398  const char *fmt, ...);
403 
404 int _cs_convert_not_client(CS_CONTEXT *ctx, const TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src);
405 
407  CS_VOID * srcdata, const CS_DATAFMT_COMMON * destfmt,
408  CS_VOID * destdata, CS_INT * resultlen,
409  TDS_SERVER_TYPE desttype, CS_VOID ** handle);
410 void _csclient_msg(CS_CONTEXT * ctx, const char *funcname, int layer,
411  int origin, int severity, int number, const char *fmt, ...);
412 
414 const CS_DATAFMT_COMMON * _ct_datafmt_common(CS_CONTEXT * ctx, const CS_DATAFMT * datafmt);
417 void _ct_datafmt_conv_back(CS_DATAFMT * datafmt, CS_DATAFMT_LARGE * fmtbuf);
418 
419 #ifdef __cplusplus
420 #if 0
421 {
422 #endif
423 }
424 #endif
425 
426 #include <freetds/popvis.h>
427 
428 #endif
CS_RETCODE(* CS_SERVERMSG_FUNC)(CS_CONTEXT *, CS_CONNECTION *, CS_SERVERMSG *)
Definition: cspublic.h:71
CS_RETCODE(* CS_CLIENTMSG_FUNC)(CS_CONTEXT *, CS_CONNECTION *, CS_CLIENTMSG *)
Definition: cspublic.h:70
CS_RETCODE(* CS_CSLIBMSG_FUNC)(CS_CONTEXT *, CS_CLIENTMSG *)
Definition: cspublic.h:69
Int4 CS_INT
Definition: cstypes.h:41
Int2 CS_SMALLINT
Definition: cstypes.h:45
#define CS_MAX_MSG
Definition: cstypes.h:69
void CS_VOID
Definition: cstypes.h:53
unsigned char CS_BYTE
Definition: cstypes.h:49
CS_INT CS_RETCODE
Definition: cstypes.h:63
CS_INT CS_MSGNUM
Definition: cstypes.h:182
char CS_CHAR
Definition: cstypes.h:48
#define CS_SQLSTATE_SIZE
Definition: cstypes.h:70
CS_CONTEXT * ctx
Definition: t0006.c:12
CS_LOCALE * _cs_locale_copy(CS_LOCALE *orig)
Definition: cs.c:300
int _ct_handle_client_message(const TDSCONTEXT *ctxptr, TDSSOCKET *tdsptr, TDSMESSAGE *msgptr)
Definition: ctutil.c:100
struct _cs_param CS_PARAM
Definition: ctlib.h:36
TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype)
Definition: ct.c:2128
void _cs_locale_free(CS_LOCALE *locale)
Definition: cs.c:249
CS_PARAM CSREMOTE_PROC_PARAM
Definition: ctlib.h:165
struct _ct_colinfo CT_COLINFO
int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig)
Definition: cs.c:262
int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO *resinfo, TDSRESULTINFO *bindinfo, CS_INT offset)
Definition: ct.c:1794
void _ctclient_msg(CS_CONNECTION *con, const char *funcname, int layer, int origin, int severity, int number, const char *fmt,...)
Definition: ct.c:188
void _csclient_msg(CS_CONTEXT *ctx, const char *funcname, int layer, int origin, int severity, int number, const char *fmt,...)
Definition: cs.c:188
int _ct_get_client_type(CS_CONTEXT *ctx, TDSCOLUMN *col)
Definition: ct.c:1964
CS_PARAM CS_DYNAMIC_PARAM
Definition: ctlib.h:179
CS_INT _ct_diag_clearmsg(CS_CONTEXT *context, CS_INT type)
Definition: ct.c:4805
int _cs_convert_not_client(CS_CONTEXT *ctx, TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src)
Try to convert to a type we can handle.
Definition: cs.c:1508
TDSRET _ct_handle_server_message(const TDSCONTEXT *ctxptr, TDSSOCKET *tdsptr, TDSMESSAGE *msgptr)
Definition: ctutil.c:158
struct _csremote_proc CSREMOTE_PROC
TDS_SERVER_TYPE
Definition: proto.h:161
tds_sysdep_int16_type TDS_SMALLINT
Definition: tds.h:147
int TDSRET
Definition: tds.h:201
int offset
Definition: replacements.h:160
static TDSSOCKET * tds
Definition: collations.c:37
union cs_servermsg_internal CS_SERVERMSG_INTERNAL
struct cs_servermsg_large CS_SERVERMSG_LARGE
struct cs_servermsg_common1 CS_SERVERMSG_COMMON1
static size_t cs_servermsg_len(CS_CONTEXT *ctx)
Definition: ctlib.h:179
struct cs_servermsg_small CS_SERVERMSG_SMALL
CS_DATAFMT_LARGE * _ct_datafmt_conv_prepare(CS_CONTEXT *ctx, CS_DATAFMT *datafmt, CS_DATAFMT_LARGE *fmtbuf)
Prepares to Convert CS_DATAFMT output parameter to CS_DATAFMT_LARGE.
Definition: ctutil.c:289
bool _ct_is_large_identifiers_version(CS_INT version)
Check if a give version supports large identifiers.
Definition: ctutil.c:231
CS_RETCODE _cs_convert(CS_CONTEXT *ctx, const CS_DATAFMT_COMMON *srcfmt, CS_VOID *srcdata, const CS_DATAFMT_COMMON *destfmt, CS_VOID *destdata, CS_INT *resultlen, TDS_SERVER_TYPE desttype, CS_VOID **handle)
Definition: cs.c:488
const CS_DATAFMT_COMMON * _ct_datafmt_common(CS_CONTEXT *ctx, const CS_DATAFMT *datafmt)
Definition: ctutil.c:244
void _ct_datafmt_conv_back(CS_DATAFMT *datafmt, CS_DATAFMT_LARGE *fmtbuf)
Converts CS_DATAFMT output parameter to CS_DATAFMT_LARGE after setting it.
Definition: ctutil.c:308
const CS_DATAFMT_LARGE * _ct_datafmt_conv_in(CS_CONTEXT *ctx, const CS_DATAFMT *datafmt, CS_DATAFMT_LARGE *fmtbuf)
Converts CS_DATAFMT input parameter to CS_DATAFMT_LARGE.
Definition: ctutil.c:261
where boath are integers</td > n< td ></td > n</tr > n< tr > n< td > tse</td > n< td > optional</td > n< td > String</td > n< td class=\"description\"> TSE option controls what blob is orig
static int version
Definition: mdb_load.c:29
static const GLdouble origin[]
static BOOL number
Definition: pcregrep.c:193
static char * locale
Definition: pcregrep.c:149
CS_INT maxlength
Definition: ctlib.h:373
CS_INT format
Definition: ctlib.h:372
CS_INT precision
Definition: ctlib.h:375
CS_INT status
Definition: ctlib.h:376
CS_INT datatype
Definition: ctlib.h:371
CS_INT usertype
Definition: ctlib.h:378
CS_INT count
Definition: ctlib.h:377
CS_LOCALE * locale
Definition: ctlib.h:379
CS_INT scale
Definition: ctlib.h:374
CS_INT maxlength
Definition: ctlib.h:361
CS_INT format
Definition: ctlib.h:360
CS_INT precision
Definition: ctlib.h:363
CS_INT usertype
Definition: ctlib.h:366
CS_INT status
Definition: ctlib.h:364
CS_INT datatype
Definition: ctlib.h:359
CS_INT namelen
Definition: ctlib.h:358
CS_INT scale
Definition: ctlib.h:362
CS_INT count
Definition: ctlib.h:365
CS_LOCALE * locale
Definition: ctlib.h:367
CS_INT status
Definition: ctlib.h:350
CS_INT precision
Definition: ctlib.h:349
CS_INT usertype
Definition: ctlib.h:352
CS_LOCALE * locale
Definition: ctlib.h:353
CS_INT maxlength
Definition: ctlib.h:347
CS_INT scale
Definition: ctlib.h:348
CS_INT datatype
Definition: ctlib.h:345
CS_INT namelen
Definition: ctlib.h:344
CS_INT format
Definition: ctlib.h:346
CS_INT count
Definition: ctlib.h:351
CS_INT sqlstatelen
Definition: ctlib.h:120
TDSBCPINFO bcpinfo
Definition: ctlib.h:246
CS_DYNAMIC * dyn
Definition: ctlib.h:228
CS_INT client_cursor_id
Definition: ctlib.h:238
int row_prefetched
Definition: ctlib.h:229
CS_INT cursor_state
Definition: ctlib.h:223
CS_IODESC * iodesc
Definition: ctlib.h:234
CS_INT send_data_started
Definition: ctlib.h:235
CS_INT results_state
Definition: ctlib.h:221
int get_data_bytes_returned
Definition: ctlib.h:233
int get_data_item
Definition: ctlib.h:232
CS_CONNECTION * con
Definition: ctlib.h:224
CS_INT cancel_state
Definition: ctlib.h:222
CS_INT command_type
Definition: ctlib.h:225
CSREMOTE_PROC * rpc
Definition: ctlib.h:236
int curr_result_type
Definition: ctlib.h:230
short dynamic_cmd
Definition: ctlib.h:227
CS_INT command_state
Definition: ctlib.h:220
TDSCURSOR * cursor
Definition: ctlib.h:239
void * userdata
Definition: ctlib.h:240
int bind_count
Definition: ctlib.h:231
CS_PARAM * input_params
Definition: ctlib.h:237
struct _cs_command * next
Definition: ctlib.h:219
CS_CHAR * query
Definition: ctlib.h:226
int userdata_len
Definition: ctlib.h:241
short cs_expose_formats
Definition: ctlib.h:54
int userdata_len
Definition: ctlib.h:131
CS_LOCALE * locale
Definition: ctlib.h:132
void * userdata
Definition: ctlib.h:130
TDSSOCKET * tds_socket
Definition: ctlib.h:127
bool network_auth
Definition: ctlib.h:210
char * server_addr
Definition: ctlib.h:135
CS_COMMAND * cmds
Definition: ctlib.h:133
CS_CONTEXT * ctx
Definition: ctlib.h:125
CS_SERVERMSG_FUNC _servermsg_cb
Definition: ctlib.h:129
CS_CLIENTMSG_FUNC _clientmsg_cb
Definition: ctlib.h:128
TDSLOGIN * tds_login
Definition: ctlib.h:126
CS_DYNAMIC * dynlist
Definition: ctlib.h:134
CS_INT cs_diag_msglimit_client
Definition: ctlib.h:91
int login_timeout
not used unless positive
Definition: ctlib.h:109
CS_CONFIG config
Definition: ctlib.h:108
TDSCONTEXT * tds_ctx
Definition: ctlib.h:107
CS_CSLIBMSG_FUNC _cslibmsg_cb
Definition: ctlib.h:100
CS_INT date_convert_fmt
Definition: ctlib.h:84
bool use_large_identifiers
structures uses large identifiers
Definition: ctlib.h:176
struct cs_diag_msg_client * clientstore
Definition: ctlib.h:94
CS_INT cs_diag_msglimit_total
Definition: ctlib.h:93
struct cs_diag_msg * msgstore
Definition: ctlib.h:99
CS_INT cs_diag_msglimit_server
Definition: ctlib.h:92
struct cs_diag_msg_svr * svrstore
Definition: ctlib.h:95
int query_timeout
not used unless positive
Definition: ctlib.h:110
CS_SERVERMSG_FUNC _servermsg_cb
Definition: ctlib.h:102
CS_INT cs_errhandletype
Definition: ctlib.h:85
CS_CLIENTMSG_FUNC _clientmsg_cb
Definition: ctlib.h:101
int userdata_len
Definition: ctlib.h:105
CS_INT cs_diag_msglimit
Definition: ctlib.h:86
void * userdata
Definition: ctlib.h:104
TDSDYNAMIC * tdsdyn
Definition: ctlib.h:187
struct _cs_dynamic * next
Definition: ctlib.h:183
char * stmt
Definition: ctlib.h:185
char * id
Definition: ctlib.h:184
CS_DYNAMIC_PARAM * param_list
Definition: ctlib.h:186
char * time
Definition: ctlib.h:257
char * collate
Definition: ctlib.h:258
char * language
Definition: ctlib.h:255
char * charset
Definition: ctlib.h:256
CS_SMALLINT * ind
Definition: ctlib.h:153
int datatype
Definition: ctlib.h:148
CS_INT maxlen
Definition: ctlib.h:149
CS_SMALLINT indicator_value
Definition: ctlib.h:157
CS_INT precision
Definition: ctlib.h:151
int status
Definition: ctlib.h:147
struct _cs_param * next
Definition: ctlib.h:145
char * name
Definition: ctlib.h:146
CS_INT scale
Definition: ctlib.h:150
CS_INT * datalen
Definition: ctlib.h:152
CS_BYTE * value
Definition: ctlib.h:154
int param_by_value
Definition: ctlib.h:155
CS_INT datalen_value
Definition: ctlib.h:156
CSREMOTE_PROC_PARAM * param_list
Definition: ctlib.h:171
CS_SMALLINT options
Definition: ctlib.h:170
char * name
Definition: ctlib.h:169
TDS_SMALLINT * indicator
Definition: ctlib.h:118
struct cs_diag_msg_client * next
Definition: ctlib.h:65
CS_CLIENTMSG clientmsg
Definition: ctlib.h:73
CS_SERVERMSG_INTERNAL servermsg
Definition: ctlib.h:134
struct cs_diag_msg_svr * next
Definition: ctlib.h:71
struct cs_diag_msg * next
Definition: ctlib.h:79
CS_CLIENTMSG * msg
Definition: ctlib.h:78
CS_CHAR text[CS_MAX_MSG]
Definition: ctlib.h:112
CS_MSGNUM msgnumber
Definition: ctlib.h:109
CS_INT proclen
Definition: ctlib.h:101
CS_INT svrnlen
Definition: ctlib.h:99
CS_INT state
Definition: ctlib.h:94
CS_BYTE sqlstate[CS_SQLSTATE_SIZE]
Definition: ctlib.h:104
CS_INT sqlstatelen
Definition: ctlib.h:105
CS_INT status
Definition: ctlib.h:103
CS_INT severity
Definition: ctlib.h:95
CS_CHAR text[CS_MAX_MSG]
Definition: ctlib.h:96
CS_INT textlen
Definition: ctlib.h:97
CS_MSGNUM msgnumber
Definition: ctlib.h:93
CS_CHAR svrname[256]
Definition: ctlib.h:98
CS_CHAR proc[256]
Definition: ctlib.h:100
CS_INT line
Definition: ctlib.h:86
CS_MSGNUM msgnumber
Definition: ctlib.h:77
CS_INT textlen
Definition: ctlib.h:81
CS_BYTE sqlstate[CS_SQLSTATE_SIZE]
Definition: ctlib.h:88
CS_INT severity
Definition: ctlib.h:79
CS_CHAR svrname[132]
Definition: ctlib.h:82
CS_INT status
Definition: ctlib.h:87
CS_CHAR proc[132]
Definition: ctlib.h:84
CS_CHAR text[CS_MAX_MSG]
Definition: ctlib.h:80
CS_INT svrnlen
Definition: ctlib.h:83
CS_INT sqlstatelen
Definition: ctlib.h:89
CS_INT proclen
Definition: ctlib.h:85
CS_INT state
Definition: ctlib.h:78
Metadata about columns in regular and compute rows.
Definition: tds.h:761
Holds informations about a cursor.
Definition: tds.h:1007
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1047
Definition: tds.h:584
Hold information for any results.
Definition: tds.h:842
Information for a server connection.
Definition: tds.h:1211
Definition: type.c:6
CS_DATAFMT user
Definition: ctlib.h:386
CS_DATAFMT_SMALL small
Definition: ctlib.h:384
CS_DATAFMT_LARGE large
Definition: ctlib.h:385
CS_SERVERMSG user
Definition: ctlib.h:128
CS_SERVERMSG_SMALL small
Definition: ctlib.h:125
CS_SERVERMSG_LARGE large
Definition: ctlib.h:126
CS_SERVERMSG_COMMON1 common
Definition: ctlib.h:127
static CS_CONTEXT * context
Definition: will_convert.c:21
Modified on Wed Jun 12 11:18:37 2024 by modify_doxy.py rev. 669887