FreeTDS API
Loading...
Searching...
No Matches
ctlib.h
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 _tdsguard_gH4tOYBTzynx4DgqFzOEbB_
21#define _tdsguard_gH4tOYBTzynx4DgqFzOEbB_
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#include <freetds/pushvis.h>
33
34#ifdef __cplusplus
35extern "C"
36{
37#if 0
38}
39#endif
40#endif
41
42/* Fix a problem with Windows headers */
43#undef small
44
45/*
46 * internal types
47 */
49{
50 bool cs_expose_formats;
51 bool cs_note_empty_data;
52};
53
54/* Code changed for error handling */
55/* Code changes starts here - CT_DIAG - 01 */
56
57/* This structure is used in CT_DIAG */
58
60{
61 struct cs_diag_msg_client *next;
62 CS_CLIENTMSG clientmsg;
63};
64
65typedef struct {
66 CS_MSGNUM msgnumber;
67 CS_INT state;
68 CS_INT severity;
69 CS_CHAR text[CS_MAX_MSG];
70 CS_INT textlen;
71 CS_CHAR svrname[132];
72 CS_INT svrnlen;
73 CS_CHAR proc[132];
74 CS_INT proclen;
75 CS_INT line;
76 CS_INT status;
77 CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
78 CS_INT sqlstatelen;
80
81typedef struct {
82 CS_MSGNUM msgnumber;
83 CS_INT state;
84 CS_INT severity;
85 CS_CHAR text[CS_MAX_MSG];
86 CS_INT textlen;
87 CS_CHAR svrname[256];
88 CS_INT svrnlen;
89 CS_CHAR proc[256];
90 CS_INT proclen;
91 CS_INT line;
92 CS_INT status;
93 CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
94 CS_INT sqlstatelen;
96
97typedef struct {
98 CS_MSGNUM msgnumber;
99 CS_INT state;
100 CS_INT severity;
101 CS_CHAR text[CS_MAX_MSG];
102 CS_INT textlen;
104
105typedef struct {
106 CS_INT line;
107 CS_INT status;
108 CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
109 CS_INT sqlstatelen;
111
112typedef union
113{
114 CS_SERVERMSG_SMALL small;
115 CS_SERVERMSG_LARGE large;
117 CS_SERVERMSG user;
119
121{
122 struct cs_diag_msg_svr *next;
123 CS_SERVERMSG_INTERNAL servermsg;
124};
125
126/* Code changes ends here - CT_DIAG - 01 */
127
129{
130 CS_CLIENTMSG *msg;
131 struct cs_diag_msg *next;
132};
133
135{
136 CS_INT date_convert_fmt;
137 CS_INT cs_errhandletype;
138 CS_INT cs_diag_msglimit;
139
140 /* added for storing the maximum messages limit CT_DIAG */
141 /* code changes starts here - CT_DIAG - 02 */
142
143 CS_INT cs_diag_msglimit_client;
144 CS_INT cs_diag_msglimit_server;
145 CS_INT cs_diag_msglimit_total;
146 struct cs_diag_msg_client *clientstore;
147 struct cs_diag_msg_svr *svrstore;
148
149 /* code changes ends here - CT_DIAG - 02 */
150
151 struct cs_diag_msg *msgstore;
152 CS_CSLIBMSG_FUNC _cslibmsg_cb;
153 CS_CLIENTMSG_FUNC _clientmsg_cb;
154 CS_SERVERMSG_FUNC _servermsg_cb;
155 /* code changes start here - CS_CONFIG - 01*/
156 void *userdata;
157 int userdata_len;
158 /* code changes end here - CS_CONFIG - 01*/
159 TDSCONTEXT *tds_ctx;
160 CS_CONFIG config;
166};
167
168static inline size_t cs_servermsg_len(CS_CONTEXT *ctx)
169{
170 if (ctx->use_large_identifiers)
171 return sizeof(CS_SERVERMSG_LARGE);
172 return sizeof(CS_SERVERMSG_SMALL);
173}
174
175/*
176 * internal typedefs
177 */
178typedef struct _ct_colinfo
179{
180 TDS_SMALLINT *indicator;
181}
183
184typedef struct _cs_dynamic CS_DYNAMIC;
185
187{
188 CS_CONTEXT *ctx;
191 CS_CLIENTMSG_FUNC _clientmsg_cb;
192 CS_SERVERMSG_FUNC _servermsg_cb;
193 void *userdata;
194 int userdata_len;
195 CS_LOCALE *locale;
196 CS_COMMAND *cmds;
197 CS_DYNAMIC *dynlist;
198 char *server_addr;
199 bool network_auth;
200};
201
202/*
203 * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
204 * places, too.
205 */
206
207typedef struct _cs_param
208{
209 struct _cs_param *next;
210 char *name;
211 int status;
212 int datatype;
213 CS_INT maxlen;
214 CS_INT scale;
215 CS_INT precision;
216 CS_INT *datalen;
217 CS_SMALLINT *ind;
218 CS_BYTE *value;
219 int param_by_value;
220 CS_INT datalen_value;
221 CS_SMALLINT indicator_value;
222} CS_PARAM;
223
224/*
225 * Code added for RPC functionality - SUHA
226 * RPC Code changes starts here
227 */
228
230
231typedef struct _csremote_proc
232{
233 char *name;
234 CS_SMALLINT options;
235 CSREMOTE_PROC_PARAM *param_list;
237
238/*
239 * Structure CS_COMMAND changed for RPC functionality -SUHA
240 * Added CSREMOTE_PROC *rpc to CS_COMMAND structure
241 */
242
244
246{
247 struct _cs_dynamic *next;
248 char *id;
249 char *stmt;
250 CS_DYNAMIC_PARAM *param_list;
251 TDSDYNAMIC *tdsdyn;
252};
253
254/* specific FreeTDS commands */
255#define CS_DYNAMIC_CMD 160
256#define CS_CUR_CMD 161
257
258/* values for cs_command.results_state */
259
260#define _CS_RES_NONE -1
261#define _CS_RES_INIT 0
262#define _CS_RES_RESULTSET_EMPTY 1
263#define _CS_RES_RESULTSET_ROWS 2
264#define _CS_RES_STATUS 3
265#define _CS_RES_CMD_DONE 4
266#define _CS_RES_CMD_SUCCEED 5
267#define _CS_RES_END_RESULTS 6
268#define _CS_RES_DESCRIBE_RESULT 7
269
270/* values for cs_command.command_state */
271
272#define _CS_COMMAND_IDLE 0
273#define _CS_COMMAND_BUILDING 1
274#define _CS_COMMAND_READY 2
275#define _CS_COMMAND_SENT 3
276
277/* values for cs_command.cancel_state */
278#define _CS_CANCEL_NOCANCEL 0
279#define _CS_CANCEL_PENDING 1
280
282{
283 struct _cs_command *next;
284 CS_INT command_state;
285 CS_INT results_state;
286 CS_INT cancel_state;
287 CS_INT cursor_state;
288 CS_CONNECTION *con;
289 CS_INT command_type;
290 CS_CHAR *query;
291 short dynamic_cmd;
292 CS_DYNAMIC *dyn;
293 int row_prefetched;
294 int curr_result_type;
295 int bind_count;
296 int get_data_item;
297 int get_data_bytes_returned;
298 CS_IODESC *iodesc;
299 CS_INT send_data_started;
300 CSREMOTE_PROC *rpc;
301 CS_PARAM *input_params;
302 CS_INT client_cursor_id;
303 TDSCURSOR *cursor;
304 void *userdata;
305 int userdata_len;
306};
307
309{
310 TDSBCPINFO bcpinfo;
311};
312
313
314#define _CS_ERRHAND_INLINE 1
315#define _CS_ERRHAND_CB 2
316
318{
319 char *language;
320 char *charset;
321 char *time;
322 char *collate;
323};
324
325/* internal defines for cursor processing */
326
327#define _CS_CURS_TYPE_UNACTIONED 0
328#define _CS_CURS_TYPE_REQUESTED 1
329#define _CS_CURS_TYPE_SENT 2
330
331typedef struct {
332 CS_CHAR name[132];
333 CS_INT namelen;
334 CS_INT datatype;
335 CS_INT format;
336 CS_INT maxlength;
337 CS_INT scale;
338 CS_INT precision;
339 CS_INT status;
340 CS_INT count;
341 CS_INT usertype;
342 CS_LOCALE *locale;
344
345typedef struct {
346 CS_CHAR name[256];
347 CS_INT namelen;
348 CS_INT datatype;
349 CS_INT format;
350 CS_INT maxlength;
351 CS_INT scale;
352 CS_INT precision;
353 CS_INT status;
354 CS_INT count;
355 CS_INT usertype;
356 CS_LOCALE *locale;
358
359typedef struct {
360 CS_INT datatype;
361 CS_INT format;
362 CS_INT maxlength;
363 CS_INT scale;
364 CS_INT precision;
365 CS_INT status;
366 CS_INT count;
367 CS_INT usertype;
368 CS_LOCALE *locale;
370
371typedef union
372{
373 CS_DATAFMT_SMALL small;
374 CS_DATAFMT_LARGE large;
375 CS_DATAFMT user;
377
378/*
379 * internal prototypes
380 */
381TDSRET _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
382int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
383TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype);
384int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset);
385int _ct_get_client_type(const TDSCOLUMN *col, bool describe);
386void _ctclient_msg(CS_CONTEXT *ctx, CS_CONNECTION * con, const char *funcname,
387 int layer, int origin, int severity, int number,
388 const char *fmt, ...);
389CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type);
390void _cs_locale_free(CS_LOCALE *locale);
391CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig);
392int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig);
393CS_INT _ct_get_string_length(const char *buf, CS_INT buflen);
394
395int _cs_convert_not_client(CS_CONTEXT *ctx, const TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src);
396
397CS_RETCODE _cs_convert(CS_CONTEXT * ctx, const CS_DATAFMT_COMMON * srcfmt, CS_VOID * srcdata,
398 const CS_DATAFMT_COMMON * destfmt, CS_VOID * destdata, CS_INT * resultlen);
399bool _ct_is_large_identifiers_version(CS_INT version);
400const CS_DATAFMT_COMMON * _ct_datafmt_common(CS_CONTEXT * ctx, const CS_DATAFMT * datafmt);
401const CS_DATAFMT_LARGE *_ct_datafmt_conv_in(CS_CONTEXT * ctx, const CS_DATAFMT * datafmt, CS_DATAFMT_LARGE * fmtbuf);
402CS_DATAFMT_LARGE *_ct_datafmt_conv_prepare(CS_CONTEXT * ctx, CS_DATAFMT * datafmt, CS_DATAFMT_LARGE * fmtbuf);
403void _ct_datafmt_conv_back(CS_DATAFMT * datafmt, CS_DATAFMT_LARGE * fmtbuf);
404
405CS_RETCODE _ct_props_dstr(CS_CONNECTION * con, DSTR *s, CS_INT action, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
406
407#ifdef __cplusplus
408#if 0
409{
410#endif
411}
412#endif
413
414#include <freetds/popvis.h>
415
416#endif
Main include file for libtds.
Definition cstypes.h:102
Definition cstypes.h:119
Definition cstypes.h:186
Definition cstypes.h:200
Definition ctlib.h:49
Definition ctlib.h:60
Definition ctlib.h:65
Definition ctlib.h:81
Definition ctlib.h:97
Definition ctlib.h:105
Definition ctlib.h:113
Definition ctlib.h:121
Definition ctlib.h:129
Definition ctlib.h:135
int login_timeout
not used unless positive
Definition ctlib.h:161
bool use_large_identifiers
structures uses large identifiers
Definition ctlib.h:165
int query_timeout
not used unless positive
Definition ctlib.h:162
Definition ctlib.h:179
Definition ctlib.h:187
Definition ctlib.h:208
Definition ctlib.h:232
Definition ctlib.h:246
Definition ctlib.h:282
Definition ctlib.h:309
Definition ctlib.h:318
Definition ctlib.h:331
Definition ctlib.h:345
Definition ctlib.h:359
Definition ctlib.h:372
Definition convert.h:34
Definition tds.h:498
Metadata about columns in regular and compute rows.
Definition tds.h:674
Hold information for any results.
Definition tds.h:754
Definition tds.h:861
Holds information about a cursor.
Definition tds.h:922
Holds information for a dynamic (also called prepared) query.
Definition tds.h:962
Definition tds.h:1014
Information for a server connection.
Definition tds.h:1161
Definition tds.h:1681
Structure to hold a string.
Definition string.h:36