42 #include "qplatformdefs.h" 55 #include <private/qcoreapplication_p.h> 57 # include <private/qcore_mac_p.h> 70 # define QLIBRARY_AS_DEBUG false 72 # define QLIBRARY_AS_DEBUG true 75 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) 78 # define QT_NO_DEBUG_PLUGIN_CHECK 181 #ifndef QT_NO_PLUGIN_CHECK 210 ulong pos = 0, field = 0, fieldlen = 0;
222 if (! current || pos == s_len + 1) {
224 token_info.
results[(int)field] = s;
225 token_info.
lengths[(int)field] = fieldlen - 1;
232 if (current == token_info.
fields[field]) {
234 token_info.
results[(int)field] = s;
235 token_info.
lengths[(int)field] = fieldlen - 1;
270 parse =
qt_tokenize(s + at, parselen, &advance, pinfo);
283 &advance, pinfo2) != -1) {
299 }
while (parse == 1 && parselen > 0);
303 #endif // QT_NO_PLUGIN_CHECK 305 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK) 307 static long qt_find_pattern(
const char *s,
ulong s_len,
308 const char *pattern,
ulong p_len)
322 if (! s || ! pattern || p_len > s_len)
return -1;
323 ulong i, hs = 0, hp = 0, delta = s_len - p_len;
325 for (i = 0; i < p_len; ++i) {
331 if (hs == hp &&
qstrncmp(s + i, pattern, p_len) == 0)
367 const char *filedata = 0;
369 filedata = (
char *) file.
map(0, fdlen);
381 const char pattern[] =
"pattern=QT_PLUGIN_VERIFICATION_DATA";
383 #if defined (Q_OF_ELF) && defined(Q_CC_GNU) 384 int r = QElfParser().parse(filedata, fdlen, library, lib, &pos, &fdlen);
385 if (r == QElfParser::NoQtSection) {
388 long rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen);
395 pos = qt_find_pattern(filedata, fdlen, pattern, plen);
404 pos = qt_find_pattern(filedata, fdlen, pattern, plen);
405 #endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) 411 lib->errorString =
QLibrary::tr(
"Plugin verification data mismatch in '%1'").
arg(library);
416 #endif // Q_OS_UNIX && !Q_OS_MAC && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK) 434 :pHnd(0),
fileName(canonicalFileName), fullVersion(version), instance(0), qt_version(0),
435 libraryRefCount(1), libraryUnloadCount(0), pluginState(MightBeAPlugin)
442 lib->libraryRefCount.ref();
480 lib->loadedLibs +=
this;
500 if (lib->loadedLibs.remove(
this))
527 #if defined(Q_OS_SYMBIAN) 561 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) 563 #elif defined(Q_OS_SYMBIAN) 572 # if defined(Q_OS_DARWIN) 576 const QString firstSuffix = suffixes.
at(0);
583 # else // Generic Unix 586 # if defined(Q_OS_HPUX) 596 # elif defined(Q_OS_AIX) 598 # elif defined(Q_OS_UNIX) 611 for (suffix = 0; suffix < validSuffixList.
count() && suffixPos == -1; ++
suffix)
612 suffixPos = suffixes.
indexOf(validSuffixList.
at(suffix));
614 bool valid = suffixPos != -1;
615 for (
int i = suffixPos + 1; i < suffixes.
count() && valid; ++i)
624 #if defined (Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_CC_INTEL) 625 #define QT_USE_MS_STD_EXCEPTION 1 626 const char* qt_try_versioninfo(
void *pfn,
bool *exceptionThrown)
628 *exceptionThrown =
false;
629 const char *szData = 0;
630 typedef const char * (*VerificationFunction)();
631 VerificationFunction func =
reinterpret_cast<VerificationFunction
>(pfn);
635 } __except(EXCEPTION_EXECUTE_HANDLER) {
636 *exceptionThrown =
true;
645 typedef const char * (*QtPluginQueryVerificationDataFunction)();
650 *exceptionThrown =
false;
651 const char *szData = 0;
654 #ifdef QT_USE_MS_STD_EXCEPTION 655 szData = qt_try_versioninfo((
void *)pfn, exceptionThrown);
656 if (*exceptionThrown)
662 #ifdef QT_NO_PLUGIN_CHECK 675 #ifndef QT_NO_PLUGIN_CHECK 678 bool success =
false;
680 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) 696 #ifndef QT_NO_DATESTRING 709 #if defined(__x86_64__) 711 #elif defined(__i386__) 713 #elif defined(__ppc64__) 715 #elif defined(__ppc__) 721 #ifndef QT_NO_SETTINGS 729 debug = bool(reg.
at(1).
toInt());
733 #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) 740 bool retryLoadLibrary =
false;
742 bool temporary_load =
false;
744 HMODULE hTempModule = 0;
748 DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES;
754 # if defined(Q_OS_SYMBIAN) 764 ::GetProcAddress(hTempModule, L
"qt_plugin_query_verification_data")
766 ::GetProcAddress(hTempModule,
"qt_plugin_query_verification_data")
771 # if defined(Q_OS_SYMBIAN) 772 if (temporary_load) {
775 if (!qtPluginQueryVerificationDataFunction)
782 bool exceptionThrown =
false;
785 if (!exceptionThrown) {
794 retryLoadLibrary =
false;
796 #ifdef QT_USE_MS_STD_EXCEPTION 802 retryLoadLibrary = !retryLoadLibrary;
807 BOOL ok = ::FreeLibrary(hTempModule);
814 }
while(retryLoadLibrary);
821 #ifndef QT_NO_SETTINGS 827 settings->
setValue(regkey, queried);
846 " Plugin uses incompatible Qt library (%d.%d.%d) [%s]",
849 debug ?
"debug" :
"release");
859 #ifdef QT_BUILD_KEY_COMPAT
860 && key != QT_BUILD_KEY_COMPAT
862 #ifdef QT_BUILD_KEY_COMPAT2
863 && key != QT_BUILD_KEY_COMPAT2
865 #ifdef QT_BUILD_KEY_COMPAT3
866 && key != QT_BUILD_KEY_COMPAT3
871 " Plugin uses incompatible Qt library\n" 872 " expected build key \"%s\", got \"%s\"",
875 key.
isEmpty() ?
"<null>" : (
const char *) key);
878 " Expected build key \"%2\", got \"%3\"")
882 #ifndef QT_NO_DEBUG_PLUGIN_CHECK 886 " (Cannot mix debug and release libraries.)").
arg(
fileName);
958 :
QObject(parent),
d(0), did_load(false)
1060 QLibrary::LoadHints lh;
1094 QLibrary::LoadHints lh;
1121 QLibrary::LoadHints lh;
1184 return library.
resolve(symbol);
1209 QLibrary library(fileName, verNum);
1210 return library.
resolve(symbol);
1236 QLibrary library(fileName, version);
1237 return library.
resolve(symbol);
1321 static int debug_env = -1;
1322 if (debug_env == -1)
1325 return debug_env != 0;
1330 #endif // QT_NO_LIBRARY static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
LoadHints loadHints() const
QString qt_error_string(int errorCode)
bool isPlugin(QSettings *settings=0)
void setValue(const QString &key, const QVariant &value)
Sets the value of setting key to value.
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
void setFileNameAndVersion(const QString &fileName, int verNum)
Sets the fileName property and major version number to fileName and versionNumber respectively...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
#define QT_END_NAMESPACE
This macro expands to.
#define QLIBRARY_AS_DEBUG
The QMutex class provides access serialization between threads.
bool unload()
Unloads the library and returns true if the library could be unloaded; otherwise returns false...
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QWeakPointer< QObject > inst
The QSettings class provides persistent platform-independent application settings.
static QLibraryPrivate * findOrCreate(const QString &fileName, const QString &version=QString())
QVector< const char * > results
#define at(className, varName)
The QByteArray class provides an array of bytes.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
QLibraryPrivate(const QString &canonicalFileName, const QString &version)
QtPluginInstanceFunction instance
#define SEM_FAILCRITICALERRORS
QLibrary(QObject *parent=0)
Constructs a library with the given parent.
QString completeSuffix() const
Returns the complete suffix of the file.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool exists() const
Returns true if the file exists; otherwise returns false.
int count(const T &t) const
Returns the number of occurrences of value in the list.
bool ref()
Atomically increments the value of this QAtomicInt.
void * resolve(const char *symbol)
Returns the address of the exported symbol symbol.
void * resolve(const char *)
The QString class provides a Unicode character string.
bool isLoaded() const
Returns true if the library is loaded; otherwise returns false.
QAtomicInt libraryRefCount
void setFileName(const QString &fileName)
The QVector class is a template class that provides a dynamic array.
The QObject class is the base class of all Qt objects.
bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, QByteArray *key, bool *exceptionThrown)
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the datetime as a string in the format given.
static bool isLibrary(const QString &fileName)
Returns true if fileName has a valid suffix for a loadable library; otherwise returns false...
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
int indexOf(const QRegExp &rx, int from=0) const
Returns the index position of the first exact match of rx in the list, searching forward from index p...
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QObject *(* QtPluginInstanceFunction)()
enum QLibraryPrivate::@42 pluginState
~QLibrary()
Destroys the QLibrary object.
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
const T & at(int i) const
Returns the item at index position i in the list.
bool deref()
Atomically decrements the value of this QAtomicInt.
The QStringList class provides a list of strings.
static int toInt(const QByteArray &str)
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
Q_CORE_EXPORT void qWarning(const char *,...)
void * resolve_sys(const char *)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
static LibraryMap * libraryMap()
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
qint64 size() const
Returns the size of the file.
static QSettings * trolltechConf()
const char * constData() const
Returns a pointer to the data stored in the byte array.
qt_token_info(const char *f, const ulong fc)
uint qstrlen(const char *str)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
bool load()
Loads the library and returns true if the library was loaded successfully; otherwise returns false...
The QFile class provides an interface for reading from and writing to files.
QSet< QLibraryPrivate * > loadedLibs
void clear()
Clears the contents of the string and makes it empty.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
QObject * parent() const
Returns a pointer to the parent object.
int qstrncmp(const char *str1, const char *str2, uint len)
uint toUInt(bool *ok=0, int base=10) const
Returns the string converted to an unsigned int using base base, which is 10 by default and must be b...
#define SEM_NOOPENFILEERRORBOX
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
int size() const
Returns the number of bytes in this byte array.
void setLoadHints(LoadHints hints)
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user's loca...
QByteArray & replace(int index, int len, const char *s)
This is an overloaded member function, provided for convenience. It differs from the above function o...
T take(const Key &key)
Removes the item with the key key from the map and returns the value associated with it...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
uchar * map(qint64 offset, qint64 size, MemoryMapFlags flags=NoOptions)
Maps size bytes of the file into memory starting at offset.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
The QFileInfo class provides system-independent file information.
static QString toNativeSeparators(const QString &pathName)
Returns pathName with the '/' separators converted to separators that are appropriate for the underly...
virtual void close()
Calls QFile::flush() and closes the file.
uint toUInt(bool *ok=0, int base=10) const
Returns the byte array converted to an {unsigned int} using base base, which is 10 by default and mus...
QLibrary::LoadHints loadHints
#define qPrintable(string)
QString qualifiedFileName
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static bool qt_parse_pattern(const char *s, uint *version, bool *debug, QByteArray *key)
static QString fileName(const QString &fileUrl)
static int qt_tokenize(const char *s, ulong s_len, ulong *advance, qt_token_info &token_info)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
bool qt_debug_component()
QMap< QString, QLibraryPrivate * > LibraryMap
QString errorString() const
Returns a text string with the description of the last error that occurred.
const char *(* QtPluginQueryVerificationDataFunction)()
The QLibrary class loads shared libraries at runtime.
QAtomicInt libraryUnloadCount
#define QT_VERSION
This macro expands a numeric value of the form 0xMMNNPP (MM = major, NN = minor, PP = patch) that spe...
QDateTime lastModified() const
Returns the date and time when the file was last modified.