⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlg_specific.c

📁 postgresql-odbc,跨平台应用
💻 C
📖 第 1 页 / 共 3 页
字号:
	else if (stricmp(attribute, INI_ROWVERSIONING) == 0 || stricmp(attribute, ABBR_ROWVERSIONING) == 0)		strcpy(ci->row_versioning, value);	else if (stricmp(attribute, INI_SHOWSYSTEMTABLES) == 0 || stricmp(attribute, ABBR_SHOWSYSTEMTABLES) == 0)		strcpy(ci->show_system_tables, value);	else if (stricmp(attribute, INI_CONNSETTINGS) == 0 || stricmp(attribute, ABBR_CONNSETTINGS) == 0)	{		decode(value, ci->conn_settings);		/* strcpy(ci->conn_settings, value); */	}	else if (stricmp(attribute, INI_DISALLOWPREMATURE) == 0 || stricmp(attribute, ABBR_DISALLOWPREMATURE) == 0)		ci->disallow_premature = atoi(value);	else if (stricmp(attribute, INI_UPDATABLECURSORS) == 0 || stricmp(attribute, ABBR_UPDATABLECURSORS) == 0)		ci->allow_keyset = atoi(value);	else if (stricmp(attribute, INI_LFCONVERSION) == 0 || stricmp(attribute, ABBR_LFCONVERSION) == 0)		ci->lf_conversion = atoi(value);	else if (stricmp(attribute, INI_TRUEISMINUS1) == 0 || stricmp(attribute, ABBR_TRUEISMINUS1) == 0)		ci->true_is_minus1 = atoi(value);	else if (stricmp(attribute, INI_INT8AS) == 0)		ci->int8_as = atoi(value);	else if (stricmp(attribute, INI_BYTEAASLONGVARBINARY) == 0 || stricmp(attribute, ABBR_BYTEAASLONGVARBINARY) == 0)		ci->bytea_as_longvarbinary = atoi(value);	else if (stricmp(attribute, INI_USESERVERSIDEPREPARE) == 0 || stricmp(attribute, ABBR_USESERVERSIDEPREPARE) == 0)		ci->use_server_side_prepare = atoi(value);	else if (stricmp(attribute, INI_LOWERCASEIDENTIFIER) == 0 || stricmp(attribute, ABBR_LOWERCASEIDENTIFIER) == 0)		ci->lower_case_identifier = atoi(value);	else if (stricmp(attribute, INI_SSLMODE) == 0 || stricmp(attribute, ABBR_SSLMODE) == 0)	{		switch (value[0])		{			case 'a':				strcpy(ci->sslmode, SSLMODE_ALLOW);				break;			case 'p':				strcpy(ci->sslmode, SSLMODE_PREFER);				break;			case 'r':				strcpy(ci->sslmode, SSLMODE_REQUIRE);				break;			case 'd':			default:				strcpy(ci->sslmode, SSLMODE_DISABLE);				break;		}	}	else if (stricmp(attribute, INI_ABBREVIATE) == 0)		unfoldCXAttribute(ci, value);#ifdef	_HANDLE_ENLIST_IN_DTC_	else if (stricmp(attribute, INI_XAOPT) == 0)		ci->xa_opt = atoi(value);#endif /* _HANDLE_ENLIST_IN_DTC_ */	else if (stricmp(attribute, INI_EXTRAOPTIONS) == 0)	{		UInt4	val1 = 0, val2 = 0;			if ('+' == value[0])		{			sscanf(value + 1, "%x-%x", &val1, &val2);			add_removeExtraOptions(ci, val1, val2);		}		else if ('-' == value[0])		{			sscanf(value + 1, "%x", &val2);			add_removeExtraOptions(ci, 0, val2);		}		else		{			setExtraOptions(ci, value, hex_format);		}		mylog("force_abbrev=%d bde=%d cvt_null_date=%x\n", ci->force_abbrev_connstr, ci->bde_environment, ci->cvt_null_date_string);	}	else		found = FALSE;	mylog("%s: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", func, ci->dsn, ci->server, ci->database, ci->username, ci->password ? "xxxxx" : "", ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature);	return found;}BOOLcopyCommonAttributes(ConnInfo *ci, const char *attribute, const char *value){	CSTR	func = "copyCommonAttributes";	BOOL	found = TRUE;	if (stricmp(attribute, INI_FETCH) == 0 || stricmp(attribute, ABBR_FETCH) == 0)		ci->drivers.fetch_max = atoi(value);	else if (stricmp(attribute, INI_SOCKET) == 0 || stricmp(attribute, ABBR_SOCKET) == 0)		ci->drivers.socket_buffersize = atoi(value);	else if (stricmp(attribute, INI_DEBUG) == 0 || stricmp(attribute, ABBR_DEBUG) == 0)		ci->drivers.debug = atoi(value);	else if (stricmp(attribute, INI_COMMLOG) == 0 || stricmp(attribute, ABBR_COMMLOG) == 0)		ci->drivers.commlog = atoi(value);	else if (stricmp(attribute, INI_OPTIMIZER) == 0 || stricmp(attribute, ABBR_OPTIMIZER) == 0)		ci->drivers.disable_optimizer = atoi(value);	else if (stricmp(attribute, INI_KSQO) == 0 || stricmp(attribute, ABBR_KSQO) == 0)		ci->drivers.ksqo = atoi(value);	/*	 * else if (stricmp(attribute, INI_UNIQUEINDEX) == 0 ||	 * stricmp(attribute, "UIX") == 0) ci->drivers.unique_index =	 * atoi(value);	 */	else if (stricmp(attribute, INI_UNKNOWNSIZES) == 0 || stricmp(attribute, ABBR_UNKNOWNSIZES) == 0)		ci->drivers.unknown_sizes = atoi(value);	else if (stricmp(attribute, INI_LIE) == 0)		ci->drivers.lie = atoi(value);	else if (stricmp(attribute, INI_PARSE) == 0 || stricmp(attribute, ABBR_PARSE) == 0)		ci->drivers.parse = atoi(value);	else if (stricmp(attribute, INI_CANCELASFREESTMT) == 0 || stricmp(attribute, ABBR_CANCELASFREESTMT) == 0)		ci->drivers.cancel_as_freestmt = atoi(value);	else if (stricmp(attribute, INI_USEDECLAREFETCH) == 0 || stricmp(attribute, ABBR_USEDECLAREFETCH) == 0)		ci->drivers.use_declarefetch = atoi(value);	else if (stricmp(attribute, INI_MAXVARCHARSIZE) == 0 || stricmp(attribute, ABBR_MAXVARCHARSIZE) == 0)		ci->drivers.max_varchar_size = atoi(value);	else if (stricmp(attribute, INI_MAXLONGVARCHARSIZE) == 0 || stricmp(attribute, ABBR_MAXLONGVARCHARSIZE) == 0)		ci->drivers.max_longvarchar_size = atoi(value);	else if (stricmp(attribute, INI_TEXTASLONGVARCHAR) == 0 || stricmp(attribute, ABBR_TEXTASLONGVARCHAR) == 0)		ci->drivers.text_as_longvarchar = atoi(value);	else if (stricmp(attribute, INI_UNKNOWNSASLONGVARCHAR) == 0 || stricmp(attribute, ABBR_UNKNOWNSASLONGVARCHAR) == 0)		ci->drivers.unknowns_as_longvarchar = atoi(value);	else if (stricmp(attribute, INI_BOOLSASCHAR) == 0 || stricmp(attribute, ABBR_BOOLSASCHAR) == 0)		ci->drivers.bools_as_char = atoi(value);	else if (stricmp(attribute, INI_EXTRASYSTABLEPREFIXES) == 0 || stricmp(attribute, ABBR_EXTRASYSTABLEPREFIXES) == 0)		strcpy(ci->drivers.extra_systable_prefixes, value);	else		found = FALSE;	mylog("%s: 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", func,		  ci->drivers.fetch_max,		  ci->drivers.socket_buffersize,		  ci->drivers.unknown_sizes,		  ci->drivers.max_varchar_size,		  ci->drivers.max_longvarchar_size,		  ci->drivers.debug,		  ci->drivers.commlog,		  ci->drivers.disable_optimizer,		  ci->drivers.ksqo,		  ci->drivers.use_declarefetch,		  ci->drivers.text_as_longvarchar,		  ci->drivers.unknowns_as_longvarchar,		  ci->drivers.bools_as_char,		  ci->drivers.parse,		  ci->drivers.cancel_as_freestmt,		  ci->drivers.extra_systable_prefixes);	return found;}voidgetDSNdefaults(ConnInfo *ci){	mylog("calling getDSNdefaults\n");	if (ci->port[0] == '\0')		strcpy(ci->port, DEFAULT_PORT);	if (ci->onlyread[0] == '\0')		sprintf(ci->onlyread, "%d", globals.onlyread);	if (ci->protocol[0] == '\0')		strcpy(ci->protocol, globals.protocol);	if (ci->fake_oid_index[0] == '\0')		sprintf(ci->fake_oid_index, "%d", DEFAULT_FAKEOIDINDEX);	if (ci->show_oid_column[0] == '\0')		sprintf(ci->show_oid_column, "%d", DEFAULT_SHOWOIDCOLUMN);	if (ci->show_system_tables[0] == '\0')		sprintf(ci->show_system_tables, "%d", DEFAULT_SHOWSYSTEMTABLES);	if (ci->row_versioning[0] == '\0')		sprintf(ci->row_versioning, "%d", DEFAULT_ROWVERSIONING);	if (ci->disallow_premature < 0)		ci->disallow_premature = DEFAULT_DISALLOWPREMATURE;	if (ci->allow_keyset < 0)		ci->allow_keyset = DEFAULT_UPDATABLECURSORS;	if (ci->lf_conversion < 0)		ci->lf_conversion = DEFAULT_LFCONVERSION;	if (ci->true_is_minus1 < 0)		ci->true_is_minus1 = DEFAULT_TRUEISMINUS1;	if (ci->int8_as < -100)		ci->int8_as = DEFAULT_INT8AS;	if (ci->bytea_as_longvarbinary < 0)		ci->bytea_as_longvarbinary = DEFAULT_BYTEAASLONGVARBINARY;	if (ci->use_server_side_prepare < 0)		ci->use_server_side_prepare = DEFAULT_USESERVERSIDEPREPARE;	if (ci->lower_case_identifier < 0)		ci->lower_case_identifier = DEFAULT_LOWERCASEIDENTIFIER;	if (ci->sslmode[0] == '\0')		strcpy(ci->sslmode, DEFAULT_SSLMODE);	if (ci->force_abbrev_connstr < 0)		ci->force_abbrev_connstr = 0;	if (ci->fake_mss < 0)		ci->fake_mss = 0;	if (ci->bde_environment < 0)		ci->bde_environment = 0;	if (ci->cvt_null_date_string < 0)		ci->cvt_null_date_string = 0;#ifdef	_HANDLE_ENLIST_IN_DTC_	if (ci->xa_opt < 0)		ci->xa_opt = DEFAULT_XAOPT;#endif /* _HANDLE_ENLIST_IN_DTC_ */}intgetDriverNameFromDSN(const char *dsn, char *driver_name, int namelen){	return SQLGetPrivateProfileString(ODBC_DATASOURCES, dsn, "", driver_name, namelen, ODBC_INI);}voidgetDSNinfo(ConnInfo *ci, char overwrite){	CSTR	func = "getDSNinfo";	char	   *DSN = ci->dsn;	char		encoded_conn_settings[LARGE_REGISTRY_LEN],				temp[SMALL_REGISTRY_LEN];/* *	If a driver keyword was present, then dont use a DSN and return. *	If DSN is null and no driver, then use the default datasource. */	mylog("%s: DSN=%s overwrite=%d\n", func, DSN, overwrite);	if (DSN[0] == '\0')	{		if (ci->drivername[0] != '\0')			return;		else			strncpy_null(DSN, INI_DSN, sizeof(ci->dsn));	}	/* brute-force chop off trailing blanks... */	while (*(DSN + strlen(DSN) - 1) == ' ')		*(DSN + strlen(DSN) - 1) = '\0';	if (ci->drivername[0] == '\0' || overwrite)	{		getDriverNameFromDSN(DSN, ci->drivername, sizeof(ci->drivername));		if (ci->drivername[0] && stricmp(ci->drivername, DBMS_NAME))			getCommonDefaults(ci->drivername, ODBCINST_INI, ci);	}	/* 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->onlyread[0] == '\0' || overwrite)		SQLGetPrivateProfileString(DSN, INI_READONLY, "", ci->onlyread, sizeof(ci->onlyread), 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)	{		char	*ptr;		SQLGetPrivateProfileString(DSN, INI_PROTOCOL, "", ci->protocol, sizeof(ci->protocol), ODBC_INI);		if (ptr = strchr(ci->protocol, '-'), NULL != ptr)		{			*ptr = '\0';			if (overwrite || ci->rollback_on_error < 0)			{				ci->rollback_on_error = atoi(ptr + 1);				mylog("rollback_on_error=%d\n", ci->rollback_on_error);			}		}	}	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);	if (ci->disallow_premature < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_DISALLOWPREMATURE, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->disallow_premature = atoi(temp);	}	if (ci->allow_keyset < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_UPDATABLECURSORS, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->allow_keyset = atoi(temp);	}	if (ci->lf_conversion < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_LFCONVERSION, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->lf_conversion = atoi(temp);	}	if (ci->true_is_minus1 < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_TRUEISMINUS1, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->true_is_minus1 = atoi(temp);	}	if (ci->int8_as < -100 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_INT8AS, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->int8_as = atoi(temp);	}	if (ci->bytea_as_longvarbinary < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_BYTEAASLONGVARBINARY, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->bytea_as_longvarbinary = atoi(temp);	}	if (ci->use_server_side_prepare < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_USESERVERSIDEPREPARE, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->use_server_side_prepare = atoi(temp);	}	if (ci->lower_case_identifier < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_LOWERCASEIDENTIFIER, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->lower_case_identifier = atoi(temp);	}	if (ci->sslmode[0] == '\0' || overwrite)		SQLGetPrivateProfileString(DSN, INI_SSLMODE, "", ci->sslmode, sizeof(ci->sslmode), ODBC_INI);#ifdef	_HANDLE_ENLIST_IN_DTC_	if (ci->xa_opt < 0 || overwrite)	{		SQLGetPrivateProfileString(DSN, INI_XAOPT, "", temp, sizeof(temp), ODBC_INI);		if (temp[0])			ci->xa_opt = atoi(temp);	}#endif /* _HANDLE_ENLIST_IN_DTC_ */	/* Force abbrev connstr or bde */	SQLGetPrivateProfileString(DSN, INI_EXTRAOPTIONS, "",					temp, sizeof(temp), ODBC_INI);	if (temp[0])	{		UInt4	val = 0;		sscanf(temp, "%x", &val);		replaceExtraOptions(ci, val, overwrite);		mylog("force_abbrev=%d bde=%d cvt_null_date=%d\n", ci->force_abbrev_connstr, ci->bde_environment, ci->cvt_null_date_string);	}	/* Allow override of odbcinst.ini parameters here */	getCommonDefaults(DSN, ODBC_INI, ci);	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 ? "xxxxx" : "");	qlog("          onlyread='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n",		 ci->onlyread,		 ci->protocol,		 ci->show_oid_column,		 ci->fake_oid_index,		 ci->show_system_tables);	if (get_qlog())	{		UCHAR	*enc = check_client_encoding(ci->conn_settings);		qlog("          conn_settings='%s',conn_encoding='%s'\n",		 	ci->conn_settings, enc ? enc : "(null)");		if (enc)			free(enc);		qlog("          translation_dll='%s',translation_option='%s'\n",		 	ci->translation_dll,		 	ci->translation_option);	}}/* *	This function writes any global parameters (that can be manipulated) *	to the ODBCINST.INI portion of the registry */intwriteDriverCommoninfo(const char *fileName, const char *sectionName,			 const GLOBAL_VALUES *comval){	char		tmp[128];	int		errc = 0;	if (ODBCINST_INI == fileName && NULL == sectionName)		sectionName = DBMS_NAME; 	sprintf(tmp, "%d", comval->commlog);	if (!SQLWritePrivateProfileString(sectionName, INI_COMMLOG, tmp, fileName))		errc--;	sprintf(tmp, "%d", comval->debug);	if (!SQLWritePrivateProfileString(sectionName, INI_DEBUG, tmp, fileName))		errc--;	sprintf(tmp, "%d", comval->fetch_max);	if (!SQLWritePrivateProfileString(sectionName, INI_FETCH, tmp, fileName))		errc--;	if (stricmp(ODBCINST_INI, fileName) == 0)		return errc;	sprintf(tmp, "%d", comval->fetch_max);	if (!SQLWritePrivateProfileString(sectionName, INI_FETCH, tmp, fileName))		errc--;	sprintf(tmp, "%d", comval->disable_optimizer);	if (!SQLWritePrivateProfileString(sectionName, INI_OPTIMIZER, tmp, fileName))		errc--;	sprintf(tmp, "%d", comval->ksqo);	if (!SQLWritePrivateProfileString(sectionName, INI_KSQO, tmp, fileName))		errc--;	sprintf(tmp, "%d", comval->unique_index);	if (!SQLWritePrivateProfileString(sectionName, INI_UNIQUEINDEX, tmp, fileName))		errc--;	/*	 * Never update the onlyread from this module.	 */	if (stricmp(ODBCINST_INI, fileName) == 0)	{		sprintf(tmp, "%d", comval->onlyread);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -