FreeTDS API

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 /*
24 * Internal (not part of the exposed API) prototypes and such.
25 */
26
27 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
28 #pragma GCC visibility push(hidden)
29 #endif
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #if 0
35 }
36 #endif
37 #endif
38
39 static const char rcsid_ctlib_h[] = "$Id: ctlib.h,v 1.30 2010-10-05 08:36:36 freddy77 Exp $";
40 static const void *const no_unused_ctlib_h_warn[] = { rcsid_ctlib_h, no_unused_ctlib_h_warn };
41
42 #include <tds.h>
43 /*
44 * internal types
45 */
46 struct _cs_config
47 {
48 short cs_expose_formats;
49 };
50
51 /* Code changed for error handling */
52 /* Code changes starts here - CT_DIAG - 01 */
53
54 /* This structure is used in CT_DIAG */
55
56 struct cs_diag_msg_client
57 {
58 CS_CLIENTMSG *clientmsg;
59 struct cs_diag_msg_client *next;
60 };
61
62 struct cs_diag_msg_svr
63 {
64 CS_SERVERMSG *servermsg;
65 struct cs_diag_msg_svr *next;
66 };
67
68 /* Code changes ends here - CT_DIAG - 01 */
69
70 struct cs_diag_msg
71 {
72 CS_CLIENTMSG *msg;
73 struct cs_diag_msg *next;
74 };
75
76 struct _cs_context
77 {
78 CS_INT date_convert_fmt;
79 CS_INT cs_errhandletype;
80 CS_INT cs_diag_msglimit;
81
82 /* added for storing the maximum messages limit CT_DIAG */
83 /* code changes starts here - CT_DIAG - 02 */
84
85 CS_INT cs_diag_msglimit_client;
86 CS_INT cs_diag_msglimit_server;
87 CS_INT cs_diag_msglimit_total;
88 struct cs_diag_msg_client *clientstore;
89 struct cs_diag_msg_svr *svrstore;
90
91 /* code changes ends here - CT_DIAG - 02 */
92
93 struct cs_diag_msg *msgstore;
94 CS_CSLIBMSG_FUNC _cslibmsg_cb;
95 CS_CLIENTMSG_FUNC _clientmsg_cb;
96 CS_SERVERMSG_FUNC _servermsg_cb;
97 /* code changes start here - CS_CONFIG - 01*/
98 void *userdata;
99 int userdata_len;
100 /* code changes end here - CS_CONFIG - 01*/
101 TDSCONTEXT *tds_ctx;
102 CS_CONFIG config;
103 };
104
105 /*
106 * internal typedefs
107 */
108 typedef struct _ct_colinfo
109 {
110 TDS_SMALLINT *indicator;
111 }
112 CT_COLINFO;
113
114 typedef struct _cs_command_list CS_COMMAND_LIST;
115 typedef struct _cs_dynamic CS_DYNAMIC_LIST;
116 typedef struct _cs_dynamic CS_DYNAMIC;
117
118 struct _cs_connection
119 {
120 CS_CONTEXT *ctx;
121 TDSLOGIN *tds_login;
122 TDSSOCKET *tds_socket;
123 CS_CLIENTMSG_FUNC _clientmsg_cb;
124 CS_SERVERMSG_FUNC _servermsg_cb;
125 void *userdata;
126 int userdata_len;
127 CS_LOCALE *locale;
128 CS_COMMAND_LIST *cmds;
129 CS_DYNAMIC_LIST *dynlist;
130 char *server_addr;
131 };
132
133 /*
134 * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
135 * places, too.
136 */
137
138 typedef struct _cs_param
139 {
140 struct _cs_param *next;
141 char *name;
142 int status;
143 int datatype;
144 CS_INT maxlen;
145 CS_INT scale;
146 CS_INT precision;
147 CS_INT *datalen;
148 CS_SMALLINT *ind;
149 CS_BYTE *value;
150 int param_by_value;
151 CS_INT datalen_value;
152 CS_SMALLINT indicator_value;
153 } CS_PARAM;
154
155 /*
156 * Code added for RPC functionality - SUHA
157 * RPC Code changes starts here
158 */
159
160 typedef CS_PARAM CSREMOTE_PROC_PARAM;
161
162 typedef struct _csremote_proc
163 {
164 char *name;
165 CS_SMALLINT options;
166 CSREMOTE_PROC_PARAM *param_list;
167 } CSREMOTE_PROC;
168
169 /*
170 * Structure CS_COMMAND changed for RPC functionality -SUHA
171 * Added CSREMOTE_PROC *rpc to CS_COMMAND structure
172 */
173
174 typedef CS_PARAM CS_DYNAMIC_PARAM;
175
176 struct _cs_dynamic
177 {
178 char *id;
179 char *stmt;
180 CS_DYNAMIC_PARAM *param_list;
181 struct _cs_dynamic *next;
182 };
183
184 /* specific FreeTDS commands */
185 #define CS_DYNAMIC_CMD 160
186 #define CS_CUR_CMD 161
187
188 /* values for cs_command.results_state */
189
190 #define _CS_RES_NONE -1
191 #define _CS_RES_INIT 0
192 #define _CS_RES_RESULTSET_EMPTY 1
193 #define _CS_RES_RESULTSET_ROWS 2
194 #define _CS_RES_STATUS 3
195 #define _CS_RES_CMD_DONE 4
196 #define _CS_RES_CMD_SUCCEED 5
197 #define _CS_RES_END_RESULTS 6
198 #define _CS_RES_DESCRIBE_RESULT 7
199
200 /* values for cs_command.command_state */
201
202 #define _CS_COMMAND_IDLE 0
203 #define _CS_COMMAND_BUILDING 1
204 #define _CS_COMMAND_READY 2
205 #define _CS_COMMAND_SENT 3
206
207 /* values for cs_command.cancel_state */
208 #define _CS_CANCEL_NOCANCEL 0
209 #define _CS_CANCEL_PENDING 1
210
211 struct _cs_command
212 {
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
237 struct _cs_command_list
238 {
239 struct _cs_command *cmd;
240 struct _cs_command_list *next;
241 };
242
243 struct _cs_blkdesc
244 {
245 CS_CONNECTION *con;
246 TDSBCPINFO bcpinfo;
247 };
248
249
250 #define _CS_ERRHAND_INLINE 1
251 #define _CS_ERRHAND_CB 2
252
253 struct _cs_locale
254 {
255 char *language;
256 char *charset;
257 char *time;
258 char *collate;
259 };
260
261 /* internal defines for cursor processing */
262
263 #define _CS_CURS_TYPE_UNACTIONED 0
264 #define _CS_CURS_TYPE_REQUESTED 1
265 #define _CS_CURS_TYPE_SENT 2
266
267 /*
268 * internal prototypes
269 */
270 int _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
271 int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
272 int _ct_get_server_type(int datatype);
273 int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset);
274 int _ct_get_client_type(TDSCOLUMN *col);
275 void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number,
276 const char *fmt, ...);
277 CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type);
278 void _cs_locale_free(CS_LOCALE *locale);
279 CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig);
280 int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig);
281
282 #ifdef __cplusplus
283 #if 0
284 {
285 #endif
286 }
287 #endif
288
289 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
290 #pragma GCC visibility pop
291 #endif
292
293 #endif