32
33
#include <sqlucode.h>
33
34
#include "__stats.h"
45
#ifdef UNICODE_ENCODING
46
#define DEFAULT_ICONV_ENCODING UNICODE_ENCODING
48
#define DEFAULT_ICONV_ENCODING "auto-search"
35
51
#define ERROR_PREFIX "[unixODBC]"
36
52
#define DM_ERROR_PREFIX "[Driver Manager]"
37
53
#define LOG_MESSAGE_LEN 128 /* length of string to display in log */
56
* SQLSetStmt/ConnectionAttr limits
59
#define SQL_CONN_DRIVER_MIN 20000
60
#define SQL_STMT_DRIVER_MIN 20000
41
63
* DEFAULT FILE NAMES
153
175
SQLRETURN diag_dynamic_function_code_ret;
154
176
SQLRETURN diag_number_ret;
155
177
SQLRETURN diag_row_count_ret;
156
SQLINTEGER diag_cursor_row_count;
178
SQLLEN diag_cursor_row_count;
157
179
SQLWCHAR diag_dynamic_function[ 128 ];
158
180
SQLINTEGER diag_dynamic_function_code;
159
SQLINTEGER diag_number;
160
SQLINTEGER diag_row_count;
182
SQLLEN diag_row_count;
163
185
struct log_structure
207
229
char *str, int str_len );
208
230
void __release_attr_str( struct attr_struct *attr_str );
209
231
void __set_attributes( void *handle, int type );
232
void __set_local_attributes( void *handle, int type );
210
233
void *__attr_override( void *handle, int type, int attribute, void * value, SQLINTEGER *string_length );
236
* use this to maintain a list of the drivers that are loaded under this env,
237
* and to decide if we want to call SQLAllocHandle( SQL_ENV ) om them
240
struct env_lib_struct
245
struct env_lib_struct *next;
212
248
typedef struct environment
214
250
int type; /* magic number */
304
341
char password[ 128 ];
305
342
int password_length;
306
343
char cli_year[ 5 ];
307
struct attr_struct env_attribute; /* Extended attribute set info */
344
struct attr_struct env_attribute; /* Extended attribute set info */
308
345
struct attr_struct dbc_attribute;
309
346
struct attr_struct stmt_attribute;
310
struct save_attr *save_attr; /* SQLConnectAttr before connect */
347
struct save_attr *save_attr; /* SQLConnectAttr before connect */
349
iconv_t iconv_cd_uc_to_ascii; /* in and out conversion descriptor */
350
iconv_t iconv_cd_ascii_to_uc;
351
char unicode_string[ 64 ]; /* name of unicode conversion */
353
struct env_lib_struct *env_list_ent;/* pointer to reference in the env list */
313
356
typedef struct connection_pool
408
454
* defined down here to get the DMHDBC definition
411
void __handle_attr_extensions( DMHDBC connection, char *dsn );
457
void __handle_attr_extensions( DMHDBC connection, char *dsn, char *driver_name );
414
460
* handle allocation functions
442
488
SQLRETURN __SQLFreeHandle( SQLSMALLINT handle_type,
443
489
SQLHANDLE handle );
445
int __connect_part_one( DMHDBC connection, char *driver_lib, char *driver_name );
491
int __connect_part_one( DMHDBC connection, char *driver_lib, char *driver_name, int *warnings );
446
492
void __disconnect_part_one( DMHDBC connection );
447
493
int __connect_part_two( DMHDBC connection );
448
494
void __disconnect_part_two( DMHDBC connection );
495
void __disconnect_part_three( DMHDBC connection );
449
496
DMHDBC __get_dbc_root( void );
497
DMHSTMT __get_stmt_root( void );
451
499
void __check_for_function( DMHDBC connection,
452
500
SQLUSMALLINT function_id,
453
501
SQLUSMALLINT *supported );
503
int __clean_stmt_from_dbc( DMHDBC connection );
504
int __clean_desc_from_dbc( DMHDBC connection );
505
void __map_error_state( char * state, int requested_version );
506
void __map_error_state_w( SQLWCHAR * wstate, int requested_version );
456
509
* mapping from ODBC 2 <-> 3 datetime types
521
575
#define function_return(h,r) function_return_ex(h,r,FALSE)
577
#define SUBCLASS_ODBC 0
578
#define SUBCLASS_ISO 1
523
580
void __post_internal_error( EHEAD *error_handle,
524
581
error_id, char *txt, int connection_mode );
582
void __post_internal_error_api( EHEAD *error_handle,
583
error_id, char *txt, int connection_mode, int calling_api );
525
584
void __post_internal_error_ex( EHEAD *error_handle,
526
585
SQLCHAR *sqlstate,
527
586
SQLINTEGER native_error,
528
SQLCHAR *message_text );
587
SQLCHAR *message_text,
589
int subclass_origin );
529
590
void __post_internal_error_ex_w( EHEAD *error_handle,
530
591
SQLWCHAR *sqlstate,
531
592
SQLINTEGER native_error,
532
SQLWCHAR *message_text );
593
SQLWCHAR *message_text,
595
int subclass_origin );
533
596
int function_return_ex( void * handle, int ret_code, int save_to_diag );
534
597
void function_entry( void *handle );
535
598
void setup_error_head( EHEAD *error_header, void *handle, int handle_type );
536
599
void clear_error_head( EHEAD *error_header );
537
SQLWCHAR *ansi_to_unicode( SQLCHAR *str, SQLINTEGER len );
538
SQLWCHAR *ansi_to_unicode_in_place( SQLCHAR *str, SQLINTEGER len );
539
SQLWCHAR *ansi_back_to_unicode( char *str, SQLINTEGER len );
540
char *unicode_to_ansi( SQLWCHAR *str, SQLINTEGER len );
541
char * __get_return_status( SQLRETURN ret );
600
SQLWCHAR *ansi_to_unicode_copy( SQLWCHAR * dest, char *src, SQLINTEGER buffer_len, DMHDBC connection );
601
SQLWCHAR *ansi_to_unicode_alloc( SQLCHAR *str, SQLINTEGER len, DMHDBC connection );
602
char *unicode_to_ansi_copy( char* dest, SQLWCHAR *src, SQLINTEGER len, DMHDBC connection );
603
char *unicode_to_ansi_alloc( SQLWCHAR *str, SQLINTEGER len, DMHDBC connection );
604
int unicode_setup( DMHDBC connection );
605
void unicode_shutdown( DMHDBC connection );
606
char * __get_return_status( SQLRETURN ret, SQLCHAR *buffer );
542
607
char * __sql_as_text( SQLINTEGER type );
543
608
char * __c_as_text( SQLINTEGER type );
544
609
char * __string_with_length( SQLCHAR *out, SQLCHAR *str, SQLINTEGER len );
548
613
char * __wstring_with_length_pass( SQLCHAR *out, SQLWCHAR *str, SQLINTEGER len );
549
614
char * __wstring_with_length_hide_pwd( SQLCHAR *out, SQLWCHAR *str, SQLINTEGER len );
550
615
SQLWCHAR *wide_strcpy( SQLWCHAR *str1, SQLWCHAR *str2 );
616
SQLWCHAR *wide_strncpy( SQLWCHAR *str1, SQLWCHAR *str2, int buffer_length );
551
617
SQLWCHAR *wide_strcat( SQLWCHAR *str1, SQLWCHAR *str2 );
552
618
SQLWCHAR *wide_strdup( SQLWCHAR *str1 );
553
619
int wide_strlen( SQLWCHAR *str1 );
573
639
SQLHANDLE __get_driver_handle( EHEAD * head );
574
640
int __get_version( EHEAD * head );
643
* These are passed to the cursor lib as helper functions
646
struct driver_helper_funcs
648
void (*__post_internal_error_ex)( EHEAD *error_header,
650
SQLINTEGER native_error,
651
SQLCHAR *message_text,
653
int subclass_origin );
655
void (*__post_internal_error)( EHEAD *error_handle,
656
error_id id, char *txt, int connection_mode );
657
void (*dm_log_write)( char *function_name, int line, int type, int severity,
577
662
* thread protection funcs
636
721
* the following two are part of a effort to get a particular unicode driver working
640
* set this if you are using a unicode driver that expects to get data in little
643
#define BROKEN_UNICODE 1
646
724
SQLINTEGER map_ca_odbc3_to_2( SQLINTEGER field_identifier );
647
725
SQLINTEGER map_ca_odbc2_to_3( SQLINTEGER field_identifier );
650
* set this if your unicode driver is rearly ANSI
652
#define BROKEN_UNICODE_SUPPORT 1
654
#define BROKEN_UNICODE_SUPPORT 1
657
728
* entry exit functions in drivers
847
918
#define SQLDRIVERCONNECT(con,dbc,wh,ics,sl1,ocs,bl,sl2p,dc)\
848
919
(con->functions[22].func)\
849
920
(dbc,wh,ics,sl1,ocs,bl,sl2p,dc)
850
922
#define CHECK_SQLDRIVERCONNECTW(con) (con->functions[22].funcW!=NULL)
851
923
#define SQLDRIVERCONNECTW(con,dbc,wh,ics,sl1,ocs,bl,sl2p,dc)\
852
(con->functions[22].funcW)\
924
(con->functions[22].funcW)\
853
925
(dbc,wh,ics,sl1,ocs,bl,sl2p,dc)
855
927
#define DM_SQLDRIVERS 23
866
938
(env,dbc,stmt,st,nat,msg,mm,pcb)
867
939
#define CHECK_SQLERRORW(con) (con->functions[25].funcW!=NULL)
868
940
#define SQLERRORW(con,env,dbc,stmt,st,nat,msg,mm,pcb)\
869
(con->functions[25].funcW)\
941
(con->functions[25].funcW)\
870
942
(env,dbc,stmt,st,nat,msg,mm,pcb)
872
944
#define DM_SQLEXECDIRECT 26