Modified:
branches/feature-linux-port/Driver/Driver/Library/Library.pro
branches/feature-linux-port/Driver/Driver/Library/MYODBCDriverMain.cpp
branches/feature-linux-port/SDK/Installer/Library/MYODBCInsDataSource.cpp
branches/feature-linux-port/config.pri
Log:
added init/deinit tracing functions
small portability fix
Modified: branches/feature-linux-port/Driver/Driver/Library/Library.pro
===================================================================
--- branches/feature-linux-port/Driver/Driver/Library/Library.pro 2006-12-19 16:22:44 UTC
(rev 755)
+++ branches/feature-linux-port/Driver/Driver/Library/Library.pro 2006-12-20 04:03:19 UTC
(rev 756)
@@ -40,8 +40,6 @@
RC_FILE = MYODBCDriver.rc
libraries.path = /windows/system32
libraries.files = MYODBCDriver5.dll
-
- SOURCES = MYODBCDriverMain.cpp
}
win32-msvc2005 {
@@ -69,6 +67,7 @@
MYODBCDriverInternal.h
SOURCES += \
+ MYODBCDriverMain.cpp \
SQLAllocHandle.cpp \
SQLBindCol.cpp \
SQLBindParameter.cpp \
Modified: branches/feature-linux-port/Driver/Driver/Library/MYODBCDriverMain.cpp
===================================================================
--- branches/feature-linux-port/Driver/Driver/Library/MYODBCDriverMain.cpp 2006-12-19
16:22:44 UTC (rev 755)
+++ branches/feature-linux-port/Driver/Driver/Library/MYODBCDriverMain.cpp 2006-12-20
04:03:19 UTC (rev 756)
@@ -36,12 +36,66 @@
#define tgetenv getenv
#endif
+#ifdef __GNUC__
+void libinit() __attribute__((constructor));
+void libdeinit() __attribute__((destructor));
+#endif
+
+/* TODO put this elsewhere */
+#ifdef UNICODE
+# define TEXT(x) L##x
+#else
+# define TEXT(x) (x)
+#endif
+
int gnMYODBCDrvProcesses = 0;
int gnMYODBCDrvThreads = 0;
-HANDLE ghMYODBCDrvModule = NULL;
QFile gMYODBCTraceFile;
/*!
+ Initialize MyODBC tracing.
+
+ \param dest The trace output destination.
+*/
+static void init_myodbc_trace(wchar_t *dest)
+{
+ if ( dest )
+ {
+ if ( !(*dest) || wcscmp( dest, TEXT("off") ) == 0 )
+ ;/* do nothing */
+ else if ( wcscmp( dest, TEXT("stdout") ) == 0 )
+ {
+ MYODBCDbgInit( stdout );
+ }
+ else if ( wcscmp( dest, TEXT("stderr") ) == 0 )
+ {
+ MYODBCDbgInit( stderr );
+ }
+ else
+ {
+ gMYODBCTraceFile.setFileName( MYODBCC::QString_fromWCharArray( dest ) );
+ if ( gMYODBCTraceFile.open( QFile::WriteOnly ) )
+ {
+ MYODBCDbgInit( &gMYODBCTraceFile );
+ }
+ else
+ MYODBCDbgInit( stdout );
+ }
+ }
+}
+
+/*!
+ De-initialize MyODBC tracing.
+*/
+static void deinit_myodbc_trace()
+{
+ MYODBCDbgFini();
+ if ( !gMYODBCTraceFile.fileName().isEmpty() )
+ gMYODBCTraceFile.close();
+}
+
+#ifdef _WIN32
+/*!
\internal
\brief Does init and fini on MS Windows platforms.
@@ -93,32 +147,9 @@
/* First reference? */
if ( !gnMYODBCDrvProcesses++ )
{
- ghMYODBCDrvModule = hInst;
/* Init tracing? */
SQLWCHAR *psMYODBC_LOG = _wgetenv( TEXT("MYODBC_LOG") );
- if ( psMYODBC_LOG )
- {
- if ( !(*psMYODBC_LOG) || wcscmp( psMYODBC_LOG, TEXT("off") ) == 0 )
- ;/* do nothing */
- else if ( wcscmp( psMYODBC_LOG, TEXT("stdout") ) == 0 )
- {
- MYODBCDbgInit( stdout );
- }
- else if ( wcscmp( psMYODBC_LOG, TEXT("stderr") ) == 0 )
- {
- MYODBCDbgInit( stderr );
- }
- else
- {
- gMYODBCTraceFile.setFileName( MYODBCC::QString_fromWCharArray(
psMYODBC_LOG ) );
- if ( gMYODBCTraceFile.open( QFile::WriteOnly ) )
- {
- MYODBCDbgInit( &gMYODBCTraceFile );
- }
- else
- MYODBCDbgInit( stdout );
- }
- }
+ init_myodbc_trace(psMYODBC_LOG);
}
break;
@@ -131,9 +162,7 @@
if ( !--gnMYODBCDrvProcesses )
{
/* Fini any tracing... */
- MYODBCDbgFini();
- if ( !gMYODBCTraceFile.fileName().isEmpty() )
- gMYODBCTraceFile.close();
+ deinit_myodbc_trace();
}
break;
@@ -154,11 +183,25 @@
UNREFERENCED_PARAMETER(pReserved);
}
-
/* Entry point to cause DM to load using ordinals */
void __declspec(dllexport) FAR PASCAL LoadByOrdinal(void);
void __declspec(dllexport) FAR PASCAL LoadByOrdinal(void)
{
}
+#else
+/* shared library hooks for unix */
+void libinit()
+{
+ wchar_t wlogdest[255];
+ char *logdest = getenv("MYODBC_LOG");
+ if(logdest && (mbstowcs(wlogdest, logdest, 254) != -1))
+ init_myodbc_trace(wlogdest);
+}
+void libdeinit()
+{
+ deinit_myodbc_trace();
+}
+#endif
+
Modified: branches/feature-linux-port/SDK/Installer/Library/MYODBCInsDataSource.cpp
===================================================================
--- branches/feature-linux-port/SDK/Installer/Library/MYODBCInsDataSource.cpp 2006-12-19
16:22:44 UTC (rev 755)
+++ branches/feature-linux-port/SDK/Installer/Library/MYODBCInsDataSource.cpp 2006-12-20
04:03:19 UTC (rev 756)
@@ -373,10 +373,10 @@
if ( hashAttributes.contains( stringEntryNameUpper ) )
hashAttributes[stringEntryNameUpper] = stringValue.trimmed();
else
- MYODBCDbgError( "Unknown attribute (%s).", psEntryName );
+ MYODBCDbgError( "Unknown attribute (%ls).", QString::fromWCharArray(
psEntryName ).utf16() );
}
else
- MYODBCDbgWarning( "Failed to get value for attribute (%s).", psEntryName );
+ MYODBCDbgWarning( "Failed to get value for attribute (%ls).",
QString::fromWCharArray( psEntryName ).utf16() );
psEntryName += MYODBCC::getStrLen( psEntryName, SQL_MAX_DSN_LENGTH *
MYODBC_INS_MAX_DSN_NAMES ) + 1;
} /* while */
Modified: branches/feature-linux-port/config.pri
===================================================================
--- branches/feature-linux-port/config.pri 2006-12-19 16:22:44 UTC (rev 755)
+++ branches/feature-linux-port/config.pri 2006-12-20 04:03:19 UTC (rev 756)
@@ -20,7 +20,7 @@
# debug | release
#
# #########################################################
-CONFIG += warn_on release
+CONFIG += warn_on debug
CONFIG += thread
| Thread |
|---|
| • Connector/ODBC 5 commit: r756 - in branches/feature-linux-port: . Driver/Driver/Library SDK/Installer/Library | jbalint | 20 Dec |