~ubuntu-branches/ubuntu/gutsy/psqlodbc/gutsy

« back to all changes in this revision

Viewing changes to dlg_specific.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2004-05-13 10:47:36 UTC
  • Revision ID: james.westby@ubuntu.com-20040513104736-a530gmn0p3knep89
Tags: upstream-07.03.0200
ImportĀ upstreamĀ versionĀ 07.03.0200

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------
 
2
 * Module:                      dlg_specific.c
 
3
 *
 
4
 * Description:         This module contains any specific code for handling
 
5
 *                                      dialog boxes such as driver/datasource options.  Both the
 
6
 *                                      ConfigDSN() and the SQLDriverConnect() functions use
 
7
 *                                      functions in this module.  If you were to add a new option
 
8
 *                                      to any dialog box, you would most likely only have to change
 
9
 *                                      things in here rather than in 2 separate places as before.
 
10
 *
 
11
 * Classes:                     none
 
12
 *
 
13
 * API functions:       none
 
14
 *
 
15
 * Comments:            See "notice.txt" for copyright and license information.
 
16
 *-------
 
17
 */
 
18
/* Multibyte support    Eiji Tokuya 2001-03-15 */
 
19
 
 
20
#include "dlg_specific.h"
 
21
 
 
22
#include "convert.h"
 
23
 
 
24
#include "multibyte.h"
 
25
#include "pgapifunc.h"
 
26
 
 
27
#ifndef BOOL
 
28
#define BOOL    int
 
29
#endif
 
30
#ifndef FALSE
 
31
#define FALSE   (BOOL)0
 
32
#endif
 
33
#ifndef TRUE
 
34
#define TRUE    (BOOL)1
 
35
#endif
 
36
 
 
37
extern GLOBAL_VALUES globals;
 
38
 
 
39
void
 
40
makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
 
41
{
 
42
        char            got_dsn = (ci->dsn[0] != '\0');
 
43
        char            encoded_conn_settings[LARGE_REGISTRY_LEN];
 
44
        UWORD           hlen;
 
45
        /*BOOL          abbrev = (len <= 400);*/
 
46
        BOOL            abbrev = (len < 1024);
 
47
 
 
48
        /* fundamental info */
 
49
        sprintf(connect_string, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s",
 
50
                        got_dsn ? "DSN" : "DRIVER",
 
51
                        got_dsn ? ci->dsn : ci->drivername,
 
52
                        ci->database,
 
53
                        ci->server,
 
54
                        ci->port,
 
55
                        ci->username,
 
56
                        ci->password);
 
57
 
 
58
        encode(ci->conn_settings, encoded_conn_settings);
 
59
 
 
60
        /* extra info */
 
61
        hlen = strlen(connect_string);
 
62
        if (!abbrev)
 
63
                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",
 
65
                                INI_READONLY,
 
66
                                ci->onlyread,
 
67
                                INI_PROTOCOL,
 
68
                                ci->protocol,
 
69
                                INI_FAKEOIDINDEX,
 
70
                                ci->fake_oid_index,
 
71
                                INI_SHOWOIDCOLUMN,
 
72
                                ci->show_oid_column,
 
73
                                INI_ROWVERSIONING,
 
74
                                ci->row_versioning,
 
75
                                INI_SHOWSYSTEMTABLES,
 
76
                                ci->show_system_tables,
 
77
                                INI_CONNSETTINGS,
 
78
                                encoded_conn_settings,
 
79
                                INI_FETCH,
 
80
                                ci->drivers.fetch_max,
 
81
                                INI_SOCKET,
 
82
                                ci->drivers.socket_buffersize,
 
83
                                INI_UNKNOWNSIZES,
 
84
                                ci->drivers.unknown_sizes,
 
85
                                INI_MAXVARCHARSIZE,
 
86
                                ci->drivers.max_varchar_size,
 
87
                                INI_MAXLONGVARCHARSIZE,
 
88
                                ci->drivers.max_longvarchar_size,
 
89
                                INI_DEBUG,
 
90
                                ci->drivers.debug,
 
91
                                INI_COMMLOG,
 
92
                                ci->drivers.commlog,
 
93
                                INI_OPTIMIZER,
 
94
                                ci->drivers.disable_optimizer,
 
95
                                INI_KSQO,
 
96
                                ci->drivers.ksqo,
 
97
                                INI_USEDECLAREFETCH,
 
98
                                ci->drivers.use_declarefetch,
 
99
                                INI_TEXTASLONGVARCHAR,
 
100
                                ci->drivers.text_as_longvarchar,
 
101
                                INI_UNKNOWNSASLONGVARCHAR,
 
102
                                ci->drivers.unknowns_as_longvarchar,
 
103
                                INI_BOOLSASCHAR,
 
104
                                ci->drivers.bools_as_char,
 
105
                                INI_PARSE,
 
106
                                ci->drivers.parse,
 
107
                                INI_CANCELASFREESTMT,
 
108
                                ci->drivers.cancel_as_freestmt,
 
109
                                INI_EXTRASYSTABLEPREFIXES,
 
110
                                ci->drivers.extra_systable_prefixes,
 
111
                                INI_LFCONVERSION,
 
112
                                ci->lf_conversion,
 
113
                                INI_UPDATABLECURSORS,
 
114
                                ci->allow_keyset,
 
115
                                INI_DISALLOWPREMATURE,
 
116
                                ci->disallow_premature,
 
117
                                INI_TRUEISMINUS1,
 
118
                                ci->true_is_minus1,
 
119
                                INI_INT8AS,
 
120
                                ci->int8_as,
 
121
                                INI_BYTEAASLONGVARBINARY,
 
122
                                ci->bytea_as_longvarbinary,
 
123
                                INI_USESERVERSIDEPREPARE,
 
124
                                ci->use_server_side_prepare,
 
125
                                INI_LOWERCASEIDENTIFIER,
 
126
                                ci->lower_case_identifier);
 
127
        /* Abbrebiation is needed ? */
 
128
        if (abbrev || strlen(connect_string) >= len)
 
129
        {
 
130
                unsigned long flag = 0;
 
131
                if (ci->disallow_premature)
 
132
                        flag |= BIT_DISALLOWPREMATURE;
 
133
                if (ci->allow_keyset)
 
134
                        flag |= BIT_UPDATABLECURSORS;
 
135
                if (ci->lf_conversion)
 
136
                        flag |= BIT_LFCONVERSION;
 
137
                if (ci->drivers.unique_index)
 
138
                        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
                switch (ci->drivers.unknown_sizes)
 
144
                {
 
145
                        case UNKNOWNS_AS_DONTKNOW:
 
146
                                flag |= BIT_UNKNOWN_DONTKNOW;
 
147
                                break;
 
148
                        case UNKNOWNS_AS_MAX:
 
149
                                flag |= BIT_UNKNOWN_ASMAX;
 
150
                                break;
 
151
                }
 
152
                if (ci->drivers.disable_optimizer)
 
153
                        flag |= BIT_OPTIMIZER;
 
154
                if (ci->drivers.ksqo)
 
155
                        flag |= BIT_KSQO;
 
156
                if (ci->drivers.commlog)
 
157
                        flag |= BIT_COMMLOG;
 
158
                if (ci->drivers.debug)
 
159
                        flag |= BIT_DEBUG;
 
160
                if (ci->drivers.parse)
 
161
                        flag |= BIT_PARSE;
 
162
                if (ci->drivers.cancel_as_freestmt)
 
163
                        flag |= BIT_CANCELASFREESTMT;
 
164
                if (ci->drivers.use_declarefetch)
 
165
                        flag |= BIT_USEDECLAREFETCH;
 
166
                if (ci->onlyread[0] == '1')
 
167
                        flag |= BIT_READONLY;
 
168
                if (ci->drivers.text_as_longvarchar)
 
169
                        flag |= BIT_TEXTASLONGVARCHAR;
 
170
                if (ci->drivers.unknowns_as_longvarchar)
 
171
                        flag |= BIT_UNKNOWNSASLONGVARCHAR;
 
172
                if (ci->drivers.bools_as_char)
 
173
                        flag |= BIT_BOOLSASCHAR;
 
174
                if (ci->row_versioning[0] == '1')
 
175
                        flag |= BIT_ROWVERSIONING;
 
176
                if (ci->show_system_tables[0] == '1')
 
177
                        flag |= BIT_SHOWSYSTEMTABLES;
 
178
                if (ci->show_oid_column[0] == '1')
 
179
                        flag |= BIT_SHOWOIDCOLUMN;
 
180
                if (ci->fake_oid_index[0] == '1')
 
181
                        flag |= BIT_FAKEOIDINDEX;
 
182
                if (ci->true_is_minus1)
 
183
                        flag |= BIT_TRUEISMINUS1;
 
184
                if (ci->bytea_as_longvarbinary)
 
185
                        flag |= BIT_BYTEAASLONGVARBINARY;
 
186
                if (ci->use_server_side_prepare)
 
187
                        flag |= BIT_USESERVERSIDEPREPARE;
 
188
                if (ci->lower_case_identifier)
 
189
                        flag |= BIT_LOWERCASEIDENTIFIER;
 
190
 
 
191
                sprintf(&connect_string[hlen],
 
192
                                ";A6=%s;A7=%d;A8=%d;B0=%d;B1=%d;%s=%d;C2=%s;CX=%02x%lx",
 
193
                                encoded_conn_settings,
 
194
                                ci->drivers.fetch_max,
 
195
                                ci->drivers.socket_buffersize,
 
196
                                ci->drivers.max_varchar_size,
 
197
                                ci->drivers.max_longvarchar_size,
 
198
                                INI_INT8AS,
 
199
                                ci->int8_as,
 
200
                                ci->drivers.extra_systable_prefixes,
 
201
                                EFFECTIVE_BIT_COUNT,
 
202
                                flag);
 
203
        }
 
204
}
 
205
 
 
206
static void
 
207
unfoldCXAttribute(ConnInfo *ci, const char *value)
 
208
{
 
209
        int             count;
 
210
        unsigned long   flag;
 
211
 
 
212
        if (strlen(value) < 2)
 
213
        {
 
214
                count = 3;
 
215
                sscanf(value, "%lx", &flag);
 
216
        }
 
217
        else
 
218
        {
 
219
                char    cnt[8];
 
220
                memcpy(cnt, value, 2);
 
221
                cnt[2] = '\0';
 
222
                sscanf(cnt, "%x", &count);
 
223
                sscanf(value + 2, "%lx", &flag);
 
224
        }
 
225
        ci->disallow_premature = (char)((flag & BIT_DISALLOWPREMATURE) != 0);
 
226
        ci->allow_keyset = (char)((flag & BIT_UPDATABLECURSORS) != 0);
 
227
        ci->lf_conversion = (char)((flag & BIT_LFCONVERSION) != 0);
 
228
        if (count < 4)
 
229
                return;
 
230
        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
        if ((flag & BIT_UNKNOWN_DONTKNOW) != 0)
 
238
                ci->drivers.unknown_sizes = UNKNOWNS_AS_DONTKNOW;
 
239
        else if ((flag & BIT_UNKNOWN_ASMAX) != 0)
 
240
                ci->drivers.unknown_sizes = UNKNOWNS_AS_MAX;
 
241
        else 
 
242
                ci->drivers.unknown_sizes = UNKNOWNS_AS_LONGEST;
 
243
        ci->drivers.disable_optimizer = (char)((flag & BIT_OPTIMIZER) != 0);
 
244
        ci->drivers.ksqo = (char)((flag & BIT_KSQO) != 0);
 
245
        ci->drivers.commlog = (char)((flag & BIT_COMMLOG) != 0);
 
246
        ci->drivers.debug = (char)((flag & BIT_DEBUG) != 0);
 
247
        ci->drivers.parse = (char)((flag & BIT_PARSE) != 0);
 
248
        ci->drivers.cancel_as_freestmt = (char)((flag & BIT_CANCELASFREESTMT) != 0);
 
249
        ci->drivers.use_declarefetch = (char)((flag & BIT_USEDECLAREFETCH) != 0);
 
250
        sprintf(ci->onlyread, "%d", (char)((flag & BIT_READONLY) != 0));
 
251
        ci->drivers.text_as_longvarchar = (char)((flag & BIT_TEXTASLONGVARCHAR) !=0);
 
252
        ci->drivers.unknowns_as_longvarchar = (char)((flag & BIT_UNKNOWNSASLONGVARCHAR) !=0);
 
253
        ci->drivers.bools_as_char = (char)((flag & BIT_BOOLSASCHAR) != 0);
 
254
        sprintf(ci->row_versioning, "%d", (char)((flag & BIT_ROWVERSIONING) != 0));
 
255
        sprintf(ci->show_system_tables, "%d", (char)((flag & BIT_SHOWSYSTEMTABLES) != 0));
 
256
        sprintf(ci->show_oid_column, "%d", (char)((flag & BIT_SHOWOIDCOLUMN) != 0));
 
257
        sprintf(ci->fake_oid_index, "%d", (char)((flag & BIT_FAKEOIDINDEX) != 0));
 
258
        ci->true_is_minus1 = (char)((flag & BIT_TRUEISMINUS1) != 0);
 
259
        ci->bytea_as_longvarbinary = (char)((flag & BIT_BYTEAASLONGVARBINARY) != 0);
 
260
        ci->use_server_side_prepare = (char)((flag & BIT_USESERVERSIDEPREPARE) != 0);
 
261
        ci->lower_case_identifier = (char)((flag & BIT_LOWERCASEIDENTIFIER) != 0);
 
262
}
 
263
void
 
264
copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
 
265
{
 
266
        if (stricmp(attribute, "DSN") == 0)
 
267
                strcpy(ci->dsn, value);
 
268
 
 
269
        else if (stricmp(attribute, "driver") == 0)
 
270
                strcpy(ci->drivername, value);
 
271
 
 
272
        else if (stricmp(attribute, INI_DATABASE) == 0)
 
273
                strcpy(ci->database, value);
 
274
 
 
275
        else if (stricmp(attribute, INI_SERVER) == 0 || stricmp(attribute, "server") == 0)
 
276
                strcpy(ci->server, value);
 
277
 
 
278
        else if (stricmp(attribute, INI_USER) == 0 || stricmp(attribute, "uid") == 0)
 
279
                strcpy(ci->username, value);
 
280
 
 
281
        else if (stricmp(attribute, INI_PASSWORD) == 0 || stricmp(attribute, "pwd") == 0)
 
282
                strcpy(ci->password, value);
 
283
 
 
284
        else if (stricmp(attribute, INI_PORT) == 0)
 
285
                strcpy(ci->port, value);
 
286
 
 
287
        else if (stricmp(attribute, INI_READONLY) == 0 || stricmp(attribute, "A0") == 0)
 
288
                strcpy(ci->onlyread, value);
 
289
 
 
290
        else if (stricmp(attribute, INI_PROTOCOL) == 0 || stricmp(attribute, "A1") == 0)
 
291
                strcpy(ci->protocol, value);
 
292
 
 
293
        else if (stricmp(attribute, INI_SHOWOIDCOLUMN) == 0 || stricmp(attribute, "A3") == 0)
 
294
                strcpy(ci->show_oid_column, value);
 
295
 
 
296
        else if (stricmp(attribute, INI_FAKEOIDINDEX) == 0 || stricmp(attribute, "A2") == 0)
 
297
                strcpy(ci->fake_oid_index, value);
 
298
 
 
299
        else if (stricmp(attribute, INI_ROWVERSIONING) == 0 || stricmp(attribute, "A4") == 0)
 
300
                strcpy(ci->row_versioning, value);
 
301
 
 
302
        else if (stricmp(attribute, INI_SHOWSYSTEMTABLES) == 0 || stricmp(attribute, "A5") == 0)
 
303
                strcpy(ci->show_system_tables, value);
 
304
 
 
305
        else if (stricmp(attribute, INI_CONNSETTINGS) == 0 || stricmp(attribute, "A6") == 0)
 
306
        {
 
307
                decode(value, ci->conn_settings);
 
308
                /* strcpy(ci->conn_settings, value); */
 
309
        }
 
310
        else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, "C3") == 0)
 
311
                ci->disallow_premature = atoi(value);
 
312
        else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, "C4") == 0)
 
313
                ci->allow_keyset = atoi(value);
 
314
        else if (stricmp(attribute, INI_LFCONVERSION) == 0)
 
315
                ci->lf_conversion = atoi(value);
 
316
        else if (stricmp(attribute, INI_TRUEISMINUS1) == 0)
 
317
                ci->true_is_minus1 = atoi(value);
 
318
        else if (stricmp(attribute, INI_INT8AS) == 0)
 
319
                ci->int8_as = atoi(value);
 
320
        else if (stricmp(attribute, INI_BYTEAASLONGVARBINARY) == 0)
 
321
                ci->bytea_as_longvarbinary = atoi(value);
 
322
        else if (stricmp(attribute, INI_USESERVERSIDEPREPARE) == 0)
 
323
                ci->use_server_side_prepare = atoi(value);
 
324
        else if (stricmp(attribute, INI_LOWERCASEIDENTIFIER) == 0)
 
325
                ci->lower_case_identifier = atoi(value);
 
326
        else if (stricmp(attribute, "CX") == 0)
 
327
                unfoldCXAttribute(ci, value);
 
328
 
 
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);
 
330
}
 
331
 
 
332
void
 
333
copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value)
 
334
{
 
335
        if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, "A7") == 0)
 
336
                ci->drivers.fetch_max = atoi(value);
 
337
        else if (stricmp(attribute, INI_SOCKET) == 0 || stricmp(attribute, "A8") == 0)
 
338
                ci->drivers.socket_buffersize = atoi(value);
 
339
        else if (stricmp(attribute, INI_DEBUG) == 0 || stricmp(attribute, "B2") == 0)
 
340
                ci->drivers.debug = atoi(value);
 
341
        else if (stricmp(attribute, INI_COMMLOG) == 0 || stricmp(attribute, "B3") == 0)
 
342
                ci->drivers.commlog = atoi(value);
 
343
        else if (stricmp(attribute, INI_OPTIMIZER) == 0 || stricmp(attribute, "B4") == 0)
 
344
                ci->drivers.disable_optimizer = atoi(value);
 
345
        else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, "B5") == 0)
 
346
                ci->drivers.ksqo = atoi(value);
 
347
 
 
348
        /*
 
349
         * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 ||
 
350
         * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index =
 
351
         * atoi(value);
 
352
         */
 
353
        else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, "A9") == 0)
 
354
                ci->drivers.unknown_sizes = atoi(value);
 
355
        else if (stricmp(attribute, INI_LIE) == 0)
 
356
                ci->drivers.lie = atoi(value);
 
357
        else if (stricmp(attribute, INI_PARSE) == 0 || stricmp(attribute, "C0") == 0)
 
358
                ci->drivers.parse = atoi(value);
 
359
        else if (stricmp(attribute, INI_CANCELASFREESTMT) == 0 || stricmp(attribute, "C1") == 0)
 
360
                ci->drivers.cancel_as_freestmt = atoi(value);
 
361
        else if (stricmp(attribute, INI_USEDECLAREFETCH) == 0 || stricmp(attribute, "B6") == 0)
 
362
                ci->drivers.use_declarefetch = atoi(value);
 
363
        else if (stricmp(attribute, INI_MAXVARCHARSIZE) == 0 || stricmp(attribute, "B0") == 0)
 
364
                ci->drivers.max_varchar_size = atoi(value);
 
365
        else if (stricmp(attribute, INI_MAXLONGVARCHARSIZE) == 0 || stricmp(attribute, "B1") == 0)
 
366
                ci->drivers.max_longvarchar_size = atoi(value);
 
367
        else if (stricmp(attribute, INI_TEXTASLONGVARCHAR) == 0 || stricmp(attribute, "B7") == 0)
 
368
                ci->drivers.text_as_longvarchar = atoi(value);
 
369
        else if (stricmp(attribute, INI_UNKNOWNSASLONGVARCHAR) == 0 || stricmp(attribute, "B8") == 0)
 
370
                ci->drivers.unknowns_as_longvarchar = atoi(value);
 
371
        else if (stricmp(attribute, INI_BOOLSASCHAR) == 0 || stricmp(attribute, "B9") == 0)
 
372
                ci->drivers.bools_as_char = atoi(value);
 
373
        else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, "C2") == 0)
 
374
                strcpy(ci->drivers.extra_systable_prefixes, value);
 
375
        mylog("CopyCommonAttributes: A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s",
 
376
                  ci->drivers.fetch_max,
 
377
                  ci->drivers.socket_buffersize,
 
378
                  ci->drivers.unknown_sizes,
 
379
                  ci->drivers.max_varchar_size,
 
380
                  ci->drivers.max_longvarchar_size,
 
381
                  ci->drivers.debug,
 
382
                  ci->drivers.commlog,
 
383
                  ci->drivers.disable_optimizer,
 
384
                  ci->drivers.ksqo,
 
385
                  ci->drivers.use_declarefetch,
 
386
                  ci->drivers.text_as_longvarchar,
 
387
                  ci->drivers.unknowns_as_longvarchar,
 
388
                  ci->drivers.bools_as_char,
 
389
                  ci->drivers.parse,
 
390
                  ci->drivers.cancel_as_freestmt,
 
391
                  ci->drivers.extra_systable_prefixes);
 
392
}
 
393
 
 
394
 
 
395
void
 
396
getDSNdefaults(ConnInfo *ci)
 
397
{
 
398
        if (ci->port[0] == '\0')
 
399
                strcpy(ci->port, DEFAULT_PORT);
 
400
 
 
401
        if (ci->onlyread[0] == '\0')
 
402
                sprintf(ci->onlyread, "%d", globals.onlyread);
 
403
 
 
404
        if (ci->protocol[0] == '\0')
 
405
                strcpy(ci->protocol, globals.protocol);
 
406
 
 
407
        if (ci->fake_oid_index[0] == '\0')
 
408
                sprintf(ci->fake_oid_index, "%d", DEFAULT_FAKEOIDINDEX);
 
409
 
 
410
        if (ci->show_oid_column[0] == '\0')
 
411
                sprintf(ci->show_oid_column, "%d", DEFAULT_SHOWOIDCOLUMN);
 
412
 
 
413
        if (ci->show_system_tables[0] == '\0')
 
414
                sprintf(ci->show_system_tables, "%d", DEFAULT_SHOWSYSTEMTABLES);
 
415
 
 
416
        if (ci->row_versioning[0] == '\0')
 
417
                sprintf(ci->row_versioning, "%d", DEFAULT_ROWVERSIONING);
 
418
 
 
419
        if (ci->disallow_premature < 0)
 
420
                ci->disallow_premature = DEFAULT_DISALLOWPREMATURE;
 
421
        if (ci->allow_keyset < 0)
 
422
                ci->allow_keyset = DEFAULT_UPDATABLECURSORS;
 
423
        if (ci->lf_conversion < 0)
 
424
                ci->lf_conversion = DEFAULT_LFCONVERSION;
 
425
        if (ci->true_is_minus1 < 0)
 
426
                ci->true_is_minus1 = DEFAULT_TRUEISMINUS1;
 
427
        if (ci->int8_as < -100)
 
428
                ci->int8_as = DEFAULT_INT8AS;
 
429
        if (ci->bytea_as_longvarbinary < 0)
 
430
                ci->bytea_as_longvarbinary = DEFAULT_BYTEAASLONGVARBINARY;
 
431
        if (ci->use_server_side_prepare < 0)
 
432
                ci->use_server_side_prepare = DEFAULT_USESERVERSIDEPREPARE;
 
433
        if (ci->lower_case_identifier < 0)
 
434
                ci->lower_case_identifier = DEFAULT_LOWERCASEIDENTIFIER;
 
435
}
 
436
 
 
437
int
 
438
getDriverNameFromDSN(const char *dsn, char *driver_name, int namelen)
 
439
{
 
440
        return SQLGetPrivateProfileString(ODBC_DATASOURCES, dsn, "", driver_name, namelen, ODBC_INI);
 
441
}
 
442
 
 
443
void
 
444
getDSNinfo(ConnInfo *ci, char overwrite)
 
445
{
 
446
        char       *DSN = ci->dsn;
 
447
        char            encoded_conn_settings[LARGE_REGISTRY_LEN],
 
448
                                temp[SMALL_REGISTRY_LEN];
 
449
 
 
450
/*
 
451
 *      If a driver keyword was present, then dont use a DSN and return.
 
452
 *      If DSN is null and no driver, then use the default datasource.
 
453
 */
 
454
        if (DSN[0] == '\0')
 
455
        {
 
456
                if (ci->drivername[0] != '\0')
 
457
                        return;
 
458
                else
 
459
                        strcpy(DSN, INI_DSN);
 
460
        }
 
461
 
 
462
        /* brute-force chop off trailing blanks... */
 
463
        while (*(DSN + strlen(DSN) - 1) == ' ')
 
464
                *(DSN + strlen(DSN) - 1) = '\0';
 
465
 
 
466
        if (ci->drivername[0] == '\0' || overwrite)
 
467
        {
 
468
                getDriverNameFromDSN(DSN, ci->drivername, sizeof(ci->drivername));
 
469
                if (ci->drivername[0] && stricmp(ci->drivername, DBMS_NAME))
 
470
                        getCommonDefaults(ci->drivername, ODBCINST_INI, ci);
 
471
        }
 
472
 
 
473
        /* Proceed with getting info for the given DSN. */
 
474
 
 
475
        if (ci->desc[0] == '\0' || overwrite)
 
476
                SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
 
477
 
 
478
        if (ci->server[0] == '\0' || overwrite)
 
479
                SQLGetPrivateProfileString(DSN, INI_SERVER, "", ci->server, sizeof(ci->server), ODBC_INI);
 
480
 
 
481
        if (ci->database[0] == '\0' || overwrite)
 
482
                SQLGetPrivateProfileString(DSN, INI_DATABASE, "", ci->database, sizeof(ci->database), ODBC_INI);
 
483
 
 
484
        if (ci->username[0] == '\0' || overwrite)
 
485
                SQLGetPrivateProfileString(DSN, INI_USER, "", ci->username, sizeof(ci->username), ODBC_INI);
 
486
 
 
487
        if (ci->password[0] == '\0' || overwrite)
 
488
                SQLGetPrivateProfileString(DSN, INI_PASSWORD, "", ci->password, sizeof(ci->password), ODBC_INI);
 
489
 
 
490
        if (ci->port[0] == '\0' || overwrite)
 
491
                SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI);
 
492
 
 
493
        if (ci->onlyread[0] == '\0' || overwrite)
 
494
                SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), ODBC_INI);
 
495
 
 
496
        if (ci->show_oid_column[0] == '\0' || overwrite)
 
497
                SQLGetPrivateProfileString(DSN, INI_SHOWOIDCOLUMN, "", ci->show_oid_column, sizeof(ci->show_oid_column), ODBC_INI);
 
498
 
 
499
        if (ci->fake_oid_index[0] == '\0' || overwrite)
 
500
                SQLGetPrivateProfileString(DSN, INI_FAKEOIDINDEX, "", ci->fake_oid_index, sizeof(ci->fake_oid_index), ODBC_INI);
 
501
 
 
502
        if (ci->row_versioning[0] == '\0' || overwrite)
 
503
                SQLGetPrivateProfileString(DSN, INI_ROWVERSIONING, "", ci->row_versioning, sizeof(ci->row_versioning), ODBC_INI);
 
504
 
 
505
        if (ci->show_system_tables[0] == '\0' || overwrite)
 
506
                SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, "", ci->show_system_tables, sizeof(ci->show_system_tables), ODBC_INI);
 
507
 
 
508
        if (ci->protocol[0] == '\0' || overwrite)
 
509
                SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI);
 
510
 
 
511
        if (ci->conn_settings[0] == '\0' || overwrite)
 
512
        {
 
513
                SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", encoded_conn_settings, sizeof(encoded_conn_settings), ODBC_INI);
 
514
                decode(encoded_conn_settings, ci->conn_settings);
 
515
        }
 
516
 
 
517
        if (ci->translation_dll[0] == '\0' || overwrite)
 
518
                SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, "", ci->translation_dll, sizeof(ci->translation_dll), ODBC_INI);
 
519
 
 
520
        if (ci->translation_option[0] == '\0' || overwrite)
 
521
                SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI);
 
522
 
 
523
        if (ci->disallow_premature < 0 || overwrite)
 
524
        {
 
525
                SQLGetPrivateProfileString(DSN, INI_DISALLOWPREMATURE, "", temp, sizeof(temp), ODBC_INI);
 
526
                if (temp[0])
 
527
                        ci->disallow_premature = atoi(temp);
 
528
        }
 
529
 
 
530
        if (ci->allow_keyset < 0 || overwrite)
 
531
        {
 
532
                SQLGetPrivateProfileString(DSN, INI_UPDATABLECURSORS, "", temp, sizeof(temp), ODBC_INI);
 
533
                if (temp[0])
 
534
                        ci->allow_keyset = atoi(temp);
 
535
        }
 
536
 
 
537
        if (ci->lf_conversion < 0 || overwrite)
 
538
        {
 
539
                SQLGetPrivateProfileString(DSN, INI_LFCONVERSION, "", temp, sizeof(temp), ODBC_INI);
 
540
                if (temp[0])
 
541
                        ci->lf_conversion = atoi(temp);
 
542
        }
 
543
 
 
544
        if (ci->true_is_minus1 < 0 || overwrite)
 
545
        {
 
546
                SQLGetPrivateProfileString(DSN, INI_TRUEISMINUS1, "", temp, sizeof(temp), ODBC_INI);
 
547
                if (temp[0])
 
548
                        ci->true_is_minus1 = atoi(temp);
 
549
        }
 
550
 
 
551
        if (ci->int8_as < -100 || overwrite)
 
552
        {
 
553
                SQLGetPrivateProfileString(DSN, INI_INT8AS, "", temp, sizeof(temp), ODBC_INI);
 
554
                if (temp[0])
 
555
                        ci->int8_as = atoi(temp);
 
556
        }
 
557
 
 
558
        if (ci->bytea_as_longvarbinary < 0 || overwrite)
 
559
        {
 
560
                SQLGetPrivateProfileString(DSN, INI_BYTEAASLONGVARBINARY, "", temp, sizeof(temp), ODBC_INI);
 
561
                if (temp[0])
 
562
                        ci->bytea_as_longvarbinary = atoi(temp);
 
563
        }
 
564
 
 
565
        if (ci->use_server_side_prepare < 0 || overwrite)
 
566
        {
 
567
                SQLGetPrivateProfileString(DSN, INI_USESERVERSIDEPREPARE, "", temp, sizeof(temp), ODBC_INI);
 
568
                if (temp[0])
 
569
                        ci->use_server_side_prepare = atoi(temp);
 
570
        }
 
571
 
 
572
        if (ci->lower_case_identifier < 0 || overwrite)
 
573
        {
 
574
                SQLGetPrivateProfileString(DSN, INI_LOWERCASEIDENTIFIER, "", temp, sizeof(temp), ODBC_INI);
 
575
                if (temp[0])
 
576
                        ci->lower_case_identifier = atoi(temp);
 
577
        }
 
578
 
 
579
        /* Allow override of odbcinst.ini parameters here */
 
580
        getCommonDefaults(DSN, ODBC_INI, ci);
 
581
 
 
582
        qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n",
 
583
                 DSN,
 
584
                 ci->server,
 
585
                 ci->port,
 
586
                 ci->database,
 
587
                 ci->username,
 
588
                 ci->password ? "xxxxx" : "");
 
589
        qlog("          onlyread='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",
 
590
                 ci->onlyread,
 
591
                 ci->protocol,
 
592
                 ci->show_oid_column,
 
593
                 ci->fake_oid_index,
 
594
                 ci->show_system_tables);
 
595
 
 
596
        check_client_encoding(ci->conn_settings);
 
597
        qlog("          conn_settings='%s',conn_encoding='%s'\n",
 
598
                 ci->conn_settings,
 
599
                 check_client_encoding(ci->conn_settings));
 
600
        qlog("          translation_dll='%s',translation_option='%s'\n",
 
601
                 ci->translation_dll,
 
602
                 ci->translation_option);
 
603
}
 
604
 
 
605
/*
 
606
 *      This function writes any global parameters (that can be manipulated)
 
607
 *      to the ODBCINST.INI portion of the registry
 
608
 */
 
609
void
 
610
writeDriverCommoninfo(const char *fileName, const char *sectionName,
 
611
                         const GLOBAL_VALUES *comval)
 
612
{
 
613
        char            tmp[128];
 
614
 
 
615
        if (ODBCINST_INI == fileName && NULL == sectionName)
 
616
                sectionName = DBMS_NAME;
 
617
 
 
618
        sprintf(tmp, "%d", comval->fetch_max);
 
619
        SQLWritePrivateProfileString(sectionName,
 
620
                                                                 INI_FETCH, tmp, fileName);
 
621
 
 
622
        sprintf(tmp, "%d", comval->commlog);
 
623
        SQLWritePrivateProfileString(sectionName,
 
624
                                                                 INI_COMMLOG, tmp, fileName);
 
625
 
 
626
        sprintf(tmp, "%d", comval->debug);
 
627
        SQLWritePrivateProfileString(sectionName,
 
628
                                                                 INI_DEBUG, tmp, fileName);
 
629
 
 
630
        sprintf(tmp, "%d", comval->disable_optimizer);
 
631
        SQLWritePrivateProfileString(sectionName,
 
632
                                                                 INI_OPTIMIZER, tmp, fileName);
 
633
 
 
634
        sprintf(tmp, "%d", comval->ksqo);
 
635
        SQLWritePrivateProfileString(sectionName,
 
636
                                                                 INI_KSQO, tmp, fileName);
 
637
 
 
638
        sprintf(tmp, "%d", comval->unique_index);
 
639
        SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName);
 
640
        /*
 
641
         * Never update the onlyread from this module.
 
642
         */
 
643
        if (ODBCINST_INI == fileName)
 
644
        {
 
645
                sprintf(tmp, "%d", comval->onlyread);
 
646
                SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
 
647
                                                                         fileName);
 
648
        }
 
649
 
 
650
        sprintf(tmp, "%d", comval->use_declarefetch);
 
651
        SQLWritePrivateProfileString(sectionName,
 
652
                                                                 INI_USEDECLAREFETCH, tmp, fileName);
 
653
 
 
654
        sprintf(tmp, "%d", comval->unknown_sizes);
 
655
        SQLWritePrivateProfileString(sectionName,
 
656
                                                                 INI_UNKNOWNSIZES, tmp, fileName);
 
657
 
 
658
        sprintf(tmp, "%d", comval->text_as_longvarchar);
 
659
        SQLWritePrivateProfileString(sectionName,
 
660
                                                                 INI_TEXTASLONGVARCHAR, tmp, fileName);
 
661
 
 
662
        sprintf(tmp, "%d", comval->unknowns_as_longvarchar);
 
663
        SQLWritePrivateProfileString(sectionName,
 
664
                                                           INI_UNKNOWNSASLONGVARCHAR, tmp, fileName);
 
665
 
 
666
        sprintf(tmp, "%d", comval->bools_as_char);
 
667
        SQLWritePrivateProfileString(sectionName,
 
668
                                                                 INI_BOOLSASCHAR, tmp, fileName);
 
669
 
 
670
        sprintf(tmp, "%d", comval->parse);
 
671
        SQLWritePrivateProfileString(sectionName,
 
672
                                                                 INI_PARSE, tmp, fileName);
 
673
 
 
674
        sprintf(tmp, "%d", comval->cancel_as_freestmt);
 
675
        SQLWritePrivateProfileString(sectionName,
 
676
                                                                 INI_CANCELASFREESTMT, tmp, fileName);
 
677
 
 
678
        sprintf(tmp, "%d", comval->max_varchar_size);
 
679
        SQLWritePrivateProfileString(sectionName,
 
680
                                                                 INI_MAXVARCHARSIZE, tmp, fileName);
 
681
 
 
682
        sprintf(tmp, "%d", comval->max_longvarchar_size);
 
683
        SQLWritePrivateProfileString(sectionName,
 
684
                                                                 INI_MAXLONGVARCHARSIZE, tmp, fileName);
 
685
 
 
686
        SQLWritePrivateProfileString(sectionName,
 
687
        INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName);
 
688
 
 
689
        /*
 
690
         * Never update the conn_setting from this module
 
691
         * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS,
 
692
         * comval->conn_settings, fileName);
 
693
         */
 
694
}
 
695
 
 
696
/*      This is for datasource based options only */
 
697
void
 
698
writeDSNinfo(const ConnInfo *ci)
 
699
{
 
700
        const char *DSN = ci->dsn;
 
701
        char            encoded_conn_settings[LARGE_REGISTRY_LEN],
 
702
                                temp[SMALL_REGISTRY_LEN];
 
703
 
 
704
        encode(ci->conn_settings, encoded_conn_settings);
 
705
 
 
706
        SQLWritePrivateProfileString(DSN,
 
707
                                                                 INI_KDESC,
 
708
                                                                 ci->desc,
 
709
                                                                 ODBC_INI);
 
710
 
 
711
        SQLWritePrivateProfileString(DSN,
 
712
                                                                 INI_DATABASE,
 
713
                                                                 ci->database,
 
714
                                                                 ODBC_INI);
 
715
 
 
716
        SQLWritePrivateProfileString(DSN,
 
717
                                                                 INI_SERVER,
 
718
                                                                 ci->server,
 
719
                                                                 ODBC_INI);
 
720
 
 
721
        SQLWritePrivateProfileString(DSN,
 
722
                                                                 INI_PORT,
 
723
                                                                 ci->port,
 
724
                                                                 ODBC_INI);
 
725
 
 
726
        SQLWritePrivateProfileString(DSN,
 
727
                                                                 INI_USER,
 
728
                                                                 ci->username,
 
729
                                                                 ODBC_INI);
 
730
 
 
731
        SQLWritePrivateProfileString(DSN,
 
732
                                                                 INI_PASSWORD,
 
733
                                                                 ci->password,
 
734
                                                                 ODBC_INI);
 
735
 
 
736
        SQLWritePrivateProfileString(DSN,
 
737
                                                                 INI_READONLY,
 
738
                                                                 ci->onlyread,
 
739
                                                                 ODBC_INI);
 
740
 
 
741
        SQLWritePrivateProfileString(DSN,
 
742
                                                                 INI_SHOWOIDCOLUMN,
 
743
                                                                 ci->show_oid_column,
 
744
                                                                 ODBC_INI);
 
745
 
 
746
        SQLWritePrivateProfileString(DSN,
 
747
                                                                 INI_FAKEOIDINDEX,
 
748
                                                                 ci->fake_oid_index,
 
749
                                                                 ODBC_INI);
 
750
 
 
751
        SQLWritePrivateProfileString(DSN,
 
752
                                                                 INI_ROWVERSIONING,
 
753
                                                                 ci->row_versioning,
 
754
                                                                 ODBC_INI);
 
755
 
 
756
        SQLWritePrivateProfileString(DSN,
 
757
                                                                 INI_SHOWSYSTEMTABLES,
 
758
                                                                 ci->show_system_tables,
 
759
                                                                 ODBC_INI);
 
760
 
 
761
        SQLWritePrivateProfileString(DSN,
 
762
                                                                 INI_PROTOCOL,
 
763
                                                                 ci->protocol,
 
764
                                                                 ODBC_INI);
 
765
 
 
766
        SQLWritePrivateProfileString(DSN,
 
767
                                                                 INI_CONNSETTINGS,
 
768
                                                                 encoded_conn_settings,
 
769
                                                                 ODBC_INI);
 
770
 
 
771
        sprintf(temp, "%d", ci->disallow_premature);
 
772
        SQLWritePrivateProfileString(DSN,
 
773
                                                                 INI_DISALLOWPREMATURE,
 
774
                                                                 temp,
 
775
                                                                 ODBC_INI);
 
776
        sprintf(temp, "%d", ci->allow_keyset);
 
777
        SQLWritePrivateProfileString(DSN,
 
778
                                                                 INI_UPDATABLECURSORS,
 
779
                                                                 temp,
 
780
                                                                 ODBC_INI);
 
781
        sprintf(temp, "%d", ci->lf_conversion);
 
782
        SQLWritePrivateProfileString(DSN,
 
783
                                                                 INI_LFCONVERSION,
 
784
                                                                 temp,
 
785
                                                                 ODBC_INI);
 
786
        sprintf(temp, "%d", ci->true_is_minus1);
 
787
        SQLWritePrivateProfileString(DSN,
 
788
                                                                 INI_TRUEISMINUS1,
 
789
                                                                 temp,
 
790
                                                                 ODBC_INI);
 
791
        sprintf(temp, "%d", ci->int8_as);
 
792
        SQLWritePrivateProfileString(DSN,
 
793
                                                                 INI_INT8AS,
 
794
                                                                 temp,
 
795
                                                                 ODBC_INI);
 
796
        sprintf(temp, "%d", ci->bytea_as_longvarbinary);
 
797
        SQLWritePrivateProfileString(DSN,
 
798
                                                                 INI_BYTEAASLONGVARBINARY,
 
799
                                                                 temp,
 
800
                                                                 ODBC_INI);
 
801
        sprintf(temp, "%d", ci->use_server_side_prepare);
 
802
        SQLWritePrivateProfileString(DSN,
 
803
                                                                 INI_USESERVERSIDEPREPARE,
 
804
                                                                 temp,
 
805
                                                                 ODBC_INI);
 
806
        sprintf(temp, "%d", ci->lower_case_identifier);
 
807
        SQLWritePrivateProfileString(DSN,
 
808
                                                                 INI_LOWERCASEIDENTIFIER,
 
809
                                                                 temp,
 
810
                                                                 ODBC_INI);
 
811
}
 
812
 
 
813
 
 
814
/*
 
815
 *      This function reads the ODBCINST.INI portion of
 
816
 *      the registry and gets any driver defaults.
 
817
 */
 
818
void
 
819
getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
 
820
{
 
821
        char            temp[256];
 
822
        GLOBAL_VALUES *comval;
 
823
 
 
824
        if (ci)
 
825
                comval = &(ci->drivers);
 
826
        else
 
827
                comval = &globals;
 
828
        /* Fetch Count is stored in driver section */
 
829
        SQLGetPrivateProfileString(section, INI_FETCH, "",
 
830
                                                           temp, sizeof(temp), filename);
 
831
        if (temp[0])
 
832
        {
 
833
                comval->fetch_max = atoi(temp);
 
834
                /* sanity check if using cursors */
 
835
                if (comval->fetch_max <= 0)
 
836
                        comval->fetch_max = FETCH_MAX;
 
837
        }
 
838
        else if (!ci)
 
839
                comval->fetch_max = FETCH_MAX;
 
840
 
 
841
        /* Socket Buffersize is stored in driver section */
 
842
        SQLGetPrivateProfileString(section, INI_SOCKET, "",
 
843
                                                           temp, sizeof(temp), filename);
 
844
        if (temp[0])
 
845
                comval->socket_buffersize = atoi(temp);
 
846
        else if (!ci)
 
847
                comval->socket_buffersize = SOCK_BUFFER_SIZE;
 
848
 
 
849
        /* Debug is stored in the driver section */
 
850
        SQLGetPrivateProfileString(section, INI_DEBUG, "",
 
851
                                                           temp, sizeof(temp), filename);
 
852
        if (temp[0])
 
853
                comval->debug = atoi(temp);
 
854
        else if (!ci)
 
855
                comval->debug = DEFAULT_DEBUG;
 
856
 
 
857
        /* CommLog is stored in the driver section */
 
858
        SQLGetPrivateProfileString(section, INI_COMMLOG, "",
 
859
                                                           temp, sizeof(temp), filename);
 
860
        if (temp[0])
 
861
                comval->commlog = atoi(temp);
 
862
        else if (!ci)
 
863
                comval->commlog = DEFAULT_COMMLOG;
 
864
 
 
865
        if (!ci)
 
866
                logs_on_off(0, 0, 0);
 
867
        /* Optimizer is stored in the driver section only */
 
868
        SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
 
869
                                                           temp, sizeof(temp), filename);
 
870
        if (temp[0])
 
871
                comval->disable_optimizer = atoi(temp);
 
872
        else if (!ci)
 
873
                comval->disable_optimizer = DEFAULT_OPTIMIZER;
 
874
 
 
875
        /* KSQO is stored in the driver section only */
 
876
        SQLGetPrivateProfileString(section, INI_KSQO, "",
 
877
                                                           temp, sizeof(temp), filename);
 
878
        if (temp[0])
 
879
                comval->ksqo = atoi(temp);
 
880
        else if (!ci)
 
881
                comval->ksqo = DEFAULT_KSQO;
 
882
 
 
883
        /* Recognize Unique Index is stored in the driver section only */
 
884
        SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, "",
 
885
                                                           temp, sizeof(temp), filename);
 
886
        if (temp[0])
 
887
                comval->unique_index = atoi(temp);
 
888
        else if (!ci)
 
889
                comval->unique_index = DEFAULT_UNIQUEINDEX;
 
890
 
 
891
 
 
892
        /* Unknown Sizes is stored in the driver section only */
 
893
        SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, "",
 
894
                                                           temp, sizeof(temp), filename);
 
895
        if (temp[0])
 
896
                comval->unknown_sizes = atoi(temp);
 
897
        else if (!ci)
 
898
                comval->unknown_sizes = DEFAULT_UNKNOWNSIZES;
 
899
 
 
900
 
 
901
        /* Lie about supported functions? */
 
902
        SQLGetPrivateProfileString(section, INI_LIE, "",
 
903
                                                           temp, sizeof(temp), filename);
 
904
        if (temp[0])
 
905
                comval->lie = atoi(temp);
 
906
        else if (!ci)
 
907
                comval->lie = DEFAULT_LIE;
 
908
 
 
909
        /* Parse statements */
 
910
        SQLGetPrivateProfileString(section, INI_PARSE, "",
 
911
                                                           temp, sizeof(temp), filename);
 
912
        if (temp[0])
 
913
                comval->parse = atoi(temp);
 
914
        else if (!ci)
 
915
                comval->parse = DEFAULT_PARSE;
 
916
 
 
917
        /* SQLCancel calls SQLFreeStmt in Driver Manager */
 
918
        SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "",
 
919
                                                           temp, sizeof(temp), filename);
 
920
        if (temp[0])
 
921
                comval->cancel_as_freestmt = atoi(temp);
 
922
        else if (!ci)
 
923
                comval->cancel_as_freestmt = DEFAULT_CANCELASFREESTMT;
 
924
 
 
925
        /* UseDeclareFetch is stored in the driver section only */
 
926
        SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
 
927
                                                           temp, sizeof(temp), filename);
 
928
        if (temp[0])
 
929
                comval->use_declarefetch = atoi(temp);
 
930
        else if (!ci)
 
931
                comval->use_declarefetch = DEFAULT_USEDECLAREFETCH;
 
932
 
 
933
        /* Max Varchar Size */
 
934
        SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
 
935
                                                           temp, sizeof(temp), filename);
 
936
        if (temp[0])
 
937
                comval->max_varchar_size = atoi(temp);
 
938
        else if (!ci)
 
939
                comval->max_varchar_size = MAX_VARCHAR_SIZE;
 
940
 
 
941
        /* Max TextField Size */
 
942
        SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "",
 
943
                                                           temp, sizeof(temp), filename);
 
944
        if (temp[0])
 
945
                comval->max_longvarchar_size = atoi(temp);
 
946
        else if (!ci)
 
947
                comval->max_longvarchar_size = TEXT_FIELD_SIZE;
 
948
 
 
949
        /* Text As LongVarchar  */
 
950
        SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "",
 
951
                                                           temp, sizeof(temp), filename);
 
952
        if (temp[0])
 
953
                comval->text_as_longvarchar = atoi(temp);
 
954
        else if (!ci)
 
955
                comval->text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
 
956
 
 
957
        /* Unknowns As LongVarchar      */
 
958
        SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "",
 
959
                                                           temp, sizeof(temp), filename);
 
960
        if (temp[0])
 
961
                comval->unknowns_as_longvarchar = atoi(temp);
 
962
        else if (!ci)
 
963
                comval->unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
 
964
 
 
965
        /* Bools As Char */
 
966
        SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "",
 
967
                                                           temp, sizeof(temp), filename);
 
968
        if (temp[0])
 
969
                comval->bools_as_char = atoi(temp);
 
970
        else if (!ci)
 
971
                comval->bools_as_char = DEFAULT_BOOLSASCHAR;
 
972
 
 
973
        /* Extra Systable prefixes */
 
974
 
 
975
        /*
 
976
         * Use @@@ to distinguish between blank extra prefixes and no key
 
977
         * entry
 
978
         */
 
979
        SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@",
 
980
                                                           temp, sizeof(temp), filename);
 
981
        if (strcmp(temp, "@@@"))
 
982
                strcpy(comval->extra_systable_prefixes, temp);
 
983
        else if (!ci)
 
984
                strcpy(comval->extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES);
 
985
 
 
986
        mylog("globals.extra_systable_prefixes = '%s'\n", comval->extra_systable_prefixes);
 
987
 
 
988
 
 
989
        /* Dont allow override of an override! */
 
990
        if (!ci)
 
991
        {
 
992
                /*
 
993
                 * ConnSettings is stored in the driver section and per datasource
 
994
                 * for override
 
995
                 */
 
996
                SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
 
997
                 comval->conn_settings, sizeof(comval->conn_settings), filename);
 
998
 
 
999
                /* Default state for future DSN's Readonly attribute */
 
1000
                SQLGetPrivateProfileString(section, INI_READONLY, "",
 
1001
                                                                   temp, sizeof(temp), filename);
 
1002
                if (temp[0])
 
1003
                        comval->onlyread = atoi(temp);
 
1004
                else
 
1005
                        comval->onlyread = DEFAULT_READONLY;
 
1006
 
 
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
        }
 
1019
}