1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _ctlib_h_
#define _ctlib_h_
/*
* Internal (not part of the exposed API) prototypes and such.
*/
#if defined(__GNUC__) && __GNUC__ >= 4
#pragma GCC visibility push(hidden)
#endif
#ifdef __cplusplus
extern "C"
{
#if 0
}
#endif
#endif
static const char rcsid_ctlib_h[] = "$Id: ctlib.h,v 1.25 2007/06/25 09:48:20 freddy77 Exp $";
static const void *const no_unused_ctlib_h_warn[] = { rcsid_ctlib_h, no_unused_ctlib_h_warn };
#include <tds.h>
/*
* internal types
*/
struct _cs_config
{
short cs_expose_formats;
};
/* Code changed for error handling */
/* Code changes starts here - CT_DIAG - 01 */
/* This structure is used in CT_DIAG */
struct cs_diag_msg_client
{
CS_CLIENTMSG *clientmsg;
struct cs_diag_msg_client *next;
};
struct cs_diag_msg_svr
{
CS_SERVERMSG *servermsg;
struct cs_diag_msg_svr *next;
};
/* Code changes ends here - CT_DIAG - 01 */
struct cs_diag_msg
{
CS_CLIENTMSG *msg;
struct cs_diag_msg *next;
};
struct _cs_context
{
CS_INT date_convert_fmt;
CS_INT cs_errhandletype;
CS_INT cs_diag_msglimit;
/* added for storing the maximum messages limit CT_DIAG */
/* code changes starts here - CT_DIAG - 02 */
CS_INT cs_diag_msglimit_client;
CS_INT cs_diag_msglimit_server;
CS_INT cs_diag_msglimit_total;
struct cs_diag_msg_client *clientstore;
struct cs_diag_msg_svr *svrstore;
/* code changes ends here - CT_DIAG - 02 */
struct cs_diag_msg *msgstore;
CS_CSLIBMSG_FUNC _cslibmsg_cb;
CS_CLIENTMSG_FUNC _clientmsg_cb;
CS_SERVERMSG_FUNC _servermsg_cb;
/* code changes start here - CS_CONFIG - 01*/
void *userdata;
int userdata_len;
/* code changes end here - CS_CONFIG - 01*/
TDSCONTEXT *tds_ctx;
CS_CONFIG config;
};
/*
* internal typedefs
*/
typedef struct _ct_colinfo
{
TDS_SMALLINT *indicator;
}
CT_COLINFO;
typedef struct _cs_command_list CS_COMMAND_LIST;
typedef struct _cs_dynamic CS_DYNAMIC_LIST;
typedef struct _cs_dynamic CS_DYNAMIC;
struct _cs_connection
{
CS_CONTEXT *ctx;
TDSLOGIN *tds_login;
TDSSOCKET *tds_socket;
CS_CLIENTMSG_FUNC _clientmsg_cb;
CS_SERVERMSG_FUNC _servermsg_cb;
void *userdata;
int userdata_len;
CS_LOCALE *locale;
CS_COMMAND_LIST *cmds;
CS_DYNAMIC_LIST *dynlist;
};
/*
* Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
* places, too.
*/
typedef struct _cs_param
{
struct _cs_param *next;
char *name;
int status;
int type;
CS_INT maxlen;
CS_INT scale;
CS_INT precision;
CS_INT *datalen;
CS_SMALLINT *ind;
CS_BYTE *value;
int param_by_value;
CS_INT datalen_value;
CS_SMALLINT indicator_value;
} CS_PARAM;
/*
* Code added for RPC functionality - SUHA
* RPC Code changes starts here
*/
typedef CS_PARAM CSREMOTE_PROC_PARAM;
typedef struct _csremote_proc
{
char *name;
CS_SMALLINT options;
CSREMOTE_PROC_PARAM *param_list;
} CSREMOTE_PROC;
/*
* Structure CS_COMMAND changed for RPC functionality -SUHA
* Added CSREMOTE_PROC *rpc to CS_COMMAND structure
*/
typedef CS_PARAM CS_DYNAMIC_PARAM;
struct _cs_dynamic
{
char *id;
char *stmt;
CS_DYNAMIC_PARAM *param_list;
struct _cs_dynamic *next;
};
/* specific FreeTDS commands */
#define CS_DYNAMIC_CMD 160
#define CS_CUR_CMD 161
/* values for cs_command.results_state */
#define _CS_RES_NONE -1
#define _CS_RES_INIT 0
#define _CS_RES_RESULTSET_EMPTY 1
#define _CS_RES_RESULTSET_ROWS 2
#define _CS_RES_STATUS 3
#define _CS_RES_CMD_DONE 4
#define _CS_RES_CMD_SUCCEED 5
#define _CS_RES_END_RESULTS 6
#define _CS_RES_DESCRIBE_RESULT 7
/* values for cs_command.command_state */
#define _CS_COMMAND_IDLE 0
#define _CS_COMMAND_BUILDING 1
#define _CS_COMMAND_READY 2
#define _CS_COMMAND_SENT 3
/* values for cs_command.cancel_state */
#define _CS_CANCEL_NOCANCEL 0
#define _CS_CANCEL_PENDING 1
struct _cs_command
{
CS_INT command_state;
CS_INT results_state;
CS_INT cancel_state;
CS_INT cursor_state;
CS_CONNECTION *con;
CS_INT command_type;
CS_CHAR *query;
short dynamic_cmd;
CS_DYNAMIC *dyn;
int row_prefetched;
int curr_result_type;
int bind_count;
int get_data_item;
int get_data_bytes_returned;
CS_IODESC *iodesc;
CS_INT send_data_started;
CSREMOTE_PROC *rpc;
CS_PARAM *input_params;
CS_INT client_cursor_id;
TDSCURSOR *cursor;
void *userdata;
int userdata_len;
};
struct _cs_command_list
{
struct _cs_command *cmd;
struct _cs_command_list *next;
};
struct _cs_blkdesc
{
CS_CONNECTION *con;
CS_CHAR *tablename;
CS_CHAR *insert_stmt;
CS_INT direction;
CS_INT identity_insert_on;
CS_INT bind_count;
CS_INT xfer_init;
CS_INT var_cols;
TDSRESULTINFO *bindinfo;
};
#define _CS_ERRHAND_INLINE 1
#define _CS_ERRHAND_CB 2
struct _cs_locale
{
char *language;
char *charset;
char *time;
char *collate;
};
/* internal defines for cursor processing */
#define _CS_CURS_TYPE_UNACTIONED 0
#define _CS_CURS_TYPE_REQUESTED 1
#define _CS_CURS_TYPE_SENT 2
/*
* internal prototypes
*/
int _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
int _ct_get_server_type(int datatype);
int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset);
int _ct_get_client_type(int datatype, int usertype, int size);
void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number,
const char *fmt, ...);
CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type);
void _cs_locale_free(CS_LOCALE *locale);
CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig);
int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig);
#ifdef __cplusplus
#if 0
{
#endif
}
#endif
#if defined(__GNUC__) && __GNUC__ >= 4
#pragma GCC visibility pop
#endif
#endif
|