コード例 #1
0
ファイル: FUUri.cpp プロジェクト: jb55/jgblue
FUUri::FUUri(const fstring& uri, bool escape)
	:	scheme(FUUri::NONE),
		port(0),
		path(FC(""))
{
	if (uri.empty()) return;

	fstring _uri;

	if (escape)
	{
		_uri = Escape(uri);
	}
	else
	{
		_uri = uri;
	}

	// Replace all '\\' characters by '/' so the path is only using them
	_uri.replace(FC('\\'), FC('/'));

	// Find the scheme from its ':' delimiter
	size_t schemeDelimiterIndex = _uri.find(FC(':'));
	size_t hostIndex = 0;

	if (schemeDelimiterIndex != fstring::npos && schemeDelimiterIndex > 1)
	{
		fstring _scheme = _uri.substr(0, schemeDelimiterIndex);

		if (IsEquivalent(_scheme, FC("FILE")) || IsEquivalent(_scheme, FC("file")))
		{
			scheme = FUUri::FILE;
		}
		else if (IsEquivalent(_scheme, FC("FTP")) || IsEquivalent(_scheme, FC("ftp")))
		{
			scheme = FUUri::FTP;
		}
		else if (IsEquivalent(_scheme, FC("HTTP")) || IsEquivalent(_scheme, FC("http")))
		{
			scheme = FUUri::HTTP;
		}
		else if (IsEquivalent(_scheme, FC("HTTPS")) || IsEquivalent(_scheme, FC("https")))
		{
			scheme = FUUri::HTTPS;
		}
		else
		{
#ifdef WIN32
			// Scheme not supported (could be a NFS path)
			FUFail(return);
#endif // WIN32
		}

		schemeDelimiter = _uri.substr(schemeDelimiterIndex, 3);
		hostIndex = schemeDelimiterIndex + 3;
	}
コード例 #2
0
ファイル: Scripting.cpp プロジェクト: LosEcher/si_plugins
int l_plugin_call(lua_State *L)
{
  char *plugin = (char *) luaL_checkstring(L, 1);
  char *command = (char *) luaL_checkstring(L, 2);
  char *params = (char *) luaL_checkstring(L, 3);

  int escaped_count = Escape(NULL, params, '\\');
  if (escaped_count)
  {
    char *escaped_params = new char[ lstrlen(params) + escaped_count + 1];
    Escape(escaped_params, params, '\\');

    siFuncs->DoCommand(plugin, command, escaped_params);
    delete escaped_params;
  }
  else
    siFuncs->DoCommand(plugin, command, params);

  return 0; // number of return values
}
コード例 #3
0
 // First result as string
 bool CArgMap::Get ( const SString& strCmd, SString& strOut, const char* szDefault ) const
 {
     assert ( szDefault );
     if ( const SString* pResult = MapFind ( m_Map, Escape ( strCmd ) ) )
     {
         strOut = Unescape ( *pResult );
         return true;
     }
     strOut = szDefault;
     return false;
 }
コード例 #4
0
std::string ToMathematica(Quantity<D> const& quantity) {
  std::string s = DebugString(quantity);
  if (IsFinite(quantity)) {
    s.replace(s.find("e"), 1, "*^");
  }
  std::string const number = ToMathematica(quantity / SIUnit<Quantity<D>>());
  std::size_t const split = s.find(" ");
  std::string const units = Escape(s.substr(split, s.size()));
  return Apply(
      "SetPrecision",
      {Apply("Quantity", {number, units}), "MachinePrecision"});
}
コード例 #5
0
ファイル: main.cpp プロジェクト: dreamsxin/ultimatepp
void Main()
{
	String code = LoadFile("E:\\sic.sic");
	ArrayMap<String, SVal> global;

	Escape(global, "print(x)", SIC_Print);
	Escape(global, "dump_locals()", SIC_DumpLocals);

	StdLib(global);

	try {
		Scan(global, code);
		TimeStop();
		SVal ret = Execute(global, "main");
		RLOG(TimeStop());
		RLOG("RETURN VALUE: " << ret.Dump());
	}
	catch(CParser::Error& e)
	{
		RLOG(e);
	}
}
コード例 #6
0
ファイル: oauth.cpp プロジェクト: smandava/cuteflix
QByteArray Oauth::HmacSha1(QString secretKey, QString data, QString tokenSecret)
{
    QString signingKey = QString("%1&%2").arg(Escape(secretKey),Escape(tokenSecret));

    unsigned char result[EVP_MAX_MD_SIZE];
    unsigned int resultlen = 0;
    HMAC(
         EVP_sha1(),
         qPrintable(signingKey),
         signingKey.toLocal8Bit().length(),
         (unsigned char*)data.toLocal8Bit().data(),
         data.toLocal8Bit().length(),
         result,
         &resultlen
         );
    char* cbase64 = base64(result,resultlen);
    QByteArray resultArray(cbase64);
    qDebug() << resultArray;
    resultArray = resultArray.toPercentEncoding();
    free(cbase64);
    return resultArray;
}
コード例 #7
0
ファイル: uPrinter.cpp プロジェクト: vagabond1132/Code
//取得纸张的物理尺寸---单位:点
TPoint __fastcall CPrinter::GetPhicalPaper()
{
    if (PPRN == NULL)
    {
        return TPoint(-1, -1);
    }

    TPoint PageSize;
    //PageSize.X; 纸张物理宽度-单位:点
    //PageSize.Y; 纸张物理高度-单位:点
    Escape(PPRN->Handle, GETPHYSPAGESIZE, 0, NULL, &PageSize);
    return PageSize;
}
コード例 #8
0
ファイル: edt_editmain.c プロジェクト: tjordanchat/eag
static void LayoutOnEscape ()
	{ if (try_and_replace_rule (layout_rule, layout_dir))
	     { XtPopdown (layout_popup);
	       Escape ();
	     }
	  else
	     { StartArgs;
	       SetArg (XtNlabel, tuple_error_buffer);
	       XtSetValues (layout_error, UseArgs);
	       StartArgs;
	       SetArg (XtNeditable, True);
	       XtSetValues (layout_edit, UseArgs);
	     };
	};
コード例 #9
0
ファイル: xmlHandler.cpp プロジェクト: baidang201/sixpieces
string MXMLHandler::GetNodeWithTag(const string& xml, string name)
{
	Escape(name);
	string::size_type begin = xml.find("<"+name+">");
	if (begin == string::npos)
		return "";

	string::size_type end = xml.find("</"+name+">", begin);
	if (end == string::npos)
		return "";

	end += name.length() + 3;
	return xml.substr(begin, end - begin);
}
コード例 #10
0
ファイル: CSVWriter.cpp プロジェクト: fatterbetter/ZTools
void CCSVWriter::WriteRevisions (std::ostream& os, const CCachedLogInfo& cache)
{
	// header

	os << "Revision,AuthorID,TimeStamp,Comment,"
	   << "HasStdInfo,HasChangeInfo,HasMergeInfo,HasUserRevPropInfo\n";

	// content

	const CRevisionIndex& revisions = cache.GetRevisions();
	const CRevisionInfoContainer& logInfo = cache.GetLogInfo();

	for ( revision_t revision = revisions.GetFirstRevision()
		, last = revisions.GetLastRevision()
		; revision < last
		; ++revision)
	{
		index_t index = revisions[revision];
        if (index == NO_INDEX)
            continue;

		std::string comment = logInfo.GetComment (index);
		Escape (comment);

		char presenceFlags = logInfo.GetPresenceFlags (index);
		bool hasStdInfo 
			= (presenceFlags & CRevisionInfoContainer::HAS_STANDARD_INFO) != 0;
		bool hasChangeInfo
			= (presenceFlags & CRevisionInfoContainer::HAS_CHANGEDPATHS) != 0;
		bool hasMergeInfo 
			= (presenceFlags & CRevisionInfoContainer::HAS_MERGEINFO) != 0;
		bool hasRevPropInfo 
			= (presenceFlags & CRevisionInfoContainer::HAS_USERREVPROPS) != 0;

        enum {BUFFER_SIZE = 100};
        char buffer[BUFFER_SIZE];

        __time64_t timestamp = logInfo.GetTimeStamp(index);

		os << revision << ','
		   << logInfo.GetAuthorID(index) << ','
		   << Time64ToZuluString (buffer, timestamp) << ",\""
		   << comment.c_str() << "\","
		   << hasStdInfo << ','
		   << hasChangeInfo << ','
		   << hasMergeInfo << ','
		   << hasRevPropInfo
		   << "\n";
	}
}
コード例 #11
0
ファイル: KAIBase.cpp プロジェクト: 1suming/pap2
void KAIBase::OnEscape(void)
{
	// 决定是否还要逃跑
	BOOL bRetCode = FALSE;

	KG_PROCESS_ERROR(g_pSO3World->m_nGameLoop < m_EscapeData.nEscapeFrame);

	Escape();
	return;
Exit0:
	// 不跑了,开打
	DoPursuit();
	return;
}
コード例 #12
0
ファイル: ScreenFailure.cpp プロジェクト: Arc0re/lithtech
LTBOOL CScreenFailure::HandleKeyDown(int key, int rep)
{
	if (key == VK_F9)
	{
		g_pMissionMgr->StartGameFromQuickSave();
		return LTTRUE;
	}
	else if (g_fDuration > g_fMinDelay)
	{
		Escape();
		return LTTRUE;
	}
	return LTFALSE;

}
コード例 #13
0
ファイル: CSVWriter.cpp プロジェクト: fatterbetter/ZTools
void CCSVWriter::WriteRevProps (std::ostream& os, const CCachedLogInfo& cache)
{
	// header

	os << "ID,Revision,RevPropID,Value\n";

	// content

	const CRevisionIndex& revisions = cache.GetRevisions();
	const CRevisionInfoContainer& logInfo = cache.GetLogInfo();

	// ids will be added on-the-fly

	size_t id = 0;
	for ( revision_t revision = revisions.GetFirstRevision()
		, last = revisions.GetLastRevision()
		; revision < last
		; ++revision)
	{
		index_t index = revisions[revision];
        if (index == NO_INDEX)
            continue;

		typedef CRevisionInfoContainer::CUserRevPropsIterator RI;

		if (  logInfo.GetPresenceFlags (index) 
            & CRevisionInfoContainer::HAS_USERREVPROPS)
		{
			// we actually have a valid (possibly empty) merge list 
			// for this revision

			for ( RI iter = logInfo.GetUserRevPropsBegin (index)
				, end = logInfo.GetUserRevPropsEnd (index)
				; iter != end
				; ++iter)
			{
				std::string value = iter->GetValue();
				Escape (value);

				os << id++ << ',' 
				   << revision << ','
				   << iter->GetNameID()<< ",\""
				   << value.c_str()
				   << "\"\n";
			}
		}
	}
}
コード例 #14
0
ファイル: StdLib.cpp プロジェクト: dreamsxin/ultimatepp
void StdLib(ArrayMap<String, SVal>& global)
{
	Escape(global, "is_number(x)", SIC_is_number);
	Escape(global, "is_string(x)", SIC_is_string);

	Escape(global, "def_fn(x, y)", SIC_DefFn);
	Escape(global, "count(x)", SIC_count);
	Escape(global, "get_item(x, i)", SIC_get_item);
	Escape(global, "get_key(x, i)", SIC_get_key);
}
コード例 #15
0
    std::string Args::EscapedArgs(int start, int end) const {
        std::string res;

        if (end < 0) {
            end = args.size() - 1;
        }

        for (int i = start; i < end + 1; i++) {
            if (i != start) {
                res += " ";
            }
            res += Escape(args[i]);
        }

        return res;
    }
コード例 #16
0
void Game_Battle::UseSkill(Battle::Ally& ally, const RPG::Skill& skill) {

	int sp = ally.GetActor()->CalculateSkillCost(skill.ID);
	if (sp > ally.GetActor()->GetSp()) // not enough SP
		return;

	switch (skill.type) {
		case RPG::Skill::Type_teleport:
			// FIXME: teleport skill
			break;
		case RPG::Skill::Type_escape:
			Escape();
			break;
		case RPG::Skill::Type_switch:
			if (!skill.occasion_battle)
				return;
			Game_Switches[skill.switch_id] = true;
			break;
		case RPG::Skill::Type_normal:
		default:
			switch (skill.scope) {
				case RPG::Skill::Scope_enemy:
					UseSkillEnemy(ally, skill, Game_Battle::GetTargetEnemy());
					return;
				case RPG::Skill::Scope_enemies:
					for (std::vector<Battle::Enemy>::iterator it = Game_Battle::enemies.begin(); it != Game_Battle::enemies.end(); it++)
						UseSkillEnemy(ally, skill, *it);
					break;
				case RPG::Skill::Scope_self:
					UseSkillAlly(ally, skill, ally);
					break;
				case RPG::Skill::Scope_ally:
					UseSkillAlly(ally, skill, Game_Battle::GetTargetAlly());
					return;
				case RPG::Skill::Scope_party:
					for (std::vector<Battle::Ally>::iterator it = Game_Battle::allies.begin(); it != Game_Battle::allies.end(); it++)
						UseSkillAlly(ally, skill, *it);
					break;
			}
			break;
	}

	if (skill.type != RPG::Skill::Type_normal)
		Game_System::SePlay(skill.sound_effect);

	ally.GetActor()->SetSp(ally.GetActor()->GetSp() - sp);
}
コード例 #17
0
ファイル: net.cpp プロジェクト: yappy/DollsKit
// https://developer.twitter.com
// /en/docs/basics/authentication/guides/creating-a-signature.html
std::string Network::CalcSignature(
	const std::string &http_method, const std::string &base_url,
	const KeyValue &oauth_param, const KeyValue &query_param,
	const std::string &consumer_secret, const std::string &token_secret)
{
	// "Collecting parameters"
	// percent encode しつつ合成してキーでソートする
	KeyValue param;
	auto encode_insert = [this, &param](const KeyValue &map) {
		for (const auto &entry : map) {
			param.emplace(Escape(entry.first), Escape(entry.second));
		}
	};
	encode_insert(oauth_param);
	encode_insert(query_param);
	// 文字列にする
	// key1=value1&key2=value2&...
	std::string param_str;
	bool is_first = true;
	for (const auto &entry : param) {
		if (is_first) {
			is_first = false;
		}
		else {
			param_str += '&';
		}
		param_str += entry.first;
		param_str += '=';
		param_str += entry.second;
	}

	// "Creating the signature base string"
	// 署名対象
	std::string base = http_method;
	base += '&';
	base += Escape(base_url);
	base += '&';
	base += Escape(param_str);

	// "Getting a signing key"
	// 署名鍵は consumer_secret と token_secret をエスケープして & でつなぐだけ
	std::string key = Escape(consumer_secret);
	key += '&';
	key += Escape(token_secret);

	// "Calculating the signature"
	ShaDigest signature;
	HmacSha1(
		key.data(), key.size(),
		reinterpret_cast<const unsigned char *>(base.data()), base.size(),
		signature);

	return Base64Encode(signature, sizeof(signature));
}
コード例 #18
0
ファイル: xmlHandler.cpp プロジェクト: baidang201/sixpieces
string MXMLHandler::GetNode(const string& xml, string name, unsigned long& start)
{
	Escape(name);
	string::size_type begin = xml.find("<"+name+">", start);
	if (begin == string::npos)
		return "";

	begin += name.length() + 2;

	string::size_type end = xml.find("</"+name+">", begin);

	if (end == string::npos)
		return "";

	start = end + name.length() + 3;
	return xml.substr(begin, end - begin);
}
コード例 #19
0
ファイル: PrintrDC.cpp プロジェクト: chrisoldwood/WIN16
CRect CPrinterDC::PrintableArea(void) const
{
	ASSERT(m_hDC);

	CPoint	ptOffset(0, 0);
	CRect	rcPage = PageArea();

	// Get margin and adjust page.
	if (Escape(m_hDC, GETPRINTINGOFFSET, 0, NULL, &ptOffset) > 0)
	{
		rcPage.left    += ptOffset.x;
		rcPage.top     += ptOffset.y;
		rcPage.right   -= ptOffset.x;
		rcPage.bottom  -= ptOffset.y;
	}
	
	return rcPage;
}
コード例 #20
0
ファイル: StrLib.cpp プロジェクト: doozan/si_plugins
void SaveStr(char *param) {
    if ( (posBytesLeft <= 3) || !posSave)
        return;

    posBytesLeft -= 3;  // subtract 3 for the 2 quotation marks and the space

    if (*posSave == 0)
        *posSave++ = ' ';

    int len = lstrlen(param);

    *posSave++ = '"';
    len += Escape(posSave, param, '"');
    posSave += len;

    *posSave++ = '"';
    *posSave   = 0;
    posBytesLeft -= len;
}
コード例 #21
0
ファイル: XML.cpp プロジェクト: lemonxiao0/peerproject
void CXMLElement::ToString(CString& strXML, BOOL bNewline) const
{
	// strXML += '<' + m_sName; Optimzed:
	strXML.AppendChar( _T('<') );
	strXML.Append( m_sName );

	POSITION pos = GetAttributeIterator();
	for ( ; pos ; )
	{
		strXML.AppendChar( _T(' ') );
		const CXMLAttribute* pAttribute = GetNextAttribute( pos );
		pAttribute->ToString( strXML );
	}

	pos = GetElementIterator();

	if ( pos == NULL && m_sValue.IsEmpty() )
	{
		strXML.Append( _PT("/>") );
		if ( bNewline )
			strXML.Append( _PT("\r\n") );
		return;
	}

	strXML.AppendChar( _T('>') );
	if ( bNewline && pos )
		strXML.Append( _PT("\r\n") );

	while ( pos )
	{
		const CXMLElement* pElement = GetNextElement( pos );
		pElement->ToString( strXML, bNewline );
	}

	strXML += Escape( m_sValue );

	strXML.Append( _PT("</") );
	strXML.Append( m_sName );
	strXML.AppendChar( _T('>') );
	if ( bNewline )
		strXML.Append( _PT("\r\n") );
}
コード例 #22
0
bool WriteStrings(ostream& out,
                  const string& header,
                  StringTable& strings,
                  bool escape)
{
  out << "[" << header << "]" << std::endl;
  for (StringTable::iterator iter = strings.begin();
       iter != strings.end();
       iter++) {
    out << iter->first << "=";
    if (escape)
      out << Escape(iter->second);
    else
      out << iter->second;

    out << std::endl;
  }

  return true;
}
コード例 #23
0
ファイル: Printer.cpp プロジェクト: DsRQuicke/praat
int Printer_postScript_printf (void *stream, const char *format, ... ) {
#if defined (_WIN32)
    static union {
        char chars [3002];
        short shorts [1501];
    } theLine;
#elif cocoa
#elif defined (macintosh)
    static Handle theLine;
#endif
    int length;
    va_list args;
    va_start (args, format);
    (void) stream;
#if cocoa
#elif defined (_WIN32)
    vsprintf (theLine.chars + 2, format, args);
    length = strlen (theLine.chars + 2);
    theLine.shorts [0] = length;
    if (length > 0 && theLine.chars [length + 1] == '\n') {
        theLine.chars [length + 1] = '\r';
        theLine.chars [length + 2] = '\n';
        theLine.chars [length + 3] = '\0';
        length ++;
    }
    Escape (theWinDC, POSTSCRIPT_PASSTHROUGH, length + 2, theLine.chars, nullptr);
#elif defined (macintosh)
    if (! theLine) {
        theLine = NewHandle (3000);
        HLock (theLine);
    }
    vsprintf (*theLine, format, args);
    length = strlen (*theLine);
    if (length > 0 && (*theLine) [length - 1] == '\n')
        (*theLine) [length - 1] = '\r';
    SetPort (theMacPort);
    PMSessionPostScriptData (theMacPrintSession, *theLine, strlen (*theLine));
#endif
    va_end (args);
    return 1;
}
コード例 #24
0
ファイル: comm.cpp プロジェクト: autosportlabs/RaceAnalyzer
void RaceAnalyzerComm::writeScript(wxString &script){

	wxMutexLocker lock(_commMutex);
	size_t index = 0;
	int page,to;
	page = 0;
	to = 0;
	size_t length = script.Length();

	CComm *serialPort = GetSerialPort();
	if (NULL==serialPort) throw CommException(CommException::OPEN_PORT_FAILED);

	while(index < length && page < SCRIPT_PAGES && !to){
		wxString scriptFragment;
		if (index + SCRIPT_PAGE_LENGTH > length){
			scriptFragment = script.Mid(index);
		}else{
			scriptFragment = script.Mid(index, SCRIPT_PAGE_LENGTH);
		}
		Escape(scriptFragment);
		//wxString cmd = wxString::Format("updateScriptPage(%d,\"%s\")", page,data.ToAscii());
		wxString cmd = wxString::Format("writeScriptPage %d %s",page,scriptFragment.ToAscii());
		wxString result = SendCommand(serialPort, cmd);
		CheckThrowResult(result);
		page++;
		index += SCRIPT_PAGE_LENGTH;
	}
	//did we write fewer than the max number of script pages?
	//note we're subtracting script pages by one to account for integer divide truncation
	if ((length / SCRIPT_PAGE_LENGTH) < SCRIPT_PAGES - 1 ){
		//write a null to the next page
		wxString cmd = wxString::Format("writeScriptPage %d",page);
		wxString result = SendCommand(serialPort, cmd);
		CheckThrowResult(result);
	}

	CloseSerialPort();
	if (to){
		throw CommException(CommException::COMM_TIMEOUT);
	}
}
コード例 #25
0
void CScreenHostOptionFile::New(const wchar_t* pwsName )
{
	if( !LTFileOperations::DirectoryExists( GameModeMgr::Instance( ).GetOptionsFolder( )))
	{
		if( !LTFileOperations::CreateNewDirectory( GameModeMgr::Instance( ).GetOptionsFolder( )))
		{
			//TODO: error message
			return;
		}
	}

	// check if this name exists in the map file
	if( CHostOptionsMapMgr::Instance().IsFriendlyNameMapped(pwsName) )
	{
		MBCreate mb;
		mb.eType = LTMB_OK;
		g_pInterfaceMgr->ShowMessageBox("IDS_OPTIONFILE_EXISTS",&mb);
		return;
	}

	// create a new file name that is in ANSI
	char szFileTitle[64];
	char szPath[MAX_PATH*2];
	for(uint32 nFile=0;;++nFile)
	{
		LTSNPrintF( szFileTitle, LTARRAYSIZE(szFileTitle), "ServerOptions%.4d", nFile );
		GameModeMgr::Instance( ).GetOptionsFilePath( szFileTitle, szPath, LTARRAYSIZE( szPath ));
		if( !LTFileOperations::FileExists(szPath) && 
			!CHostOptionsMapMgr::Instance().IsFileNameMapped(szPath) )
			break;
	}

	// add this combination
	CHostOptionsMapMgr::Instance().Add( szFileTitle, pwsName );

	g_pProfileMgr->GetCurrentProfile()->m_sServerOptionsFile = szFileTitle;

	CreateFileList();
	Escape( );
}
コード例 #26
0
void TPrinter::CalcBandingFlags()
{
  struct TBandInfoStruct {
    BOOL fGraphicsFlag;
    BOOL fTextFlag;
    RECT GraphicsRect;
  };

  TBandInfoStruct BandInfoRec;
  WORD pFlags = 0;

  // Calculate text verses graphics banding
  if (UseBandInfo) {
    Escape(PrnDC, BANDINFO, sizeof(TBandInfoStruct), NULL,
        (LPSTR) &BandInfoRec);
    if (BandInfoRec.fGraphicsFlag)
        pFlags = PF_GRAPHICS;
    if (BandInfoRec.fTextFlag)
        pFlags = pFlags | PF_TEXT;
    Flags = (Flags & !PF_BOTH) | pFlags;
  }
  else {
    // If a driver does not support BANDINFO the Microsoft
    //  Recommended way of determining text only bands is if
    //  the first band is the full page, all others are
    //  graphics only.  Otherwise it handles both.
    if ( (FirstBand) && (BandRect.left == 0)
       && (BandRect.top == 0)
       && (BandRect.right == PageSize.x)
       && (BandRect.bottom == PageSize.y) )
      Flags = PF_TEXT;
    else
      if ((Flags & PF_BOTH) == PF_TEXT)
        // All other bands are graphics only
        Flags = ((Flags & !PF_BOTH) | PF_GRAPHICS);
      else
        Flags = Flags | PF_BOTH;
  }
  FirstBand = FALSE;
}
コード例 #27
0
ファイル: dal.cpp プロジェクト: Mixone-FinallyHere/planeshift
    uint64 psMysqlConnection::GenericInsertWithID(const char *table,const char **fieldnames,psStringArray& fieldvalues)
    {
        csString command;
        const size_t count = fieldvalues.GetSize();
        uint i;
        command = "INSERT INTO ";
        command.Append(table);
        command.Append(" (");
        for (i=0;i<count;i++)
        {
            if (i>0)
                command.Append(",");
            command.Append(fieldnames[i]);
        }

        command.Append(") VALUES (");
        for (i=0;i<count;i++)
        {
            if (i>0)
                command.Append(",");
            if (fieldvalues[i]!=NULL)
            {
                command.Append("'");
                csString escape;
                Escape( escape, fieldvalues[i] );
                command.Append(escape);
                command.Append("'");
            }
            else
            {
                command.Append("NULL");
            }
        }
        command.Append(")");

        if (Command("%s", command.GetDataSafe())!=1)
            return 0;

        return GetLastInsertID();
    }
コード例 #28
0
ファイル: xmlHandler.cpp プロジェクト: baidang201/sixpieces
bool MXMLHandler::SetNode(string& xml, string name, string value)
{
	Escape(name);
	if (name.length() == 0)
		return false;

	if (value.length() == 0)
	{
		RemoveNode(xml, name);
		return true;
	}

	string::size_type begin = xml.find("<"+name+">");
	string::size_type end = xml.find("</"+name+">", begin + name.length() + 2);
	if ((begin != string::npos) && (end != string::npos))
	{
		begin += name.length() + 2;
		xml = xml.substr(0, begin) + value + xml.substr(end, xml.length() - end);
		return true;
	}

	string newnode = CreateNode(name, value);
	begin = xml.find("<"+name+"/>");
	if (begin != string::npos)
	{
		string left = xml.substr(0, begin);

		begin += name.length() + 3;
		while ((begin < xml.length()) && ((xml[begin] == '\n') || (xml[begin] == '\r')))
			begin++;

		string right = xml.substr (begin, xml.length());
		xml = left + newnode + right;
		return true;
	}
	else{
		xml += newnode;
		return false;
	}
}
コード例 #29
0
ファイル: HTTP.cpp プロジェクト: CodeAsm/open-sauce
		/*!
		 * \brief
		 * Builds a complete URL string, combining the values contained in the URL interface instance.
		 * 
		 * \returns
		 * Returns a string containing the URL.
		 * 
		 * Builds a complete URL string, combining the values contained in the URL interface instance.
		 */
		std::string c_url_interface::GetURL()
		{
			std::ostringstream url_stream("");

			// add the scheme
			if(m_scheme.length() == 0)
				url_stream << "http://";
			else
				url_stream << m_scheme << "://";

			// add the username and password
			url_stream << Escape(m_username);
			if(m_password.length())
				url_stream << ":" << Escape(m_password);

			// add the address and port (don't need to escape the address as it cannot have invalid characters)
			url_stream << m_address;
			if(m_port != 80)
				url_stream << ":" << m_port;

			// add the path
			if(m_path.size())
			{
				for(std::vector<std::string>::iterator iter = m_path.begin(); iter != m_path.end(); iter++)
					url_stream << "/" << Escape(*iter);
			}
			else
				url_stream << "/";

			// add the queries
			if(m_query_count)
			{
				url_stream << "?";
				for(uint32 i = 0; i < m_query_count; i++)
				{
					if(i > 0) url_stream << "&";

					url_stream << Escape(m_queries[i].m_field) << "=" << Escape(m_queries[i].m_value);
				}
			}

			// add the fragment
			if(m_fragment.length())
				url_stream << "#" << Escape(m_fragment);

			return url_stream.str();
		}
コード例 #30
0
ファイル: xmlHandler.cpp プロジェクト: baidang201/sixpieces
bool MXMLHandler::SetNode(string& xml, string name, string value, unsigned long& start)
{
	Escape(name);
	if (name.length() == 0)
		return false;

	if (value.length() == 0)
	{
		MXMLHandler::RemoveNode(xml, name);
		return true;
	}

	string::size_type begin = xml.find("<"+name+">",start);
	string::size_type end = xml.find("</"+name+">", begin + name.length() + 2);

	if ((begin != string::npos) && (end != string::npos))
	{
		begin += name.length() + 2;
		xml = xml.substr(0, begin) + value + xml.substr(end, xml.length() - end);
		start = begin + value.length() + name.length() + 3;
		return true;
	}
	return false;
}