CDrvrGlobal::CDrvrGlobal() : gOdbcMsg(DRVRMSG_DLL) { OSVERSIONINFO VersionInformation; void *pVersionInfo; VS_FIXEDFILEINFO *pInfo; UINT wInfoLen; DWORD dwVersionInfoSz; DWORD hFile; unsigned long len; WORD* langInfo; UINT cbLang; TCHAR tszVerStrName[128]; LPVOID lpt; InitializeCriticalSection(&gCSObject); InitializeCriticalSection(&gHandleCSObject); InitializeCriticalSection(&gCollectionCSObject); strcpy(gCapsuleName, "TRAF ODBC Driver"); len = sizeof(gComputerName); if (GetComputerName(gComputerName, &len) == 0) strcpy(gComputerName, "UNKNOWN"); gProcessId = GetCurrentProcessId(); //referer to the enum cnv_charset in csconvert.h //TranslateOption <4bytes from charset,4 bytes to charset> gUTF8_To_UTF16_TranslateOption = ((DWORD)0x00010002L); gUTF16_To_UTF8_TranslateOption = ((DWORD)0x00020001L); VersionInformation.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); if (GetVersionEx( &VersionInformation ) == 0) { gPlatformId = 0; gMinorVersion = 0; } else { gPlatformId = VersionInformation.dwPlatformId; gMinorVersion = VersionInformation.dwMinorVersion; } gClientVersion.componentId = 0; // Unknown strcpy(gDriverDLLName, DRIVER_DLL_NAME); if ((gModuleHandle = GetModuleHandle(DRIVER_DLL_NAME)) != NULL) { if (GetModuleFileName(gModuleHandle, gDriverDLLName, sizeof(gDriverDLLName))) { if ((dwVersionInfoSz = GetFileVersionInfoSize(gDriverDLLName, &hFile)) != 0) { pVersionInfo = (void *)new char[dwVersionInfoSz]; if (GetFileVersionInfo(gDriverDLLName, hFile, dwVersionInfoSz, (LPVOID)pVersionInfo) && VerQueryValue((LPVOID)pVersionInfo, "\\",(LPVOID *)&pInfo, &wInfoLen) ) { gClientVersion.componentId = WIN_UNICODE_DRVR_COMPONENT; gClientVersion.majorVersion = HIWORD(pInfo->dwProductVersionMS); gClientVersion.minorVersion = LOWORD(pInfo->dwProductVersionMS); gClientVersion.buildId = LOWORD(pInfo->dwFileVersionLS); // Get the vproc in the Comments field strncpy(gClientVproc, VprocString, sizeof(gClientVproc)-1); gClientVproc[sizeof(gClientVproc)-1] = '\0'; } delete[] pVersionInfo; } } } if (gClientVersion.componentId == 0) { gClientVersion.componentId = DRVR_COMPONENT; gClientVersion.majorVersion = 3; gClientVersion.minorVersion = 51; gClientVersion.buildId = 0; } gCEEInitialized = FALSE; gCEESyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL); gCEEExecuteThread = NULL; gDefaultTxnIsolation = SQL_TXN_READ_COMMITTED; gWaitCursor = LoadCursor(NULL, IDC_WAIT); gCEEMessageFilter = TRUE; ghWindow = NULL; gSpecial_1 = false; loadTransportAndTranslateDll(); SecurityInitialize(); noSchemaInDSN = false; // Assume that DSN has a schema value char envValue[STRICT_SCHEMA_ENV_VAL_SIZE]; size_t valueSize = STRICT_SCHEMA_ENV_VAL_SIZE ; size_t returnLen=0 ; RestrictSchema = false; if (getenv_s(&returnLen, envValue, valueSize, "TRAFODBC-SQLTABLES-RESTRICT-DSNSCHEMA") == 0) //success if(returnLen != 0) RestrictSchema = true; #ifdef TRACE_COMPRESSION char *envTraceCompression=NULL; gTraceCompression=false; if( (envTraceCompression = getenv("TRAFODBC_TRACE_COMPRESSION")) != NULL) { if(strcmp(envTraceCompression,"1")==0) { gTraceCompression=true; } } #endif }
CDrvrGlobal::CDrvrGlobal()// : gOdbcMsg(DRVRMSG_DLL) { char *envDisablePreFetch = getenv("HPODBC_DISABLE_PREFETCH"); if(envDisablePreFetch != NULL && (strcmp(envDisablePreFetch,"1") == 0)) gDisablePreFetch = true; else gDisablePreFetch = false; #ifdef TRACE_COMPRESSION char *envTraceCompression=NULL; gTraceCompression=false; if( (envTraceCompression = getenv("TRAFODBC_TRACE_COMPRESSION")) != NULL) { if(strcmp(envTraceCompression,"1")==0) { gTraceCompression=true; } } #endif InitializeCriticalSection(&gCSObject); InitializeCriticalSection(&gHandleCSObject); struct sigaction SigTermActionHandler; sigaction(SIGTERM,NULL,&SigTermActionHandler); if(SigTermActionHandler.sa_handler == SIG_DFL) { /* If the application has not arm'ed a handler for SIGTERM, then we'll setup a trap handler for that so that we can call SQLCancel on all the queries that are still running. Otherwise it is the application's responsibility to call SQLCancel() from their SIGTERM handler */ SigTermActionHandler.sa_handler = ODBC_SIGTERM_handler; sigaction(SIGTERM,&SigTermActionHandler,&gOldSigTermActionHandler); } strcpy(gCapsuleName, "TRAF ODBC Driver"); strcpy(gProcName, "$ZTCP0"); #ifdef MXAIX // AIX behaves a bit differently. On other unix systems when libhpodbc.so exports SQLGetPrivateProfileString, // a call to dlsym can get the address of the function. On AIX it does not unless we do an explicit dlopen void *phandle = dlopen(0,RTLD_LAZY|RTLD_GLOBAL); #endif // for some unknown reason fpSQLGetPrivateProfileString = (FPSQLGetPrivateProfileString) SQLGetPrivateProfileString // does not work for the Informatica/DataDirect/libhpodbc_drvr.so combination // (perhaps its because this is an unresolved reference - but it does not explain the fact that it works from // a stand alone application like our connect_test.cpp/DataDirect/libhpodbc_drvr combintation // fpSQLGetPrivateProfileString = (FPSQLGetPrivateProfileString) SQLGetPrivateProfileString; #if defined(MXHPUX) && !defined(MXOSS) || defined(MXSUNSPARC) fpSQLGetPrivateProfileString = (FPSQLGetPrivateProfileString) dlsym(RTLD_SELF,"SQLGetPrivateProfileString"); #elif defined(MXOSS) // OSS did not implement psedo handle so we must use dlHandle dlhdl_search = dlopen(0,RTLD_LAZY|RTLD_GLOBAL); if(dlhdl_search != NULL) fpSQLGetPrivateProfileString = (FPSQLGetPrivateProfileString) dlsym(dlhdl_search,"SQLGetPrivateProfileString"); #else fpSQLGetPrivateProfileString = (FPSQLGetPrivateProfileString) dlsym(RTLD_DEFAULT,"SQLGetPrivateProfileString"); #endif #ifndef MXOSS if(fpSQLGetPrivateProfileString == NULL) { #if defined(MXHPUXPA) dlhdl_odbcinst = dlopen("libodbcinst.sl",RTLD_LAZY|RTLD_GLOBAL); #else dlhdl_odbcinst = dlopen("libodbcinst.so",RTLD_LAZY|RTLD_GLOBAL); #endif if(dlhdl_odbcinst != NULL) fpSQLGetPrivateProfileString = (FPSQLGetPrivateProfileString) dlsym(RTLD_DEFAULT,"SQLGetPrivateProfileString"); } #endif #ifdef MXOSS dlclose(dlhdl_search); #endif #ifdef MXAIX dlclose(phandle); #endif if (gClientVersion.componentId == 0) { #ifdef MXHPUX gClientVersion.componentId = HPUX_DRVR_COMPONENT; #elif MXSUNSPARC #ifdef __LP64__ gClientVersion.componentId = SUNSPARC64_DRVR_COMPONENT; #else gClientVersion.componentId = SUNSPARC32_DRVR_COMPONENT; #endif #elif MXAIX gClientVersion.componentId = AIX_DRVR_COMPONENT; #elif unixcli gClientVersion.componentId = LINUX_DRVR_COMPONENT; #else gClientVersion.componentId = DRVR_COMPONENT; #endif gClientVersion.majorVersion = 3; gClientVersion.minorVersion = 0; gClientVersion.buildId = 0; strcpy(gClientVproc, versionString); //strcpy(gClientVproc,"T0775N29_SQ"); } // gCEEInitialized = FALSE; // gCEESyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL); // gCEEExecuteThread = NULL; gDefaultTxnIsolation = SQL_TXN_READ_COMMITTED; // gWaitCursor = LoadCursor(NULL, IDC_WAIT); #ifdef OSS_PTHREAD #ifdef OSS_DRIVER gMutex.field1 = (void*)-1; gMutex.field2 = -1; gMutex.field3 = -1; pthread_mutex_init(&gMutex, NULL); #endif #endif gSpecial_1 = false; // default is false. CQD // has to be set to be in special mode #ifndef MXOSS SecurityInitialize(); #endif }