~ubuntu-branches/ubuntu/precise/psqlodbc/precise

« back to all changes in this revision

Viewing changes to dlg_specific.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2007-03-05 22:28:19 UTC
  • mfrom: (3.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20070305222819-95d0rzmt2ah6dwwc
Tags: 1:08.01.0200-2.1
* Non-maintainer upload.
* High-urgency upload for RC bugfix.
* Fix the signature of SQLGetData on 64-bit architectures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 *
13
13
 * API functions:       none
14
14
 *
 
15
 * Removed params:  Don't reuse old parameter name if it's not for original
 
16
 *                  purpose. Here is list of deleted params:
 
17
 *                  Protocol              communication protocol (before libpq)
 
18
 *
15
19
 * Comments:            See "notice.txt" for copyright and license information.
16
20
 *-------
17
21
 */
46
50
        BOOL            abbrev = (len < 1024);
47
51
 
48
52
        /* fundamental info */
49
 
        sprintf(connect_string, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s",
 
53
        sprintf(connect_string, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;SSLMODE=%s;UID=%s;PWD=%s",
50
54
                        got_dsn ? "DSN" : "DRIVER",
51
55
                        got_dsn ? ci->dsn : ci->drivername,
52
56
                        ci->database,
53
57
                        ci->server,
54
58
                        ci->port,
 
59
            ci->sslmode,
55
60
                        ci->username,
56
61
                        ci->password);
57
62
 
61
66
        hlen = strlen(connect_string);
62
67
        if (!abbrev)
63
68
                sprintf(&connect_string[hlen],
64
 
                                ";%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%s;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d",
 
69
                                ";%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%s;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%s;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d;%s=%d",
65
70
                                INI_READONLY,
66
71
                                ci->onlyread,
67
 
                                INI_PROTOCOL,
68
 
                                ci->protocol,
69
72
                                INI_FAKEOIDINDEX,
70
73
                                ci->fake_oid_index,
71
74
                                INI_SHOWOIDCOLUMN,
127
130
        /* Abbrebiation is needed ? */
128
131
        if (abbrev || strlen(connect_string) >= len)
129
132
        {
130
 
                unsigned long flag = 0;
 
133
                UInt4 flag = 0;
131
134
                if (ci->disallow_premature)
132
135
                        flag |= BIT_DISALLOWPREMATURE;
133
136
                if (ci->allow_keyset)
136
139
                        flag |= BIT_LFCONVERSION;
137
140
                if (ci->drivers.unique_index)
138
141
                        flag |= BIT_UNIQUEINDEX;
139
 
                if (strncmp(ci->protocol, PG64, strlen(PG64)) == 0)
140
 
                        flag |= BIT_PROTOCOL_64;
141
 
                else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
142
 
                        flag |= BIT_PROTOCOL_63;
143
142
                switch (ci->drivers.unknown_sizes)
144
143
                {
145
144
                        case UNKNOWNS_AS_DONTKNOW:
199
198
                                ci->int8_as,
200
199
                                ci->drivers.extra_systable_prefixes,
201
200
                                EFFECTIVE_BIT_COUNT,
202
 
                                flag);
 
201
                                (long unsigned int) flag);
203
202
        }
204
203
}
205
204
 
207
206
unfoldCXAttribute(ConnInfo *ci, const char *value)
208
207
{
209
208
        int             count;
210
 
        unsigned long   flag;
 
209
        UInt4           flag;
211
210
 
212
211
        if (strlen(value) < 2)
213
212
        {
214
213
                count = 3;
215
 
                sscanf(value, "%lx", &flag);
 
214
                sscanf(value, "%lx", (long unsigned int *) &flag);
216
215
        }
217
216
        else
218
217
        {
220
219
                memcpy(cnt, value, 2);
221
220
                cnt[2] = '\0';
222
221
                sscanf(cnt, "%x", &count);
223
 
                sscanf(value + 2, "%lx", &flag);
 
222
                sscanf(value + 2, "%lx", (long unsigned int *) &flag);
224
223
        }
225
224
        ci->disallow_premature = (char)((flag & BIT_DISALLOWPREMATURE) != 0);
226
225
        ci->allow_keyset = (char)((flag & BIT_UPDATABLECURSORS) != 0);
228
227
        if (count < 4)
229
228
                return;
230
229
        ci->drivers.unique_index = (char)((flag & BIT_UNIQUEINDEX) != 0);
231
 
        if ((flag & BIT_PROTOCOL_64) != 0)
232
 
                strcpy(ci->protocol, PG64);
233
 
        else if ((flag & BIT_PROTOCOL_63) != 0)
234
 
                strcpy(ci->protocol, PG63);
235
 
        else
236
 
                strcpy(ci->protocol, PG62);
237
230
        if ((flag & BIT_UNKNOWN_DONTKNOW) != 0)
238
231
                ci->drivers.unknown_sizes = UNKNOWNS_AS_DONTKNOW;
239
232
        else if ((flag & BIT_UNKNOWN_ASMAX) != 0)
283
276
 
284
277
        else if (stricmp(attribute, INI_PORT) == 0)
285
278
                strcpy(ci->port, value);
 
279
    
 
280
        else if (stricmp(attribute, INI_SSLMODE) == 0 || stricmp(attribute, "sslmode") == 0)
 
281
                strcpy(ci->sslmode, value);
286
282
 
287
283
        else if (stricmp(attribute, INI_READONLY) == 0 || stricmp(attribute, "A0") == 0)
288
284
                strcpy(ci->onlyread, value);
289
285
 
290
 
        else if (stricmp(attribute, INI_PROTOCOL) == 0 || stricmp(attribute, "A1") == 0)
291
 
                strcpy(ci->protocol, value);
292
 
 
293
286
        else if (stricmp(attribute, INI_SHOWOIDCOLUMN) == 0 || stricmp(attribute, "A3") == 0)
294
287
                strcpy(ci->show_oid_column, value);
295
288
 
326
319
        else if (stricmp(attribute, "CX") == 0)
327
320
                unfoldCXAttribute(ci, value);
328
321
 
329
 
        mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password ? "xxxxx" : "", ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature);
 
322
        mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',sslmode='%s',onlyread='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password ? "xxxxx" : "", ci->port, ci->sslmode, ci->onlyread, ci->conn_settings, ci->disallow_premature);
330
323
}
331
324
 
332
325
void
397
390
{
398
391
        if (ci->port[0] == '\0')
399
392
                strcpy(ci->port, DEFAULT_PORT);
 
393
    
 
394
        if (ci->sslmode[0] == '\0')
 
395
                strcpy(ci->sslmode, DEFAULT_SSLMODE);
400
396
 
401
397
        if (ci->onlyread[0] == '\0')
402
398
                sprintf(ci->onlyread, "%d", globals.onlyread);
403
399
 
404
 
        if (ci->protocol[0] == '\0')
405
 
                strcpy(ci->protocol, globals.protocol);
406
 
 
407
400
        if (ci->fake_oid_index[0] == '\0')
408
401
                sprintf(ci->fake_oid_index, "%d", DEFAULT_FAKEOIDINDEX);
409
402
 
490
483
        if (ci->port[0] == '\0' || overwrite)
491
484
                SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI);
492
485
 
 
486
        if (ci->sslmode[0] == '\0' || overwrite)
 
487
                SQLGetPrivateProfileString(DSN, INI_SSLMODE, "", ci->sslmode, sizeof(ci->sslmode), ODBC_INI);
 
488
    
493
489
        if (ci->onlyread[0] == '\0' || overwrite)
494
490
                SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), ODBC_INI);
495
491
 
505
501
        if (ci->show_system_tables[0] == '\0' || overwrite)
506
502
                SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, "", ci->show_system_tables, sizeof(ci->show_system_tables), ODBC_INI);
507
503
 
508
 
        if (ci->protocol[0] == '\0' || overwrite)
509
 
                SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI);
510
 
 
511
504
        if (ci->conn_settings[0] == '\0' || overwrite)
512
505
        {
513
506
                SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", encoded_conn_settings, sizeof(encoded_conn_settings), ODBC_INI);
586
579
                 ci->database,
587
580
                 ci->username,
588
581
                 ci->password ? "xxxxx" : "");
589
 
        qlog("          onlyread='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",
 
582
        qlog("          onlyread='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",
590
583
                 ci->onlyread,
591
 
                 ci->protocol,
592
584
                 ci->show_oid_column,
593
585
                 ci->fake_oid_index,
594
586
                 ci->show_system_tables);
722
714
                                                                 INI_PORT,
723
715
                                                                 ci->port,
724
716
                                                                 ODBC_INI);
 
717
                                 
 
718
        SQLWritePrivateProfileString(DSN,
 
719
                                                                 INI_SSLMODE,
 
720
                                                                 ci->sslmode,
 
721
                                                                 ODBC_INI);
725
722
 
726
723
        SQLWritePrivateProfileString(DSN,
727
724
                                                                 INI_USER,
759
756
                                                                 ODBC_INI);
760
757
 
761
758
        SQLWritePrivateProfileString(DSN,
762
 
                                                                 INI_PROTOCOL,
763
 
                                                                 ci->protocol,
764
 
                                                                 ODBC_INI);
765
 
 
766
 
        SQLWritePrivateProfileString(DSN,
767
759
                                                                 INI_CONNSETTINGS,
768
760
                                                                 encoded_conn_settings,
769
761
                                                                 ODBC_INI);
1004
996
                else
1005
997
                        comval->onlyread = DEFAULT_READONLY;
1006
998
 
1007
 
                /*
1008
 
                 * Default state for future DSN's protocol attribute This isn't a
1009
 
                 * real driver option YET.      This is more intended for
1010
 
                 * customization from the install.
1011
 
                 */
1012
 
                SQLGetPrivateProfileString(section, INI_PROTOCOL, "@@@",
1013
 
                                                                   temp, sizeof(temp), filename);
1014
 
                if (strcmp(temp, "@@@"))
1015
 
                        strcpy(comval->protocol, temp);
1016
 
                else
1017
 
                        strcpy(comval->protocol, DEFAULT_PROTOCOL);
1018
999
        }
1019
1000
}