From: <ibr...@us...> - 2011-11-24 00:55:47
|
Revision: 4157 http://tora.svn.sourceforge.net/tora/?rev=4157&view=rev Author: ibre5041 Date: 2011-11-24 00:55:41 +0000 (Thu, 24 Nov 2011) Log Message: ----------- lin fixes Modified Paths: -------------- branches/tora-trotl/sandbox/tora3/src/connection/tooraclefind.cpp branches/tora-trotl/sandbox/tora3/src/core/tologger.h branches/tora-trotl/sandbox/tora3/src/ts_log/toostream.h Modified: branches/tora-trotl/sandbox/tora3/src/connection/tooraclefind.cpp =================================================================== --- branches/tora-trotl/sandbox/tora3/src/connection/tooraclefind.cpp 2011-11-23 21:20:04 UTC (rev 4156) +++ branches/tora-trotl/sandbox/tora3/src/connection/tooraclefind.cpp 2011-11-24 00:55:41 UTC (rev 4157) @@ -54,6 +54,9 @@ #ifdef Q_OS_WIN32 #include <Windows.h> //#include <Psapi.h> +#else +#include <stdlib.h> +#include <dlfcn.h> #endif TORA_EXPORT class toOracleInstantFinder : public toConnectionProviderFinder @@ -239,10 +242,41 @@ // break; // } //} - return retval; +#else + QFileInfo fipath(path); + QString oldDir = QDir::currentPath(); + bool i = QDir::setCurrent(fipath.absolutePath()); + + void* handle = dlopen(path.toStdString().c_str(), RTLD_LAZY | RTLD_GLOBAL); + if( !handle) + { + const char *e; + e = dlerror(); + return QString::null; + } + + pOCIClientVersion = (tpOCIClientVersion) dlsym(handle, "OCIClientVersion"); + const char *dlsym_error = dlerror(); + if( !pOCIClientVersion || dlsym_error) + { + retval = "pre-10g client"; + goto EXIT; + } + + ret = pOCIClientVersion(&major, &minor, &update, &patch, &port); + if( ret == OCI_ERROR) + { + retval = "error calling OCIClientVersion"; + goto EXIT; + } + + s << major << '.' << minor << '.' << update << '.' << patch << '.' << port; +EXIT: + dlclose(handle); + i = QDir::setCurrent(oldDir); #endif - + return retval; }; QList<toConnectionProviderFinder::ConnectionProvirerParams> toOracleInstantFinder::find() @@ -270,12 +304,12 @@ #if defined(Q_OS_WIN32) QStringList slPath = QString(getenv("PATH")).split(';', QString::SkipEmptyParts ); slEnvPaths.append(slPath); -#else defined(Q_OS_LINUX) - QStringList slLDPath = QString(getEnv("LD_LIBRARY_PATH")).split(';', QString::SkipEmptyParts ); +#elif defined(Q_OS_LINUX) + QStringList slLDPath = QString(getenv("LD_LIBRARY_PATH")).split(';', QString::SkipEmptyParts ); slEnvPaths.append(slLDPath); - QStringList slLDPath32 = QString(getEnv("LD_LIBRARY_PATH32")).split(';', QString::SkipEmptyParts ); + QStringList slLDPath32 = QString(getenv("LD_LIBRARY_PATH32")).split(';', QString::SkipEmptyParts ); slEnvPaths.append(slLDPath32); - QStringList slLDPath64 = QString(getEnv("LD_LIBRARY_PATH64")).split(';', QString::SkipEmptyParts ); + QStringList slLDPath64 = QString(getenv("LD_LIBRARY_PATH64")).split(';', QString::SkipEmptyParts ); slEnvPaths.append(slLDPath64); #endif foreach(QString sHome, slEnvPaths) @@ -455,6 +489,23 @@ TLOG(5, toNoDecorator, __HERE__) << "FAIL:(" << dw << ')' << errmsg << std::endl; } +#else + QFileInfo libPath(params.value("LIBPATH").toString()); + QString oldDir = QDir::currentPath(); + bool i = QDir::setCurrent(libPath.absolutePath()); + + TLOG(5, toNoDecorator, __HERE__) << "Loading:" << libPath.absoluteFilePath() << std::endl; + void* handle = dlopen(libPath.fileName().toStdString().c_str(), RTLD_LAZY | RTLD_GLOBAL); + if(handle) + TLOG(5, toNoDecorator, __HERE__) << "OK" << std::endl; + + QDir::setCurrent(oldDir); + TLOG(5, toNoDecorator, __HERE__) << "Loading:" << libPath.absoluteFilePath() << std::endl; + + TLOG(5, toNoDecorator, __HERE__) << "Loading:" << "libporacle.so" << std::endl; + handle = dlopen("libporacle.so", RTLD_LAZY | RTLD_GLOBAL); + if(handle) + TLOG(5, toNoDecorator, __HERE__) << "OK" << std::endl; #endif } Modified: branches/tora-trotl/sandbox/tora3/src/core/tologger.h =================================================================== --- branches/tora-trotl/sandbox/tora3/src/core/tologger.h 2011-11-23 21:20:04 UTC (rev 4156) +++ branches/tora-trotl/sandbox/tora3/src/core/tologger.h 2011-11-24 00:55:41 UTC (rev 4157) @@ -203,6 +203,8 @@ // TODO add some comment on this MSVC inline std::ostream& operator<<( std::ostream & stream, const QString & str) { // TODO review this + if( str.isEmpty()) + return stream; QByteArray b( str.toAscii()); const char *c = b.constData(); stream << c; Modified: branches/tora-trotl/sandbox/tora3/src/ts_log/toostream.h =================================================================== --- branches/tora-trotl/sandbox/tora3/src/ts_log/toostream.h 2011-11-23 21:20:04 UTC (rev 4156) +++ branches/tora-trotl/sandbox/tora3/src/ts_log/toostream.h 2011-11-24 00:55:41 UTC (rev 4157) @@ -1,117 +1,117 @@ -#ifndef __UGLY_OSTREAM -#define __UGLY_OSTREAM - -#include <streambuf> -#include <iostream> -#include <QObject> -#include "tomainwindow.h" -#include "tomain.h" - -class toSender : public QObject -{ - Q_OBJECT; -public: - toSender() - : QObject(NULL) - , initialized(false) - { - toMainWindow *mv = toMainWidget(); - if( mv == NULL) - return; - - const QPlainTextEdit *e = mv->getLoggingWidget(); - if( e == NULL) - return; - - connect(this, SIGNAL(send(QString const&)), (const QObject *)e, SLOT(appendPlainText(QString const&)), Qt::QueuedConnection); - - initialized = true; - }; - - void emit_send(QString const& s) - { - if(initialized) - emit send(s); - } - -signals: - - void send(QString const& s); -private: - bool initialized; -}; - -class toBuffer : public std::basic_streambuf< char, std::char_traits< char > > -{ - -public: - - inline toBuffer() - { - //setp(buf, buf + BUF_SIZE); - } - -protected: - - //// This is called when buffer becomes full. If - //// buffer is not used, then this is called every - //// time when characters are put to stream. - //inline virtual int overflow(int c = std::char_traits< char >::eof()) - //{ - // putChars(pbase(), pptr()); - // if (c != Traits::eof()) { - // char c2 = c; - // // Handle the one character that didn't fit to buffer - // putChars(&c2, &c2 + 1); - // } - // // This tells that buffer is empty again - // setp(buf, buf + BUF_SIZE); - // return 0; - //} - - //// This function is called when stream is flushed, - //// for example when std::endl is put to stream. - //virtual int sync(void) - //{ - // putChars(pbase(), pptr()); - // setp(buf, buf + BUF_SIZE); - // return 0; - //} - - std::streamsize xsputn(const char * s, std::streamsize n) - { - putChars(s, n); - return n; - } - -private: - - // For EOF detection - typedef std::char_traits< char > Traits; - - // Work in no buffer mode. It is also possible to work wit buffer. - ///static size_t const BUF_SIZE = 32; - ///char buf[BUF_SIZE]; - - toSender sender; - - void putChars(char const* begin, std::streamsize len) - { - QString s = QString::fromAscii(begin, len); - sender.emit_send(s); - } - -}; - -class toOStream : public std::basic_ostream< char, std::char_traits< char > > -{ -public: - - inline toOStream() : std::basic_ostream< char, std::char_traits< char > >(&buf) - {} - -private: - toBuffer buf; -}; - -#endif +#ifndef __UGLY_OSTREAM +#define __UGLY_OSTREAM + +#include <streambuf> +#include <iostream> +#include <QObject> +#include "tomainwindow.h" +#include "tomain.h" + +class toSender : public QObject +{ + Q_OBJECT; +public: + toSender() + : QObject(NULL) + , initialized(false) + { + toMainWindow *mv = toMainWidget(); + if( mv == NULL) + return; + + const QPlainTextEdit *e = mv->getLoggingWidget(); + if( e == NULL) + return; + + connect(this, SIGNAL(send(QString const&)), (const QObject *)e, SLOT(appendPlainText(QString const&)), Qt::QueuedConnection); + + initialized = true; + }; + + void emit_send(QString const& s) + { + if(initialized) + emit send(s); + } + +signals: + + void send(QString const& s); +private: + bool initialized; +}; + +class toBuffer : public std::basic_streambuf< char, std::char_traits< char > > +{ + +public: + + inline toBuffer() + { + //setp(buf, buf + BUF_SIZE); + } + +protected: + + //// This is called when buffer becomes full. If + //// buffer is not used, then this is called every + //// time when characters are put to stream. + //inline virtual int overflow(int c = std::char_traits< char >::eof()) + //{ + // putChars(pbase(), pptr()); + // if (c != Traits::eof()) { + // char c2 = c; + // // Handle the one character that didn't fit to buffer + // putChars(&c2, &c2 + 1); + // } + // // This tells that buffer is empty again + // setp(buf, buf + BUF_SIZE); + // return 0; + //} + + //// This function is called when stream is flushed, + //// for example when std::endl is put to stream. + //virtual int sync(void) + //{ + // putChars(pbase(), pptr()); + // setp(buf, buf + BUF_SIZE); + // return 0; + //} + + std::streamsize xsputn(const char * s, std::streamsize n) + { + putChars(s, n); + return n; + } + +private: + + // For EOF detection + typedef std::char_traits< char > Traits; + + // Work in no buffer mode. It is also possible to work wit buffer. + ///static size_t const BUF_SIZE = 32; + ///char buf[BUF_SIZE]; + + toSender sender; + + void putChars(char const* begin, std::streamsize len) + { + QString s = QString::fromAscii(begin, len); + sender.emit_send(s); + } + +}; + +class toOStream : public std::basic_ostream< char, std::char_traits< char > > +{ +public: + + inline toOStream() : std::basic_ostream< char, std::char_traits< char > >(&buf) + {} + +private: + toBuffer buf; +}; + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |