FreeTDS API

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

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tdsodbc.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3 * Copyright (C) 2004-2010 Frediano Ziglio
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21 #ifndef _sql_h_
22 #define _sql_h_
23
24 #include "tds.h"
25
26 #if defined(UNIXODBC) || defined(TDS_NO_DM)
27 #include <sql.h>
28 #include <sqlext.h>
29 #ifdef UNIXODBC
30 #include <odbcinst.h>
31 #endif
32 #else /* IODBC */
33 #include <isql.h>
34 #include <isqlext.h>
35 #ifdef HAVE_IODBCINST_H
36 #include <iodbcinst.h>
37 #endif /* HAVE_IODBCINST_H */
38 #endif
39
40 #ifndef HAVE_SQLLEN
41 #ifndef SQLULEN
42 #define SQLULEN SQLUINTEGER
43 #endif
44 #ifndef SQLLEN
45 #define SQLLEN SQLINTEGER
46 #endif
47 #endif
48
49 #ifndef HAVE_SQLSETPOSIROW
50 #define SQLSETPOSIROW SQLUSMALLINT
51 #endif
52
53 #ifndef HAVE_SQLROWOFFSET
54 #define SQLROWOFFSET SQLLEN
55 #endif
56
57 #ifndef HAVE_SQLROWSETSIZE
58 #define SQLROWSETSIZE SQLULEN
59 #endif
60
61 #ifdef __cplusplus
62 extern "C"
63 {
64 #if 0
65 }
66 #endif
67 #endif
68
69 /* $Id: tdsodbc.h,v 1.127 2010-11-09 15:46:42 freddy77 Exp $ */
70
71 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
72 #pragma GCC visibility push(hidden)
73 #define ODBC_API SQL_API __attribute__((externally_visible))
74 #else
75 #define ODBC_API SQL_API
76 #endif
77
78 #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(__GNUC__)
79 # define ODBC_PUBLIC __attribute__((dllexport))
80 #else
81 # define ODBC_PUBLIC
82 #endif
83
84 #define ODBC_MAX(a,b) ( (a) > (b) ? (a) : (b) )
85 #define ODBC_MIN(a,b) ( (a) < (b) ? (a) : (b) )
86
87 struct _sql_error
88 {
89 const char *msg;
90 char state2[6];
91 char state3[6];
92 TDS_UINT native;
93 char *server;
94 int linenum;
95 int msgstate;
96 int row;
97 };
98
99 struct _sql_errors
100 {
101 struct _sql_error *errs;
102 int num_errors;
103 SQLRETURN lastrc;
104 char ranked;
105 };
106
107 typedef struct _sql_errors TDS_ERRS;
108
109 #if ENABLE_EXTRA_CHECKS
110 void odbc_check_struct_extra(void *p);
111
112 #define ODBC_RETURN(handle, rc) \
113 do { odbc_check_struct_extra(handle); return (handle->errs.lastrc = (rc)); } while(0)
114 #define ODBC_RETURN_(handle) \
115 do { odbc_check_struct_extra(handle); return handle->errs.lastrc; } while(0)
116 #else
117 #define ODBC_RETURN(handle, rc) \
118 do { return (handle->errs.lastrc = (rc)); } while(0)
119 #define ODBC_RETURN_(handle) \
120 do { return handle->errs.lastrc; } while(0)
121 #endif
122
124 void odbc_errs_reset(struct _sql_errors *errs);
125
127 void odbc_errs_add(struct _sql_errors *errs, const char *sqlstate, const char *msg);
128
130 void odbc_errs_add_rdbms(struct _sql_errors *errs, TDS_UINT native, const char *sqlstate, const char *msg, int linenum,
131 int msgstate, const char *server, int row);
132
133 struct _dheader
134 {
135 SQLSMALLINT sql_desc_alloc_type;
136 SQLINTEGER sql_desc_bind_type;
137 SQLULEN sql_desc_array_size;
138 /* TODO SQLLEN ?? see http://support.microsoft.com/default.aspx?scid=kb;en-us;298678 */
139 SQLSMALLINT sql_desc_count;
140 SQLUSMALLINT *sql_desc_array_status_ptr;
141 SQLULEN *sql_desc_rows_processed_ptr;
142 SQLLEN *sql_desc_bind_offset_ptr;
143 };
144
145 struct _drecord
146 {
147 SQLUINTEGER sql_desc_auto_unique_value;
148 DSTR sql_desc_base_column_name;
149 DSTR sql_desc_base_table_name;
150 SQLINTEGER sql_desc_case_sensitive;
151 DSTR sql_desc_catalog_name;
152 SQLSMALLINT sql_desc_concise_type;
153 SQLPOINTER sql_desc_data_ptr;
154 SQLSMALLINT sql_desc_datetime_interval_code;
155 SQLINTEGER sql_desc_datetime_interval_precision;
156 SQLLEN sql_desc_display_size;
157 SQLSMALLINT sql_desc_fixed_prec_scale;
158 SQLLEN *sql_desc_indicator_ptr;
159 DSTR sql_desc_label;
160 SQLULEN sql_desc_length;
161 /* this point to a constant buffer, do not free or modify */
162 const char *sql_desc_literal_prefix;
163 /* this point to a constant buffer, do not free or modify */
164 const char *sql_desc_literal_suffix;
165 DSTR sql_desc_local_type_name;
166 DSTR sql_desc_name;
167 SQLSMALLINT sql_desc_nullable;
168 SQLINTEGER sql_desc_num_prec_radix;
169 SQLLEN sql_desc_octet_length;
170 SQLLEN *sql_desc_octet_length_ptr;
171 SQLSMALLINT sql_desc_parameter_type;
172 SQLSMALLINT sql_desc_precision;
173 SQLSMALLINT sql_desc_rowver;
174 SQLSMALLINT sql_desc_scale;
175 DSTR sql_desc_schema_name;
176 SQLSMALLINT sql_desc_searchable;
177 DSTR sql_desc_table_name;
178 SQLSMALLINT sql_desc_type;
179 /* this point to a constant buffer, do not free or modify */
180 const char *sql_desc_type_name;
181 SQLSMALLINT sql_desc_unnamed;
182 SQLSMALLINT sql_desc_unsigned;
183 SQLSMALLINT sql_desc_updatable;
184 };
185
186 struct _hdesc
187 {
188 SQLSMALLINT htype; /* do not reorder this field */
189 struct _sql_errors errs; /* do not reorder this field */
190 int type;
191 SQLHANDLE parent;
192 struct _dheader header;
193 struct _drecord *records;
194 };
195
196 typedef struct _hdesc TDS_DESC;
197
198 #define DESC_IRD 1
199 #define DESC_IPD 2
200 #define DESC_ARD 3
201 #define DESC_APD 4
202
203 struct _heattr
204 {
205 SQLUINTEGER connection_pooling;
206 SQLUINTEGER cp_match;
207 SQLINTEGER odbc_version;
208 SQLINTEGER output_nts;
209 };
210
211 struct _hchk
212 {
213 SQLSMALLINT htype; /* do not reorder this field */
214 struct _sql_errors errs; /* do not reorder this field */
215 };
216
217 struct _henv
218 {
219 SQLSMALLINT htype; /* do not reorder this field */
220 struct _sql_errors errs; /* do not reorder this field */
221 TDSCONTEXT *tds_ctx;
222 struct _heattr attr;
223 };
224
225 struct _hcattr
226 {
227 SQLUINTEGER access_mode;
228 SQLUINTEGER async_enable;
229 SQLUINTEGER auto_ipd;
230 SQLUINTEGER autocommit;
231 SQLUINTEGER connection_dead;
232 SQLUINTEGER connection_timeout;
233 DSTR current_catalog;
234 SQLUINTEGER login_timeout;
235 SQLUINTEGER metadata_id;
236 SQLUINTEGER odbc_cursors;
237 SQLUINTEGER packet_size;
238 SQLHWND quite_mode;
239 DSTR translate_lib;
240 SQLUINTEGER translate_option;
241 SQLUINTEGER txn_isolation;
242 SQLUINTEGER cursor_type;
243 #ifdef TDS_NO_DM
244 SQLUINTEGER trace;
245 DSTR tracefile;
246 #endif
247 };
248
249 #define TDS_MAX_APP_DESC 100
250
251 struct _hstmt;
252 struct _hdbc
253 {
254 SQLSMALLINT htype; /* do not reorder this field */
255 struct _sql_errors errs; /* do not reorder this field */
256 struct _henv *env;
257 TDSSOCKET *tds_socket;
258 DSTR dsn;
259 DSTR server; /* aka Instance */
260 #ifdef ENABLE_ODBC_WIDE
261 DSTR original_charset;
262 TDSICONV *mb_conv;
263 #endif
264
270 struct _hstmt *current_statement;
272 struct _hstmt *stmt_list;
273 struct _hcattr attr;
275 TDS_DESC *uad[TDS_MAX_APP_DESC];
277 unsigned int cursor_support;
278 TDS_INT default_query_timeout;
279 };
280
281 struct _hsattr
282 {
283 /* TODO remove IRD, ARD, IPD, APD from statement, do not duplicate */
284 /* TDS_DESC *app_row_desc; */
285 /* TDS_DESC *app_param_desc; */
286 SQLUINTEGER async_enable;
287 SQLUINTEGER concurrency;
288 SQLUINTEGER cursor_scrollable;
289 SQLUINTEGER cursor_sensitivity;
290 SQLUINTEGER cursor_type;
291 SQLUINTEGER enable_auto_ipd;
292 SQLPOINTER fetch_bookmark_ptr;
293 SQLULEN keyset_size;
294 SQLULEN max_length;
295 SQLULEN max_rows;
296 SQLUINTEGER metadata_id;
297 SQLUINTEGER noscan;
298 /* apd->sql_desc_bind_offset_ptr */
299 /* SQLUINTEGER *param_bind_offset_ptr; */
300 /* apd->sql_desc_bind_type */
301 /* SQLUINTEGER param_bind_type; */
302 /* apd->sql_desc_array_status_ptr */
303 /* SQLUSMALLINT *param_operation_ptr; */
304 /* ipd->sql_desc_array_status_ptr */
305 /* SQLUSMALLINT *param_status_ptr; */
306 /* ipd->sql_desc_rows_processed_ptr */
307 /* SQLUSMALLINT *params_processed_ptr; */
308 /* apd->sql_desc_array_size */
309 /* SQLUINTEGER paramset_size; */
310 SQLUINTEGER query_timeout;
311 SQLUINTEGER retrieve_data;
312 /* ard->sql_desc_bind_offset_ptr */
313 /* SQLUINTEGER *row_bind_offset_ptr; */
314 /* ard->sql_desc_array_size */
315 /* SQLUINTEGER row_array_size; */
316 /* ard->sql_desc_bind_type */
317 /* SQLUINTEGER row_bind_type; */
318 SQLULEN row_number;
319 /* ard->sql_desc_array_status_ptr */
320 /* SQLUINTEGER *row_operation_ptr; */
321 /* ird->sql_desc_array_status_ptr */
322 /* SQLUINTEGER *row_status_ptr; */
323 /* ird->sql_desc_rows_processed_ptr */
324 /* SQLUINTEGER *rows_fetched_ptr; */
325 SQLUINTEGER simulate_cursor;
326 SQLUINTEGER use_bookmarks;
327 /* SQLGetStmtAttr only */
328 /* TDS_DESC *imp_row_desc; */
329 /* TDS_DESC *imp_param_desc; */
330 };
331
332 typedef enum
333 {
334 NOT_IN_ROW,
335 IN_NORMAL_ROW,
336 IN_COMPUTE_ROW,
337 AFTER_COMPUTE_ROW,
338 PRE_NORMAL_ROW
339 } TDS_ODBC_ROW_STATUS;
340
341 typedef enum
342 {
343 ODBC_SPECIAL_NONE = 0,
344 ODBC_SPECIAL_GETTYPEINFO = 1,
345 ODBC_SPECIAL_COLUMNS = 2,
346 ODBC_SPECIAL_PROCEDURECOLUMNS = 3,
347 ODBC_SPECIAL_SPECIALCOLUMNS = 4
348 } TDS_ODBC_SPECIAL_ROWS;
349
350 struct _hstmt
351 {
352 SQLSMALLINT htype; /* do not reorder this field */
353 struct _sql_errors errs; /* do not reorder this field */
354 struct _hdbc *dbc;
356 char *query;
357
359 struct _hstmt *next;
361 struct _hstmt *prev;
362
363 /* begin prepared query stuff */
364 char *prepared_query;
365 unsigned prepared_query_is_func:1;
366 unsigned prepared_query_is_rpc:1;
367 unsigned need_reprepare:1;
368 unsigned param_data_called:1;
369 /* end prepared query stuff */
370
372 TDSPARAMINFO *params;
374 int param_num;
376 char *prepared_pos;
377
378 unsigned int curr_param_row, num_param_rows;
379
381 unsigned int param_count;
382 int row;
384 TDS_INT8 row_count;
386 TDS_ODBC_ROW_STATUS row_status;
387 /* do NOT free dynamic, free from socket or attach to connection */
388 TDSDYNAMIC *dyn;
389 TDS_DESC *ard, *ird, *apd, *ipd;
390 TDS_DESC *orig_ard, *orig_apd;
391 SQLULEN sql_rowset_size;
392 struct _hsattr attr;
393 DSTR cursor_name; /* auto generated cursor name */
394 TDS_ODBC_SPECIAL_ROWS special_row;
395 /* do NOT free cursor, free from socket or attach to connection */
396 TDSCURSOR *cursor;
397 unsigned char cancel_sent;
398 };
399
400 typedef struct _henv TDS_ENV;
401 typedef struct _hdbc TDS_DBC;
402 typedef struct _hstmt TDS_STMT;
403 typedef struct _hchk TDS_CHK;
404
405 #define IS_HENV(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_ENV)
406 #define IS_HDBC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DBC)
407 #define IS_HSTMT(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_STMT)
408 #define IS_HDESC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DESC)
409
410 /* fix a bug in MingW headers */
411 #ifdef __MINGW32__
412 #if SQL_INTERVAL_YEAR == (100 + SQL_CODE_SECOND)
413
414 #undef SQL_INTERVAL_YEAR
415 #undef SQL_INTERVAL_MONTH
416 #undef SQL_INTERVAL_DAY
417 #undef SQL_INTERVAL_HOUR
418 #undef SQL_INTERVAL_MINUTE
419 #undef SQL_INTERVAL_SECOND
420 #undef SQL_INTERVAL_YEAR_TO_MONTH
421 #undef SQL_INTERVAL_DAY_TO_HOUR
422 #undef SQL_INTERVAL_DAY_TO_MINUTE
423 #undef SQL_INTERVAL_DAY_TO_SECOND
424 #undef SQL_INTERVAL_HOUR_TO_MINUTE
425 #undef SQL_INTERVAL_HOUR_TO_SECOND
426 #undef SQL_INTERVAL_MINUTE_TO_SECOND
427
428 #define SQL_INTERVAL_YEAR (100 + SQL_CODE_YEAR)
429 #define SQL_INTERVAL_MONTH (100 + SQL_CODE_MONTH)
430 #define SQL_INTERVAL_DAY (100 + SQL_CODE_DAY)
431 #define SQL_INTERVAL_HOUR (100 + SQL_CODE_HOUR)
432 #define SQL_INTERVAL_MINUTE (100 + SQL_CODE_MINUTE)
433 #define SQL_INTERVAL_SECOND (100 + SQL_CODE_SECOND)
434 #define SQL_INTERVAL_YEAR_TO_MONTH (100 + SQL_CODE_YEAR_TO_MONTH)
435 #define SQL_INTERVAL_DAY_TO_HOUR (100 + SQL_CODE_DAY_TO_HOUR)
436 #define SQL_INTERVAL_DAY_TO_MINUTE (100 + SQL_CODE_DAY_TO_MINUTE)
437 #define SQL_INTERVAL_DAY_TO_SECOND (100 + SQL_CODE_DAY_TO_SECOND)
438 #define SQL_INTERVAL_HOUR_TO_MINUTE (100 + SQL_CODE_HOUR_TO_MINUTE)
439 #define SQL_INTERVAL_HOUR_TO_SECOND (100 + SQL_CODE_HOUR_TO_SECOND)
440 #define SQL_INTERVAL_MINUTE_TO_SECOND (100 + SQL_CODE_MINUTE_TO_SECOND)
441
442 #endif
443 #endif
444
445 #ifdef _WIN32
446 BOOL get_login_info(HWND hwndParent, TDSCONNECTION * connection);
447 #endif
448
449 #define ODBC_PARAM_LIST \
450 ODBC_PARAM(Servername) \
451 ODBC_PARAM(Server) \
452 ODBC_PARAM(DSN) \
453 ODBC_PARAM(UID) \
454 ODBC_PARAM(PWD) \
455 ODBC_PARAM(Address) \
456 ODBC_PARAM(Port) \
457 ODBC_PARAM(TDS_Version) \
458 ODBC_PARAM(Language) \
459 ODBC_PARAM(Database) \
460 ODBC_PARAM(TextSize) \
461 ODBC_PARAM(PacketSize) \
462 ODBC_PARAM(ClientCharset) \
463 ODBC_PARAM(DumpFile) \
464 ODBC_PARAM(DumpFileAppend) \
465 ODBC_PARAM(DebugFlags) \
466 ODBC_PARAM(Encryption) \
467 ODBC_PARAM(Trusted_Connection) \
468 ODBC_PARAM(APP) \
469 ODBC_PARAM(WSID) \
470 ODBC_PARAM(UseNTLMv2)
471
472 #define ODBC_PARAM(p) ODBC_PARAM_##p,
473 enum {
474 ODBC_PARAM_LIST
475 ODBC_PARAM_SIZE
476 };
477 #undef ODBC_PARAM
478
479
480 /*
481 * connectparams.h
482 */
483
484 typedef struct {
485 const char *p;
486 size_t len;
487 } TDS_PARSED_PARAM;
488
496 int odbc_parse_connect_string(TDS_ERRS *errs, const char *connect_string, const char *connect_string_end, TDSCONNECTION * connection, TDS_PARSED_PARAM *parsed_params);
497 int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSCONNECTION * connection);
498 #ifdef _WIN32
499 int odbc_build_connect_string(TDS_ERRS *errs, TDS_PARSED_PARAM *params, char **out);
500 #endif
501
502 /*
503 * convert_tds2sql.c
504 */
505 SQLLEN odbc_tds2sql(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, const struct _drecord *drec_ixd);
506
507 /*
508 * descriptor.c
509 */
510 TDS_DESC *desc_alloc(SQLHANDLE parent, int desc_type, int alloc_type);
511 SQLRETURN desc_free(TDS_DESC * desc);
512 SQLRETURN desc_alloc_records(TDS_DESC * desc, unsigned count);
513 SQLRETURN desc_copy(TDS_DESC * dest, TDS_DESC * src);
514 SQLRETURN desc_free_records(TDS_DESC * desc);
515 TDS_DBC *desc_get_dbc(TDS_DESC *desc);
516
517 /*
518 * odbc.c
519 */
520 SQLRETURN _SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow);
521
522 /*
523 * odbc_checks.h
524 */
525 #if ENABLE_EXTRA_CHECKS
526 /* macro */
527 #define CHECK_ENV_EXTRA(env) odbc_check_env_extra(env)
528 #define CHECK_DBC_EXTRA(dbc) odbc_check_dbc_extra(dbc)
529 #define CHECK_STMT_EXTRA(stmt) odbc_check_stmt_extra(stmt)
530 #define CHECK_DESC_EXTRA(desc) odbc_check_desc_extra(desc)
531 /* declarations*/
532 void odbc_check_env_extra(TDS_ENV * env);
533 void odbc_check_dbc_extra(TDS_DBC * dbc);
534 void odbc_check_stmt_extra(TDS_STMT * stmt);
535 void odbc_check_desc_extra(TDS_DESC * desc);
536 #else
537 /* macro */
538 #define CHECK_ENV_EXTRA(env)
539 #define CHECK_DBC_EXTRA(dbc)
540 #define CHECK_STMT_EXTRA(stmt)
541 #define CHECK_DESC_EXTRA(desc)
542 #endif
543
544 /*
545 * odbc_util.h
546 */
547
548 /* helpers for ODBC wide string support */
549 #undef _wide
550 #undef _WIDE
551 #ifdef ENABLE_ODBC_WIDE
552 typedef union {
553 char mb[1];
554 SQLWCHAR wide[1];
555 } ODBC_CHAR;
556 # define _wide ,wide
557 # define _wide0 ,0
558 # define _WIDE ,int wide
559 #else
560 # define _wide
561 # define _wide0
562 # define _WIDE
563 # define ODBC_CHAR SQLCHAR
564 #endif
565 int odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
566 int odbc_set_stmt_prepared_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
567 void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row);
568 void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row);
569
570 SQLSMALLINT odbc_server_to_sql_type(int col_type, int col_size);
571 int odbc_sql_to_c_type_default(int sql_type);
572 int odbc_sql_to_server_type(TDSSOCKET * tds, int sql_type);
573 int odbc_c_to_server_type(int c_type);
574
575 void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver);
576 SQLINTEGER odbc_sql_to_displaysize(int sqltype, TDSCOLUMN *col);
577 int odbc_get_string_size(int size, ODBC_CHAR * str _WIDE);
578 void odbc_rdbms_version(TDSSOCKET * tds_socket, char *pversion_string);
579 SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC* axd, unsigned int n_row);
580
581 #ifdef ENABLE_ODBC_WIDE
582 DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, ODBC_CHAR * str, int flag);
583 #define odbc_dstr_copy(dbc, s, len, out) \
584 odbc_dstr_copy_flag(dbc, s, len, sizeof((out)->mb) ? (out) : (out), wide)
585 #define odbc_dstr_copy_oct(dbc, s, len, out) \
586 odbc_dstr_copy_flag(dbc, s, len, out, wide|0x20)
587 #else
588 DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, ODBC_CHAR * str);
589 #define odbc_dstr_copy_oct odbc_dstr_copy
590 #endif
591
592
593 SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer, const char *s, int len, int flag);
594 #ifdef ENABLE_ODBC_WIDE
595 #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
596 odbc_set_string_flag(dbc, sizeof((buf)->mb) ? (buf) : (buf), buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
597 #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \
598 odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30))
599 #else
600 #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
601 odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
602 #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \
603 odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30))
604 #endif
605
606 SQLSMALLINT odbc_get_concise_sql_type(SQLSMALLINT type, SQLSMALLINT interval);
607 SQLRETURN odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only);
608 SQLSMALLINT odbc_get_concise_c_type(SQLSMALLINT type, SQLSMALLINT interval);
609 SQLRETURN odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only);
610
611 SQLLEN odbc_get_octet_len(int c_type, const struct _drecord *drec);
612 void odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err);
613
614 /*
615 * prepare_query.c
616 */
617 SQLRETURN prepare_call(struct _hstmt *stmt);
618 SQLRETURN native_sql(struct _hdbc *dbc, char *s);
619 int parse_prepared_query(struct _hstmt *stmt, int compute_row);
620 int start_parse_prepared_query(struct _hstmt *stmt, int compute_row);
621 int continue_parse_prepared_query(struct _hstmt *stmt, SQLPOINTER DataPtr, SQLLEN StrLen_or_Ind);
622 const char *parse_const_param(const char * s, TDS_SERVER_TYPE *type);
623
624 /*
625 * sql2tds.c
626 */
627 SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd, const struct _drecord *drec_axd, TDSCOLUMN *curcol, int compute_row, const TDS_DESC* axd, unsigned int n_row);
628
629 /*
630 * sqlwchar.c
631 */
632 #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T
633 size_t sqlwcslen(const SQLWCHAR * s);
634 #else
635 #define sqlwcslen wcslen
636 #endif
637
638 #if SIZEOF_SQLWCHAR == 2
639 # if WORDS_BIGENDIAN
640 # define ODBC_WIDE_NAME "UCS-2BE"
641 # else
642 # define ODBC_WIDE_NAME "UCS-2LE"
643 # endif
644 #elif SIZEOF_SQLWCHAR == 4
645 # if WORDS_BIGENDIAN
646 # define ODBC_WIDE_NAME "UCS-4BE"
647 # else
648 # define ODBC_WIDE_NAME "UCS-4LE"
649 # endif
650 #else
651 #error SIZEOF_SQLWCHAR not supported !!
652 #endif
653
654 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
655 #pragma GCC visibility pop
656 #endif
657
658 #ifdef __cplusplus
659 #if 0
660 {
661 #endif
662 }
663 #endif
664
665 #endif