Qt 4.8
Classes | Macros | Typedefs | Functions
qlibrary.cpp File Reference
#include "qplatformdefs.h"
#include "qlibrary.h"
#include "qlibrary_p.h"
#include <qstringlist.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qmutex.h>
#include <qmap.h>
#include <qsettings.h>
#include <qdatetime.h>
#include <private/qcoreapplication_p.h>
#include <private/qcore_mac_p.h>
#include <errno.h>
#include <qdebug.h>
#include <qvector.h>
#include <qdir.h>
#include "qelfparser_p.h"

Go to the source code of this file.

Classes

struct  LibraryData
 
struct  qt_token_info
 

Macros

#define QLIBRARY_AS_DEBUG   true
 

Typedefs

typedef QMap< QString, QLibraryPrivate * > LibraryMap
 
typedef const char *(* QtPluginQueryVerificationDataFunction) ()
 

Functions

static LibraryMaplibraryMap ()
 
bool qt_debug_component ()
 
bool qt_get_verificationdata (QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, QByteArray *key, bool *exceptionThrown)
 
static bool qt_parse_pattern (const char *s, uint *version, bool *debug, QByteArray *key)
 
static int qt_tokenize (const char *s, ulong s_len, ulong *advance, qt_token_info &token_info)
 

Macro Definition Documentation

◆ QLIBRARY_AS_DEBUG

#define QLIBRARY_AS_DEBUG   true

Definition at line 72 of file qlibrary.cpp.

Referenced by QLibraryPrivate::isPlugin().

Typedef Documentation

◆ LibraryMap

Definition at line 418 of file qlibrary.cpp.

◆ QtPluginQueryVerificationDataFunction

typedef const char*(* QtPluginQueryVerificationDataFunction) ()

Definition at line 645 of file qlibrary.cpp.

Function Documentation

◆ libraryMap()

static LibraryMap* libraryMap ( )
static

Definition at line 427 of file qlibrary.cpp.

Referenced by QLibraryPrivate::findOrCreate(), QLibraryPrivate::QLibraryPrivate(), and QLibraryPrivate::~QLibraryPrivate().

428 {
429  LibraryData *data = libraryData();
430  return data ? &data->libraryMap : 0;
431 }
LibraryMap libraryMap
Definition: qlibrary.cpp:421
static const char * data(const QByteArray &arr)

◆ qt_debug_component()

bool qt_debug_component ( )

Definition at line 1319 of file qlibrary.cpp.

Referenced by QLibraryPrivate::isPlugin(), QLibraryPrivate::loadPlugin(), qt_parse_pattern(), QPluginLoader::setFileName(), QLibraryPrivate::unload(), QFactoryLoader::update(), and QFactoryLoader::updateDir().

1320 {
1321  static int debug_env = -1;
1322  if (debug_env == -1)
1323  debug_env = QT_PREPEND_NAMESPACE(qgetenv)("QT_DEBUG_PLUGINS").toInt();
1324 
1325  return debug_env != 0;
1326 }
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
static int toInt(const QByteArray &str)
Definition: generator.cpp:167
#define QT_PREPEND_NAMESPACE(name)
This macro qualifies identifier with the full namespace.
Definition: qglobal.h:87

◆ qt_get_verificationdata()

bool qt_get_verificationdata ( QtPluginQueryVerificationDataFunction  pfn,
uint qt_version,
bool *  debug,
QByteArray key,
bool *  exceptionThrown 
)

Definition at line 648 of file qlibrary.cpp.

Referenced by QLibraryPrivate::isPlugin().

649 {
650  *exceptionThrown = false;
651  const char *szData = 0;
652  if (!pfn)
653  return false;
654 #ifdef QT_USE_MS_STD_EXCEPTION
655  szData = qt_try_versioninfo((void *)pfn, exceptionThrown);
656  if (*exceptionThrown)
657  return false;
658 #else
659  szData = pfn();
660 #endif
661 
662 #ifdef QT_NO_PLUGIN_CHECK
663  return true;
664 #else
665  return qt_parse_pattern(szData, qt_version, debug, key);
666 #endif
667 }
static bool qt_parse_pattern(const char *s, uint *version, bool *debug, QByteArray *key)
Definition: qlibrary.cpp:262

◆ qt_parse_pattern()

static bool qt_parse_pattern ( const char *  s,
uint version,
bool *  debug,
QByteArray key 
)
static

Definition at line 262 of file qlibrary.cpp.

Referenced by qt_get_verificationdata().

263 {
264  bool ret = true;
265 
266  qt_token_info pinfo("=\n", 2);
267  int parse;
268  ulong at = 0, advance, parselen = qstrlen(s);
269  do {
270  parse = qt_tokenize(s + at, parselen, &advance, pinfo);
271  if (parse == -1) {
272  ret = false;
273  break;
274  }
275 
276  at += advance;
277  parselen -= advance;
278 
279  if (qstrncmp("version", pinfo.results[0], pinfo.lengths[0]) == 0) {
280  // parse version string
281  qt_token_info pinfo2("..-", 3);
282  if (qt_tokenize(pinfo.results[1], pinfo.lengths[1],
283  &advance, pinfo2) != -1) {
284  QByteArray m(pinfo2.results[0], pinfo2.lengths[0]);
285  QByteArray n(pinfo2.results[1], pinfo2.lengths[1]);
286  QByteArray p(pinfo2.results[2], pinfo2.lengths[2]);
287  *version = (m.toUInt() << 16) | (n.toUInt() << 8) | p.toUInt();
288  } else {
289  ret = false;
290  break;
291  }
292  } else if (qstrncmp("debug", pinfo.results[0], pinfo.lengths[0]) == 0) {
293  *debug = qstrncmp("true", pinfo.results[1], pinfo.lengths[1]) == 0;
294  } else if (qstrncmp("buildkey", pinfo.results[0],
295  pinfo.lengths[0]) == 0){
296  // save buildkey
297  *key = QByteArray(pinfo.results[1], pinfo.lengths[1]);
298  }
299  } while (parse == 1 && parselen > 0);
300 
301  return ret;
302 }
int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qbytearray.h:101
#define at(className, varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
unsigned long ulong
Definition: qglobal.h:997
uint qstrlen(const char *str)
Definition: qbytearray.h:79
static int qt_tokenize(const char *s, ulong s_len, ulong *advance, qt_token_info &token_info)
Definition: qlibrary.cpp:204

◆ qt_tokenize()

static int qt_tokenize ( const char *  s,
ulong  s_len,
ulong advance,
qt_token_info token_info 
)
static

Definition at line 204 of file qlibrary.cpp.

Referenced by qt_parse_pattern().

206 {
207  if (!s)
208  return -1;
209 
210  ulong pos = 0, field = 0, fieldlen = 0;
211  char current;
212  int ret = -1;
213  *advance = 0;
214  for (;;) {
215  current = s[pos];
216 
217  // next char
218  ++pos;
219  ++fieldlen;
220  ++*advance;
221 
222  if (! current || pos == s_len + 1) {
223  // save result
224  token_info.results[(int)field] = s;
225  token_info.lengths[(int)field] = fieldlen - 1;
226 
227  // end of string
228  ret = 0;
229  break;
230  }
231 
232  if (current == token_info.fields[field]) {
233  // save result
234  token_info.results[(int)field] = s;
235  token_info.lengths[(int)field] = fieldlen - 1;
236 
237  // end of field
238  fieldlen = 0;
239  ++field;
240  if (field == token_info.field_count - 1) {
241  // parse ok
242  ret = 1;
243  }
244  if (field == token_info.field_count) {
245  // done parsing
246  break;
247  }
248 
249  // reset string and its length
250  s = s + pos;
251  s_len -= pos;
252  pos = 0;
253  }
254  }
255 
256  return ret;
257 }
const char * fields
Definition: qlibrary.cpp:191
QVector< const char * > results
Definition: qlibrary.cpp:194
unsigned long ulong
Definition: qglobal.h:997
QVector< ulong > lengths
Definition: qlibrary.cpp:195
const ulong field_count
Definition: qlibrary.cpp:192