Ejemplo n.º 1
0
void TBParser::ConsumeValue(TBValue &dst_value, char *&line)
{
	// Find value (As quoted string, or as auto)
	char *value = line;
	if (*line == '\"' || *line == '\'')
	{
		const char quote_type = *line;
		// Consume starting quote
		line++;
		value++;
		// Find ending quote or end
		while (!IsEndQuote(value, line, quote_type) && *line != 0)
			line++;
		// Terminate away the quote
		if (*line == quote_type)
			*line++ = 0;

		// consume any whitespace
		while (is_white_space(line))
			line++;
		// consume any comma
		if (*line == ',')
			line++;

		UnescapeString(value);
		dst_value.SetString(value, TBValue::SET_AS_STATIC);
	}
	else
	{
		// Find next comma or end
		while (*line != ',' && *line != 0)
			line++;
		// Terminate away the comma
		if (*line == ',')
			*line++ = 0;

		UnescapeString(value);
		dst_value.SetFromStringAuto(value, TBValue::SET_AS_STATIC);
	}

	// Check if we still have pending value data on the following line and set pending_multiline.
	bool continuing_multiline = pending_multiline;
	pending_multiline = is_pending_multiline(line);

	// Append the multi line value to the buffer.
	if (continuing_multiline || pending_multiline)
		multi_line_value.AppendString(dst_value.GetString());
}
Ejemplo n.º 2
0
    Fragment* Fragment::Initialize(std::string markup)
    {
        // Null variables
        if ((markup == "null") ||
            (markup == "nil"))
            return new NullFragment();
        
        // Empty variables
        if (markup == "empty")
            return new EmptyFragment();

        // Boolean variables
        if (markup == "true")
            return new BooleanFragment(true);
        if (markup == "false")
            return new BooleanFragment(false);

        // Integer variables
        if (Expressions::IntegerFragment.FullMatch(markup))
            return new IntegerFragment(markup);
        
        // Floating point variables
        if (Expressions::FloatFragment.FullMatch(markup))
            return new FloatFragment(markup);

        // String variables
        if (Expressions::StringFragment.FullMatch(markup))
            return new StringFragment(UnescapeString(markup));

        // Contextual variables

        return NULL;
    }
void FOOTPRINT_LIST_IMPL::ReadCacheFromFile( wxTextFile* aCacheFile )
{
    m_list_timestamp = 0;
    m_list.clear();

    try
    {
        if( aCacheFile->Exists() )
        {
            aCacheFile->Open();

            aCacheFile->GetFirstLine().ToLongLong( &m_list_timestamp );

            while( aCacheFile->GetCurrentLine() + 6 < aCacheFile->GetLineCount() )
            {
                wxString libNickname = aCacheFile->GetNextLine();
                wxString name = aCacheFile->GetNextLine();
                wxString description = UnescapeString( aCacheFile->GetNextLine() );
                wxString keywords = UnescapeString( aCacheFile->GetNextLine() );
                int orderNum = wxAtoi( aCacheFile->GetNextLine() );
                unsigned int padCount = (unsigned) wxAtoi( aCacheFile->GetNextLine() );
                unsigned int uniquePadCount = (unsigned) wxAtoi( aCacheFile->GetNextLine() );

                auto* fpinfo = new FOOTPRINT_INFO_IMPL( libNickname, name, description, keywords,
                                                        orderNum, padCount, uniquePadCount );
                m_list.emplace_back( std::unique_ptr<FOOTPRINT_INFO>( fpinfo ) );
            }
        }
    }
    catch( ... )
    {
        // whatever went wrong, invalidate the cache
        m_list_timestamp = 0;
    }

    // Sanity check: an empty list is very unlikely to be correct.
    if( m_list.size() == 0 )
        m_list_timestamp = 0;

    if( aCacheFile->IsOpened() )
        aCacheFile->Close();
}
Ejemplo n.º 4
0
bool SerializedConsoleOutput::readEscapedString(FILE *stream, std::string *str)
{
	char buf[1024];
	if (fgets(buf, sizeof(buf), stream)) {
		buf[strlen(buf) - 1] = '\0';
		*str = buf;
		UnescapeString(*str);
		return true;
	}
	return false;
}
Ejemplo n.º 5
0
CTranslationItem::CTranslationItem(const tchar_t* pszText, uint_t uiChecksum) :
	m_pszText(NULL),
	m_stTextLength(0),
	m_uiChecksum(uiChecksum)
{
	if(pszText)
	{
		m_stTextLength = _tcslen(pszText);
		if(m_stTextLength > 0)
		{
			m_pszText = new tchar_t[m_stTextLength + 1];
			_tcscpy(m_pszText, pszText);

			UnescapeString();
		}
	}
}
Ejemplo n.º 6
0
///////////////////////////////////////////////////////////////
//
// SharedUtil_String_Tests
//
// Test behaviour of strings
//
///////////////////////////////////////////////////////////////
void SharedUtil_String_Tests ( void )
{
    // Formatting
    {
        SString strTemp1 ( "name:" PRSinS, "dave" );
        SString strTemp2 ( "name:" PRWinS, L"dave" );
        WString wstrTemp3 ( L"name:" PRSinW, "dave" );
        WString wstrTemp4 ( L"name:" PRWinW, L"dave" );

        assert ( strTemp1 == "name:dave" );
        assert ( strTemp2 == "name:dave" );
        assert ( wstrTemp3 == L"name:dave" );
        assert ( wstrTemp4 == L"name:dave" );
    }

    // To/From Ansi
    {
        SString strTemp1 = "abcABC 123";
        WString wstrTemp2 = "defDEF 456";
        WString wstrTemp3 = L"ghiGHI 789";

        assert ( wstrTemp2 == L"defDEF 456" );

        SString strTemp2 = wstrTemp2.ToAnsi ();
        SString strTemp3 = wstrTemp3.ToAnsi ();

        assert ( strTemp2 == "defDEF 456" );
        assert ( strTemp3 == "ghiGHI 789" );
    }

    // Escaping URL arguments
    {
        TEST_FUNCTION
            SStringX strInputA( (const char*)a, sizeof( a ) );
            SString strEscaped = EscapeURLArgument( strInputA );
            SString strUnescaped = UnescapeString ( strEscaped, '%' );
            assert ( strEscaped == result );
            assert ( strInputA == strUnescaped );
        TEST_VARS
            const uchar a[5];
            const char* result;
        TEST_DATA
            { {0x00, 0x10, 0x20, 0x21, 0x22},       "%00%10%20%21%22" },
            { {0x7F, 0x80, 0x81, 0xFE, 0xFF},       "%7F%80%81%FE%FF" },
Ejemplo n.º 7
0
void CTranslationItem::SetText(const tchar_t* pszText, bool bUnescapeString)
{
	delete [] m_pszText;
	if(pszText)
	{
		m_stTextLength = _tcslen(pszText);
		if(m_stTextLength > 0)
		{
			m_pszText = new tchar_t[m_stTextLength + 1];
			_tcscpy(m_pszText, pszText);
			if(bUnescapeString)
				UnescapeString();
			return;
		}
	}

	m_pszText = NULL;
	m_stTextLength = 0;
}
Ejemplo n.º 8
0
HTREEITEM AddOutlineItem( char const * start, size_t len, bool hasChildren, HTREEITEM parent, void * value )
{
	USES_CONVERSION;
	char temp[512];
	size_t escaped_len;
	escaped_len = UnescapeString( temp, start, start + len );
	temp[escaped_len] = 0;
	
	TV_INSERTSTRUCT is;
	::memset( &is, 0, sizeof( TV_INSERTSTRUCT ) );
	is.hParent = parent;
	is.hInsertAfter = TVI_LAST;
	is.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM;
	is.item.cChildren = hasChildren ? 1 : 0;
	is.item.pszText = A2W( temp );
	is.item.cchTextMax = escaped_len;
	is.item.lParam = (LPARAM)value;

	return TreeView_InsertItem( outlineHwnd, &is );
}
Ejemplo n.º 9
0
    Fragment* Fragment::Initialize(Token* token)
    {
        if (token->Type & TokenString)
            return new StringFragment(UnescapeString(token->Value));
        if (token->Type & TokenInteger)
            return new IntegerFragment(token->Value);
        if (token->Type & TokenFloat)
            return new FloatFragment(token->Value);
        if (token->Type & TokenTrue)
            return new BooleanFragment(true);
        if (token->Type & TokenFalse)
            return new BooleanFragment(false);
        if (token->Type & TokenNull)
            return new NullFragment();
        if (token->Type & TokenEmpty)
            return new EmptyFragment();
        if (token->Type & TokenPath)
            return new ContextualFragment(token->Value);

        throw;
    }
Ejemplo n.º 10
0
void CPODocument::GetString(CStrEntry &strEntry)
{
  size_t nextLFPos;
  size_t startPos = strEntry.Pos;
  strEntry.Str.clear();

  while (startPos < m_Entry.Content.size())
  {
    nextLFPos = m_Entry.Content.find("\n", startPos);
    if (nextLFPos == std::string::npos)
      nextLFPos = m_Entry.Content.size();

    // check syntax, if it really is a valid quoted string line
    if (nextLFPos-startPos < 2 ||  m_Entry.Content[startPos] != '\"' ||
        m_Entry.Content[nextLFPos-1] != '\"')
      break;

    strEntry.Str.append(m_Entry.Content, startPos+1, nextLFPos-2-startPos);
    startPos = nextLFPos+1;
  }

  strEntry.Str = UnescapeString(strEntry.Str);
}
   void 
   AddresslistParser::ExtractParts(const String &sCompound, String &sFullName, String &sMailbox, String &sDomain) const
   {
      // Extract the name and address from a string like:
      // first last <*****@*****.**>. This method is extremly
      // fuzzy and won't work unless the address is really properly
      // formatted.
      
      String sEmailAddress;

      ExtractQuotedString_(sCompound, sFullName);
      ExtractWithinGTLT_(sCompound, sEmailAddress);
      
      UnescapeString(sFullName);
      UnescapeString(sEmailAddress);

      if (sFullName.IsEmpty())
      {
         // We could not find a full name in this email address. It
         // could be that the full name is not enclosed within quotes.
         // Instead, let's assume that the string before the first <
         // is the full user name.

         int iGTPos = sCompound.Find(_T("<"));

         if (iGTPos > 0)
         {
            sFullName = sCompound.Mid(0, iGTPos);

            // If there's a space between the fullname and
            // the email address, remove it.
            sFullName.TrimRight();
         }

      }

      // If no full name has been specified, use the email address
      // as full name, so that we have something to show in the
      // recipients email client
      if (sFullName.IsEmpty())
         sFullName = sEmailAddress;

      if (sFullName.IsEmpty() && sEmailAddress.IsEmpty())
      {
         // We haven't been able to parse out any useful information
         // from this string. Let's assume that the string contains
         // just the full name of the holder of the mailbox.
         sFullName = sCompound;
      }

      if (sEmailAddress.IsEmpty())
      {
         // We haven't been able to parse out the email address. Check
         // if the full name is a valid email address and if so assume
         // it's the email address.
         if (StringParser::IsValidEmailAddress(sFullName))
         {
            sEmailAddress = sFullName;
         }
      }

      // Find the domain part and the mailbox part.
      sMailbox = StringParser::ExtractAddress(sEmailAddress);
      sDomain = StringParser::ExtractDomain(sEmailAddress);

   }
Ejemplo n.º 12
0
int ParseLine(CString sLine, CString& sBody, CString& sResOut, int& iFrom, double dSpeed, WKCallbackInterface* pCallback)
{
	if(rtDesktop.bottom==0 && rtDesktop.right==0){
		GetWindowRect(GetDesktopWindow(),&rtDesktop);
	}
	CString sParams;
	sParams=CDataXMLSaver::GetInstringPartGreedly("('","')",sLine);
	if(sParams==""){
		sParams=CDataXMLSaver::GetInstringPartGreedly("(",")",sLine);
		if(sParams!=""){
			sLine=sLine.SpanExcluding("(");
		}
	}else{
		sLine=sLine.SpanExcluding("('");
	}
	if(sParams==""){
		sParams=CDataXMLSaver::GetInstringPartGreedly("\"","\"",sLine);
		if(sParams!=""){
			sLine=sLine.SpanExcluding("\"");
		}
	}
	if(sParams==""){
		sParams=CDataXMLSaver::GetInstringPartGreedly("'","'",sLine);
		if(sParams!=""){
			sLine=sLine.SpanExcluding("'");
		}
	}
	sLine.TrimLeft();
	sLine.TrimRight();
	sLine.MakeUpper();
	if(sLine!=""){
		if(sLine=="RETURN"){
			sResOut=sParams;
			sResOut.TrimLeft(" \"'\t");
			sResOut.TrimRight(" \"'\t");
			iFrom=-1;
			return 1;
		}
		if(sLine=="IF"){
			int iDelPos=sParams.Find("==");
			if(iDelPos!=-1){
				CString sLeft=sParams.Left(iDelPos);
				if(sLeft.Find("unescape")==0){
					sLeft=CDataXMLSaver::GetInstringPart("(",")",sLeft);
					sLeft=UnescapeString(sLeft);
				}
				CString sRight=sParams.Mid(iDelPos+2);
				if(sLeft!=sRight){
					iFrom=sBody.Find('}',iFrom);
				}
			}
		}
		if(sLine=="SET_SPEED"){
			double dSpeed=atof(sParams);
			if(dSpeed<0.1){
				dSpeed=1;
			}
		}
		if(sLine=="CALLACTION"){
			if(pCallback){
				pCallback->CallWKAction(atol(sParams));
			}
		}
		if(sLine=="CALLMACRO"){
			if(pCallback){
				pCallback->StartQuickRunByName(sParams,"");
			}
		}
		if(sLine=="WAIT"){
			Sleep(DWORD(atof(sParams)*1000*dSpeed));
		}
		if(sLine=="ACTIVATEWINDOW"){
			sParams.TrimLeft();
			sParams.TrimRight();
			sParams.TrimLeft("\"");
			sParams.TrimRight("\"");
			HWND hActivate=::FindWindow(NULL,sParams);
			if(hActivate){
				::SetForegroundWindow(hActivate);
				::SendMessage(::GetDesktopWindow(), WM_SYSCOMMAND, (WPARAM) SC_HOTKEY, (LPARAM)hActivate);
			}
		}
		if(sLine=="ALERT"){
			AfxMessageBox(sParams);
		}
		if(sLine=="WAITWHILEALLKEYSARERELEASED"){
			if(pCallback){
				pCallback->WaitWhileAllKeysAreReleased();
			}
		}
		if(sLine=="COMMAND"){
			HWND hCur=GetForegroundWindow();
#ifdef _DEBUG
			char szDebugTitle[128]={0};
			GetWindowText(hCur,szDebugTitle,128);
#endif
			CString sTargetByClass=CDataXMLSaver::GetInstringPart("targetByClass=[","]",sParams);
			CString sTargetByTitle=CDataXMLSaver::GetInstringPart("targetByTitle=[","]",sParams);
			if(sTargetByClass!="" || sTargetByTitle!=""){
				hCur=0;// Слать куда попало предназначенные спецклассу мессаги нельзя!
				// Walton Dell <*****@*****.**>
				HWND hTarget=::FindWindow((sTargetByClass!="")?LPCSTR(sTargetByClass):NULL,(sTargetByTitle!="")?LPCSTR(sTargetByTitle):NULL);
				if(hTarget){
					hCur=hTarget;
				}else{
					BOOL bInvis=atol(CDataXMLSaver::GetInstringPart("evenInvisible=[","]",sParams));
					if(bInvis){
						sSearchClass=sTargetByClass;
						sSearchTitle=sTargetByTitle;
						::EnumWindows(EnumFindWndBox,LPARAM(&hTarget));
						if(hTarget){
							hCur=hTarget;
						}
					}
				}
			}
			BOOL bUsedChildWindows=0;
			if(hCur){
				CString sCTargetByID=CDataXMLSaver::GetInstringPart("childTargetByID=[","]",sParams);
				if(sCTargetByID!=""){
					HWND hTarget=::GetDlgItem(hCur,atolx(sCTargetByID));
					if(hTarget){
						bUsedChildWindows=1;
						hCur=hTarget;
					}
				}
				CString sCTargetByClass=CDataXMLSaver::GetInstringPart("childTargetByClass=[","]",sParams);
				CString sCTargetByTitle=CDataXMLSaver::GetInstringPart("childTargetByTitle=[","]",sParams);
				if(sCTargetByClass!="" || sCTargetByClass!=""){
					HWND hTarget=::FindWindowEx(hCur,0,(sCTargetByClass!="")?LPCSTR(sCTargetByClass):NULL,(sCTargetByTitle!="")?LPCSTR(sCTargetByTitle):NULL);
					if(hTarget){
						bUsedChildWindows=1;
						hCur=hTarget;
					}
				}
			}
			{// Выбираем тип и выполняем код
				if(hCur && sParams.Find("activate::")!=-1){
					SwitchToWindow(hCur,TRUE);
				}
				if(sParams.Find("wnd::")!=-1){
					CString sX=CDataXMLSaver::GetInstringPart("x=[","]",sParams);
					long lX=atolx(sX);
					if(sX=="SCREEN_R"){
						lX=rtDesktop.right;
					}
					if(sX=="SCREEN_L"){
						lX=rtDesktop.left;
					}
					CString sY=CDataXMLSaver::GetInstringPart("y=[","]",sParams);
					long lY=atolx(sY);
					if(sY=="SCREEN_B"){
						lY=rtDesktop.bottom;
					}
					if(sY=="SCREEN_T"){
						lY=rtDesktop.top;
					}
					CString sRel=(CDataXMLSaver::GetInstringPart("rel=[","]",sParams));
					long lRel=atolx(sRel);
					sRel.MakeUpper();
					long lSz=atolx(CDataXMLSaver::GetInstringPart("savesize=[","]",sParams));
					long lRb=atolx(CDataXMLSaver::GetInstringPart("rightbottom=[","]",sParams));
					long lCn=atolx(CDataXMLSaver::GetInstringPart("center=[","]",sParams));
					if(hCur){
						HWND hOrif=hCur;
						CRect rt;
						if(!bUsedChildWindows){
							GetWindowTopParent(hCur);
							GetWindowRect(hCur,&rt);
						}else{
							GetClientRect(hCur,&rt);
						}
						CSize sz=rt.Size();
						if(sY=="NOCHANGE_B"){
							lY=rt.bottom;
						}
						if(sY=="NOCHANGE_T"){
							lY=rt.top;
						}
						if(sX=="NOCHANGE_L"){
							lX=rt.left;
						}
						if(sX=="NOCHANGE_R"){
							lX=rt.right;
						}
						/*if(sRel=="CURSOR"){
						CPoint pt;
						GetCursorPos(&pt);
						rt.OffsetRect(lX,lY);
					}*/
						if(lRel || sRel=="RELATIVE"){
							rt.OffsetRect(lX,lY);
						}else if(lSz){
							if(lCn){
								rt.left=(lX-sz.cx)/2;
								rt.top=(lY-sz.cy)/2;
								rt.right=rt.left+sz.cx;
								rt.bottom=rt.top+sz.cy;
							}else if(lRb){
								rt.OffsetRect(lX-rt.right,lY-rt.bottom);
							}else{
								rt.OffsetRect(lX-rt.left,lY-rt.top);
							}
						}else if(lRb){
							rt.right=lX;
							rt.bottom=lY;
						}else{
							rt.left=lX;
							rt.top=lY;
						}
						MoveWindow(hCur,rt.left,rt.top,rt.Width(),rt.Height(),TRUE);
					}
				}
				if(hCur && sParams.Find("cmd::")!=-1){
					DWORD dwMsg=atolx(CDataXMLSaver::GetInstringPart("msg=[","]",sParams));
					LPARAM lPar=atolx(CDataXMLSaver::GetInstringPart("l=[","]",sParams));
					WPARAM wPar=atolx(CDataXMLSaver::GetInstringPart("h=[","]",sParams));
					if(hCur){
						HWND hOrif=hCur;
						if(!bUsedChildWindows){
							GetWindowTopParent(hCur);
						}
						BOOL bRes=0; 
						bRes=::SendMessage(hOrif,dwMsg,wPar,lPar);
					}
				}
				if(sParams.Find("key::")!=-1){
					DWORD dwMsg=atolx(CDataXMLSaver::GetInstringPart("msg=[","]",sParams));
					CString sLow=CDataXMLSaver::GetInstringPart("l=[","]",sParams);
					LPARAM lPar=0;
					if(sLow.GetLength()==9 && sLow[0]=='#'){
						lPar=(hexCode(sLow.Mid(1,2))<<(8*3))+(hexCode(sLow.Mid(3,2))<<(8*2))+(hexCode(sLow.Mid(5,2))<<8)+hexCode(sLow.Mid(7,2));
					}else{
						lPar=atolx(sLow);
					}
					BOOL bKeyDown=atolx(CDataXMLSaver::GetInstringPart("keydown=[","]",sParams));
					DWORD dwVK=LOBYTE(lPar);
					DWORD dwScan=HIBYTE(lPar);
					BOOL bExtended=atolx(CDataXMLSaver::GetInstringPart("ext=[","]",sParams));;
					::keybd_event(BYTE(dwVK), BYTE(dwScan), (bKeyDown?0:KEYEVENTF_KEYUP)|(bExtended?KEYEVENTF_EXTENDEDKEY:0), 0);
				}
				if(sParams.Find("mou::")!=-1){
					DWORD dwMsg=atolx(CDataXMLSaver::GetInstringPart("msg=[","]",sParams));
					long dwX=atolx(CDataXMLSaver::GetInstringPart("x=[","]",sParams));
					long dwY=atolx(CDataXMLSaver::GetInstringPart("y=[","]",sParams));
					// Если все относительно, то колбасим...
					CString sRel=(CDataXMLSaver::GetInstringPart("rel=[","]",sParams));
					sRel.MakeUpper();
					int dwRel=atolx(sRel);
					if(dwRel>0 || sRel=="WINDOW" || sRel=="RELATIVE"){
						if(hCur){
							CRect rt;
							GetWindowRect(hCur,&rt);
							dwX+=rt.left;
							dwY+=rt.top;
						}else{
							// Относительные клики без активного окна скипаем нахрен!
							return 0;
						}
					}
					if(dwRel<0 || sRel=="CURSOR"){
						CPoint pt;
						GetCursorPos(&pt);
						dwX+=pt.x;
						dwY+=pt.y;
					}
					dwX=long(65536*double(dwX)/double(rtDesktop.Width()));
					dwY=long(65536*double(dwY)/double(rtDesktop.Height()));
					if(dwMsg!=WM_MOUSEMOVE){// Сначала двигаем
						::mouse_event(
							MOUSEEVENTF_ABSOLUTE|MOUSEEVENTF_MOVE
							,dwX
							,dwY
							,0,0);
					}
					if(dwMsg==WM_LBUTTONDOWN){
						dwMsg=MOUSEEVENTF_LEFTDOWN;
					}else if(dwMsg==WM_LBUTTONUP){
						dwMsg=MOUSEEVENTF_LEFTUP;
					}else if(dwMsg==WM_RBUTTONDOWN){
						dwMsg=MOUSEEVENTF_RIGHTDOWN;
					}else if(dwMsg==WM_RBUTTONUP){
						dwMsg=MOUSEEVENTF_RIGHTUP;
					}else if(dwMsg==WM_MBUTTONDOWN){
						dwMsg=MOUSEEVENTF_MIDDLEDOWN;
					}else if(dwMsg==WM_MBUTTONUP){
						dwMsg=MOUSEEVENTF_MIDDLEUP;
					}else{
						dwMsg=MOUSEEVENTF_MOVE;
					}
					::mouse_event(
						MOUSEEVENTF_ABSOLUTE|dwMsg
						,dwX
						,dwY
						,0,0);
				}
			}
		}
	}
	return 0;
}
Ejemplo n.º 13
0
BOOL CNetRssProtocol::SendNet_StatusExch(const char* szRec,const char* szProtocol)
{
	if(CString(szProtocol)=="sms"){
		return 1;
	}
	if(objSettings.lRSSLocUser){
		if(isScreenSaverActiveOrCLocked()){
			return -1;
		}
	}
	CString szRecipient=GetCompNameNoProtocol(szRec);
	int iPerson=objSettings.AddrBook.FindPersonByIP(szRecipient,TRUE);
	if(iPerson!=-1){
		if(objSettings.AddrBook.aPersons[iPerson]->IsGroup()){
			// Групповой-заблокирован
			return -1;
		};
	}
	CWebWorld url;
	CString sRSS=url.GetWebPage(szRecipient);
	if(sRSS==""){
		// Не доступен
		return -1;
	}
	#ifdef _DEBUG
	CString sFile=CString("lastblog")+szRecipient+".xml";//http://davydov.blogspot.com/atom.xml
	MakeSafeFileName(sFile);
	SaveFile(CString("c://")+sFile,sRSS);
	#endif
	int iStatus=1;
	XDoc* feedDoc=parseXML(sRSS);
	XNode* feed=0;
	if(feedDoc){
		feed=feedDoc->GetRoot();
		if(!feed){
			delete feedDoc;
			return -1;
		}
		CString sLnewsBuildDate=aLoadedRss[szRecipient];
		int iMaxNews=objSettings.dwProtocolRSSMAxNews;
		if(sLnewsBuildDate==""){
			iMaxNews=5;
		}
		CString sLnewsBuildDateToSet="";
		BOOL bAtom=0;
		CString sGlobalTitle;
		if(feed->GetChild("channel",1)==GetEmptyNode() && feed->GetChild("title",1)!=GetEmptyNode()){
			// Atom!!!
			bAtom=1;
			sGlobalTitle=feed->GetChild("title",1)->value;
		}else{
			sGlobalTitle=feed->GetChild("channel",1)->GetChild("title",1)->value;
		}
		CString sFrom="";
		if(iPerson!=-1){
			sFrom=objSettings.AddrBook.aPersons[iPerson]->GetTitle();
		}else{
			sFrom=sGlobalTitle+"/rss";
		}
		CXMLNodes feedItems;
		if(bAtom){
			feed->FindByTagName("entry",FALSE,feedItems);
		}else{
			feed->GetChild("channel",1)->FindByTagName("item",FALSE,feedItems);
		}
		int iCount=0;
		int iLenCount=feedItems.GetSize();
		if(iLenCount==0){
			// Может rdf???
			feed->FindByTagName("item",FALSE,feedItems);
			iLenCount=feedItems.GetSize();
		}
		CString sSummary;
		while(iCount<iLenCount && iCount<iMaxNews){
			XNode* item=feedItems[iCount];
			CString sPubDate;
			if(bAtom){
				sPubDate=item->GetChild("issued",1)->value;
			}else{
				sPubDate=item->GetChild("pubDate",1)->value;
				if(sPubDate==""){
					//rdf???
					sPubDate=item->GetChild("dc:date",1)->value;
				}
			}
			//sPubDate=UnescapeString(sPubDate);
			StripTags(sPubDate);
			DeEntitize(sPubDate);

			CString sTitle;
			sTitle=item->GetChild("title",1)->value;
			//sTitle=UnescapeString(sTitle);
			StripTags(sTitle);
			DeEntitize(sTitle);
			if(sTitle==""){
				sTitle=sGlobalTitle;
			}
			
			CString sAuthor;
			if(bAtom){
				LPXNode pAut;
				pAut=item->GetChild("author",1);
				if(pAut->iBeginPos!=-1 && pAut->iEndPos!=-1){
					sAuthor=sRSS.Mid(pAut->iBeginPos,pAut->iEndPos-pAut->iBeginPos);
				}
			}else{
				sAuthor=item->GetChild("author",1)->value;
				if(sAuthor==""){
					//rdf???
					sAuthor=item->GetChild("dc:creator",1)->value;
				}
			}
			//sAuthor=UnescapeString(sAuthor);
			StripTags(sAuthor);
			DeEntitize(sAuthor);
			if(sAuthor!=""){
				sTitle+=" (";
				sTitle+=sAuthor;
				sTitle+=")";
			}
			
			LPXNode pDesk;
			if(bAtom){
				pDesk=item->GetChild("content",1);
			}else{
				pDesk=item->GetChild("description",1);
			}
			CString sDesk;
			if(pDesk->iBeginPos!=-1 && pDesk->iEndPos!=-1){
				sDesk=sRSS.Mid(pDesk->iBeginPos,pDesk->iEndPos-pDesk->iBeginPos);
			}
			/*
			if(sDesk.Find("%20")!=-1){
				sDesk=UnescapeString(sDesk);
			}
			*/
			CString sDeskL=sDesk;
			sDeskL.MakeLower();
			if(sDeskL.Find(";div")!=-1 || sDeskL.Find(";span")!=-1){
				// Для извращенных...
				DeEntitize(sDesk);
				StripTags(sDesk);
			}else{
				// Это по правильному
				StripTags(sDesk);
				DeEntitize(sDesk);
			}
			sDesk.TrimLeft();
			sDesk.TrimRight();

			CString sLink;
			if(bAtom){
				CXMLNodes feedLinks;
				item->FindByTagName("link",FALSE,feedLinks);
				for(int j=0;j<feedLinks.GetSize();j++){
					XNode* itemLnk=feedLinks[j];
					sLink=itemLnk->GetAttr("href")->value;
					CString sType=itemLnk->GetAttr("type")->value;
					sType.MakeLower();
					if(sType.Find("text")!=-1){
						break;// Наша линка!
					}
				}
			}else{
				sLink=item->GetChild("link",1)->value;
			}
			sLink=UnescapeString(sLink);
			StripTags(sLink);
			DeEntitize(sLink);
			sLink.TrimLeft();
			sLink.TrimRight();
			
			{
				CSmartLock SL(&csRssFeeds,TRUE);
				CString sRnewsBuildDate=sLink+"\t"+sPubDate+" "+sTitle+" "+sDesk;
				if(sLnewsBuildDate==sRnewsBuildDate){
					if(iCount==0){
						iStatus=1;
					}
					break;
				}
				if(sLnewsBuildDateToSet==""){// Запомнили самую первую новость
					sLnewsBuildDateToSet=sRnewsBuildDate;
				}
				/*
				#ifdef _DEBUG
				else{
					sDesk+="\nOld id-text:"+sLnewsBuildDate;
					sDesk+="\nNew id-text:"+sRnewsBuildDate;
				}
				#endif
				*/
			}

			if(sPubDate!=""){
				COleDateTime dt;
				dt.ParseDateTime(sPubDate);
				if(dt.GetStatus()==COleDateTimeSpan::valid){
					sTitle=dt.Format("%x %X. ")+sTitle;
				}
			}
			CString sNews=sTitle;
			sNews+="\n";
			if(sDesk!=""){
				sNews+="\n";
				sNews+=sDesk;
			}
			if(sLink!=""){
				sNews+="\n\n";
				sNews+=_l("Read more")+": ";
				sNews+=sLink;
			}
			CDataXMLSaver::Xml2Str(sNews);
			if(objSettings.lRSSSummar){
				sSummary+="\n";
				sSummary+="\n";
				sSummary+=sTitle;
				sSummary+="\n";
				sSummary+=_l("Read more")+": ";
				sSummary+=sLink;
			}else{
				CString sAttach="";
				if(objSettings.dwProtocolRSSOType){
					sAttach+=Format("["DEF_OPENTYPE"%i]",objSettings.dwProtocolRSSOType);
				}
				OpenMessage(sFrom,"",sNews,"",sAttach,sGlobalTitle);
			}
			iCount++;
		}
		if(sSummary!=""){
			CString sAttach="";
			if(objSettings.dwProtocolRSSOType){
				sAttach+=Format("["DEF_OPENTYPE"%i]",objSettings.dwProtocolRSSOType);
			}
			sSummary.TrimLeft();
			OpenMessage(sFrom,"",sSummary,"",sAttach,sGlobalTitle);
		}
		if(feedDoc){
			delete feedDoc;
		}
		if(sLnewsBuildDateToSet!=""){
			aLoadedRss.SetAt(szRecipient,sLnewsBuildDateToSet);
		}
	}
	if(iPerson!=-1){
		objSettings.AddrBook.aPersons[iPerson]->iOnlineStatus=iStatus;
		RefreshUserStatusIcon(iPerson);
	}
	return 0;
}
Ejemplo n.º 14
0
            assert ( strEscaped == result );
            assert ( strInputA == strUnescaped );
        TEST_VARS
            const uchar a[5];
            const char* result;
        TEST_DATA
            { {0x00, 0x10, 0x20, 0x21, 0x22},       "%00%10%20%21%22" },
            { {0x7F, 0x80, 0x81, 0xFE, 0xFF},       "%7F%80%81%FE%FF" },
        TEST_END
    }

    {
        TEST_FUNCTION
            SStringX strInputA( a );
            SString strEscaped = EscapeURLArgument( strInputA );
            SString strUnescaped = UnescapeString ( strEscaped, '%' );
            assert ( strEscaped == result );
            assert ( strInputA == strUnescaped );
        TEST_VARS
            const char* a;
            const char* result;
        TEST_DATA
            { "!*'();:@",           "%21%2A%27%28%29%3B%3A%40" },
            { "&=+$,/?#",           "%26%3D%2B%24%2C%2F%3F%23" },
            { "[] \"%<>\\",         "%5B%5D%20%22%25%3C%3E%5C" },
            { "^`{|}",              "%5E%60%7B%7C%7D" },
            { "AZaz09-_.~",         "AZaz09-_.~" },
        TEST_END
    }

    // RemoveColorCodes
Ejemplo n.º 15
0
 SString CArgMap::Unescape ( const SString& strIn ) const
 {
     return UnescapeString ( strIn, m_cEscapeCharacter );
 } 
Ejemplo n.º 16
0
void TBParser::OnLine(char *line, TBParserTarget *target)
{
	if (is_space_or_comment(line))
	{
		if (*line == '#')
			target->OnComment(current_line_nr, line + 1);
		return;
	}
	if (pending_multiline)
	{
		OnMultiline(line, target);
		return;
	}

	// Check indent
	int indent = 0;
	while (line[indent] == '\t' && line[indent] != 0)
		indent++;
	line += indent;

	if (indent - current_indent > 1)
	{
		target->OnError(current_line_nr, "Indentation error. (Line skipped)");
		return;
	}

	if (indent > current_indent)
	{
		// FIX: Report indentation error if more than 1 higher!
		assert(indent - current_indent == 1);
		target->Enter();
		current_indent++;
	}
	else if (indent < current_indent)
	{
		while (indent < current_indent)
		{
			target->Leave();
			current_indent--;
		}
	}

	if (*line == 0)
		return;
	else
	{
		char *token = line;
		// Read line while consuming it and copy over to token buf
		while (!is_white_space(line) && *line != 0)
			line++;
		int token_len = line - token;
		// Consume any white space after the token
		while (is_white_space(line))
			line++;

		bool is_compact_line = token_len && token[token_len - 1] == ':';

		TBValue value;
		if (is_compact_line)
		{
			token_len--;
			token[token_len] = 0;

			// Check if the first argument is not a child but the value for this token
			if (*line == '[' || *line == '\"' || *line == '\'' ||
				is_start_of_number(line) ||
				is_start_of_color(line) ||
				is_start_of_reference(line))
			{
				ConsumeValue(value, line);

				if (pending_multiline)
				{
					// The value wrapped to the next line, so we should remember the token and continue.
					multi_line_token.Set(token);
					return;
				}
			}
		}
		else if (token[token_len])
		{
			token[token_len] = 0;
			UnescapeString(line);
			value.SetFromStringAuto(line, TBValue::SET_AS_STATIC);
		}
		target->OnToken(current_line_nr, token, value);

		if (is_compact_line)
			OnCompactLine(line, target);
	}
}
Ejemplo n.º 17
0
void D_PAD::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM>& aList )
{
    MODULE*     module;
    wxString    msg;
    BOARD*      board;

    module = (MODULE*) m_Parent;

    if( module )
    {
        aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), module->GetReference(), DARKCYAN ) );
        aList.push_back( MSG_PANEL_ITEM( _( "Pad" ), m_name, BROWN ) );
    }

    aList.push_back( MSG_PANEL_ITEM( _( "Net" ), UnescapeString( GetNetname() ), DARKCYAN ) );

    board = GetBoard();

    aList.push_back( MSG_PANEL_ITEM( _( "Layer" ),
                     LayerMaskDescribe( board, m_layerMask ), DARKGREEN ) );

    aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) );

    msg = MessageTextFromValue( aUnits, m_Size.x, true );
    aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) );

    msg = MessageTextFromValue( aUnits, m_Size.y, true );
    aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) );

    msg = MessageTextFromValue( aUnits, m_Drill.x, true );

    if( GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
    {
        aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), msg, RED ) );
    }
    else
    {
        msg = MessageTextFromValue( aUnits, m_Drill.x, true )
               + wxT( "/" )
               + MessageTextFromValue( aUnits, m_Drill.y, true );
        aList.push_back( MSG_PANEL_ITEM( _( "Drill X / Y" ), msg, RED ) );
    }

    double module_orient_degrees = module ? module->GetOrientationDegrees() : 0;

    if( module_orient_degrees != 0.0 )
        msg.Printf( wxT( "%3.1f(+%3.1f)" ),
                    GetOrientationDegrees() - module_orient_degrees,
                    module_orient_degrees );
    else
        msg.Printf( wxT( "%3.1f" ), GetOrientationDegrees() );

    aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, LIGHTBLUE ) );

    msg = MessageTextFromValue( aUnits, m_Pos.x )
           + wxT( ", " )
           + MessageTextFromValue( aUnits, m_Pos.y );
    aList.push_back( MSG_PANEL_ITEM( _( "Position" ), msg, LIGHTBLUE ) );

    if( GetPadToDieLength() )
    {
        msg = MessageTextFromValue( aUnits, GetPadToDieLength(), true );
        aList.push_back( MSG_PANEL_ITEM( _( "Length in package" ), msg, CYAN ) );
    }
}