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