FreeTDS API

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/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
34 extern "C"
35 {
36 #if 0
37 }
38 #endif
39 #endif
40
41 /*
42 * internal types
43 */
44 struct _cs_config
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
54 struct cs_diag_msg_client
55 {
56 CS_CLIENTMSG *clientmsg;
57 struct cs_diag_msg_client *next;
58 };
59
60 struct cs_diag_msg_svr
61 {
62 CS_SERVERMSG *servermsg;
63 struct cs_diag_msg_svr *next;
64 };
65
66 /* Code changes ends here - CT_DIAG - 01 */
67
68 struct cs_diag_msg
69 {
70 CS_CLIENTMSG *msg;
71 struct cs_diag_msg *next;
72 };
73
74 struct _cs_context
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;
101 };
102
103 /*
104 * internal typedefs
105 */
106 typedef struct _ct_colinfo
107 {
108 TDS_SMALLINT *indicator;
109 }
110 CT_COLINFO;
111
112 typedef struct _cs_dynamic CS_DYNAMIC;
113
114 struct _cs_connection
115 {
116 CS_CONTEXT *ctx;
117 TDSLOGIN *tds_login;
118 TDSSOCKET *tds_socket;
119 CS_CLIENTMSG_FUNC _clientmsg_cb;
120 CS_SERVERMSG_FUNC _servermsg_cb;
121 void *userdata;
122 int userdata_len;
123 CS_LOCALE *locale;
124 CS_COMMAND *cmds;
125 CS_DYNAMIC *dynlist;
126 char *server_addr;
127 };
128
129 /*
130 * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
131 * places, too.
132 */
133
134 typedef struct _cs_param
135 {
136 struct _cs_param *next;
137 char *name;
138 int status;
139 int datatype;
140 CS_INT maxlen;
141 CS_INT scale;
142 CS_INT precision;
143 CS_INT *datalen;
144 CS_SMALLINT *ind;
145 CS_BYTE *value;
146 int param_by_value;
147 CS_INT datalen_value;
148 CS_SMALLINT indicator_value;
149 } CS_PARAM;
150
151 /*
152 * Code added for RPC functionality - SUHA
153 * RPC Code changes starts here
154 */
155
156 typedef CS_PARAM CSREMOTE_PROC_PARAM;
157
158 typedef struct _csremote_proc
159 {
160 char *name;
161 CS_SMALLINT options;
162 CSREMOTE_PROC_PARAM *param_list;
163 } CSREMOTE_PROC;
164
165 /*
166 * Structure CS_COMMAND changed for RPC functionality -SUHA
167 * Added CSREMOTE_PROC *rpc to CS_COMMAND structure
168 */
169
170 typedef CS_PARAM CS_DYNAMIC_PARAM;
171
172 struct _cs_dynamic
173 {
174 struct _cs_dynamic *next;
175 char *id;
176 char *stmt;
177 CS_DYNAMIC_PARAM *param_list;
178 TDSDYNAMIC *tdsdyn;
179 };
180
181 /* specific FreeTDS commands */
182 #define CS_DYNAMIC_CMD 160
183 #define CS_CUR_CMD 161
184
185 /* values for cs_command.results_state */
186
187 #define _CS_RES_NONE -1
188 #define _CS_RES_INIT 0
189 #define _CS_RES_RESULTSET_EMPTY 1
190 #define _CS_RES_RESULTSET_ROWS 2
191 #define _CS_RES_STATUS 3
192 #define _CS_RES_CMD_DONE 4
193 #define _CS_RES_CMD_SUCCEED 5
194 #define _CS_RES_END_RESULTS 6
195 #define _CS_RES_DESCRIBE_RESULT 7
196
197 /* values for cs_command.command_state */
198
199 #define _CS_COMMAND_IDLE 0
200 #define _CS_COMMAND_BUILDING 1
201 #define _CS_COMMAND_READY 2
202 #define _CS_COMMAND_SENT 3
203
204 /* values for cs_command.cancel_state */
205 #define _CS_CANCEL_NOCANCEL 0
206 #define _CS_CANCEL_PENDING 1
207
208 struct _cs_command
209 {
210 struct _cs_command *next;
211 CS_INT command_state;
212 CS_INT results_state;
213 CS_INT cancel_state;
214 CS_INT cursor_state;
215 CS_CONNECTION *con;
216 CS_INT command_type;
217 CS_CHAR *query;
218 short dynamic_cmd;
219 CS_DYNAMIC *dyn;
220 int row_prefetched;
221 int curr_result_type;
222 int bind_count;
223 int get_data_item;
224 int get_data_bytes_returned;
225 CS_IODESC *iodesc;
226 CS_INT send_data_started;
227 CSREMOTE_PROC *rpc;
228 CS_PARAM *input_params;
229 CS_INT client_cursor_id;
230 TDSCURSOR *cursor;
231 void *userdata;
232 int userdata_len;
233 };
234
235 struct _cs_blkdesc
236 {
237 TDSBCPINFO bcpinfo;
238 };
239
240
241 #define _CS_ERRHAND_INLINE 1
242 #define _CS_ERRHAND_CB 2
243
244 struct _cs_locale
245 {
246 char *language;
247 char *charset;
248 char *time;
249 char *collate;
250 };
251
252 /* internal defines for cursor processing */
253
254 #define _CS_CURS_TYPE_UNACTIONED 0
255 #define _CS_CURS_TYPE_REQUESTED 1
256 #define _CS_CURS_TYPE_SENT 2
257
258 /*
259 * internal prototypes
260 */
261 TDSRET _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
262 int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
263 TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype);
264 int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset);
265 int _ct_get_client_type(TDSCOLUMN *col);
266 void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number,
267 const char *fmt, ...);
268 CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type);
269 void _cs_locale_free(CS_LOCALE *locale);
270 CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig);
271 int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig);
272
273 int _cs_convert_not_client(CS_CONTEXT *ctx, TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src);
274
275 #ifdef __cplusplus
276 #if 0
277 {
278 #endif
279 }
280 #endif
281
282 #include <freetds/popvis.h>
283
284 #endif
tds_bcpinfo
Definition: tds.h:1606
tds_context
Definition: tds.h:1063
tds_socket
Information for a server connection.
Definition: tds.h:1175
cs_diag_msg_client
Definition: ctlib.h:54
tds_login
Definition: tds.h:549
_cs_connection
Definition: ctlib.h:114
_cs_clientmsg
Definition: cstypes.h:179
_cs_blkdesc
Definition: ctlib.h:235
tds_result_info
Hold information for any results.
Definition: tds.h:803
cs_diag_msg
Definition: ctlib.h:68
_cs_iodesc
Definition: cstypes.h:99
_cs_config
Definition: ctlib.h:44
tds.h
Main include file for libtds.
_csremote_proc
Definition: ctlib.h:158
_ct_colinfo
Definition: ctlib.h:106
cs_diag_msg_svr
Definition: ctlib.h:60
_cs_servermsg
Definition: cstypes.h:193
conv_result
Definition: convert.h:33
_cs_command
Definition: ctlib.h:208
_cs_param
Definition: ctlib.h:134
_cs_context
Definition: ctlib.h:74
_cs_locale
Definition: ctlib.h:244
tds_cursor
Holds informations about a cursor.
Definition: tds.h:971
_cs_dynamic
Definition: ctlib.h:172
tds_message
Definition: tds.h:910
tds_column
Metadata about columns in regular and compute rows.
Definition: tds.h:726
tds_dynamic
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1011