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

« back to all changes in this revision

Viewing changes to DriverManager/SQLGetConnectAttrW.c

  • 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:
27
27
 *
28
28
 **********************************************************************
29
29
 *
30
 
 * $Id: SQLGetConnectAttrW.c,v 1.3 2001/12/13 13:00:32 lurcher Exp $
 
30
 * $Id: SQLGetConnectAttrW.c,v 1.9 2002/12/05 17:44:30 lurcher Exp $
31
31
 *
32
32
 * $Log: SQLGetConnectAttrW.c,v $
 
33
 * Revision 1.9  2002/12/05 17:44:30  lurcher
 
34
 *
 
35
 * Display unknown return values in return logging
 
36
 *
 
37
 * Revision 1.8  2002/11/11 17:10:10  lurcher
 
38
 *
 
39
 * VMS changes
 
40
 *
 
41
 * Revision 1.7  2002/08/23 09:42:37  lurcher
 
42
 *
 
43
 * Fix some build warnings with casts, and a AIX linker mod, to include
 
44
 * deplib's on the link line, but not the libtool generated ones
 
45
 *
 
46
 * Revision 1.6  2002/08/12 13:17:52  lurcher
 
47
 *
 
48
 * Replicate the way the MS DM handles loading of driver libs, and allocating
 
49
 * handles in the driver. usage counting in the driver means that dlopen is
 
50
 * only called for the first use, and dlclose for the last. AllocHandle for
 
51
 * the driver environment is only called for the first time per driver
 
52
 * per application environment.
 
53
 *
 
54
 * Revision 1.5  2002/07/24 08:49:52  lurcher
 
55
 *
 
56
 * Alter UNICODE support to use iconv for UNICODE-ANSI conversion
 
57
 *
 
58
 * Revision 1.4  2002/07/16 13:08:18  lurcher
 
59
 *
 
60
 * Filter attribute values from SQLSetStmtAttr to SQLSetStmtOption to fit
 
61
 * within ODBC 2
 
62
 * Make DSN's double clickable in ODBCConfig
 
63
 *
33
64
 * Revision 1.3  2001/12/13 13:00:32  lurcher
34
65
 *
35
66
 * Remove most if not all warnings on 64 bit platforms
108
139
 
109
140
        ptr = log_info.log_file_name;
110
141
 
111
 
        if ( log_info.log_file_name )
 
142
        if ( ptr )
112
143
        {
 
144
            int len = strlen( ptr ) * sizeof( SQLWCHAR );
113
145
            if ( string_length )
114
146
            {
115
 
                *string_length = strlen( ptr );
 
147
                *string_length = len;
116
148
            }
117
149
            if ( value )
118
150
            {
119
 
                if ( buffer_length > strlen((char*) ptr ) + 1 )
 
151
                if ( buffer_length > len + sizeof( SQLWCHAR ))
120
152
                {
121
 
                    strcpy( value, ptr );
 
153
                    ansi_to_unicode_copy( value, ptr, SQL_NTS, connection );
122
154
                }
123
155
                else
124
156
                {
125
 
                    memcpy( value, ptr, buffer_length - 1 );
126
 
                    ((char*)value)[ buffer_length - 1 ] = '\0';
 
157
                    ansi_to_unicode_copy( value, ptr, buffer_length - 1, connection );
 
158
                    ((SQLWCHAR*)value)[( buffer_length - 1 ) / sizeof( SQLWCHAR )] = 0;
127
159
                    ret = SQL_SUCCESS_WITH_INFO;
128
160
                }
129
161
            }
136
168
            }
137
169
            if ( value )
138
170
            {
139
 
                if ( buffer_length >= 1 )
 
171
                if ( buffer_length > 0 )
140
172
                {
141
 
                    strcpy( value, "" );
 
173
                    ((SQLWCHAR*)value)[ 0 ] = 0;
142
174
                }
143
175
                else
144
176
                {
146
178
                }
147
179
            }
148
180
        }
149
 
        ansi_to_unicode_in_place( value, SQL_NTS );
150
181
        return ret;
151
182
    }
152
183
 
451
482
 
452
483
        sprintf( connection -> msg, 
453
484
                "\n\t\tExit:[%s]",
454
 
                    __get_return_status( ret ));
 
485
                    __get_return_status( ret, s1 ));
455
486
 
456
487
        dm_log_write( __FILE__, 
457
488
                __LINE__, 
465
496
    }
466
497
    else
467
498
    {
468
 
        SQLRETURN ret;
 
499
        SQLRETURN ret = 0;
469
500
 
470
501
        /*
471
502
         * call the driver
476
507
            {
477
508
                if ( CHECK_SQLGETCONNECTOPTIONW( connection ))
478
509
                {
 
510
                    /*
 
511
                     * Is it in the legal range of values
 
512
                     */
 
513
 
 
514
                    if ( attribute < SQL_CONN_DRIVER_MIN && 
 
515
                            ( attribute > SQL_PACKET_SIZE || attribute < SQL_ACCESS_MODE ))
 
516
                    {
 
517
                        dm_log_write( __FILE__, 
 
518
                                    __LINE__, 
 
519
                                LOG_INFO, 
 
520
                                LOG_INFO, 
 
521
                                "Error: HY092" );
 
522
 
 
523
                        __post_internal_error( &connection -> error,
 
524
                                ERROR_HY092, NULL,
 
525
                                connection -> environment -> requested_version );
 
526
 
 
527
                        thread_release( SQL_HANDLE_STMT, connection );
 
528
 
 
529
                        return function_return( connection, SQL_ERROR );
 
530
                    }
 
531
 
479
532
                    ret = SQLGETCONNECTOPTIONW( connection,
480
533
                        connection -> driver_dbc,
481
534
                        attribute,
512
565
        {
513
566
            if ( !CHECK_SQLGETCONNECTATTR( connection ))
514
567
            {
515
 
                if ( CHECK_SQLGETCONNECTOPTION( connection ))
 
568
                if ( ret = CHECK_SQLGETCONNECTOPTION( connection ))
516
569
                {
 
570
                    SQLCHAR *as1 = NULL;
 
571
 
 
572
                    /*
 
573
                     * Is it in the legal range of values
 
574
                     */
 
575
 
 
576
                    if ( attribute < SQL_CONN_DRIVER_MIN && 
 
577
                            ( attribute > SQL_PACKET_SIZE || attribute < SQL_ACCESS_MODE ))
 
578
                    {
 
579
                        dm_log_write( __FILE__, 
 
580
                                    __LINE__, 
 
581
                                LOG_INFO, 
 
582
                                LOG_INFO, 
 
583
                                "Error: HY092" );
 
584
 
 
585
                        __post_internal_error( &connection -> error,
 
586
                                ERROR_HY092, NULL,
 
587
                                connection -> environment -> requested_version );
 
588
 
 
589
                        thread_release( SQL_HANDLE_STMT, connection );
 
590
 
 
591
                        return function_return( connection, SQL_ERROR );
 
592
                    }
 
593
 
 
594
                    switch( attribute )
 
595
                    {
 
596
                      case SQL_ATTR_CURRENT_CATALOG:
 
597
                      case SQL_ATTR_TRACEFILE:
 
598
                      case SQL_ATTR_TRANSLATE_LIB:
 
599
                        if ( SQL_SUCCEEDED( ret ) && value && buffer_length > 0 )
 
600
                        {
 
601
                            as1 = malloc( buffer_length + 1 );
 
602
                        }
 
603
                        break;
 
604
                    }
 
605
 
517
606
                    ret = SQLGETCONNECTOPTION( connection,
518
607
                        connection -> driver_dbc,
519
608
                        attribute,
520
 
                        value );
 
609
                        as1 ? as1 : value );
521
610
 
522
611
                    switch( attribute )
523
612
                    {
524
613
                      case SQL_ATTR_CURRENT_CATALOG:
525
614
                      case SQL_ATTR_TRACEFILE:
526
615
                      case SQL_ATTR_TRANSLATE_LIB:
527
 
                        if ( SQL_SUCCEEDED( ret ) && value )
528
 
                        {
529
 
                            ansi_to_unicode_in_place( value, SQL_NTS );
 
616
                        if ( SQL_SUCCEEDED( ret ) && value && buffer_length > 0 && as1 )
 
617
                        {
 
618
                            ansi_to_unicode_copy( value, (char*) as1, SQL_NTS, connection );
 
619
                        }
 
620
 
 
621
                        if ( as1 )
 
622
                        {
 
623
                            free( as1 );
530
624
                        }
531
625
                        break;
532
626
                    }
550
644
            }
551
645
            else
552
646
            {
 
647
                SQLCHAR *as1 = NULL;
 
648
 
553
649
                switch( attribute )
554
650
                {
555
651
                  case SQL_ATTR_CURRENT_CATALOG:
556
652
                  case SQL_ATTR_TRACEFILE:
557
653
                  case SQL_ATTR_TRANSLATE_LIB:
558
654
                    buffer_length = buffer_length / 2;
 
655
                    if ( buffer_length > 0 )
 
656
                    {
 
657
                        as1 = malloc( buffer_length + 1 );
 
658
                    }
559
659
                    break;
560
660
                }
561
661
 
562
662
                ret = SQLGETCONNECTATTR( connection,
563
663
                    connection -> driver_dbc,
564
664
                    attribute,
565
 
                    value,
 
665
                    as1 ? as1 : value,
566
666
                    buffer_length,
567
667
                    string_length );
568
668
 
571
671
                  case SQL_ATTR_CURRENT_CATALOG:
572
672
                  case SQL_ATTR_TRACEFILE:
573
673
                  case SQL_ATTR_TRANSLATE_LIB:
574
 
                    if ( SQL_SUCCEEDED( ret ) && value )
575
 
                    {
576
 
                        ansi_to_unicode_in_place( value, SQL_NTS );
 
674
                    if ( SQL_SUCCEEDED( ret ) && value && buffer_length > 0 && as1 )
 
675
                    {
 
676
                        ansi_to_unicode_copy( value, (char*)as1, SQL_NTS, connection );
 
677
                    }
 
678
 
 
679
                    if ( as1 )
 
680
                    {
 
681
                        free( as1 );
577
682
                    }
578
683
                    break;
579
684
                }
584
689
        {
585
690
            sprintf( connection -> msg, 
586
691
                    "\n\t\tExit:[%s]",
587
 
                        __get_return_status( ret ));
 
692
                        __get_return_status( ret, s1 ));
588
693
 
589
694
            dm_log_write( __FILE__, 
590
695
                    __LINE__,