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 _ctlib_h_
21#define _ctlib_h_
22
23#include <freetds/tds.h>
24#include <freetds/convert.h>
25#include <freetds/utils/string.h>
26
27/*
28 * Internal (not part of the exposed API) prototypes and such.
29 */
30
31#include <freetds/pushvis.h>
32
33#ifdef __cplusplus
34extern "C"
35{
36#if 0
37}
38#endif
39#endif
40
41/*
42 * internal types
43 */
45{
46 short cs_expose_formats;
47};
48
49/* Code changed for error handling */
50/* Code changes starts here - CT_DIAG - 01 */
51
52/* This structure is used in CT_DIAG */
53
55{
56 CS_CLIENTMSG *clientmsg;
57 struct cs_diag_msg_client *next;
58};
59
61{
62 CS_SERVERMSG *servermsg;
63 struct cs_diag_msg_svr *next;
64};
65
66/* Code changes ends here - CT_DIAG - 01 */
67
69{
70 CS_CLIENTMSG *msg;
71 struct cs_diag_msg *next;
72};
73
75{
76 CS_INT date_convert_fmt;
77 CS_INT cs_errhandletype;
78 CS_INT cs_diag_msglimit;
79
80 /* added for storing the maximum messages limit CT_DIAG */
81 /* code changes starts here - CT_DIAG - 02 */
82
83 CS_INT cs_diag_msglimit_client;
84 CS_INT cs_diag_msglimit_server;
85 CS_INT cs_diag_msglimit_total;
86 struct cs_diag_msg_client *clientstore;
87 struct cs_diag_msg_svr *svrstore;
88
89 /* code changes ends here - CT_DIAG - 02 */
90
91 struct cs_diag_msg *msgstore;
92 CS_CSLIBMSG_FUNC _cslibmsg_cb;
93 CS_CLIENTMSG_FUNC _clientmsg_cb;
94 CS_SERVERMSG_FUNC _servermsg_cb;
95 /* code changes start here - CS_CONFIG - 01*/
96 void *userdata;
97 int userdata_len;
98 /* code changes end here - CS_CONFIG - 01*/
99 TDSCONTEXT *tds_ctx;
100 CS_CONFIG config;
103};
104
105/*
106 * internal typedefs
107 */
108typedef struct _ct_colinfo
109{
110 TDS_SMALLINT *indicator;
111}
112CT_COLINFO;
113
114typedef struct _cs_dynamic CS_DYNAMIC;
115
117{
118 CS_CONTEXT *ctx;
119 TDSLOGIN *tds_login;
120 TDSSOCKET *tds_socket;
121 CS_CLIENTMSG_FUNC _clientmsg_cb;
122 CS_SERVERMSG_FUNC _servermsg_cb;
123 void *userdata;
124 int userdata_len;
125 CS_LOCALE *locale;
126 CS_COMMAND *cmds;
127 CS_DYNAMIC *dynlist;
128 char *server_addr;
129};
130
131/*
132 * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
133 * places, too.
134 */
135
136typedef struct _cs_param
137{
138 struct _cs_param *next;
139 char *name;
140 int status;
141 int datatype;
142 CS_INT maxlen;
143 CS_INT scale;
144 CS_INT precision;
145 CS_INT *datalen;
146 CS_SMALLINT *ind;
147 CS_BYTE *value;
148 int param_by_value;
149 CS_INT datalen_value;
150 CS_SMALLINT indicator_value;
151} CS_PARAM;
152
153/*
154 * Code added for RPC functionality - SUHA
155 * RPC Code changes starts here
156 */
157
158typedef CS_PARAM CSREMOTE_PROC_PARAM;
159
160typedef struct _csremote_proc
161{
162 char *name;
163 CS_SMALLINT options;
164 CSREMOTE_PROC_PARAM *param_list;
165} CSREMOTE_PROC;
166
167/*
168 * Structure CS_COMMAND changed for RPC functionality -SUHA
169 * Added CSREMOTE_PROC *rpc to CS_COMMAND structure
170 */
171
172typedef CS_PARAM CS_DYNAMIC_PARAM;
173
175{
176 struct _cs_dynamic *next;
177 char *id;
178 char *stmt;
179 CS_DYNAMIC_PARAM *param_list;
180 TDSDYNAMIC *tdsdyn;
181};
182
183/* specific FreeTDS commands */
184#define CS_DYNAMIC_CMD 160
185#define CS_CUR_CMD 161
186
187/* values for cs_command.results_state */
188
189#define _CS_RES_NONE -1
190#define _CS_RES_INIT 0
191#define _CS_RES_RESULTSET_EMPTY 1
192#define _CS_RES_RESULTSET_ROWS 2
193#define _CS_RES_STATUS 3
194#define _CS_RES_CMD_DONE 4
195#define _CS_RES_CMD_SUCCEED 5
196#define _CS_RES_END_RESULTS 6
197#define _CS_RES_DESCRIBE_RESULT 7
198
199/* values for cs_command.command_state */
200
201#define _CS_COMMAND_IDLE 0
202#define _CS_COMMAND_BUILDING 1
203#define _CS_COMMAND_READY 2
204#define _CS_COMMAND_SENT 3
205
206/* values for cs_command.cancel_state */
207#define _CS_CANCEL_NOCANCEL 0
208#define _CS_CANCEL_PENDING 1
209
211{
212 struct _cs_command *next;
213 CS_INT command_state;
214 CS_INT results_state;
215 CS_INT cancel_state;
216 CS_INT cursor_state;
217 CS_CONNECTION *con;
218 CS_INT command_type;
219 CS_CHAR *query;
220 short dynamic_cmd;
221 CS_DYNAMIC *dyn;
222 int row_prefetched;
223 int curr_result_type;
224 int bind_count;
225 int get_data_item;
226 int get_data_bytes_returned;
227 CS_IODESC *iodesc;
228 CS_INT send_data_started;
229 CSREMOTE_PROC *rpc;
230 CS_PARAM *input_params;
231 CS_INT client_cursor_id;
232 TDSCURSOR *cursor;
233 void *userdata;
234 int userdata_len;
235};
236
238{
239 TDSBCPINFO bcpinfo;
240};
241
242
243#define _CS_ERRHAND_INLINE 1
244#define _CS_ERRHAND_CB 2
245
247{
248 char *language;
249 char *charset;
250 char *time;
251 char *collate;
252};
253
254/* internal defines for cursor processing */
255
256#define _CS_CURS_TYPE_UNACTIONED 0
257#define _CS_CURS_TYPE_REQUESTED 1
258#define _CS_CURS_TYPE_SENT 2
259
260/*
261 * internal prototypes
262 */
263TDSRET _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
264int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
265TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype);
266int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset);
267int _ct_get_client_type(const TDSCOLUMN *col, bool describe);
268void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number,
269 const char *fmt, ...);
270CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type);
271void _cs_locale_free(CS_LOCALE *locale);
272CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig);
273int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig);
274
275int _cs_convert_not_client(CS_CONTEXT *ctx, const TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src);
276
277#ifdef __cplusplus
278#if 0
279{
280#endif
281}
282#endif
283
284#include <freetds/popvis.h>
285
286#endif
Main include file for libtds.
struct tds_result_info TDSRESULTINFO
Hold information for any results.
struct tds_dynamic TDSDYNAMIC
Holds information for a dynamic (also called prepared) query.
struct tds_cursor TDSCURSOR
Holds informations about a cursor.
Definition ctlib.h:45
Definition ctlib.h:55
Definition ctlib.h:61
Definition ctlib.h:69
Definition ctlib.h:75
int login_timeout
not used unless positive
Definition ctlib.h:101
int query_timeout
not used unless positive
Definition ctlib.h:102
Definition ctlib.h:109
Definition ctlib.h:117
Definition ctlib.h:137
Definition ctlib.h:161
Definition ctlib.h:175
Definition ctlib.h:211
Definition ctlib.h:238
Definition ctlib.h:247