2 * Module: dlg_specific.c
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.
15 * Comments: See "notice.txt" for copyright and license information.
18 /* Multibyte support Eiji Tokuya 2001-03-15 */
20 #include "dlg_specific.h"
25 #include "multibyte.h"
27 #include "pgapifunc.h"
39 extern GLOBAL_VALUES globals;
42 makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
44 char got_dsn = (ci->dsn[0] != '\0');
45 char encoded_conn_settings[LARGE_REGISTRY_LEN];
47 /*BOOL abbrev = (len <= 400);*/
48 BOOL abbrev = (len < 1024);
50 /* fundamental info */
51 sprintf(connect_string, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s",
52 got_dsn ? "DSN" : "DRIVER",
53 got_dsn ? ci->dsn : ci->driver,
60 encode(ci->conn_settings, encoded_conn_settings);
63 hlen = strlen(connect_string);
65 sprintf(&connect_string[hlen],
66 ";%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",
78 ci->show_system_tables,
80 encoded_conn_settings,
82 ci->drivers.fetch_max,
84 ci->drivers.socket_buffersize,
86 ci->drivers.unknown_sizes,
88 ci->drivers.max_varchar_size,
89 INI_MAXLONGVARCHARSIZE,
90 ci->drivers.max_longvarchar_size,
96 ci->drivers.disable_optimizer,
100 ci->drivers.use_declarefetch,
101 INI_TEXTASLONGVARCHAR,
102 ci->drivers.text_as_longvarchar,
103 INI_UNKNOWNSASLONGVARCHAR,
104 ci->drivers.unknowns_as_longvarchar,
106 ci->drivers.bools_as_char,
109 INI_CANCELASFREESTMT,
110 ci->drivers.cancel_as_freestmt,
111 INI_EXTRASYSTABLEPREFIXES,
112 ci->drivers.extra_systable_prefixes,
115 INI_UPDATABLECURSORS,
117 INI_DISALLOWPREMATURE,
118 ci->disallow_premature,
123 /* Abbrebiation is needed ? */
124 if (abbrev || strlen(connect_string) >= len)
126 unsigned long flag = 0;
127 if (ci->disallow_premature)
128 flag |= BIT_DISALLOWPREMATURE;
129 if (ci->allow_keyset)
130 flag |= BIT_UPDATABLECURSORS;
131 if (ci->lf_conversion)
132 flag |= BIT_LFCONVERSION;
133 if (ci->drivers.unique_index)
134 flag |= BIT_UNIQUEINDEX;
135 if (strncmp(ci->protocol, PG64, strlen(PG64)) == 0)
136 flag |= BIT_PROTOCOL_64;
137 else if (strncmp(ci->protocol, PG63, strlen(PG63)) == 0)
138 flag |= BIT_PROTOCOL_63;
139 switch (ci->drivers.unknown_sizes)
141 case UNKNOWNS_AS_DONTKNOW:
142 flag |= BIT_UNKNOWN_DONTKNOW;
144 case UNKNOWNS_AS_MAX:
145 flag |= BIT_UNKNOWN_ASMAX;
148 if (ci->drivers.disable_optimizer)
149 flag |= BIT_OPTIMIZER;
150 if (ci->drivers.ksqo)
152 if (ci->drivers.commlog)
154 if (ci->drivers.debug)
156 if (ci->drivers.parse)
158 if (ci->drivers.cancel_as_freestmt)
159 flag |= BIT_CANCELASFREESTMT;
160 if (ci->drivers.use_declarefetch)
161 flag |= BIT_USEDECLAREFETCH;
162 if (ci->onlyread[0] == '1')
163 flag |= BIT_READONLY;
164 if (ci->drivers.text_as_longvarchar)
165 flag |= BIT_TEXTASLONGVARCHAR;
166 if (ci->drivers.unknowns_as_longvarchar)
167 flag |= BIT_UNKNOWNSASLONGVARCHAR;
168 if (ci->drivers.bools_as_char)
169 flag |= BIT_BOOLSASCHAR;
170 if (ci->row_versioning[0] == '1')
171 flag |= BIT_ROWVERSIONING;
172 if (ci->show_system_tables[0] == '1')
173 flag |= BIT_SHOWSYSTEMTABLES;
174 if (ci->show_oid_column[0] == '1')
175 flag |= BIT_SHOWOIDCOLUMN;
176 if (ci->fake_oid_index[0] == '1')
177 flag |= BIT_FAKEOIDINDEX;
178 if (ci->true_is_minus1)
179 flag |= BIT_TRUEISMINUS1;
181 sprintf(&connect_string[hlen],
182 ";A6=%s;A7=%d;A8=%d;B0=%d;B1=%d;%s=%d;C2=%s;CX=%02x%lx",
183 encoded_conn_settings,
184 ci->drivers.fetch_max,
185 ci->drivers.socket_buffersize,
186 ci->drivers.max_varchar_size,
187 ci->drivers.max_longvarchar_size,
190 ci->drivers.extra_systable_prefixes,
197 unfoldCXAttribute(ConnInfo *ci, const char *value)
202 if (strlen(value) < 2)
205 sscanf(value, "%lx", &flag);
210 memcpy(cnt, value, 2);
212 sscanf(cnt, "%x", &count);
213 sscanf(value + 2, "%lx", &flag);
215 ci->disallow_premature = (char)((flag & BIT_DISALLOWPREMATURE) != 0);
216 ci->allow_keyset = (char)((flag & BIT_UPDATABLECURSORS) != 0);
217 ci->lf_conversion = (char)((flag & BIT_LFCONVERSION) != 0);
220 ci->drivers.unique_index = (char)((flag & BIT_UNIQUEINDEX) != 0);
221 if ((flag & BIT_PROTOCOL_64) != 0)
222 strcpy(ci->protocol, PG64);
223 else if ((flag & BIT_PROTOCOL_63) != 0)
224 strcpy(ci->protocol, PG63);
226 strcpy(ci->protocol, PG62);
227 if ((flag & BIT_UNKNOWN_DONTKNOW) != 0)
228 ci->drivers.unknown_sizes = UNKNOWNS_AS_DONTKNOW;
229 else if ((flag & BIT_UNKNOWN_ASMAX) != 0)
230 ci->drivers.unknown_sizes = UNKNOWNS_AS_MAX;
232 ci->drivers.unknown_sizes = UNKNOWNS_AS_LONGEST;
233 ci->drivers.disable_optimizer = (char)((flag & BIT_OPTIMIZER) != 0);
234 ci->drivers.ksqo = (char)((flag & BIT_KSQO) != 0);
235 ci->drivers.commlog = (char)((flag & BIT_COMMLOG) != 0);
236 ci->drivers.debug = (char)((flag & BIT_DEBUG) != 0);
237 ci->drivers.parse = (char)((flag & BIT_PARSE) != 0);
238 ci->drivers.cancel_as_freestmt = (char)((flag & BIT_CANCELASFREESTMT) != 0);
239 ci->drivers.use_declarefetch = (char)((flag & BIT_USEDECLAREFETCH) != 0);
240 sprintf(ci->onlyread, "%d", (char)((flag & BIT_READONLY) != 0));
241 ci->drivers.text_as_longvarchar = (char)((flag & BIT_TEXTASLONGVARCHAR) !=0);
242 ci->drivers.unknowns_as_longvarchar = (char)((flag & BIT_UNKNOWNSASLONGVARCHAR) !=0);
243 ci->drivers.bools_as_char = (char)((flag & BIT_BOOLSASCHAR) != 0);
244 sprintf(ci->row_versioning, "%d", (char)((flag & BIT_ROWVERSIONING) != 0));
245 sprintf(ci->show_system_tables, "%d", (char)((flag & BIT_SHOWSYSTEMTABLES) != 0));
246 sprintf(ci->show_oid_column, "%d", (char)((flag & BIT_SHOWOIDCOLUMN) != 0));
247 sprintf(ci->fake_oid_index, "%d", (char)((flag & BIT_FAKEOIDINDEX) != 0));
248 ci->true_is_minus1 = (char)((flag & BIT_TRUEISMINUS1) != 0);
251 copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
253 if (stricmp(attribute, "DSN") == 0)
254 strcpy(ci->dsn, value);
256 else if (stricmp(attribute, "driver") == 0)
257 strcpy(ci->driver, value);
259 else if (stricmp(attribute, INI_DATABASE) == 0)
260 strcpy(ci->database, value);
262 else if (stricmp(attribute, INI_SERVER) == 0 || stricmp(attribute, "server") == 0)
263 strcpy(ci->server, value);
265 else if (stricmp(attribute, INI_USER) == 0 || stricmp(attribute, "uid") == 0)
266 strcpy(ci->username, value);
268 else if (stricmp(attribute, INI_PASSWORD) == 0 || stricmp(attribute, "pwd") == 0)
269 strcpy(ci->password, value);
271 else if (stricmp(attribute, INI_PORT) == 0)
272 strcpy(ci->port, value);
274 else if (stricmp(attribute, INI_READONLY) == 0 || stricmp(attribute, "A0") == 0)
275 strcpy(ci->onlyread, value);
277 else if (stricmp(attribute, INI_PROTOCOL) == 0 || stricmp(attribute, "A1") == 0)
278 strcpy(ci->protocol, value);
280 else if (stricmp(attribute, INI_SHOWOIDCOLUMN) == 0 || stricmp(attribute, "A3") == 0)
281 strcpy(ci->show_oid_column, value);
283 else if (stricmp(attribute, INI_FAKEOIDINDEX) == 0 || stricmp(attribute, "A2") == 0)
284 strcpy(ci->fake_oid_index, value);
286 else if (stricmp(attribute, INI_ROWVERSIONING) == 0 || stricmp(attribute, "A4") == 0)
287 strcpy(ci->row_versioning, value);
289 else if (stricmp(attribute, INI_SHOWSYSTEMTABLES) == 0 || stricmp(attribute, "A5") == 0)
290 strcpy(ci->show_system_tables, value);
292 else if (stricmp(attribute, INI_CONNSETTINGS) == 0 || stricmp(attribute, "A6") == 0)
294 decode(value, ci->conn_settings);
295 /* strcpy(ci->conn_settings, value); */
297 else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, "C3") == 0)
298 ci->disallow_premature = atoi(value);
299 else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, "C4") == 0)
300 ci->allow_keyset = atoi(value);
301 else if (stricmp(attribute, INI_LFCONVERSION) == 0)
302 ci->lf_conversion = atoi(value);
303 else if (stricmp(attribute, INI_TRUEISMINUS1) == 0)
304 ci->true_is_minus1 = atoi(value);
305 else if (stricmp(attribute, INI_INT8AS) == 0)
306 ci->int8_as = atoi(value);
307 else if (stricmp(attribute, "CX") == 0)
308 unfoldCXAttribute(ci, value);
310 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, ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature);
314 copyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value)
316 if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, "A7") == 0)
317 ci->drivers.fetch_max = atoi(value);
318 else if (stricmp(attribute, INI_SOCKET) == 0 || stricmp(attribute, "A8") == 0)
319 ci->drivers.socket_buffersize = atoi(value);
320 else if (stricmp(attribute, INI_DEBUG) == 0 || stricmp(attribute, "B2") == 0)
321 ci->drivers.debug = atoi(value);
322 else if (stricmp(attribute, INI_COMMLOG) == 0 || stricmp(attribute, "B3") == 0)
323 ci->drivers.commlog = atoi(value);
324 else if (stricmp(attribute, INI_OPTIMIZER) == 0 || stricmp(attribute, "B4") == 0)
325 ci->drivers.disable_optimizer = atoi(value);
326 else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, "B5") == 0)
327 ci->drivers.ksqo = atoi(value);
330 * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 ||
331 * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index =
334 else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, "A9") == 0)
335 ci->drivers.unknown_sizes = atoi(value);
336 else if (stricmp(attribute, INI_LIE) == 0)
337 ci->drivers.lie = atoi(value);
338 else if (stricmp(attribute, INI_PARSE) == 0 || stricmp(attribute, "C0") == 0)
339 ci->drivers.parse = atoi(value);
340 else if (stricmp(attribute, INI_CANCELASFREESTMT) == 0 || stricmp(attribute, "C1") == 0)
341 ci->drivers.cancel_as_freestmt = atoi(value);
342 else if (stricmp(attribute, INI_USEDECLAREFETCH) == 0 || stricmp(attribute, "B6") == 0)
343 ci->drivers.use_declarefetch = atoi(value);
344 else if (stricmp(attribute, INI_MAXVARCHARSIZE) == 0 || stricmp(attribute, "B0") == 0)
345 ci->drivers.max_varchar_size = atoi(value);
346 else if (stricmp(attribute, INI_MAXLONGVARCHARSIZE) == 0 || stricmp(attribute, "B1") == 0)
347 ci->drivers.max_longvarchar_size = atoi(value);
348 else if (stricmp(attribute, INI_TEXTASLONGVARCHAR) == 0 || stricmp(attribute, "B7") == 0)
349 ci->drivers.text_as_longvarchar = atoi(value);
350 else if (stricmp(attribute, INI_UNKNOWNSASLONGVARCHAR) == 0 || stricmp(attribute, "B8") == 0)
351 ci->drivers.unknowns_as_longvarchar = atoi(value);
352 else if (stricmp(attribute, INI_BOOLSASCHAR) == 0 || stricmp(attribute, "B9") == 0)
353 ci->drivers.bools_as_char = atoi(value);
354 else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, "C2") == 0)
355 strcpy(ci->drivers.extra_systable_prefixes, value);
356 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",
357 ci->drivers.fetch_max,
358 ci->drivers.socket_buffersize,
359 ci->drivers.unknown_sizes,
360 ci->drivers.max_varchar_size,
361 ci->drivers.max_longvarchar_size,
364 ci->drivers.disable_optimizer,
366 ci->drivers.use_declarefetch,
367 ci->drivers.text_as_longvarchar,
368 ci->drivers.unknowns_as_longvarchar,
369 ci->drivers.bools_as_char,
371 ci->drivers.cancel_as_freestmt,
372 ci->drivers.extra_systable_prefixes);
377 getDSNdefaults(ConnInfo *ci)
379 if (ci->port[0] == '\0')
380 strcpy(ci->port, DEFAULT_PORT);
382 if (ci->onlyread[0] == '\0')
383 sprintf(ci->onlyread, "%d", globals.onlyread);
385 if (ci->protocol[0] == '\0')
386 strcpy(ci->protocol, globals.protocol);
388 if (ci->fake_oid_index[0] == '\0')
389 sprintf(ci->fake_oid_index, "%d", DEFAULT_FAKEOIDINDEX);
391 if (ci->show_oid_column[0] == '\0')
392 sprintf(ci->show_oid_column, "%d", DEFAULT_SHOWOIDCOLUMN);
394 if (ci->show_system_tables[0] == '\0')
395 sprintf(ci->show_system_tables, "%d", DEFAULT_SHOWSYSTEMTABLES);
397 if (ci->row_versioning[0] == '\0')
398 sprintf(ci->row_versioning, "%d", DEFAULT_ROWVERSIONING);
400 if (ci->disallow_premature < 0)
401 ci->disallow_premature = DEFAULT_DISALLOWPREMATURE;
402 if (ci->allow_keyset < 0)
403 ci->allow_keyset = DEFAULT_UPDATABLECURSORS;
404 if (ci->lf_conversion < 0)
405 ci->lf_conversion = DEFAULT_LFCONVERSION;
406 if (ci->true_is_minus1 < 0)
407 ci->true_is_minus1 = DEFAULT_TRUEISMINUS1;
408 if (ci->int8_as < -100)
409 ci->int8_as = DEFAULT_INT8AS;
414 getDSNinfo(ConnInfo *ci, char overwrite)
417 char encoded_conn_settings[LARGE_REGISTRY_LEN],
418 temp[SMALL_REGISTRY_LEN];
421 * If a driver keyword was present, then dont use a DSN and return.
422 * If DSN is null and no driver, then use the default datasource.
426 if (ci->driver[0] != '\0')
429 strcpy(DSN, INI_DSN);
432 /* brute-force chop off trailing blanks... */
433 while (*(DSN + strlen(DSN) - 1) == ' ')
434 *(DSN + strlen(DSN) - 1) = '\0';
436 /* Proceed with getting info for the given DSN. */
438 if (ci->desc[0] == '\0' || overwrite)
439 SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
441 if (ci->server[0] == '\0' || overwrite)
442 SQLGetPrivateProfileString(DSN, INI_SERVER, "", ci->server, sizeof(ci->server), ODBC_INI);
444 if (ci->database[0] == '\0' || overwrite)
445 SQLGetPrivateProfileString(DSN, INI_DATABASE, "", ci->database, sizeof(ci->database), ODBC_INI);
447 if (ci->username[0] == '\0' || overwrite)
448 SQLGetPrivateProfileString(DSN, INI_USER, "", ci->username, sizeof(ci->username), ODBC_INI);
450 if (ci->password[0] == '\0' || overwrite)
451 SQLGetPrivateProfileString(DSN, INI_PASSWORD, "", ci->password, sizeof(ci->password), ODBC_INI);
453 if (ci->port[0] == '\0' || overwrite)
454 SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI);
456 if (ci->onlyread[0] == '\0' || overwrite)
457 SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), ODBC_INI);
459 if (ci->show_oid_column[0] == '\0' || overwrite)
460 SQLGetPrivateProfileString(DSN, INI_SHOWOIDCOLUMN, "", ci->show_oid_column, sizeof(ci->show_oid_column), ODBC_INI);
462 if (ci->fake_oid_index[0] == '\0' || overwrite)
463 SQLGetPrivateProfileString(DSN, INI_FAKEOIDINDEX, "", ci->fake_oid_index, sizeof(ci->fake_oid_index), ODBC_INI);
465 if (ci->row_versioning[0] == '\0' || overwrite)
466 SQLGetPrivateProfileString(DSN, INI_ROWVERSIONING, "", ci->row_versioning, sizeof(ci->row_versioning), ODBC_INI);
468 if (ci->show_system_tables[0] == '\0' || overwrite)
469 SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, "", ci->show_system_tables, sizeof(ci->show_system_tables), ODBC_INI);
471 if (ci->protocol[0] == '\0' || overwrite)
472 SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI);
474 if (ci->conn_settings[0] == '\0' || overwrite)
476 SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", encoded_conn_settings, sizeof(encoded_conn_settings), ODBC_INI);
477 decode(encoded_conn_settings, ci->conn_settings);
480 if (ci->translation_dll[0] == '\0' || overwrite)
481 SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, "", ci->translation_dll, sizeof(ci->translation_dll), ODBC_INI);
483 if (ci->translation_option[0] == '\0' || overwrite)
484 SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI);
486 if (ci->disallow_premature < 0 || overwrite)
488 SQLGetPrivateProfileString(DSN, INI_DISALLOWPREMATURE, "", temp, sizeof(temp), ODBC_INI);
490 ci->disallow_premature = atoi(temp);
493 if (ci->allow_keyset < 0 || overwrite)
495 SQLGetPrivateProfileString(DSN, INI_UPDATABLECURSORS, "", temp, sizeof(temp), ODBC_INI);
497 ci->allow_keyset = atoi(temp);
500 if (ci->lf_conversion < 0 || overwrite)
502 SQLGetPrivateProfileString(DSN, INI_LFCONVERSION, "", temp, sizeof(temp), ODBC_INI);
504 ci->lf_conversion = atoi(temp);
507 if (ci->true_is_minus1 < 0 || overwrite)
509 SQLGetPrivateProfileString(DSN, INI_TRUEISMINUS1, "", temp, sizeof(temp), ODBC_INI);
511 ci->true_is_minus1 = atoi(temp);
514 if (ci->int8_as < -100 || overwrite)
516 SQLGetPrivateProfileString(DSN, INI_INT8AS, "", temp, sizeof(temp), ODBC_INI);
518 ci->int8_as = atoi(temp);
521 /* Allow override of odbcinst.ini parameters here */
522 getCommonDefaults(DSN, ODBC_INI, ci);
524 qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n",
531 qlog(" onlyread='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",
536 ci->show_system_tables);
539 check_client_encoding(ci->conn_settings);
540 qlog(" conn_settings='%s',conn_encoding='%s'\n",
542 check_client_encoding(ci->conn_settings));
544 qlog(" conn_settings='%s'\n",
548 qlog(" translation_dll='%s',translation_option='%s'\n",
550 ci->translation_option);
554 * This function writes any global parameters (that can be manipulated)
555 * to the ODBCINST.INI portion of the registry
558 writeDriverCommoninfo(const ConnInfo *ci)
560 const char *sectionName;
561 const char *fileName;
562 const GLOBAL_VALUES *comval;
566 if (ci->dsn && ci->dsn[0])
568 mylog("DSN=%s updating\n", ci->dsn);
569 comval = &(ci->drivers);
570 sectionName = ci->dsn;
575 mylog("ci but dsn==NULL\n");
580 mylog("drivers updating\n");
582 sectionName = DBMS_NAME;
583 fileName = ODBCINST_INI;
585 sprintf(tmp, "%d", comval->fetch_max);
586 SQLWritePrivateProfileString(sectionName,
587 INI_FETCH, tmp, fileName);
589 sprintf(tmp, "%d", comval->commlog);
590 SQLWritePrivateProfileString(sectionName,
591 INI_COMMLOG, tmp, fileName);
593 sprintf(tmp, "%d", comval->debug);
594 SQLWritePrivateProfileString(sectionName,
595 INI_DEBUG, tmp, fileName);
597 sprintf(tmp, "%d", comval->disable_optimizer);
598 SQLWritePrivateProfileString(sectionName,
599 INI_OPTIMIZER, tmp, fileName);
601 sprintf(tmp, "%d", comval->ksqo);
602 SQLWritePrivateProfileString(sectionName,
603 INI_KSQO, tmp, fileName);
605 sprintf(tmp, "%d", comval->unique_index);
606 SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName);
608 * Never update the onlyread from this module.
612 sprintf(tmp, "%d", comval->onlyread);
613 SQLWritePrivateProfileString(sectionName, INI_READONLY, tmp,
617 sprintf(tmp, "%d", comval->use_declarefetch);
618 SQLWritePrivateProfileString(sectionName,
619 INI_USEDECLAREFETCH, tmp, fileName);
621 sprintf(tmp, "%d", comval->unknown_sizes);
622 SQLWritePrivateProfileString(sectionName,
623 INI_UNKNOWNSIZES, tmp, fileName);
625 sprintf(tmp, "%d", comval->text_as_longvarchar);
626 SQLWritePrivateProfileString(sectionName,
627 INI_TEXTASLONGVARCHAR, tmp, fileName);
629 sprintf(tmp, "%d", comval->unknowns_as_longvarchar);
630 SQLWritePrivateProfileString(sectionName,
631 INI_UNKNOWNSASLONGVARCHAR, tmp, fileName);
633 sprintf(tmp, "%d", comval->bools_as_char);
634 SQLWritePrivateProfileString(sectionName,
635 INI_BOOLSASCHAR, tmp, fileName);
637 sprintf(tmp, "%d", comval->parse);
638 SQLWritePrivateProfileString(sectionName,
639 INI_PARSE, tmp, fileName);
641 sprintf(tmp, "%d", comval->cancel_as_freestmt);
642 SQLWritePrivateProfileString(sectionName,
643 INI_CANCELASFREESTMT, tmp, fileName);
645 sprintf(tmp, "%d", comval->max_varchar_size);
646 SQLWritePrivateProfileString(sectionName,
647 INI_MAXVARCHARSIZE, tmp, fileName);
649 sprintf(tmp, "%d", comval->max_longvarchar_size);
650 SQLWritePrivateProfileString(sectionName,
651 INI_MAXLONGVARCHARSIZE, tmp, fileName);
653 SQLWritePrivateProfileString(sectionName,
654 INI_EXTRASYSTABLEPREFIXES, comval->extra_systable_prefixes, fileName);
657 * Never update the conn_setting from this module
658 * SQLWritePrivateProfileString(sectionName, INI_CONNSETTINGS,
659 * comval->conn_settings, fileName);
663 /* This is for datasource based options only */
665 writeDSNinfo(const ConnInfo *ci)
667 const char *DSN = ci->dsn;
668 char encoded_conn_settings[LARGE_REGISTRY_LEN],
669 temp[SMALL_REGISTRY_LEN];
671 encode(ci->conn_settings, encoded_conn_settings);
673 SQLWritePrivateProfileString(DSN,
678 SQLWritePrivateProfileString(DSN,
683 SQLWritePrivateProfileString(DSN,
688 SQLWritePrivateProfileString(DSN,
693 SQLWritePrivateProfileString(DSN,
698 SQLWritePrivateProfileString(DSN,
703 SQLWritePrivateProfileString(DSN,
708 SQLWritePrivateProfileString(DSN,
713 SQLWritePrivateProfileString(DSN,
718 SQLWritePrivateProfileString(DSN,
723 SQLWritePrivateProfileString(DSN,
724 INI_SHOWSYSTEMTABLES,
725 ci->show_system_tables,
728 SQLWritePrivateProfileString(DSN,
733 SQLWritePrivateProfileString(DSN,
735 encoded_conn_settings,
738 sprintf(temp, "%d", ci->disallow_premature);
739 SQLWritePrivateProfileString(DSN,
740 INI_DISALLOWPREMATURE,
743 sprintf(temp, "%d", ci->allow_keyset);
744 SQLWritePrivateProfileString(DSN,
745 INI_UPDATABLECURSORS,
748 sprintf(temp, "%d", ci->lf_conversion);
749 SQLWritePrivateProfileString(DSN,
753 sprintf(temp, "%d", ci->true_is_minus1);
754 SQLWritePrivateProfileString(DSN,
758 sprintf(temp, "%d", ci->int8_as);
759 SQLWritePrivateProfileString(DSN,
767 * This function reads the ODBCINST.INI portion of
768 * the registry and gets any driver defaults.
771 getCommonDefaults(const char *section, const char *filename, ConnInfo *ci)
774 GLOBAL_VALUES *comval;
777 comval = &(ci->drivers);
780 /* Fetch Count is stored in driver section */
781 SQLGetPrivateProfileString(section, INI_FETCH, "",
782 temp, sizeof(temp), filename);
785 comval->fetch_max = atoi(temp);
786 /* sanity check if using cursors */
787 if (comval->fetch_max <= 0)
788 comval->fetch_max = FETCH_MAX;
791 comval->fetch_max = FETCH_MAX;
793 /* Socket Buffersize is stored in driver section */
794 SQLGetPrivateProfileString(section, INI_SOCKET, "",
795 temp, sizeof(temp), filename);
797 comval->socket_buffersize = atoi(temp);
799 comval->socket_buffersize = SOCK_BUFFER_SIZE;
801 /* Debug is stored in the driver section */
802 SQLGetPrivateProfileString(section, INI_DEBUG, "",
803 temp, sizeof(temp), filename);
805 comval->debug = atoi(temp);
807 comval->debug = DEFAULT_DEBUG;
809 /* CommLog is stored in the driver section */
810 SQLGetPrivateProfileString(section, INI_COMMLOG, "",
811 temp, sizeof(temp), filename);
813 comval->commlog = atoi(temp);
815 comval->commlog = DEFAULT_COMMLOG;
818 logs_on_off(0, 0, 0);
819 /* Optimizer is stored in the driver section only */
820 SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
821 temp, sizeof(temp), filename);
823 comval->disable_optimizer = atoi(temp);
825 comval->disable_optimizer = DEFAULT_OPTIMIZER;
827 /* KSQO is stored in the driver section only */
828 SQLGetPrivateProfileString(section, INI_KSQO, "",
829 temp, sizeof(temp), filename);
831 comval->ksqo = atoi(temp);
833 comval->ksqo = DEFAULT_KSQO;
835 /* Recognize Unique Index is stored in the driver section only */
836 SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, "",
837 temp, sizeof(temp), filename);
839 comval->unique_index = atoi(temp);
841 comval->unique_index = DEFAULT_UNIQUEINDEX;
844 /* Unknown Sizes is stored in the driver section only */
845 SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, "",
846 temp, sizeof(temp), filename);
848 comval->unknown_sizes = atoi(temp);
850 comval->unknown_sizes = DEFAULT_UNKNOWNSIZES;
853 /* Lie about supported functions? */
854 SQLGetPrivateProfileString(section, INI_LIE, "",
855 temp, sizeof(temp), filename);
857 comval->lie = atoi(temp);
859 comval->lie = DEFAULT_LIE;
861 /* Parse statements */
862 SQLGetPrivateProfileString(section, INI_PARSE, "",
863 temp, sizeof(temp), filename);
865 comval->parse = atoi(temp);
867 comval->parse = DEFAULT_PARSE;
869 /* SQLCancel calls SQLFreeStmt in Driver Manager */
870 SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "",
871 temp, sizeof(temp), filename);
873 comval->cancel_as_freestmt = atoi(temp);
875 comval->cancel_as_freestmt = DEFAULT_CANCELASFREESTMT;
877 /* UseDeclareFetch is stored in the driver section only */
878 SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
879 temp, sizeof(temp), filename);
881 comval->use_declarefetch = atoi(temp);
883 comval->use_declarefetch = DEFAULT_USEDECLAREFETCH;
885 /* Max Varchar Size */
886 SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
887 temp, sizeof(temp), filename);
889 comval->max_varchar_size = atoi(temp);
891 comval->max_varchar_size = MAX_VARCHAR_SIZE;
893 /* Max TextField Size */
894 SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "",
895 temp, sizeof(temp), filename);
897 comval->max_longvarchar_size = atoi(temp);
899 comval->max_longvarchar_size = TEXT_FIELD_SIZE;
901 /* Text As LongVarchar */
902 SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "",
903 temp, sizeof(temp), filename);
905 comval->text_as_longvarchar = atoi(temp);
907 comval->text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
909 /* Unknowns As LongVarchar */
910 SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "",
911 temp, sizeof(temp), filename);
913 comval->unknowns_as_longvarchar = atoi(temp);
915 comval->unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
918 SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "",
919 temp, sizeof(temp), filename);
921 comval->bools_as_char = atoi(temp);
923 comval->bools_as_char = DEFAULT_BOOLSASCHAR;
925 /* Extra Systable prefixes */
928 * Use @@@ to distinguish between blank extra prefixes and no key
931 SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@",
932 temp, sizeof(temp), filename);
933 if (strcmp(temp, "@@@"))
934 strcpy(comval->extra_systable_prefixes, temp);
936 strcpy(comval->extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES);
938 mylog("globals.extra_systable_prefixes = '%s'\n", comval->extra_systable_prefixes);
941 /* Dont allow override of an override! */
945 * ConnSettings is stored in the driver section and per datasource
948 SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
949 comval->conn_settings, sizeof(comval->conn_settings), filename);
951 /* Default state for future DSN's Readonly attribute */
952 SQLGetPrivateProfileString(section, INI_READONLY, "",
953 temp, sizeof(temp), filename);
955 comval->onlyread = atoi(temp);
957 comval->onlyread = DEFAULT_READONLY;
960 * Default state for future DSN's protocol attribute This isn't a
961 * real driver option YET. This is more intended for
962 * customization from the install.
964 SQLGetPrivateProfileString(section, INI_PROTOCOL, "@@@",
965 temp, sizeof(temp), filename);
966 if (strcmp(temp, "@@@"))
967 strcpy(comval->protocol, temp);
969 strcpy(comval->protocol, DEFAULT_PROTOCOL);