bool insertDB() { std::unique_ptr<MYSQL, MysqlDestroy> mysql{ mysql_init(nullptr) }; if (!mysql_real_connect(&*mysql, IP.c_str(), USER.c_str(), PASSWORD.c_str(), "test", PORT, nullptr, 0)) { printf("error mysql_real_connect\n"); return false; } std::string sql = "INSERT INTO `txx` (`fname`, `fblob`) VALUES ('"; std::string val = "sddfa\r\n'a'b'c'"; auto buff = escapeString(&*mysql, val.data(), val.size()); sql.append(buff.begin(), buff.end()); sql += "','"; std::vector<int32_t> blob = {100,0,200,0,123456789,1234567890}; buff = escapeString(&*mysql, (const char*)blob.data(), blob.size() * sizeof(int32_t)); sql.append(buff.begin(), buff.end()); sql += "')"; if (mysql_real_query(&*mysql, sql.data(), sql.size()) != 0) { printf("error mysql_query\n"); return false; } return true; }
GerberGenerator::GerberGenerator(const QString& projName, const Uuid& projUuid, const QString& projRevision) noexcept : mProjectId(escapeString(projName)), mProjectUuid(projUuid), mProjectRevision(escapeString(projRevision)), mOutput(), mContent(), mApertureList(new GerberApertureList()), mCurrentApertureNumber(-1), mMultiQuadrantArcModeOn(false) { }
void CfgFile::addBlock(const std::string &sBlock, const blockMap &block) { if (findBlock(sBlock) == 0) { std::ofstream f; copyFirstPart(f, cfgfile.tellg()); for (auto item : block) { std::string sValue = item.second; if (sValue.find_first_of("\n\r") != std::string::npos) throw std::invalid_argument("I can't write a string containing a 'new line' to the config file!"); escapeString(sValue, "\"#", '\\'); if (sValue.find_first_of(" \t") != std::string::npos) sValue = "\"" + sValue + "\""; f << '\t' << item.first << " = " << sValue << "\n"; } findKey(""); copySecondPart(f, cfgfile.tellg()); } else { cfgfile.seekg(biggestBlockPosition); if (findKey("") != 2) throw std::logic_error( "unhandled return value of findKey(). Or something is very wrong with your cfg file."); // now we are at eof, but empty lines or comments at the end of the file do not matter cfgfile.unget(); if (cfgfile.get() != '\n') cfgfile << '\n'; cfgfile.clear(); cfgfile << "\n[" << sBlock << "]\n"; for (auto item : block) { std::string sValue = item.second; if (sValue.find_first_of("\n\r") != std::string::npos) throw std::invalid_argument("I can't write a string containing a 'new line' to the config file!"); escapeString(sValue, "\"#", '\\'); if (sValue.find_first_of(" \t") != std::string::npos) sValue = "\"" + sValue + "\""; cfgfile << '\t' << item.first << " = " << sValue << "\n"; } cfgfile.flush(); } }
bool BCLXML::save() const { if (m_path.empty()){ return false; } QDomDocument doc; doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\""); QDomElement docElement; if (m_bclXMLType == BCLXMLType::ComponentXML){ docElement = doc.createElement("component"); doc.appendChild(docElement); }else if (m_bclXMLType == BCLXMLType::MeasureXML){ docElement = doc.createElement("measure"); doc.appendChild(docElement); }else{ return false; } QDomElement element = doc.createElement("name"); docElement.appendChild(element); element.appendChild(doc.createTextNode(toQString(escapeString(m_name)))); element = doc.createElement("uid"); docElement.appendChild(element); element.appendChild(doc.createTextNode(toQString(m_uid))); element = doc.createElement("version_id"); docElement.appendChild(element); element.appendChild(doc.createTextNode(toQString(m_versionId))); element = doc.createElement("description"); docElement.appendChild(element); element.appendChild(doc.createTextNode(toQString(escapeString(m_description)))); if (m_bclXMLType == BCLXMLType::MeasureXML){ element = doc.createElement("modeler_description"); docElement.appendChild(element); element.appendChild(doc.createTextNode(toQString(escapeString(m_modelerDescription)))); } // TODO: write provenances element = doc.createElement("provenances"); docElement.appendChild(element); // write tags element = doc.createElement("tags"); Q_FOREACH(const std::string& tag, m_tags){ QDomElement tagElement = doc.createElement("tag"); element.appendChild(tagElement); tagElement.appendChild(doc.createTextNode(toQString(tag))); }
// Print the cluster of the subregions. This groups the single basic blocks // and adds a different background color for each group. static void printRegionCluster(const ScopDetection *SD, const Region *R, raw_ostream &O, unsigned depth = 0) { O.indent(2 * depth) << "subgraph cluster_" << static_cast<const void *>(R) << " {\n"; unsigned LineBegin, LineEnd; std::string FileName; getDebugLocation(R, LineBegin, LineEnd, FileName); std::string Location; if (LineBegin != (unsigned)-1) { Location = escapeString(FileName + ":" + std::to_string(LineBegin) + "-" + std::to_string(LineEnd) + "\n"); } std::string ErrorMessage = SD->regionIsInvalidBecause(R); ErrorMessage = escapeString(ErrorMessage); O.indent(2 * (depth + 1)) << "label = \"" << Location << ErrorMessage << "\";\n"; if (SD->isMaxRegionInScop(*R)) { O.indent(2 * (depth + 1)) << "style = filled;\n"; // Set color to green. O.indent(2 * (depth + 1)) << "color = 3"; } else { O.indent(2 * (depth + 1)) << "style = solid;\n"; int color = (R->getDepth() * 2 % 12) + 1; // We do not want green again. if (color == 3) color = 6; O.indent(2 * (depth + 1)) << "color = " << color << "\n"; } for (const auto &SubRegion : *R) printRegionCluster(SD, SubRegion.get(), O, depth + 1); RegionInfo *RI = R->getRegionInfo(); for (const auto &BB : R->blocks()) if (RI->getRegionFor(BB) == R) O.indent(2 * (depth + 1)) << "Node" << static_cast<void *>(RI->getTopLevelRegion()->getBBNode(BB)) << ";\n"; O.indent(2 * depth) << "}\n"; }
void SendLogsRequest::send() { QUrl url; url.setScheme( "http" ); url.setHost( "oops.last.fm" ); url.setPath( "logsubmission/add" ); url.addEncodedQueryItem( "username", QUrl::toPercentEncoding(Ws::Username) ); #ifdef Q_WS_MAC url.addQueryItem( "platform", "macosx" ); #elif defined WIN32 url.addQueryItem( "platform", "win32" ); #else url.addQueryItem( "platform", "linux" ); #endif url.addQueryItem( "clientname", QCoreApplication::applicationName() ); url.addQueryItem( "clientversion", QCoreApplication::applicationVersion() ); QNetworkRequest request = QNetworkRequest( url ); request.setRawHeader( "Content-Type", "multipart/form-data;boundary=8e61d618ca16" ); request.setRawHeader( "Accept", "*/*" ); m_data.append( postData( "usernotes", escapeString( m_usernotes ).toLatin1() ) ); m_data.append( postData( "logs", m_logs.join(",").toLatin1() ) ); m_data.append( "--8e61d618ca16--" ); // close the post request m_error = false; QNetworkReply *reply = (new WsAccessManager( this ))->post( request, m_data ); connect( reply, SIGNAL( finished() ), this, SLOT( onFinished() ) ); connect( reply, SIGNAL( error( QNetworkReply::NetworkError ) ), this, SLOT( onError( QNetworkReply::NetworkError ) ) ); }
void QueryBuilder::excludeFilter( int tables, const QString& filter ) { if ( !filter.isEmpty() ) { m_where += "AND ( true "; if ( tables & tabAlbum ) m_where += "AND album.name <> '%" + escapeString( filter ) + "%' "; if ( tables & tabArtist ) m_where += "AND artist.name <> '%" + escapeString( filter ) + "%' "; if ( tables & tabGenre ) m_where += "AND genre.name <> '%" + escapeString( filter ) + "%' "; if ( tables & tabYear ) m_where += "AND year.name <> '%" + escapeString( filter ) + "%' "; if ( tables & tabSong ) m_where += "AND tags.title <> '%" + escapeString( filter ) + "%' "; m_where += " ) "; } m_linkTables |= tables; }
std::deque< std::string > fromDB(const liboscar::Static::OsmKeyValueObjectStore & db, sserialize::StringCompleter::QuerryType qt, uint32_t count) { std::deque< std::string> ret; std::string escapeStr = "-+/\\^$[]() "; std::set<char> escapeChars(escapeStr.begin(), escapeStr.end()); if (qt & sserialize::StringCompleter::QT_SUBSTRING) { for(size_t i = 0; i < count; i++) { uint32_t itemId = ((double)rand()/RAND_MAX)*db.size(); liboscar::Static::OsmKeyValueObjectStore::Item item( db.at(itemId) ); std::string str = ""; for(size_t j = 0; j < item.strCount(); j++) { std::string s = item.strAt(j); if (s.size()) { if (*(s.begin()) == '\"') { s.erase(0,1); if (s.size() > 0 && *(s.rbegin()) == '\"') { s.erase(s.size()-1, 1); } } str += escapeString(escapeChars, s) + " "; } } if (qt & sserialize::StringCompleter::QT_CASE_INSENSITIVE) str = sserialize::unicode_to_lower(str); if (str.size() > 3) ret.push_back(str); } } return ret; }
SEXP getValue(const std::shared_ptr<cpptoml::base>& base) { if (auto v = base->as<std::string>()) { std::string s(escapeString(v->get())); return Rcpp::wrap(s); } else if (auto v = base->as<int64_t>()) { std::int64_t s(v->get()); int t = static_cast<int>(s); // we need int for wrap to work return Rcpp::wrap(t); } else if (auto v = base->as<double>()) { double s(v->get()); return Rcpp::wrap(s); } else if (auto v = base->as<bool>()) { bool s(v->get()); return Rcpp::wrap(s); } else if (auto v = base->as<cpptoml::datetime>()) { cpptoml::datetime s(v->get()); struct tm tm; tm.tm_year = s.year - 1900; tm.tm_mon = s.month - 1; tm.tm_mday = s.day; tm.tm_hour = s.hour; tm.tm_min = s.minute; tm.tm_sec = s.second; time_t tt = mktime(&tm); Rcpp::Datetime r(tt + s.microsecond * 1.0e-6); return Rcpp::wrap(r); } else { Rcpp::warning("Unparsed value, returning null"); return R_NilValue; } }
/*************************************************************** * Function: Text::toString() * Purpose : Produce a string representation of this node * Initial : Maxime Chevalier-Boisvert on October 20, 2008 **************************************************************** Revisions and bug fixes: */ std::string Text::toString(bool indent, size_t level) const { // Create a string to store the string representation std::string output; // If the output should be indented if (indent) { // If this is not the first indentation level if (level > 0) { // Begin a new line output += "\n"; } // For each indentation level for (size_t i = 0; i < level; ++i) { // Add two spaces output += " "; } } // Escape the text and add it to the output output += escapeString(m_text); // Return the string representation return output; }
string MysqlHelper::buildUpdateSQL(const string &sTableName,const RECORD_DATA &mpColumns, const string &sWhereFilter) { ostringstream sColumnNameValueSet; map<string, pair<FT, string> >::const_iterator itEnd = mpColumns.end(); for(map<string, pair<FT, string> >::const_iterator it = mpColumns.begin(); it != itEnd; ++it) { if (it == mpColumns.begin()) { sColumnNameValueSet << "`" << it->first << "`"; } else { sColumnNameValueSet << ",`" << it->first << "`"; } if(it->second.first == DB_INT) { sColumnNameValueSet << "= " << it->second.second; } else { sColumnNameValueSet << "= '" << escapeString(it->second.second) << "'"; } } ostringstream os; os << "update " << sTableName << " set " << sColumnNameValueSet.str() << " " << sWhereFilter; return os.str(); }
/** \brief Complete constructor, takes group information and msk/cmp. * * This constructor takes a msk/cmp pair. Both must be vectors of length <= * \ref HWLM_MASKLEN. */ hwlmLiteral::hwlmLiteral(const std::string &s_in, bool nocase_in, bool noruns_in, u32 id_in, hwlm_group_t groups_in, const vector<u8> &msk_in, const vector<u8> &cmp_in) : s(s_in), id(id_in), nocase(nocase_in), noruns(noruns_in), groups(groups_in), msk(msk_in), cmp(cmp_in) { assert(msk.size() <= HWLM_MASKLEN); assert(msk.size() == cmp.size()); // If we've been handled a nocase literal, all letter characters must be // upper-case. if (nocase) { upperString(s); } DEBUG_PRINTF("literal '%s'%s, msk=%s, cmp=%s\n", escapeString(s).c_str(), nocase ? " (nocase)" : "", dumpMask(msk).c_str(), dumpMask(cmp).c_str()); // Mask and compare vectors MUST be the same size. assert(msk.size() == cmp.size()); // We must have been passed a msk/cmp that can be applied to s. assert(maskIsConsistent(s, nocase, msk, cmp)); // In the name of good hygiene, zap msk/cmp if msk is all zeroes. if (all_of(begin(msk), end(msk), [](u8 val) { return val == 0; })) { msk.clear(); cmp.clear(); } }
void QueryBuilder::addFilter( int tables, const QString& filter, int /*mode*/ ) { if ( !filter.isEmpty() ) { m_where += "AND ( true "; if ( tables & tabAlbum ) m_where += "OR album.name LIKE '%" + escapeString( filter ) + "%' "; if ( tables & tabArtist ) m_where += "OR artist.name LIKE '%" + escapeString( filter ) + "%' "; if ( tables & tabGenre ) m_where += "OR genre.name LIKE '%" + escapeString( filter ) + "%' "; if ( tables & tabYear ) m_where += "OR year.name LIKE '%" + escapeString( filter ) + "%' "; if ( tables & tabSong ) m_where += "OR tags.title LIKE '%" + escapeString( filter ) + "%' "; m_where += " ) "; } m_linkTables |= tables; }
std::string DatabaseMySQL::escapePatternString(const std::string &s) { std::string str = escapeString(s); str = boost::regex_replace(str, boost::regex("%"), "\\%"); str = boost::regex_replace(str, boost::regex("_"), "\\_"); return str; }
/* Encodes a section table entry back into disk format. */ void * SgAsmPESectionTableEntry::encode(PESectionTableEntry_disk *disk) const { /* The file can hold up to eight characters of the name. The name is NUL-padded, not necessarily NUL-terminated. */ if (p_name.size()>8) { fprintf(stderr, "warning: section name too long to store in PE file: \"%s\" (truncated)\n", escapeString(p_name).c_str()); } memset(disk->name, 0, sizeof(disk->name)); #ifdef USE_ROSE // DQ (1/27/2010): std::min() does not appear to be handle different type of arguments for ROSE. Need to look into this later. // memcpy(disk->name, p_name.c_str(), std::min(sizeof(disk->name), (size_t)p_name.size())); memcpy(disk->name, p_name.c_str(), std::min( (size_t)(sizeof(disk->name)), (size_t)(p_name.size()) )); #else memcpy(disk->name, p_name.c_str(), std::min(sizeof(disk->name), p_name.size())); #endif ByteOrder::host_to_le(p_virtual_size, &(disk->virtual_size)); ByteOrder::host_to_le(p_rva, &(disk->rva)); ByteOrder::host_to_le(p_physical_size, &(disk->physical_size)); ByteOrder::host_to_le(p_physical_offset, &(disk->physical_offset)); ByteOrder::host_to_le(p_coff_line_nums, &(disk->coff_line_nums)); ByteOrder::host_to_le(p_n_relocs, &(disk->n_relocs)); ByteOrder::host_to_le(p_n_coff_line_nums, &(disk->n_coff_line_nums)); ByteOrder::host_to_le(p_flags, &(disk->flags)); return disk; }
bool LLWaterParamManager::removeParamSet(const std::string& name, bool delete_from_disk) { // remove from param list preset_map_t::iterator it = mParamList.find(name); if (it == mParamList.end()) { LL_WARNS("WindLight") << "No water preset named " << name << LL_ENDL; return false; } mParamList.erase(it); // remove from file system if requested if (delete_from_disk) { // <FS:Ansariel> FIRE-10861: Fix Windlight settings order //if (gDirUtilp->deleteFilesInDir(getUserDir(), LLURI::escape(name) + ".xml") < 1) if (gDirUtilp->deleteFilesInDir(getUserDir(), escapeString(name) + ".xml") < 1) // </FS:Ansariel> { LL_WARNS("WindLight") << "Error removing water preset " << name << " from disk" << LL_ENDL; } } // signal interested parties mPresetListChangeSignal(); return true; }
void ConfigItem::dump( StringBuffer & buf, const char * name, bool wantExpandedUidNames, int indentLevel) const { int i; int len; char * escStr; StringBuffer nameBuf; UidIdentifierProcessor uidIdProc; if (!wantExpandedUidNames) { name = uidIdProc.unexpand(name, nameBuf); } printIndent(buf, indentLevel); switch (m_type) { case Configuration::CFG_STRING: escStr = escapeString(m_stringVal); buf << name << " = \"" << escStr << "\";\n"; delete [] escStr; break; case Configuration::CFG_LIST: buf << name << " = ["; len = m_listVal->length(); for (i = 0; i < len; i++) { escStr = escapeString((*m_listVal)[i]); buf << "\"" << escStr << "\""; delete [] escStr; if (i < len-1) { buf << ", "; } } buf << "];\n"; break; case Configuration::CFG_SCOPE: buf << name << " {\n"; m_scope->dump(buf, wantExpandedUidNames, indentLevel + 1); printIndent(buf, indentLevel); buf << "}\n"; break; default: assert(0); // Bug break; }; }
inline void printNode(ostream& o, const NodeT& n) { string id = n.id(); string nodeColor = "black"; if (isSgStatement(n.getNode())) nodeColor = "blue"; else if (isSgExpression(n.getNode())) nodeColor = "green"; else if (isSgInitializedName(n.getNode())) nodeColor = "red"; o << id << " [label=\"" << escapeString(Debug ? n.toStringForDebugging() : n.toString()) << "\", color=\"" << nodeColor << "\", style=\"" << (n.isInteresting() ? "solid" : "dotted") << "\"];\n"; }
bool LLWaterParamManager::isSystemPreset(const std::string& preset_name) const { // *TODO: file system access is excessive here. // <FS:Ansariel> FIRE-10861: Fix Windlight settings order //return gDirUtilp->fileExists(getSysDir() + LLURI::escape(preset_name) + ".xml"); return gDirUtilp->fileExists(getSysDir() + escapeString(preset_name) + ".xml"); // </FS:Ansariel> }
QString IqOrmSqlDataSource::joinStringArray(const QStringList &list) { if (list.isEmpty()) return ""; QStringList escapedStringList; foreach (const QString &string, list) { escapedStringList.append(escapeString(string)); }
void ReplayBuilder::appendString(std::stringstream &out, ReplayData *data, int &i) { int len = data->getInt(i++); std::stringstream stringStream; for (int x = 0; x < len; x++) { stringStream << (char) data->getInt(i++); } out << escapeString(stringStream.str()); }
//--------------------------------------------------------- void DocumentXML::finalize() { assert(NodeStack.size() == 1 && "not completely backtracked"); addSubNode("ReferenceSection"); addSubNode("Types"); for (XML::IdMap<QualType>::iterator i = Types.begin(), e = Types.end(); i != e; ++i) { if (i->first.hasLocalQualifiers()) { writeTypeToXML(i->first); addAttribute("id", getPrefixedId(i->second, ID_NORMAL)); toParent(); } } for (XML::IdMap<const Type*>::iterator i = BasicTypes.begin(), e = BasicTypes.end(); i != e; ++i) { writeTypeToXML(i->first); addAttribute("id", getPrefixedId(i->second, ID_NORMAL)); toParent(); } toParent().addSubNode("Contexts"); for (XML::IdMap<const DeclContext*>::iterator i = Contexts.begin(), e = Contexts.end(); i != e; ++i) { addSubNode(i->first->getDeclKindName()); addAttribute("id", getPrefixedId(i->second, ID_NORMAL)); if (const NamedDecl *ND = dyn_cast<NamedDecl>(i->first)) addAttribute("name", ND->getNameAsString()); if (const TagDecl *TD = dyn_cast<TagDecl>(i->first)) addAttribute("type", getPrefixedId(BasicTypes[TD->getTypeForDecl()], ID_NORMAL)); else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(i->first)) addAttribute("type", getPrefixedId(BasicTypes[FD->getType()->getAs<FunctionType>()], ID_NORMAL)); if (const DeclContext* parent = i->first->getParent()) addAttribute("context", parent); toParent(); } toParent().addSubNode("Files"); for (XML::IdMap<std::string>::iterator i = SourceFiles.begin(), e = SourceFiles.end(); i != e; ++i) { addSubNode("File"); addAttribute("id", getPrefixedId(i->second, ID_FILE)); addAttribute("name", escapeString(i->first.c_str(), i->first.size())); toParent(); } toParent().toParent(); // write the root closing node (which has always subnodes) Out << "</" << NodeStack.top() << ">\n"; }
static void dumpLits(UNUSED const vector<hwlmLiteral> &lits) { #ifdef DEBUG DEBUG_PRINTF("building lit table for:\n"); for (const auto &lit : lits) { printf("\t%u:%016llx %s%s\n", lit.id, lit.groups, escapeString(lit.s).c_str(), lit.nocase ? " (nc)" : ""); } #endif }
bool TextOArchive::operator()(StringInterface& value, const char* name, const char* label) { placeIndent(); placeName(name); (*buffer_) << "\""; const char* str = value.get(); escapeString(*buffer_, str, str + strlen(value.get())); (*buffer_) << "\""; return true; }
void QueryBuilder::addMatches( int tables, const QStringList& match ) { if ( !match.isEmpty() ) { m_where += "AND ( true "; for ( uint i = 0; i < match.count(); i++ ) { if ( tables & tabAlbum ) m_where += "OR album.name LIKE '" + escapeString( match[i] ) + "' "; if ( tables & tabArtist ) m_where += "OR artist.name LIKE '" + escapeString( match[i] ) + "' "; if ( tables & tabGenre ) m_where += "OR genre.name LIKE '" + escapeString( match[i] ) + "' "; if ( tables & tabYear ) m_where += "OR year.name LIKE '" + escapeString( match[i] ) + "' "; if ( tables & tabSong ) m_where += "OR tags.title LIKE '" + escapeString( match[i] ) + "' "; if ( tables & tabStats ) m_where += "OR statistics.url LIKE '" + escapeString( match[i] ) + "' "; if ( match[i] == i18n( "Unknown" ) ) { if ( tables & tabAlbum ) m_where += "OR album.name = '' "; if ( tables & tabArtist ) m_where += "OR artist.name = '' "; if ( tables & tabGenre ) m_where += "OR genre.name = '' "; if ( tables & tabYear ) m_where += "OR year.name = '' "; } } m_where += " ) "; } m_linkTables |= tables; }
void Visitor::visit(SgNode* n) { SgAsmGenericSymbol *symbol = isSgAsmGenericSymbol(n); if (symbol != NULL) { printf("Found a SgAsmGenericSymbol, Here: offset = %zu, %p = %s = %s \n", (size_t)0, symbol, escapeString(symbol->class_name()).c_str(), symbol->get_name()->get_string(true).c_str()); printf ("symbol->get_name() = %s \n",symbol->get_name()->get_string(true).c_str()); printf ("symbol->get_bound() = %p \n",symbol->get_bound()); printf ("symbol->get_size() = %" PRIu64 " \n",symbol->get_size()); printf ("symbol->get_value() = %" PRIu64 " \n",symbol->get_value()); printf ("symbol->get_type() = %u = %s \n",symbol->get_type(),symbol->stringifyType().c_str()); printf ("symbol->get_binding() = %u = %s \n",symbol->get_binding(),symbol->stringifyBinding().c_str()); printf ("symbol->get_def_state() = %u = %s \n",symbol->get_def_state(),symbol->stringifyDefState().c_str()); /* All the ELF-specific stuff and most of the COFF-specific stuff is also represented in the base class, displayed * above. The general rule is that notions that are present in at least two file formats are represented in a * common base class and there's no need to access the copies that might be stored in the derived classes. However, * they are duplicated in the derived classes because those classes tend to represent data structures described * directly in the format specifications. The only reason they're publicly visible in the derived classes is because * ROSETTA doesn't support marking certain things as being for internal use only. I'm working on documenting these * things better. * * For instance, the p_st_name member of an SgAsmElfSymbol is a byte offset into an ELF String Table. The actual * string is stored in the p_name member of SgAsmGenericSymbol. Modifying the string will cause all the correct * memory management actions to occur (ultimately adjusting p_st_name), while modifying p_st_name bypasses string * table management (and your new value would be overwritten if/when memory management does occur). * * [RPM 2008-12-15] */ /* The Coff-specific stuff may eventually disappear as the base class evolves to handle more of this. In fact, some * of these are already duplicates of the same info above. */ SgAsmCoffSymbol* coffSymbol = isSgAsmCoffSymbol(symbol); if (coffSymbol != NULL) { printf (" coffSymbol->get_st_name() = %s \n",coffSymbol->get_st_name().c_str()); printf (" coffSymbol->get_st_name_offset() = %" PRIu64 " \n",coffSymbol->get_st_name_offset()); printf (" coffSymbol->get_st_section_num() = %d \n",coffSymbol->get_st_section_num()); printf (" coffSymbol->get_st_type() = %u \n",coffSymbol->get_st_type()); printf (" coffSymbol->get_st_storage_class() = %u \n",coffSymbol->get_st_storage_class()); printf (" coffSymbol->get_st_num_aux_entries() = %u \n",coffSymbol->get_st_num_aux_entries()); printf (" coffSymbol->get_aux_data(): size = %zu \n",coffSymbol->get_aux_data().size()); for (SgUnsignedCharList::iterator i = coffSymbol->get_aux_data().begin(); i != coffSymbol->get_aux_data().end(); i++) { printf (" coffSymbol->get_aux_data() = %u \n",*i); } } } }
string MysqlHelper::buildInsertSQL(const string &sTableName, const RECORD_DATA &mpColumns) { ostringstream sColumnNames; ostringstream sColumnValues; map<string, pair<FT, string> >::const_iterator itEnd = mpColumns.end(); for(map<string, pair<FT, string> >::const_iterator it = mpColumns.begin(); it != itEnd; ++it) { if (it == mpColumns.begin()) { sColumnNames << "`" << it->first << "`"; if(it->second.first == DB_INT) { sColumnValues << it->second.second; } else { sColumnValues << "'" << escapeString(it->second.second) << "'"; } } else { sColumnNames << ",`" << it->first << "`"; if(it->second.first == DB_INT) { sColumnValues << "," + it->second.second; } else { sColumnValues << ",'" + escapeString(it->second.second) << "'"; } } } ostringstream os; os << "insert into " << sTableName << " (" << sColumnNames.str() << ") values (" << sColumnValues.str() << ")"; return os.str(); }
void SendLogsRequest::addLog( QString name, QString filename ) { if ( QFile::exists( filename ) ) { QFile file( filename ); if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) return; m_data.append( postData( name, qCompress( escapeString( file.readAll() ).toLatin1() ) ) ); m_logs.append( name ); } }
SEXP getValue(const std::shared_ptr<cpptoml::base>& base) { if (auto v = base->as<std::string>()) { std::string s(escapeString(v->get())); return Rcpp::wrap(s); } else if (auto v = base->as<int64_t>()) { std::int64_t s(v->get()); int t = static_cast<int>(s); // we need int for wrap to work return Rcpp::wrap(t); } else if (auto v = base->as<double>()) { double s(v->get()); return Rcpp::wrap(s); } else if (auto v = base->as<bool>()) { bool s(v->get()); return Rcpp::wrap(s); } else if (auto v = base->as<cpptoml::local_date>()) { cpptoml::local_date s(v->get()); Rcpp::Date d(s.year,s.month,s.day); return Rcpp::wrap(d); } else if (auto v = base->as<cpptoml::local_datetime>()) { cpptoml::local_datetime s(v->get()); struct tm tm; tm.tm_year = s.year - 1900; tm.tm_mon = s.month - 1; tm.tm_mday = s.day; tm.tm_hour = s.hour; tm.tm_min = s.minute; tm.tm_sec = s.second; time_t tt = local_timegm(&tm); //tt = tt - s.hour_offset*60*60 - s.minute_offset*60; Rcpp::DatetimeVector dt(1, "UTC"); dt[0] = tt + s.microsecond * 1.0e-6; return Rcpp::wrap(dt); } else if (auto v = base->as<cpptoml::offset_datetime>()) { cpptoml::offset_datetime s(v->get()); struct tm tm; tm.tm_year = s.year - 1900; tm.tm_mon = s.month - 1; tm.tm_mday = s.day; tm.tm_hour = s.hour; tm.tm_min = s.minute; tm.tm_sec = s.second; time_t tt = local_timegm(&tm); tt = tt - s.hour_offset*60*60 - s.minute_offset*60; Rcpp::DatetimeVector dt(1, "UTC"); dt[0] = tt + s.microsecond * 1.0e-6; return Rcpp::wrap(dt); } else { Rcpp::warning("Unparsed value, returning null"); return R_NilValue; } }
END_TEST START_TEST(escapeString_test) { char *rv, *expected; rv = escapeString(request, "a+b c<d>e\"f%g{h}i|j\\k^l~m[n]o`p;q/r?s:t@u=v&" "w#x"); /* * output of python's urllib.quote(...).lower(), and replacing the remaining * '/' with %2f (it doesn't encode that for some reason. */ expected = "a%2bb%20c%3cd%3ee%22f%25g%7bh%7di%7cj%5ck%5el%7em%5bn%5do%60p" "%3bq%2fr%3fs%3at%40u%3dv%26w%23x"; fail_unless(strcmp(rv, expected) == 0); }