/* * lexstart - set up lexical stuff, scan leading options */ static void lexstart(struct vars * v) { prefixes(v); /* may turn on new type bits etc. */ NOERR(); if (v->cflags & REG_QUOTE) { assert(!(v->cflags & (REG_ADVANCED | REG_EXPANDED | REG_NEWLINE))); INTOCON(L_Q); } else if (v->cflags & REG_EXTENDED) { assert(!(v->cflags & REG_QUOTE)); INTOCON(L_ERE); } else { assert(!(v->cflags & (REG_QUOTE | REG_ADVF))); INTOCON(L_BRE); } v->nexttype = EMPTY; /* remember we were at the start */ next(v); /* set up the first token */ }
qint64 HexFileModel::search(QByteArray pattern, qint64 beginningPos) { if(pattern.isEmpty()) return -1; QVector<int> prefixes(pattern.size(), -1); int k = -1; for (int i = 1; i < pattern.size(); ++i) { while (k > -1 && pattern[k+1] != pattern[i]) k = prefixes[k]; if (pattern[i] == pattern[k+1]) k++; prefixes[i] = k; } file.seek(beginningPos); k = -1; char c; while(file.getChar(&c)) { while (k > -1 && pattern[k+1] != c) k = prefixes[k]; if (c == pattern[k+1]) ++k; if (k == pattern.size() - 1) { qint64 pos = file.pos()-pattern.size(); return 8*pos; } } if(beginningPos != 0) { int ret = QMessageBox::question(static_cast<QWidget*>(static_cast<QObject*>(this)->parent()), tr("End of file"), tr("End of file reached.\n" "Do you want to search from the beginning?"), QMessageBox::Ok | QMessageBox::Cancel); if(ret == QMessageBox::Ok) return search(pattern, 0); else return -1; } else { QMessageBox::information(static_cast<QWidget*>(static_cast<QObject*>(this)->parent()), tr("Not Found"), tr("Pattern not found.\n"), QMessageBox::Ok); return -1; } }
int instruction(int c) { int r; if (c==0) { while(prefixes()); r=instructionbody(); } else r=databody(c); return r; }
Settings::Settings(const QString &filename) : _set(filename, QSettings::IniFormat) { if (_set.status() != QSettings::NoError) { qDebug() << "Setting file is not exist. Server run with default parameters\n"; } _host = _set.value("host", "0.0.0.0").toString(); _port = _set.value("port", 9876).toInt(); _threads = _set.value("threads", QThread::idealThreadCount() /* - 2*/).toInt(); _fileNameLength = _set.value("file_name_length", 5).toInt(); QStringList _imageTypes = _set.value("image_types", QStringList() << "jpg" << "png").toStringList(); QStringList _sourceTypes= _set.value("source_types", QStringList() << "c" << "cpp" << "txt" << "py").toStringList(); QString _imageDir = _set.value("image_dir", "imageDir/").toString(); QString _sourceDir = _set.value("source_dir", "sourceDir/").toString(); _imageLinkPrefix = _set.value("image_link_prefix", "http://prefix.com/image/").toString(); _sourceLinkPrefix = _set.value("source_link_prefix", "http://prefix.com/sorces/").toString(); for (auto i = _imageTypes.begin(); i != _imageTypes.end(); ++i) { _types.insert(*i, _imageDir); _prefixes.insert(*i, _imageLinkPrefix); } for (auto i = _sourceTypes.begin(); i != _sourceTypes.end(); ++i) { _types.insert(*i, _sourceDir); _prefixes.insert(*i, _sourceLinkPrefix); } pThis = this; qDebug() << "\nSettings:" << "\n Host:" << host().toString() << "\n Port:" << port() << "\n Threads:" << threads() << "\n File name lenght:" << fileNameLenght() << "\n Types:" << types() << "\n Prefixes:" << prefixes(); }
bool Storage::save() { if(!isChanged_) return true; std::size_t pos = storageFilePath_.rfind('/'); if(pos != std::string::npos) { std::string dir = storageFilePath_.substr(0, pos); if(!FileSystem::makePath(dir)) return false; } std::ofstream file(storageFilePath_, std::ios::out | std::ios::trunc); if(!file.is_open()) return false; Json::Value root; root["binaries_path"] = binariesPath_; root["log_socket_path"] = logSocketPath_; root["default_log_level"] = static_cast<int>(defaultLogLevel_); Json::Value prefixes(Json::arrayValue); for(auto it : prefixByName_) { if(it.first == "default") continue; Json::Value prefix; prefix["name"] = it.first; prefix["path"] = it.second; prefixes.append(prefix); } root["prefixes"] = prefixes; Json::Value loaders(Json::arrayValue); for(auto it : loaderByName_) { if(it.first == "default") continue; Json::Value loader; loader["name"] = it.first; loader["path"] = it.second; loaders.append(loader); } root["loaders"] = loaders; Json::Value links(Json::arrayValue); for(auto& it : linkByPath_) { Json::Value link; link["path"] = it.first; link["loader"] = it.second.loader; link["prefix"] = it.second.prefix; link["target"] = it.second.target; link["log_level"] = static_cast<int>(it.second.level); links.append(link); } root["links"] = links; Json::StyledWriter writer; file << writer.write(root); isChanged_ = false; return true; }
static void cql_to_xml_r(struct cql_node *cn, void (*pr)(const char *buf, void *client_data), void *client_data, int level) { if (!cn) return; switch (cn->which) { case CQL_NODE_ST: pr_n("<searchClause>\n", pr, client_data, level); prefixes(cn, pr, client_data, level+2); if (cn->u.st.index) { pr_n("<index>", pr, client_data, level+2); pr_cdata(cn->u.st.index, pr, client_data); pr_n("</index>\n", pr, client_data, 0); } if (cn->u.st.relation) { pr_n("<relation>\n", pr, client_data, level+2); pr_n("<value>", pr, client_data, level+4); if (cn->u.st.relation_uri) pr_cdata("rel.", pr, client_data); pr_cdata(cn->u.st.relation, pr, client_data); pr_n("</value>\n", pr, client_data, 0); if (cn->u.st.relation_uri) { pr_n("<identifier>", pr, client_data, level+4); pr_cdata(cn->u.st.relation_uri, pr, client_data); pr_n("</identifier>\n", pr, client_data, 0); } cql_to_xml_mod(cn->u.st.modifiers, pr, client_data, level+4); pr_n("</relation>\n", pr, client_data, level+2); } if (cn->u.st.term) { pr_n("<term>", pr, client_data, level+2); pr_cdata(cn->u.st.term, pr, client_data); pr_n("</term>\n", pr, client_data, 0); } if (cn->u.st.extra_terms) { struct cql_node *n = cn->u.st.extra_terms; for (; n; n = n->u.st.extra_terms) { pr_n("<term>", pr, client_data, level+2); pr_cdata(n->u.st.term, pr, client_data); pr_n("</term>\n", pr, client_data, 0); } } pr_n("</searchClause>\n", pr, client_data, level); break; case CQL_NODE_BOOL: pr_n("<triple>\n", pr, client_data, level); if (cn->u.boolean.value) { pr_n("<boolean>\n", pr, client_data, level+2); pr_n("<value>", pr, client_data, level+4); pr_cdata(cn->u.boolean.value, pr, client_data); pr_n("</value>\n", pr, client_data, 0); cql_to_xml_mod(cn->u.boolean.modifiers, pr, client_data, level+4); pr_n("</boolean>\n", pr, client_data, level+2); } if (cn->u.boolean.left) { printf ("%*s<leftOperand>\n", level+2, ""); cql_to_xml_r(cn->u.boolean.left, pr, client_data, level+4); printf ("%*s</leftOperand>\n", level+2, ""); } if (cn->u.boolean.right) { printf ("%*s<rightOperand>\n", level+2, ""); cql_to_xml_r(cn->u.boolean.right, pr, client_data, level+4); printf ("%*s</rightOperand>\n", level+2, ""); } pr_n("</triple>\n", pr, client_data, level); } }
bool QLibraryPrivate::load_sys() { QString attempt; #if !defined(QT_NO_DYNAMIC_LIBRARY) QFileInfo fi(fileName); #if defined(Q_OS_SYMBIAN) QString path; // In Symbian, always resolve with just the filename QString name; // Replace possible ".qtplugin" suffix with ".dll" if (fi.suffix() == QLatin1String("qtplugin")) name = fi.completeBaseName() + QLatin1String(".dll"); else name = fi.fileName(); #else QString path = fi.path(); QString name = fi.fileName(); if (path == QLatin1String(".") && !fileName.startsWith(path)) path.clear(); else path += QLatin1Char('/'); #endif // The first filename we want to attempt to load is the filename as the callee specified. // Thus, the first attempt we do must be with an empty prefix and empty suffix. QStringList suffixes(QLatin1String("")), prefixes(QLatin1String("")); if (pluginState != IsAPlugin) { #if !defined(Q_OS_SYMBIAN) prefixes << QLatin1String("lib"); #endif #if defined(Q_OS_HPUX) // according to // http://docs.hp.com/en/B2355-90968/linkerdifferencesiapa.htm // In PA-RISC (PA-32 and PA-64) shared libraries are suffixed // with .sl. In IPF (32-bit and 64-bit), the shared libraries // are suffixed with .so. For compatibility, the IPF linker // also supports the .sl suffix. // But since we don't know if we are built on HPUX or HPUXi, // we support both .sl (and .<version>) and .so suffixes but // .so is preferred. # if defined(__ia64) if (!fullVersion.isEmpty()) { suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); } else { suffixes << QLatin1String(".so"); } # endif if (!fullVersion.isEmpty()) { suffixes << QString::fromLatin1(".sl.%1").arg(fullVersion); suffixes << QString::fromLatin1(".%1").arg(fullVersion); } else { suffixes << QLatin1String(".sl"); } #elif defined(Q_OS_AIX) suffixes << ".a"; #elif defined(Q_OS_SYMBIAN) suffixes << QLatin1String(".dll"); #else if (!fullVersion.isEmpty()) { suffixes << QString::fromLatin1(".so.%1").arg(fullVersion); } else { suffixes << QLatin1String(".so"); } #endif # ifdef Q_OS_MAC if (!fullVersion.isEmpty()) { suffixes << QString::fromLatin1(".%1.bundle").arg(fullVersion); suffixes << QString::fromLatin1(".%1.dylib").arg(fullVersion); } else { suffixes << QLatin1String(".bundle") << QLatin1String(".dylib"); } #endif } int dlFlags = 0; #if defined(QT_HPUX_LD) dlFlags = DYNAMIC_PATH | BIND_NONFATAL; if (loadHints & QLibrary::ResolveAllSymbolsHint) { dlFlags |= BIND_IMMEDIATE; } else { dlFlags |= BIND_DEFERRED; } #else if (loadHints & QLibrary::ResolveAllSymbolsHint) { dlFlags |= RTLD_NOW; } else { dlFlags |= RTLD_LAZY; } if (loadHints & QLibrary::ExportExternalSymbolsHint) { dlFlags |= RTLD_GLOBAL; } #if !defined(Q_OS_CYGWIN) else { #if defined(Q_OS_MAC) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) #endif dlFlags |= RTLD_LOCAL; } #endif #if defined(Q_OS_AIX) // Not sure if any other platform actually support this thing. if (loadHints & QLibrary::LoadArchiveMemberHint) { dlFlags |= RTLD_MEMBER; } #endif #endif // QT_HPUX_LD bool retry = true; for(int prefix = 0; retry && !pHnd && prefix < prefixes.size(); prefix++) { for(int suffix = 0; retry && !pHnd && suffix < suffixes.size(); suffix++) { if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix))) continue; if (!suffixes.at(suffix).isEmpty() && name.endsWith(suffixes.at(suffix))) continue; if (loadHints & QLibrary::LoadArchiveMemberHint) { attempt = name; int lparen = attempt.indexOf(QLatin1Char('(')); if (lparen == -1) lparen = attempt.count(); attempt = path + prefixes.at(prefix) + attempt.insert(lparen, suffixes.at(suffix)); } else { attempt = path + prefixes.at(prefix) + name + suffixes.at(suffix); } #if defined(QT_HPUX_LD) pHnd = (void*)shl_load(QFile::encodeName(attempt), dlFlags, 0); #else pHnd = dlopen(QFile::encodeName(attempt), dlFlags); #endif #if defined(Q_OS_SYMBIAN) // Never try again in symbian, dlopen already handles the library search logic, // and there is only one possible suffix. retry = false; #else if (!pHnd && fileName.startsWith(QLatin1Char('/')) && QFile::exists(attempt)) { // We only want to continue if dlopen failed due to that the shared library did not exist. // However, we are only able to apply this check for absolute filenames (since they are // not influenced by the content of LD_LIBRARY_PATH, /etc/ld.so.cache, DT_RPATH etc...) // This is all because dlerror is flawed and cannot tell us the reason why it failed. retry = false; } #endif } } #ifdef Q_OS_MAC if (!pHnd) { QByteArray utf8Bundle = fileName.toUtf8(); QCFType<CFURLRef> bundleUrl = CFURLCreateFromFileSystemRepresentation(NULL, reinterpret_cast<const UInt8*>(utf8Bundle.data()), utf8Bundle.length(), true); QCFType<CFBundleRef> bundle = CFBundleCreate(NULL, bundleUrl); if(bundle) { QCFType<CFURLRef> url = CFBundleCopyExecutableURL(bundle); char executableFile[FILENAME_MAX]; CFURLGetFileSystemRepresentation(url, true, reinterpret_cast<UInt8*>(executableFile), FILENAME_MAX); attempt = QString::fromUtf8(executableFile); pHnd = dlopen(QFile::encodeName(attempt), dlFlags); } } #endif #endif // QT_NO_DYNAMIC_LIBRARY if (!pHnd) { errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qdlerror()); } if (pHnd) { qualifiedFileName = attempt; errorString.clear(); } return (pHnd != 0); }
int onebyteinstr() { int r, b, x, y, y1, y2; b=PeekOneByte(); //fprintf(stderr, "b=%02X",b),getch(); switch(opcodeTable[b]) { case 0: r=op(); if(!r) return 0; x=result; //fprintf(stderr, "x=%02X",x),getch(); i_opclass=0; i_opcode=x; break; case 1: r=op(); if(!r) return 0; x=result; r=byte(); if(!r) return 0; y=result; i_opclass=1; i_opcode=x; i_byte=y; break; case 2: r=op(); if(!r) return 0; x=result; r=word(); if(!r) return 0; y=result; i_opclass=2; i_opcode=x; i_word=y; break; case 3: r=op(); if(!r) return 0; x=result; r=word(); if(!r) return 0; y1=result; r=byte(); if(!r) return 0; y2=result; i_opclass=3; i_opcode=x; i_word=y1; i_byte=y2; break; case 4: r=op(); if(!r) return 0; x=result; r=wdword(); if(!r) return 0; y=result; i_opclass=4; i_opcode=x; i_dword=y; break; case 44: r=op(); if(!r) return 0; x=result; r=adword(); if(!r) return 0; y=result; i_opclass=4; i_opcode=x; i_dword=y; break; case 5: r=op(); if(!r) return 0; x=result; r=pword(); if(!r) return 0; i_opclass=5; i_opcode=x; break; case 6: r=op(); if(!r) return 0; x=result; r=modrm(); if(!r) return 0; i_opclass=6; i_opcode=x; break; case 7: r=op(); if(!r) return 0; x=result; r=modrm(); if(!r) return 0; r=byte(); if(!r) return 0; y=result; i_opclass=7; i_opcode=x; i_byte=y; break; case 8: r=op(); if(!r) return 0; x=result; r=modrm(); if(!r) return 0; r=wdword(); if(!r) return 0; y=result; i_opclass=8; i_opcode=x; i_dword=y; break; case 9: r=op(); if(!r) return 0; x=result; r=opext(); if(!r) return 0; i_opclass=9; i_opcode=x; break; case 10: r=op(); if(!r) return 0; x=result; r=opext(); if(!r) return 0; r=byte(); if(!r) return 0; y=result; i_opclass=10; i_opcode=x; i_byte=y; break; case 11: r=op(); if(!r) return 0; x=result; r=opext(); if(!r) return 0; r=wdword(); if(!r) return 0; y=result; i_opclass=11; i_opcode=x; i_dword=y; break; case 12: r=op(); if(!r) return 0; x=result; r=opextg(); if(!r) return 0; i_opclass=12; i_opcode=x; break; case 13: r=op(); if(!r) return 0; x=result; // case jump block b=PeekOneByte(); if (b==36) { b=PeekSecondByte(); if (rmTable[b]==5) { r=op(); if(!r) return 0; y1=result; r=op(); if(!r) return 0; y2=result; i_opclass=13; i_opcode=x; i_mod=y1; i_sib=y2; r=labelstartposition(); if(!r) return 0; // .................................................................. if (nextMode) { r=label1(); finished=1; if(!r) return 1; // need to be careful ... } return 1; } } //else { b=PeekOneByte(); if (regTable[b]<7) { r=opext(); if(!r) return 0; i_opclass=13; i_opcode=x; } else return 0; } break; case 14: r=op(); if(!r) return 0; x=result; // test group if (x==246) { b=PeekOneByte(); if (regTable[b]==0) { r=opext(); if(!r) return 0; r=byte(); if(!r) return 0; y=result; i_opclass=14; i_opcode=x; i_byte=y; } else if (regTable[b]>1) { r=opext(); if(!r) return 0; i_opclass=14; i_opcode=x; } else return 0; } else { b=PeekOneByte(); if (regTable[b]==0) { r=opext(); if(!r) return 0; r=wdword(); if(!r) return 0; y=result; i_opclass=14; i_opcode=x; i_dword=y; } else { r=opext(); if(!r) return 0; i_opclass=14; i_opcode=x; } } break; case 15: r=op(); if(!r) return 0; x=result; // wait group i_opclass=15; i_opcode=x; b=PeekOneByte(); if (b==217) { b=PeekSecondByte(); if (regTable[b]==6||regTable[b]==7) { r=op(); if(!r) return 0; y=result; r=opext(); if(!r) return 0; i_opcode=y; prefixStack[i_psp++]=x; } } else if (b==219) { b=PeekSecondByte(); if (b==226||b==227) { r=op(); if(!r) return 0; y1=result; r=op(); if(!r) return 0; y2=result; i_opcode=y1; i_mod=y2; prefixStack[i_psp++]=x; } } else if (b==221) { b=PeekSecondByte(); if (regTable[b]==6||regTable[b]==7) { r=op(); if(!r) return 0; y=result; r=opext(); if(!r) return 0; i_opcode=y; prefixStack[i_psp++]=x; } } else if (b==223) { b=PeekSecondByte(); if (b==224) { r=op(); if(!r) return 0; y1=result; r=op(); if(!r) return 0; y2=result; i_opcode=y1; i_mod=y2; prefixStack[i_psp++]=x; } } break; case 16: r=op(); if(!r) return 0; x=result; // repeat group if (x==242) { while(prefixes()); b=PeekOneByte(); if (repeatgroupTable[b]==1) { r=op(); if(!r) return 0; y=result; i_opclass=16; i_opcode=y; prefixStack[i_psp++]=x; } else return 0; } else { while(prefixes()); b=PeekOneByte(); if (repeatgroupTable[b]>0) { r=op(); if(!r) return 0; y=result; i_opclass=16; i_opcode=y; prefixStack[i_psp++]=x; } else return 0; } break; default: return 0; } return 1; }
bool QLibraryPrivate::load_sys() { QFileInfo fi(fileName); QString path = fi.path(); QString name = fi.fileName(); if (path == QLatin1String(".") && !fileName.startsWith(path)) path.clear(); else path += QLatin1Char('/'); QStringList suffixes, prefixes(""); if (QLibrary::isLibrary(fileName)) suffixes << ""; if (pluginState != IsAPlugin) { prefixes << "lib"; #if defined(Q_OS_HPUX) suffixes << ".sl"; suffixes << QString(".%1").arg(majorVerNum); #elif defined(Q_OS_AIX) suffixes << ".a"; #else suffixes << ".so"; if (majorVerNum > -1) suffixes << QString(".so.%1").arg(majorVerNum); #endif # ifdef Q_OS_MAC suffixes << ".bundle" << ".dylib"; if (majorVerNum > -1) { suffixes << QString(".%1.bundle").arg(majorVerNum); suffixes << QString(".%1.dylib").arg(majorVerNum); } #endif } QString attempt; for(int prefix = 0; !pHnd && prefix < prefixes.size(); prefix++) { for(int suffix = 0; !pHnd && suffix < suffixes.size(); suffix++) { if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix))) continue; if (!suffixes.at(suffix).isEmpty() && name.endsWith(suffixes.at(suffix))) continue; attempt = path + prefixes.at(prefix) + name + suffixes.at(suffix); pHnd = DL_PREFIX(dlopen)(QFile::encodeName(attempt), RTLD_LAZY); } } #ifdef Q_OS_MAC if (!pHnd) { if(QCFType<CFBundleRef> bundle = CFBundleGetBundleWithIdentifier(QCFString(fileName))) { QCFType<CFURLRef> url = CFBundleCopyExecutableURL(bundle); QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); pHnd = DL_PREFIX(dlopen)(QFile::encodeName(str), RTLD_LAZY); attempt = str; } } # endif #if defined(QT_DEBUG_COMPONENT) if (!pHnd) { qWarning("QLibrary: Cannot load '%s' :%s", QFile::encodeName(fileName).constData(), qdlerror()); } #endif if (pHnd) qualifiedFileName = attempt; return (pHnd != 0); }