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.
26 #define SQLGetPrivateProfileString(a,b,c,d,e,f) GetPrivateProfileString(a,b,c,d,e,f)
27 #define SQLWritePrivateProfileString(a,b,c,d) WritePrivateProfileString(a,b,c,d)
29 #define stricmp(s1,s2) strcasecmp(s1,s2)
30 #define strnicmp(s1,s2,n) strncasecmp(s1,s2,n)
34 #include "dlg_specific.h"
37 extern GLOBAL_VALUES globals;
39 #ifndef UNIX /* best to find a #ifdef for WINDOWS */
41 SetDlgStuff(HWND hdlg, ConnInfo *ci)
43 /* If driver attribute NOT present, then set the datasource name and description */
44 if (ci->driver[0] == '\0') {
45 SetDlgItemText(hdlg, IDC_DSNAME, ci->dsn);
46 SetDlgItemText(hdlg, IDC_DESC, ci->desc);
49 SetDlgItemText(hdlg, IDC_DATABASE, ci->database);
50 SetDlgItemText(hdlg, IDC_SERVER, ci->server);
51 SetDlgItemText(hdlg, IDC_USER, ci->username);
52 SetDlgItemText(hdlg, IDC_PASSWORD, ci->password);
53 SetDlgItemText(hdlg, IDC_PORT, ci->port);
57 GetDlgStuff(HWND hdlg, ConnInfo *ci)
59 GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc));
61 GetDlgItemText(hdlg, IDC_DATABASE, ci->database, sizeof(ci->database));
62 GetDlgItemText(hdlg, IDC_SERVER, ci->server, sizeof(ci->server));
63 GetDlgItemText(hdlg, IDC_USER, ci->username, sizeof(ci->username));
64 GetDlgItemText(hdlg, IDC_PASSWORD, ci->password, sizeof(ci->password));
65 GetDlgItemText(hdlg, IDC_PORT, ci->port, sizeof(ci->port));
70 int CALLBACK driver_optionsProc(HWND hdlg,
78 CheckDlgButton(hdlg, DRV_COMMLOG, globals.commlog);
79 CheckDlgButton(hdlg, DRV_OPTIMIZER, globals.disable_optimizer);
80 CheckDlgButton(hdlg, DRV_UNIQUEINDEX, globals.unique_index);
81 CheckDlgButton(hdlg, DRV_READONLY, globals.readonly);
82 CheckDlgButton(hdlg, DRV_USEDECLAREFETCH, globals.use_declarefetch);
84 /* Unknown (Default) Data Type sizes */
85 switch(globals.unknown_sizes) {
86 case UNKNOWNS_AS_DONTKNOW:
87 CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 1);
89 case UNKNOWNS_AS_LONGEST:
90 CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 1);
94 CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 1);
98 CheckDlgButton(hdlg, DRV_TEXT_LONGVARCHAR, globals.text_as_longvarchar);
99 CheckDlgButton(hdlg, DRV_UNKNOWNS_LONGVARCHAR, globals.unknowns_as_longvarchar);
100 CheckDlgButton(hdlg, DRV_BOOLS_CHAR, globals.bools_as_char);
102 CheckDlgButton(hdlg, DRV_PARSE, globals.parse);
104 SetDlgItemInt(hdlg, DRV_CACHE_SIZE, globals.fetch_max, FALSE);
105 SetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, globals.max_varchar_size, FALSE);
106 SetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, globals.max_longvarchar_size, TRUE);
108 SetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes);
110 /* Driver Connection Settings */
111 SetDlgItemText(hdlg, DRV_CONNSETTINGS, globals.conn_settings);
116 switch (GET_WM_COMMAND_ID(wParam, lParam)) {
119 globals.commlog = IsDlgButtonChecked(hdlg, DRV_COMMLOG);
120 globals.disable_optimizer = IsDlgButtonChecked(hdlg, DRV_OPTIMIZER);
121 globals.unique_index = IsDlgButtonChecked(hdlg, DRV_UNIQUEINDEX);
122 globals.readonly = IsDlgButtonChecked(hdlg, DRV_READONLY);
123 globals.use_declarefetch = IsDlgButtonChecked(hdlg, DRV_USEDECLAREFETCH);
125 /* Unknown (Default) Data Type sizes */
126 if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_MAX))
127 globals.unknown_sizes = UNKNOWNS_AS_MAX;
128 else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_DONTKNOW))
129 globals.unknown_sizes = UNKNOWNS_AS_DONTKNOW;
130 else if (IsDlgButtonChecked(hdlg, DRV_UNKNOWN_LONGEST))
131 globals.unknown_sizes = UNKNOWNS_AS_LONGEST;
133 globals.unknown_sizes = UNKNOWNS_AS_MAX;
135 globals.text_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_TEXT_LONGVARCHAR);
136 globals.unknowns_as_longvarchar = IsDlgButtonChecked(hdlg, DRV_UNKNOWNS_LONGVARCHAR);
137 globals.bools_as_char = IsDlgButtonChecked(hdlg, DRV_BOOLS_CHAR);
139 globals.parse = IsDlgButtonChecked(hdlg, DRV_PARSE);
141 globals.fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE);
142 globals.max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE);
143 globals.max_longvarchar_size= GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); // allows for SQL_NO_TOTAL
145 GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes, sizeof(globals.extra_systable_prefixes));
147 /* Driver Connection Settings */
148 GetDlgItemText(hdlg, DRV_CONNSETTINGS, globals.conn_settings, sizeof(globals.conn_settings));
155 EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
159 CheckDlgButton(hdlg, DRV_COMMLOG, DEFAULT_COMMLOG);
160 CheckDlgButton(hdlg, DRV_OPTIMIZER, DEFAULT_OPTIMIZER);
161 CheckDlgButton(hdlg, DRV_UNIQUEINDEX, DEFAULT_UNIQUEINDEX);
162 CheckDlgButton(hdlg, DRV_READONLY, DEFAULT_READONLY);
163 CheckDlgButton(hdlg, DRV_USEDECLAREFETCH, DEFAULT_USEDECLAREFETCH);
165 CheckDlgButton(hdlg, DRV_PARSE, DEFAULT_PARSE);
168 CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 0);
169 CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 0);
170 CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 0);
171 switch(DEFAULT_UNKNOWNSIZES) {
172 case UNKNOWNS_AS_DONTKNOW:
173 CheckDlgButton(hdlg, DRV_UNKNOWN_DONTKNOW, 1);
175 case UNKNOWNS_AS_LONGEST:
176 CheckDlgButton(hdlg, DRV_UNKNOWN_LONGEST, 1);
178 case UNKNOWNS_AS_MAX:
179 CheckDlgButton(hdlg, DRV_UNKNOWN_MAX, 1);
183 CheckDlgButton(hdlg, DRV_TEXT_LONGVARCHAR, DEFAULT_TEXTASLONGVARCHAR);
184 CheckDlgButton(hdlg, DRV_UNKNOWNS_LONGVARCHAR, DEFAULT_UNKNOWNSASLONGVARCHAR);
185 CheckDlgButton(hdlg, DRV_BOOLS_CHAR, DEFAULT_BOOLSASCHAR);
187 SetDlgItemInt(hdlg, DRV_CACHE_SIZE, FETCH_MAX, FALSE);
188 SetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, MAX_VARCHAR_SIZE, FALSE);
189 SetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, TEXT_FIELD_SIZE, TRUE);
191 SetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, DEFAULT_EXTRASYSTABLEPREFIXES);
193 /* Driver Connection Settings */
194 SetDlgItemText(hdlg, DRV_CONNSETTINGS, "");
204 int CALLBACK ds_optionsProc(HWND hdlg,
214 ci = (ConnInfo *) lParam;
215 SetWindowLong(hdlg, DWL_USER, lParam); // save for OK
217 /* Change window caption */
219 SetWindowText(hdlg, "Advanced Options (Connection)");
221 sprintf(buf, "Advanced Options (%s)", ci->dsn);
222 SetWindowText(hdlg, buf);
226 CheckDlgButton(hdlg, DS_READONLY, atoi(ci->readonly));
229 if (strncmp(ci->protocol, PG62, strlen(PG62)) == 0)
230 CheckDlgButton(hdlg, DS_PG62, 1);
232 CheckDlgButton(hdlg, DS_PG62, 0);
235 CheckDlgButton(hdlg, DS_SHOWOIDCOLUMN, atoi(ci->show_oid_column));
236 CheckDlgButton(hdlg, DS_FAKEOIDINDEX, atoi(ci->fake_oid_index));
237 CheckDlgButton(hdlg, DS_ROWVERSIONING, atoi(ci->row_versioning));
238 CheckDlgButton(hdlg, DS_SHOWSYSTEMTABLES, atoi(ci->show_system_tables));
240 EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), atoi(ci->show_oid_column));
242 /* Datasource Connection Settings */
243 SetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings);
248 switch (GET_WM_COMMAND_ID(wParam, lParam)) {
249 case DS_SHOWOIDCOLUMN:
250 mylog("WM_COMMAND: DS_SHOWOIDCOLUMN\n");
251 EnableWindow(GetDlgItem(hdlg, DS_FAKEOIDINDEX), IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
257 ci = (ConnInfo *)GetWindowLong(hdlg, DWL_USER);
258 mylog("IDOK: got ci = %u\n", ci);
261 sprintf(ci->readonly, "%d", IsDlgButtonChecked(hdlg, DS_READONLY));
264 if ( IsDlgButtonChecked(hdlg, DS_PG62))
265 strcpy(ci->protocol, PG62);
267 ci->protocol[0] = '\0';
271 sprintf(ci->show_system_tables, "%d", IsDlgButtonChecked(hdlg, DS_SHOWSYSTEMTABLES));
273 sprintf(ci->row_versioning, "%d", IsDlgButtonChecked(hdlg, DS_ROWVERSIONING));
276 sprintf(ci->fake_oid_index, "%d", IsDlgButtonChecked(hdlg, DS_FAKEOIDINDEX));
277 sprintf(ci->show_oid_column, "%d", IsDlgButtonChecked(hdlg, DS_SHOWOIDCOLUMN));
279 /* Datasource Connection Settings */
280 GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings));
286 EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
297 makeConnectString(char *connect_string, ConnInfo *ci)
299 char got_dsn = (ci->dsn[0] != '\0');
300 char encoded_conn_settings[LARGE_REGISTRY_LEN];
302 /* fundamental info */
303 sprintf(connect_string, "%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s",
304 got_dsn ? "DSN" : "DRIVER",
305 got_dsn ? ci->dsn : ci->driver,
312 encode(ci->conn_settings, encoded_conn_settings);
315 sprintf(&connect_string[strlen(connect_string)],
316 ";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s",
322 ci->show_system_tables,
323 encoded_conn_settings);
327 copyAttributes(ConnInfo *ci, char *attribute, char *value)
330 if(stricmp(attribute, "DSN") == 0)
331 strcpy(ci->dsn, value);
333 else if(stricmp(attribute, "driver") == 0)
334 strcpy(ci->driver, value);
336 else if(stricmp(attribute, INI_DATABASE) == 0)
337 strcpy(ci->database, value);
339 else if(stricmp(attribute, INI_SERVER) == 0 || stricmp(attribute, "server") == 0)
340 strcpy(ci->server, value);
342 else if(stricmp(attribute, INI_USER) == 0 || stricmp(attribute, "uid") == 0)
343 strcpy(ci->username, value);
345 else if(stricmp(attribute, INI_PASSWORD) == 0 || stricmp(attribute, "pwd") == 0)
346 strcpy(ci->password, value);
348 else if(stricmp(attribute, INI_PORT) == 0)
349 strcpy(ci->port, value);
351 else if (stricmp(attribute, INI_READONLY) == 0)
352 strcpy(ci->readonly, value);
354 else if (stricmp(attribute, INI_PROTOCOL) == 0)
355 strcpy(ci->protocol, value);
357 else if (stricmp(attribute, INI_SHOWOIDCOLUMN) == 0)
358 strcpy(ci->show_oid_column, value);
360 else if (stricmp(attribute, INI_FAKEOIDINDEX) == 0)
361 strcpy(ci->fake_oid_index, value);
363 else if (stricmp(attribute, INI_ROWVERSIONING) == 0)
364 strcpy(ci->row_versioning, value);
366 else if (stricmp(attribute, INI_SHOWSYSTEMTABLES) == 0)
367 strcpy(ci->show_system_tables, value);
369 else if (stricmp(attribute, INI_CONNSETTINGS) == 0) {
370 decode(value, ci->conn_settings);
371 // strcpy(ci->conn_settings, value);
374 mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',readonly='%s',protocol='%s', conn_settings='%s')\n",
388 getDSNdefaults(ConnInfo *ci)
390 if (ci->port[0] == '\0')
391 strcpy(ci->port, DEFAULT_PORT);
393 if (ci->readonly[0] == '\0')
394 sprintf(ci->readonly, "%d", globals.readonly);
396 if (ci->fake_oid_index[0] == '\0')
397 sprintf(ci->fake_oid_index, "%d", DEFAULT_FAKEOIDINDEX);
399 if (ci->show_oid_column[0] == '\0')
400 sprintf(ci->show_oid_column, "%d", DEFAULT_SHOWOIDCOLUMN);
402 if (ci->show_system_tables[0] == '\0')
403 sprintf(ci->show_system_tables, "%d", DEFAULT_SHOWSYSTEMTABLES);
405 if (ci->row_versioning[0] == '\0')
406 sprintf(ci->row_versioning, "%d", DEFAULT_ROWVERSIONING);
411 getDSNinfo(ConnInfo *ci, char overwrite)
414 char encoded_conn_settings[LARGE_REGISTRY_LEN];
416 // If a driver keyword was present, then dont use a DSN and return.
417 // If DSN is null and no driver, then use the default datasource.
418 if ( DSN[0] == '\0') {
419 if ( ci->driver[0] != '\0')
422 strcpy(DSN, INI_DSN);
425 // Proceed with getting info for the given DSN.
427 if ( ci->desc[0] == '\0' || overwrite)
428 SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
430 if ( ci->server[0] == '\0' || overwrite)
431 SQLGetPrivateProfileString(DSN, INI_SERVER, "", ci->server, sizeof(ci->server), ODBC_INI);
433 if ( ci->database[0] == '\0' || overwrite)
434 SQLGetPrivateProfileString(DSN, INI_DATABASE, "", ci->database, sizeof(ci->database), ODBC_INI);
436 if ( ci->username[0] == '\0' || overwrite)
437 SQLGetPrivateProfileString(DSN, INI_USER, "", ci->username, sizeof(ci->username), ODBC_INI);
439 if ( ci->password[0] == '\0' || overwrite)
440 SQLGetPrivateProfileString(DSN, INI_PASSWORD, "", ci->password, sizeof(ci->password), ODBC_INI);
442 if ( ci->port[0] == '\0' || overwrite)
443 SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI);
445 if ( ci->readonly[0] == '\0' || overwrite)
446 SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->readonly, sizeof(ci->readonly), ODBC_INI);
448 if ( ci->show_oid_column[0] == '\0' || overwrite)
449 SQLGetPrivateProfileString(DSN, INI_SHOWOIDCOLUMN, "", ci->show_oid_column, sizeof(ci->show_oid_column), ODBC_INI);
451 if ( ci->fake_oid_index[0] == '\0' || overwrite)
452 SQLGetPrivateProfileString(DSN, INI_FAKEOIDINDEX, "", ci->fake_oid_index, sizeof(ci->fake_oid_index), ODBC_INI);
454 if ( ci->row_versioning[0] == '\0' || overwrite)
455 SQLGetPrivateProfileString(DSN, INI_ROWVERSIONING, "", ci->row_versioning, sizeof(ci->row_versioning), ODBC_INI);
457 if ( ci->show_system_tables[0] == '\0' || overwrite)
458 SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, "", ci->show_system_tables, sizeof(ci->show_system_tables), ODBC_INI);
460 if ( ci->protocol[0] == '\0' || overwrite)
461 SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI);
463 if ( ci->conn_settings[0] == '\0' || overwrite) {
464 SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", encoded_conn_settings, sizeof(encoded_conn_settings), ODBC_INI);
465 decode(encoded_conn_settings, ci->conn_settings);
468 if ( ci->translation_dll[0] == '\0' || overwrite)
469 SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, "", ci->translation_dll, sizeof(ci->translation_dll), ODBC_INI);
471 if ( ci->translation_option[0] == '\0' || overwrite)
472 SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI);
474 qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n",
481 qlog(" readonly='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",
486 ci->show_system_tables);
487 qlog(" conn_settings='%s'\n",
489 qlog(" translation_dll='%s',translation_option='%s'\n",
491 ci->translation_option);
496 /* This is for datasource based options only */
498 writeDSNinfo(ConnInfo *ci)
501 char encoded_conn_settings[LARGE_REGISTRY_LEN];
503 encode(ci->conn_settings, encoded_conn_settings);
505 SQLWritePrivateProfileString(DSN,
510 SQLWritePrivateProfileString(DSN,
515 SQLWritePrivateProfileString(DSN,
520 SQLWritePrivateProfileString(DSN,
525 SQLWritePrivateProfileString(DSN,
530 SQLWritePrivateProfileString(DSN,
535 SQLWritePrivateProfileString(DSN,
540 SQLWritePrivateProfileString(DSN,
545 SQLWritePrivateProfileString(DSN,
550 SQLWritePrivateProfileString(DSN,
555 SQLWritePrivateProfileString(DSN,
556 INI_SHOWSYSTEMTABLES,
557 ci->show_system_tables,
560 SQLWritePrivateProfileString(DSN,
565 SQLWritePrivateProfileString(DSN,
567 encoded_conn_settings,
572 /* This function reads the ODBCINST.INI portion of
573 the registry and gets any driver defaults.
575 void getGlobalDefaults(void)
580 // Fetch Count is stored in driver section
581 SQLGetPrivateProfileString(DBMS_NAME, INI_FETCH, "",
582 temp, sizeof(temp), ODBCINST_INI);
584 globals.fetch_max = atoi(temp);
585 /* sanity check if using cursors */
586 if (globals.fetch_max <= 0)
587 globals.fetch_max = FETCH_MAX;
591 globals.fetch_max = FETCH_MAX;
594 // Socket Buffersize is stored in driver section
595 SQLGetPrivateProfileString(DBMS_NAME, INI_SOCKET, "",
596 temp, sizeof(temp), ODBCINST_INI);
598 globals.socket_buffersize = atoi(temp);
600 globals.socket_buffersize = SOCK_BUFFER_SIZE;
603 // Debug is stored in the driver section
604 SQLGetPrivateProfileString(DBMS_NAME, INI_DEBUG, "0",
605 temp, sizeof(temp), ODBCINST_INI);
606 globals.debug = atoi(temp);
609 // CommLog is stored in the driver section
610 SQLGetPrivateProfileString(DBMS_NAME, INI_COMMLOG, "",
611 temp, sizeof(temp), ODBCINST_INI);
612 if ( temp[0] == '\0')
613 globals.commlog = DEFAULT_COMMLOG;
615 globals.commlog = atoi(temp);
618 // Optimizer is stored in the driver section only
619 SQLGetPrivateProfileString(DBMS_NAME, INI_OPTIMIZER, "",
620 temp, sizeof(temp), ODBCINST_INI);
621 if ( temp[0] == '\0')
622 globals.disable_optimizer = DEFAULT_OPTIMIZER;
624 globals.disable_optimizer = atoi(temp);
627 // Recognize Unique Index is stored in the driver section only
628 SQLGetPrivateProfileString(DBMS_NAME, INI_UNIQUEINDEX, "",
629 temp, sizeof(temp), ODBCINST_INI);
630 if ( temp[0] == '\0')
631 globals.unique_index = DEFAULT_UNIQUEINDEX;
633 globals.unique_index = atoi(temp);
636 // Unknown Sizes is stored in the driver section only
637 SQLGetPrivateProfileString(DBMS_NAME, INI_UNKNOWNSIZES, "",
638 temp, sizeof(temp), ODBCINST_INI);
639 if ( temp[0] == '\0')
640 globals.unknown_sizes = DEFAULT_UNKNOWNSIZES;
642 globals.unknown_sizes = atoi(temp);
645 // Lie about supported functions?
646 SQLGetPrivateProfileString(DBMS_NAME, INI_LIE, "",
647 temp, sizeof(temp), ODBCINST_INI);
648 if ( temp[0] == '\0')
649 globals.lie = DEFAULT_LIE;
651 globals.lie = atoi(temp);
654 SQLGetPrivateProfileString(DBMS_NAME, INI_PARSE, "",
655 temp, sizeof(temp), ODBCINST_INI);
656 if ( temp[0] == '\0')
657 globals.parse = DEFAULT_PARSE;
659 globals.parse = atoi(temp);
661 // Readonly is stored in the driver section AND per datasource
662 SQLGetPrivateProfileString(DBMS_NAME, INI_READONLY, "",
663 temp, sizeof(temp), ODBCINST_INI);
664 if ( temp[0] == '\0')
665 globals.readonly = DEFAULT_READONLY;
667 globals.readonly = atoi(temp);
670 // UseDeclareFetch is stored in the driver section only
671 SQLGetPrivateProfileString(DBMS_NAME, INI_USEDECLAREFETCH, "",
672 temp, sizeof(temp), ODBCINST_INI);
673 if ( temp[0] == '\0')
674 globals.use_declarefetch = DEFAULT_USEDECLAREFETCH;
676 globals.use_declarefetch = atoi(temp);
680 SQLGetPrivateProfileString(DBMS_NAME, INI_MAXVARCHARSIZE, "",
681 temp, sizeof(temp), ODBCINST_INI);
682 if ( temp[0] == '\0')
683 globals.max_varchar_size = MAX_VARCHAR_SIZE;
685 globals.max_varchar_size = atoi(temp);
687 // Max TextField Size
688 SQLGetPrivateProfileString(DBMS_NAME, INI_MAXLONGVARCHARSIZE, "",
689 temp, sizeof(temp), ODBCINST_INI);
690 if ( temp[0] == '\0')
691 globals.max_longvarchar_size = TEXT_FIELD_SIZE;
693 globals.max_longvarchar_size = atoi(temp);
695 // Text As LongVarchar
696 SQLGetPrivateProfileString(DBMS_NAME, INI_TEXTASLONGVARCHAR, "",
697 temp, sizeof(temp), ODBCINST_INI);
698 if ( temp[0] == '\0')
699 globals.text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
701 globals.text_as_longvarchar = atoi(temp);
703 // Unknowns As LongVarchar
704 SQLGetPrivateProfileString(DBMS_NAME, INI_UNKNOWNSASLONGVARCHAR, "",
705 temp, sizeof(temp), ODBCINST_INI);
706 if ( temp[0] == '\0')
707 globals.unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
709 globals.unknowns_as_longvarchar = atoi(temp);
712 SQLGetPrivateProfileString(DBMS_NAME, INI_BOOLSASCHAR, "",
713 temp, sizeof(temp), ODBCINST_INI);
714 if ( temp[0] == '\0')
715 globals.bools_as_char = DEFAULT_BOOLSASCHAR;
717 globals.bools_as_char = atoi(temp);
720 // Extra System Table prefixes
721 SQLGetPrivateProfileString(DBMS_NAME, INI_EXTRASYSTABLEPREFIXES, "@@@",
722 globals.extra_systable_prefixes, sizeof(globals.extra_systable_prefixes), ODBCINST_INI);
723 if ( ! strcmp(globals.extra_systable_prefixes, "@@@")) {
724 strcpy(globals.extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES);
726 mylog("globals.extra_systable_prefixes = '%s'\n", globals.extra_systable_prefixes);
729 // ConnSettings is stored in the driver section and per datasource for override
730 SQLGetPrivateProfileString(DBMS_NAME, INI_CONNSETTINGS, "",
731 globals.conn_settings, sizeof(globals.conn_settings), ODBCINST_INI);
737 /* This function writes any global parameters (that can be manipulated)
738 to the ODBCINST.INI portion of the registry
740 void updateGlobals(void)
744 sprintf(tmp, "%d", globals.fetch_max);
745 SQLWritePrivateProfileString(DBMS_NAME,
746 INI_FETCH, tmp, ODBCINST_INI);
748 sprintf(tmp, "%d", globals.commlog);
749 SQLWritePrivateProfileString(DBMS_NAME,
750 INI_COMMLOG, tmp, ODBCINST_INI);
752 sprintf(tmp, "%d", globals.disable_optimizer);
753 SQLWritePrivateProfileString(DBMS_NAME,
754 INI_OPTIMIZER, tmp, ODBCINST_INI);
756 sprintf(tmp, "%d", globals.unique_index);
757 SQLWritePrivateProfileString(DBMS_NAME,
758 INI_UNIQUEINDEX, tmp, ODBCINST_INI);
760 sprintf(tmp, "%d", globals.readonly);
761 SQLWritePrivateProfileString(DBMS_NAME,
762 INI_READONLY, tmp, ODBCINST_INI);
764 sprintf(tmp, "%d", globals.use_declarefetch);
765 SQLWritePrivateProfileString(DBMS_NAME,
766 INI_USEDECLAREFETCH, tmp, ODBCINST_INI);
768 sprintf(tmp, "%d", globals.unknown_sizes);
769 SQLWritePrivateProfileString(DBMS_NAME,
770 INI_UNKNOWNSIZES, tmp, ODBCINST_INI);
772 sprintf(tmp, "%d", globals.text_as_longvarchar);
773 SQLWritePrivateProfileString(DBMS_NAME,
774 INI_TEXTASLONGVARCHAR, tmp, ODBCINST_INI);
776 sprintf(tmp, "%d", globals.unknowns_as_longvarchar);
777 SQLWritePrivateProfileString(DBMS_NAME,
778 INI_UNKNOWNSASLONGVARCHAR, tmp, ODBCINST_INI);
780 sprintf(tmp, "%d", globals.bools_as_char);
781 SQLWritePrivateProfileString(DBMS_NAME,
782 INI_BOOLSASCHAR, tmp, ODBCINST_INI);
784 sprintf(tmp, "%d", globals.parse);
785 SQLWritePrivateProfileString(DBMS_NAME,
786 INI_PARSE, tmp, ODBCINST_INI);
788 sprintf(tmp, "%d", globals.max_varchar_size);
789 SQLWritePrivateProfileString(DBMS_NAME,
790 INI_MAXVARCHARSIZE, tmp, ODBCINST_INI);
792 sprintf(tmp, "%d", globals.max_longvarchar_size);
793 SQLWritePrivateProfileString(DBMS_NAME,
794 INI_MAXLONGVARCHARSIZE, tmp, ODBCINST_INI);
796 SQLWritePrivateProfileString(DBMS_NAME,
797 INI_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes, ODBCINST_INI);
799 SQLWritePrivateProfileString(DBMS_NAME,
800 INI_CONNSETTINGS, globals.conn_settings, ODBCINST_INI);