📄 dlg_specific.c
字号:
return; else strcpy(DSN, INI_DSN); } // brute-force chop off trailing blanks... while (*(DSN+strlen(DSN)-1) == ' ') *(DSN+strlen(DSN)-1) = '\0'; // Proceed with getting info for the given DSN. if ( ci->desc[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI); if ( ci->server[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_SERVER, "", ci->server, sizeof(ci->server), ODBC_INI); if ( ci->database[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_DATABASE, "", ci->database, sizeof(ci->database), ODBC_INI); if ( ci->username[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_USER, "", ci->username, sizeof(ci->username), ODBC_INI); if ( ci->password[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_PASSWORD, "", ci->password, sizeof(ci->password), ODBC_INI); if ( ci->port[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_PORT, "", ci->port, sizeof(ci->port), ODBC_INI); if ( ci->readonly[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->readonly, sizeof(ci->readonly), ODBC_INI); if ( ci->show_oid_column[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_SHOWOIDCOLUMN, "", ci->show_oid_column, sizeof(ci->show_oid_column), ODBC_INI); if ( ci->fake_oid_index[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_FAKEOIDINDEX, "", ci->fake_oid_index, sizeof(ci->fake_oid_index), ODBC_INI); if ( ci->row_versioning[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_ROWVERSIONING, "", ci->row_versioning, sizeof(ci->row_versioning), ODBC_INI); if ( ci->show_system_tables[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, "", ci->show_system_tables, sizeof(ci->show_system_tables), ODBC_INI); if ( ci->protocol[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI); if ( ci->conn_settings[0] == '\0' || overwrite) { SQLGetPrivateProfileString(DSN, INI_CONNSETTINGS, "", encoded_conn_settings, sizeof(encoded_conn_settings), ODBC_INI); decode(encoded_conn_settings, ci->conn_settings); } if ( ci->translation_dll[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_TRANSLATIONDLL, "", ci->translation_dll, sizeof(ci->translation_dll), ODBC_INI); if ( ci->translation_option[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_TRANSLATIONOPTION, "", ci->translation_option, sizeof(ci->translation_option), ODBC_INI); /* Allow override of odbcinst.ini parameters here */ getGlobalDefaults(DSN, ODBC_INI, TRUE); qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n", DSN, ci->server, ci->port, ci->database, ci->username, ci->password); qlog(" readonly='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n", ci->readonly, ci->protocol, ci->show_oid_column, ci->fake_oid_index, ci->show_system_tables); qlog(" conn_settings='%s'\n", ci->conn_settings); qlog(" translation_dll='%s',translation_option='%s'\n", ci->translation_dll, ci->translation_option);}/* This is for datasource based options only */voidwriteDSNinfo(ConnInfo *ci){char *DSN = ci->dsn;char encoded_conn_settings[LARGE_REGISTRY_LEN]; encode(ci->conn_settings, encoded_conn_settings); SQLWritePrivateProfileString(DSN, INI_KDESC, ci->desc, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_DATABASE, ci->database, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SERVER, ci->server, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_PORT, ci->port, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_USER, ci->username, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_PASSWORD, ci->password, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_READONLY, ci->readonly, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SHOWOIDCOLUMN, ci->show_oid_column, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_FAKEOIDINDEX, ci->fake_oid_index, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_ROWVERSIONING, ci->row_versioning, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_SHOWSYSTEMTABLES, ci->show_system_tables, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_PROTOCOL, ci->protocol, ODBC_INI); SQLWritePrivateProfileString(DSN, INI_CONNSETTINGS, encoded_conn_settings, ODBC_INI);}/* This function reads the ODBCINST.INI portion of the registry and gets any driver defaults.*/void getGlobalDefaults(char *section, char *filename, char override){char temp[256]; // Fetch Count is stored in driver section SQLGetPrivateProfileString(section, INI_FETCH, "", temp, sizeof(temp), filename); if ( temp[0] ) { globals.fetch_max = atoi(temp); /* sanity check if using cursors */ if (globals.fetch_max <= 0) globals.fetch_max = FETCH_MAX; } else if ( ! override) globals.fetch_max = FETCH_MAX; // Socket Buffersize is stored in driver section SQLGetPrivateProfileString(section, INI_SOCKET, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.socket_buffersize = atoi(temp); else if ( ! override) globals.socket_buffersize = SOCK_BUFFER_SIZE; // Debug is stored in the driver section SQLGetPrivateProfileString(section, INI_DEBUG, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.debug = atoi(temp); else if ( ! override) globals.debug = DEFAULT_DEBUG; // CommLog is stored in the driver section SQLGetPrivateProfileString(section, INI_COMMLOG, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.commlog = atoi(temp); else if ( ! override) globals.commlog = DEFAULT_COMMLOG; // Optimizer is stored in the driver section only SQLGetPrivateProfileString(section, INI_OPTIMIZER, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.disable_optimizer = atoi(temp); else if ( ! override) globals.disable_optimizer = DEFAULT_OPTIMIZER; // KSQO is stored in the driver section only SQLGetPrivateProfileString(section, INI_KSQO, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.ksqo = atoi(temp); else if ( ! override) globals.ksqo = DEFAULT_KSQO; // Recognize Unique Index is stored in the driver section only SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.unique_index = atoi(temp); else if ( ! override) globals.unique_index = DEFAULT_UNIQUEINDEX; // Unknown Sizes is stored in the driver section only SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.unknown_sizes = atoi(temp); else if ( ! override) globals.unknown_sizes = DEFAULT_UNKNOWNSIZES; // Lie about supported functions? SQLGetPrivateProfileString(section, INI_LIE, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.lie = atoi(temp); else if ( ! override) globals.lie = DEFAULT_LIE; // Parse statements SQLGetPrivateProfileString(section, INI_PARSE, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.parse = atoi(temp); else if ( ! override) globals.parse = DEFAULT_PARSE; // SQLCancel calls SQLFreeStmt in Driver Manager SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.cancel_as_freestmt = atoi(temp); else if ( ! override) globals.cancel_as_freestmt = DEFAULT_CANCELASFREESTMT; // UseDeclareFetch is stored in the driver section only SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.use_declarefetch = atoi(temp); else if ( ! override) globals.use_declarefetch = DEFAULT_USEDECLAREFETCH; // Max Varchar Size SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.max_varchar_size = atoi(temp); else if ( ! override) globals.max_varchar_size = MAX_VARCHAR_SIZE; // Max TextField Size SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.max_longvarchar_size = atoi(temp); else if ( ! override) globals.max_longvarchar_size = TEXT_FIELD_SIZE; // Text As LongVarchar SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.text_as_longvarchar = atoi(temp); else if ( ! override) globals.text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR; // Unknowns As LongVarchar SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.unknowns_as_longvarchar = atoi(temp); else if ( ! override) globals.unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR; // Bools As Char SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.bools_as_char = atoi(temp); else if ( ! override) globals.bools_as_char = DEFAULT_BOOLSASCHAR; // Extra Systable prefixes // Use @@@ to distinguish between blank extra prefixes and no key entry SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@", temp, sizeof(temp), filename); if ( strcmp(temp, "@@@" )) strcpy(globals.extra_systable_prefixes, temp); else if ( ! override) strcpy(globals.extra_systable_prefixes, DEFAULT_EXTRASYSTABLEPREFIXES); mylog("globals.extra_systable_prefixes = '%s'\n", globals.extra_systable_prefixes); // Dont allow override of an override! if ( ! override) { // ConnSettings is stored in the driver section and per datasource for override SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "", globals.conn_settings, sizeof(globals.conn_settings), filename); // Default state for future DSN's Readonly attribute SQLGetPrivateProfileString(section, INI_READONLY, "", temp, sizeof(temp), filename); if ( temp[0] ) globals.readonly = atoi(temp); else globals.readonly = DEFAULT_READONLY; /* Default state for future DSN's protocol attribute This isn't a real driver option YET. This is more intended for customization from the install. */ SQLGetPrivateProfileString(section, INI_PROTOCOL, "@@@", temp, sizeof(temp), filename); if ( strcmp(temp, "@@@" )) strcpy(globals.protocol, temp); else strcpy(globals.protocol, DEFAULT_PROTOCOL); }}/* This function writes any global parameters (that can be manipulated) to the ODBCINST.INI portion of the registry */void updateGlobals(void){char tmp[128]; sprintf(tmp, "%d", globals.fetch_max); SQLWritePrivateProfileString(DBMS_NAME, INI_FETCH, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.commlog); SQLWritePrivateProfileString(DBMS_NAME, INI_COMMLOG, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.disable_optimizer); SQLWritePrivateProfileString(DBMS_NAME, INI_OPTIMIZER, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.ksqo); SQLWritePrivateProfileString(DBMS_NAME, INI_KSQO, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.unique_index); SQLWritePrivateProfileString(DBMS_NAME, INI_UNIQUEINDEX, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.readonly); SQLWritePrivateProfileString(DBMS_NAME, INI_READONLY, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.use_declarefetch); SQLWritePrivateProfileString(DBMS_NAME, INI_USEDECLAREFETCH, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.unknown_sizes); SQLWritePrivateProfileString(DBMS_NAME, INI_UNKNOWNSIZES, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.text_as_longvarchar); SQLWritePrivateProfileString(DBMS_NAME, INI_TEXTASLONGVARCHAR, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.unknowns_as_longvarchar); SQLWritePrivateProfileString(DBMS_NAME, INI_UNKNOWNSASLONGVARCHAR, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.bools_as_char); SQLWritePrivateProfileString(DBMS_NAME, INI_BOOLSASCHAR, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.parse); SQLWritePrivateProfileString(DBMS_NAME, INI_PARSE, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.cancel_as_freestmt); SQLWritePrivateProfileString(DBMS_NAME, INI_CANCELASFREESTMT, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.max_varchar_size); SQLWritePrivateProfileString(DBMS_NAME, INI_MAXVARCHARSIZE, tmp, ODBCINST_INI); sprintf(tmp, "%d", globals.max_longvarchar_size); SQLWritePrivateProfileString(DBMS_NAME, INI_MAXLONGVARCHARSIZE, tmp, ODBCINST_INI); SQLWritePrivateProfileString(DBMS_NAME, INI_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes, ODBCINST_INI); SQLWritePrivateProfileString(DBMS_NAME, INI_CONNSETTINGS, globals.conn_settings, ODBCINST_INI);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -