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