~ubuntu-branches/debian/sid/unixodbc/sid

« back to all changes in this revision

Viewing changes to DriverManager/drivermanager.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2004-10-15 03:07:52 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041015030752-dzw4vhxlgycz3woj
Tags: 2.2.4-11
Brown paper bag me: conflicts do not write themselves just because
you add a line to the changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
#include <pwd.h>
8
8
#include <ltdl.h>
9
9
#include <string.h>
 
10
#include <time.h>
10
11
 
11
12
#ifdef HAVE_SYNCH_H
12
13
#include <synch.h>
32
33
#include <sqlucode.h>
33
34
#include "__stats.h"
34
35
 
 
36
/*
 
37
 * iconv support
 
38
 */
 
39
 
 
40
#ifdef HAVE_ICONV
 
41
#include <stdlib.h>
 
42
#include <iconv.h>
 
43
#endif
 
44
 
 
45
#ifdef UNICODE_ENCODING
 
46
#define DEFAULT_ICONV_ENCODING      UNICODE_ENCODING 
 
47
#else
 
48
#define DEFAULT_ICONV_ENCODING      "auto-search"
 
49
#endif
 
50
 
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 */
38
54
 
 
55
/*
 
56
 * SQLSetStmt/ConnectionAttr limits
 
57
 */
 
58
 
 
59
#define SQL_CONN_DRIVER_MIN     20000
 
60
#define SQL_STMT_DRIVER_MIN     20000
39
61
 
40
62
/*
41
63
 * DEFAULT FILE NAMES
111
133
{
112
134
    SQLWCHAR    sqlstate[ 6 ];
113
135
    SQLWCHAR    *msg;
114
 
    int         native_error;
 
136
    SQLINTEGER  native_error;
115
137
    int         return_val;
116
138
    SQLRETURN   diag_column_number_ret;
117
139
    SQLRETURN   diag_row_number_ret;
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;
 
181
    SQLLEN      diag_number;
 
182
    SQLLEN      diag_row_count;
161
183
} EHEAD;
162
184
 
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 );
211
234
 
 
235
/*
 
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
 
238
 */
 
239
 
 
240
struct env_lib_struct
 
241
{
 
242
    char            *lib_name;
 
243
    void            *env_handle;
 
244
    int             count;
 
245
    struct env_lib_struct   *next;
 
246
};
 
247
 
212
248
typedef struct environment
213
249
{
214
250
    int             type;               /* magic number */
224
260
    int             fetch_mode;         /* for SQLDataSources */
225
261
    int             entry;
226
262
    void            *sh;                /* statistics handle */
 
263
    struct env_lib_struct *env_lib_list;/* use this to avoid multiple AllocEnv in the driver */
227
264
} *DMHENV;
228
265
 
229
266
/*
269
306
    int             metadata_id_set;
270
307
    int             packet_size;
271
308
    int             packet_size_set;
272
 
    int             quite_mode;
 
309
    SQLLEN          quite_mode;
273
310
    int             quite_mode_set;
274
311
    int             txn_isolation;
275
312
    int             txn_isolation_set;
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 */
 
348
#ifdef HAVE_ICONV
 
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 */
 
352
#endif
 
353
    struct env_lib_struct *env_list_ent;/* pointer to reference in the env list */
311
354
} *DMHDBC;
312
355
 
313
356
typedef struct connection_pool
394
437
#define TS_LEVEL3   3           /* protection on a environment level */
395
438
#endif
396
439
 
 
440
void mutex_lib_entry( void );
 
441
void mutex_lib_exit( void );
 
442
 
397
443
void mutex_pool_entry( void );
398
444
void mutex_pool_exit( void );
399
445
 
408
454
 * defined down here to get the DMHDBC definition
409
455
 */
410
456
 
411
 
void __handle_attr_extensions( DMHDBC connection, char *dsn );
 
457
void __handle_attr_extensions( DMHDBC connection, char *dsn, char *driver_name );
412
458
 
413
459
/*
414
460
 * handle allocation functions
442
488
SQLRETURN __SQLFreeHandle( SQLSMALLINT handle_type,
443
489
           SQLHANDLE handle );
444
490
 
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 );
450
498
 
451
499
void  __check_for_function( DMHDBC connection,
452
500
        SQLUSMALLINT function_id,
453
501
        SQLUSMALLINT *supported );
454
502
 
 
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 );
 
507
 
455
508
/*
456
509
 * mapping from ODBC 2 <-> 3 datetime types
457
510
 */
491
544
    ERROR_HY009,
492
545
    ERROR_HY010,
493
546
    ERROR_HY011,
 
547
    ERROR_HY012,
494
548
    ERROR_HY013,
495
549
    ERROR_HY017,
496
550
    ERROR_HY024,
520
574
 
521
575
#define function_return(h,r)    function_return_ex(h,r,FALSE)
522
576
 
 
577
#define SUBCLASS_ODBC           0
 
578
#define SUBCLASS_ISO            1
 
579
 
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,
 
588
        int class_origin,
 
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,
 
594
        int class_origin,
 
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 );
575
641
 
 
642
/* 
 
643
 * These are passed to the cursor lib as helper functions
 
644
 */
 
645
 
 
646
struct driver_helper_funcs
 
647
{
 
648
    void (*__post_internal_error_ex)( EHEAD *error_header,
 
649
            SQLCHAR *sqlstate,
 
650
            SQLINTEGER native_error,
 
651
            SQLCHAR *message_text,
 
652
            int class_origin,
 
653
            int subclass_origin );
 
654
 
 
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,
 
658
        char *message );
 
659
};
 
660
 
576
661
/*
577
662
 * thread protection funcs
578
663
 */
601
686
 * setup the cursor library
602
687
 */
603
688
 
604
 
SQLRETURN CLConnect( DMHDBC connection );
 
689
SQLRETURN CLConnect( DMHDBC connection, struct driver_helper_funcs * );
605
690
 
606
691
/*
607
692
 * connection string functions
636
721
 * the following two are part of a effort to get a particular unicode driver working
637
722
 */
638
723
 
639
 
/*
640
 
 * set this if you are using a unicode driver that expects to get data in little 
641
 
 * endian order
642
 
 *
643
 
#define BROKEN_UNICODE              1
644
 
 */
645
 
 
646
724
SQLINTEGER map_ca_odbc3_to_2( SQLINTEGER field_identifier );
647
725
SQLINTEGER map_ca_odbc2_to_3( SQLINTEGER field_identifier );
648
726
 
649
727
/*
650
 
 * set this if your unicode driver is rearly ANSI
651
 
 * 
652
 
#define BROKEN_UNICODE_SUPPORT      1
653
 
 */
654
 
#define BROKEN_UNICODE_SUPPORT      1
655
 
 
656
 
/*
657
728
 * entry exit functions in drivers
658
729
 */
659
730
 
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)
 
921
 
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)
854
926
 
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)
871
943
 
872
944
#define DM_SQLEXECDIRECT            26