FreeTDS API

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

- File List
- File Members

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