CString CCopiagenda::GetLocation(CString csHeaders)
{
	int nPosRet=0;
	CString csLine;
	while((csHeaders.GetLength()) && (nPosRet!=-1))
	{
		nPosRet=csHeaders.Find(_T("\r\n"),0);
		if(nPosRet!=-1)
			csLine=csHeaders.Left(nPosRet);
		else
			csLine=csHeaders;

		int nPosLocation=csLine.Find("Location:");
		if(nPosLocation!=-1)
		{
			CString csLoc=csLine.Mid(nPosLocation+9);
			csLoc.TrimLeft();
			csLoc.TrimRight();
			return csLoc;
		}

		csHeaders=csHeaders.Mid(nPosRet+1);
	}

	return "";
}
void CProfile::_ReadElement(CFile& file, CString& strSection, CString& strEntry, CString& strValue)
{
    // assume valid until an error is found
    bool bValid = true;

    CString str;
    char c;
    int n;
    int i, j;

    // read one full element line from the file
    do
    {
        n = file.Read(&c, 1);
        str += c;

    }
    while(c != '/' && n == 1);

    if(n != 1) bValid = false;

    // parse the "section" tag
    n = str.Find("section=", 0);

    // find the opening quote
    i = str.Find("\"", n);

    // find the closing quote
    j = str.Find("\"", i+1);

    // found the full string
    strSection = str.Mid(i+1, j-i-1);


    // parse the "entry" tag
    n = str.Find("entry=", j);

    // find the opening quote
    i = str.Find("\"", n);

    // find the closing quote
    j = str.Find("\"", i+1);

    // found the full string
    strEntry = str.Mid(i+1, j-i-1);


    // parse the "value" tag
    n = str.Find("value=", j);

    // find the opening quote
    i = str.Find("\"", n);

    // find the closing quote
    j = str.Find("\"", i+1);

    // found the full string
    strValue = str.Mid(i+1, j-i-1);

}
Example #3
0
void FixFilename(CString& str)
{
	str.Trim();

	for (int i = 0, l = str.GetLength(); i < l; i++) {
		switch (str[i]) {
			case '?':
			case '"':
			case '/':
			case '\\':
			case '<':
			case '>':
			case '*':
			case '|':
			case ':':
				str.SetAt(i, '_');
		}
	}

	CString tmp;
	// not support the following file names: "con", "con.txt" "con.name.txt". But supported "name.con" and "name.con.txt".
	if (str.GetLength() == 3 || str.Find('.') == 3) {
		tmp = str.Left(3).MakeUpper();
		if (tmp == _T("CON") || tmp == _T("AUX") || tmp == _T("PRN") || tmp == _T("NUL")) {
			str = _T("___") + str.Mid(3);
		}
	}
	if (str.GetLength() == 4 || str.Find('.') == 4) {
		tmp = str.Left(4).MakeUpper();
		if (tmp == _T("COM1") || tmp == _T("COM2") || tmp == _T("COM3") || tmp == _T("COM4") ||
				tmp == _T("LPT1") || tmp == _T("LPT2") || tmp == _T("LPT3")) {
			str = _T("____") + str.Mid(4);
		}
	}
}
CString CProjectDBI::StripConfiguration (const CString &strPath, CString &strRemainder)
{
    int iPos;

    if (strPath[0] == _T ('{'))
    {
        iPos = strPath.Find (_T ('}'));
        if (iPos == -1)
        {
            strRemainder = strPath;
            return ("");
        };

        strRemainder = strPath.Mid (iPos + 1);
        strRemainder.TrimLeft(_T('.'));
        return (strPath.Left (iPos+1));
    };

    iPos = strPath.Find (_T ('.'));
    if (iPos == -1)
    {
        strRemainder = "";
        return (strPath);
    };

    strRemainder = strPath.Mid (iPos + 1);
    return (strPath.Left (iPos));
}
Example #5
0
BOOL CommandLine::IsSwitch(const CString & strParameterString,
	CString & strSwitchName,
	CString & strSwitchValue)
{
	strSwitchName.Empty();
	strSwitchValue.Empty();

	CString strPrefix = kPrefix;
	if (strParameterString.Find(strPrefix) != 0)
		return FALSE;

	const INT nSwitchStart = strPrefix.GetLength();
	const INT nEqualsPosition = strParameterString.Find(
		kDelimeter, nSwitchStart);

	if (nEqualsPosition == -1) 
	{
		strSwitchName = strParameterString.Mid(nSwitchStart);
	} 
	else 
	{
		strSwitchName = strParameterString.Mid(
			nSwitchStart, nEqualsPosition - nSwitchStart);
		strSwitchValue = strParameterString.Mid(nEqualsPosition + 1);
	}

	strSwitchName.MakeLower();

	return TRUE;
}
Example #6
0
BOOL CChatWnd::OnLocalText(const CString& sText)
{
    // Save history
    m_pHistory.Add( sText );
    if ( m_pHistory.GetSize() > EDIT_HISTORY ) m_pHistory.RemoveAt( 0 );
    m_nHistory = static_cast< int >( m_pHistory.GetSize() );

    if ( sText.GetAt( 0 ) == _T('/') )
    {
        CString strCommand = sText.SpanExcluding( _T(" \t") ).Trim();
        if ( strCommand.CompareNoCase( _T("/me") ) == 0 )
        {
            // Action text
            return OnLocalMessage( true, sText.Mid( 4 ) );
        }
        else if ( OnLocalCommand( strCommand, sText.Mid( strCommand.GetLength() + 1 ).Trim() ) )
        {
            // Handled command
            return TRUE;
        }
    }
    else if ( sText.GetAt( 0 ) == _T('*') &&
              ( sText.GetAt( 1 ) == _T(' ') || sText.GetAt( 1 ) == _T('\t') ) )
    {
        // Action text
        return OnLocalMessage( true, sText.Mid( 2 ) );
    }

    // Regular text
    return OnLocalMessage( false, sText );
}
Example #7
0
// the heading text is in the format column 1 text,column 1 width;column 2 text,column 3 width;etc.
BOOL CSortListCtrl::SetHeadings(const CString& strHeadings)
{

	int iStart = 0;

	for (;; )
	{

		const int iComma = strHeadings.Find(_T(','), iStart);

		if (iComma == -1)
			break;

		const CString strHeading = strHeadings.Mid(iStart, iComma - iStart);

		iStart = iComma + 1;

		int iSemiColon = strHeadings.Find(_T(';'), iStart);

		if (iSemiColon == -1)
			iSemiColon = strHeadings.GetLength();

		const int iWidth = atoi(strHeadings.Mid(iStart, iSemiColon - iStart));

		iStart = iSemiColon + 1;

		if (InsertColumn(m_iNumColumns++, strHeading, LVCFMT_LEFT, iWidth) == -1)
			return FALSE;

	}

	return TRUE;

}
Example #8
0
static int SplitRemoteBranchName(CString ref, CString &remote, CString &branch)
{
	if (ref.Left(13) == _T("refs/remotes/"))
		ref = ref.Mid(13);
	else if (ref.Left(8) == _T("remotes/"))
		ref = ref.Mid(8);

	STRING_VECTOR list;
	int result = g_Git.GetRemoteList(list);
	if (result != 0)
		return result;

	for (size_t i = 0; i < list.size(); ++i)
	{
		if (ref.Left(list[i].GetLength() + 1) == list[i] + _T("/"))
		{
			remote = list[i];
			branch = ref.Mid(list[i].GetLength() + 1);
			return 0;
		}
		if (ref == list[i])
		{
			remote = list[i];
			branch = _T("");
			return 0;
		}
	}

	return -1;
}
BOOL CVersionChecker::UndertakeRequest(CString& strPost)
{
	m_pRequest.SetURL( _T("http://update.trillinux.org/version/beta.php?") + strPost );
	//Remember to set the update server for final releases.
	
	if ( ! m_pRequest.Execute( FALSE ) ) return FALSE;
	
	int nStatusCode = m_pRequest.GetStatusCode();
	if ( nStatusCode < 200 || nStatusCode > 299 ) return FALSE;
	
	CString strResponse = m_pRequest.GetResponseString();
	CString strHack = theApp.GetProfileString( _T("VersionCheck"), _T("TestResponse"), _T("") );
	if ( strHack.GetLength() ) strResponse = strHack;
	
	for ( strResponse += '&' ; strResponse.GetLength() ; )
	{
		CString strItem	= strResponse.SpanExcluding( _T("&") );
		strResponse		= strResponse.Mid( strItem.GetLength() + 1 );
		
		CString strKey = strItem.SpanExcluding( _T("=") );
		if ( strKey.GetLength() == strItem.GetLength() ) continue;
		strItem = CTransfer::URLDecode( strItem.Mid( strKey.GetLength() + 1 ) );

		strItem.TrimLeft();
		strItem.TrimRight();
		
		m_pResponse.SetAt( strKey, strItem );
	}
	
	return TRUE;
}
// 获得字符串数组
EXP_API int ExStringToArray(const CString s, CArrayT<CString> &sa, TCHAR cSpl/* = _T(',')*/, BOOL bTrim/* = TRUE*/)
{
	CString::iterator_t lst_pos, pos;
	BOOL is_continue = FALSE;

	sa.Clear();
	lst_pos = s.Head();
	do
	{
		is_continue = FALSE;
		pos = s.Find(lst_pos, s.Tail(), cSpl);
		if (pos != s.Tail())
		{
			sa.Add(s.Mid(lst_pos->Index(), pos->Index() - lst_pos->Index()));
			lst_pos->nIndx = pos->Index() + 1;
			if (lst_pos != s.Last()) is_continue = TRUE;
		}
	} while(is_continue);

	if (lst_pos != s.Tail())
		sa.Add(s.Mid(lst_pos->Index(), s.GetLength() - lst_pos->Index()));

	if (bTrim)
		for(int i = 0; i < (int)sa.GetCount(); ++i)
		{
			sa[i].Trim(_T(' '));
			sa[i].Trim(_T('\t'));
			sa[i].Trim(_T('\n'));
			sa[i].Trim(_T('\r'));
		}

	return (int)sa.GetCount();
}
Example #11
0
CSms::CSms(const CString &strSms)
{
	// 2016-04-10 21:59:22,10659057607559,18157762594,497825,为您的QQ注册验证码,请您在30分钟内完成注册。如非本人操作,请忽略。【腾讯科技】

	int comma = 0, comma1;

	// 1. Time
	comma1 = strSms.Find(_T(','), comma);
	if (comma1 < 0)
		return;
	
	CString sTime = strSms.Mid(0, comma1);
	m_tSendTime = ConvertStringToTime(sTime);

	comma = comma1 + 1;

	// 2. from
	comma1 = strSms.Find(_T(','), comma);
	if (comma1 < 0)
		return;
	m_sFrom = strSms.Mid(comma, comma1 - comma);
	comma = comma1 + 1;

	// 3. to
	comma1 = strSms.Find(_T(','), comma);
	if (comma1 < 0)
		return;
	m_sTo = strSms.Mid(comma, comma1 - comma);
	comma = comma1 + 1;
	
	// 4. content
	m_sContent = strSms.Mid(comma);
}
Example #12
0
BOOL Split( LPCTSTR lpString, CSimpleArray<CString>& arr, TCHAR delimiter )
{
	if(lpString==NULL || _tcslen(lpString)==0)
		return FALSE;

	arr.RemoveAll();

	CString szString = lpString;
	int nStart = 0;
	int nOffset;
	while(1)
	{
		nOffset = szString.Find(delimiter, nStart);

		if(nOffset > 0)
		{
			arr.Add(szString.Mid(nStart, nOffset-nStart));
		}
		else if(nOffset==-1)
		{
			arr.Add(szString.Mid(nStart));
			break;
		}
		nStart = nOffset + 1;
	};
	return TRUE;
}
Example #13
0
CString CGetEnvPath::GetRealPath(LPCTSTR pszEnvPath)
{

    CString strResult;

    if (pszEnvPath == NULL)
    {
        strResult = _T("");
        goto Exit0;
    }
    
    int nFirstPos  = 0; 
    int nSecondPos = 0;
    BOOL bFind = FALSE;

    strResult = pszEnvPath;

    bFind = FindEnvironmentPos(strResult, nFirstPos, nSecondPos);

    if (bFind == TRUE)
    {
        CString strLeft       ;
        CString strRight      ;
        CString strEnvName    ;
        CString strEnvVariable;


        strLeft    = strResult.Left(nFirstPos);
        strRight   = strResult.Mid (nSecondPos + 1);
        strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);

        strEnvVariable = GetEnvVariable(strEnvName);
        if (strEnvVariable.GetLength() <= 0)
            strEnvVariable = GetFolderPath( strEnvName );

        if(strEnvVariable.Find(_T(';')) == -1)
            strResult = CombinationPath(strLeft, strEnvVariable, strRight);
        else
        {
            //SplitString()
            std::vector<CString> strvec;
            SplitString(strEnvVariable,_T(';'), strvec);
            strResult = _T("");
            for(std::vector<CString>::iterator it = strvec.begin();it != strvec.end(); it++)
            {
                strResult += CombinationPath(strLeft, (*it), strRight);
                strResult += _T(";");
            }
            
        }

        
        bFind = FindEnvironmentPos(strResult, nFirstPos, nSecondPos);
    }
Exit0:
    return strResult;
}
Example #14
0
CMyUrl::CMyUrl(const CString &sUrl)
{
	int scheme_ = sUrl.Find(_T("://"));

	if (scheme_ < 0)
	{
		m_sScheme = _T("http");

		scheme_ = 0;
	}
	else
	{
		m_sScheme = sUrl.Mid(0, scheme_);
		scheme_ += 3; // skip `://`
	}

	int domain_ = sUrl.Find(_T("/"), scheme_);

	if (domain_ < 0)
	{
		m_sDomain = "";
		domain_ = scheme_;
	}
	else
	{
		m_sDomain = sUrl.Mid(scheme_, domain_ - scheme_);
		//domain_ += 1; // skip `/`

		int colon = m_sDomain.Find(_T(':'));
		if (colon < 0)
		{
			m_Port = 80;
		}
		else
		{
			m_Port = (INTERNET_PORT)_ttoi(m_sDomain.Mid(colon + 1));
			m_sDomain = m_sDomain.Mid(0, colon);
		}
	}

	int path_ = sUrl.Find(_T("?"), domain_);
	if (path_ < 0)
	{
		//m_sDomain = _T("/");
		//path_ = domain_;
		m_sPath = sUrl.Mid(domain_);
		m_sQuery = "";
	}
	else
	{
		m_sPath = sUrl.Mid(domain_, path_ - domain_);
		path_ += 1; // skip `?`

		m_sQuery = sUrl.Mid(path_);
	}

}
void CBuildLightAnalysisDoc::OnFileOpen()
{
	CString FilePathName;
	CFileDialog dlg(TRUE, //TRUE为OPEN对话框,FALSE为SAVE AS对话框
		NULL, 
		NULL,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		(LPCTSTR)_TEXT("BLA Files (*.bla)|*.bla|All Files (*.*)|*.*||"),
		NULL);
	if(dlg.DoModal()==IDOK)
	{
		FilePathName=dlg.GetPathName(); //文件名保存在了FilePathName里


		int pos = FilePathName.ReverseFind('.');
		CString lxq = FilePathName.Mid(pos+1);
		if (pos == -1 || FilePathName.Mid(pos+1) != _T("bla"))
		{
			CString strMsg;
			strMsg.Format (_T("打开项目文件\"%s\"失败,后缀错误"), FilePathName); 
			AfxMessageBox(strMsg);
			return; 
		}

		int pos_ = FilePathName.ReverseFind('\\');

		m_projectLocation = FilePathName.Left(pos_);
		m_projectName = FilePathName.Mid(pos_+1, pos - 1 - pos_);

		CString cPath;
		cPath.Format(_T("%s\\%s.bla"), m_projectLocation, m_projectName);
		string path = CStringToString(cPath);

		ifstream inFile(path, ios::binary);
		if (!inFile.is_open())
		{
			CString strMsg;
			strMsg.Format (_T("打开项目文件\"%s\"失败"), cPath); 
			AfxMessageBox(strMsg);
			return; 
		}
		//读取文件
		loadMaterial();
		loadCity();
		loadRoomType();
		loadLumTems();
		loadControlSetTems();
		load(inFile);
		
		m_bIsOpen = true;
		SetTitle(m_projectName);//设置文档名称
	}
	else
	{
		return;
	}
}
// (3) Totally changed
//==============================================================================
CDiskItem::CDiskItem( const CString &strFullName )
{
//   wchar_t cFullName[_MAX_PATH];
//   _tcscpy( cFullName, fullName ); // M If Unicode
	wchar_t drive[_MAX_DRIVE];
	wchar_t dir[_MAX_DIR];
	wchar_t fname[_MAX_FNAME];
	wchar_t ext[_MAX_EXT];

	CString strTmp = strFullName;	// (3) We copy the string because we can't change const &
	if( strTmp.Right(1) == "\\" )	// (3) Consider a folder as a file
		strTmp = strTmp.Left( strTmp.GetLength()-1 );

	_wsplitpath_s( strTmp/*(3)strFullName*/, drive, dir, fname, ext );
	// (3) m_strDrive = drive;
	// (3) m_strDir = dir;
	// (3) m_strName = CString(fname) + CString(ext);

// Support UNC
// I must do it because _splitpath doesn't work correctly with UNC!
	if( strFullName.Left( 2 ) == "\\\\" )	// If UNC path is specified
	// (3) Was if( m_strDir.Left( 2 ) == "\\\\" )	// If UNC...
	{
	// (3) In all places - strTmp instead of m_strDir

		int compEnd = strTmp.Find( _T("\\"), 2 );
		m_strComputer = strTmp.Left( compEnd+1 );

		int driveEnd = strTmp.Find( _T("\\"), compEnd+1 );
		if( driveEnd == -1 )	// (3) Slash not found
		{
			m_strDrive = strTmp.Mid( compEnd+1 );
			m_strDir   = "";	// (3)
			m_strName = "";		// (3)
		}
		else					// (3) Slash found
		{
			m_strDrive = strTmp.Mid( compEnd+1, driveEnd-compEnd );

			int dirEnd = strTmp.ReverseFind( '\\' );				// (3)
			if( dirEnd > driveEnd )									// (3)
				m_strDir = strTmp.Mid( driveEnd+1, dirEnd-driveEnd );// (3)

			if( strTmp.GetLength() > dirEnd )				// (3)
				m_strName = CString(fname) + CString(ext);	// (3)
			else
				m_strName = "";
		}
	}
	else	// (3) All in brackets added
	{
		m_strComputer = "";
		m_strDrive = drive;
		m_strDir = dir;
		m_strName = CString(fname) + CString(ext);
	}
}
Example #17
0
BOOL CSecureRule::Match(const CEnvyFile* pFile) const
{
	if ( m_nType == srAddress || m_nType == srContentRegExp || m_nType == srExternal || ! ( pFile && m_pContent ) )
		return FALSE;

	if ( m_nType == srSizeType )
	{
		if ( pFile->m_nSize == 0 || pFile->m_nSize == SIZE_UNKNOWN )
			return FALSE;

		LPCTSTR pszExt = PathFindExtension( (LPCTSTR)pFile->m_sName );
		if ( *pszExt != L'.' )
			return FALSE;
		pszExt++;

		CString strFilter = (LPCTSTR)m_pContent;
		strFilter = strFilter.Mid( 5 );		// "size:"
		if ( ! StartsWith( strFilter, pszExt ) )
			return FALSE;

		strFilter = strFilter.Mid( strFilter.Find( L':' ) + 1 );

		if ( strFilter.Find( L':' ) > 0 )
		{
			QWORD nLower, nUpper, nSize = pFile->m_nSize;
			_stscanf( (LPCTSTR)strFilter, L"%I64i:%I64i", &nLower, &nUpper );
			return nSize >= nLower && nSize <= nUpper;
		}
		if ( strFilter.Find( L'-' ) > 0 )
		{
			QWORD nLower, nUpper, nSize = pFile->m_nSize;
			_stscanf( (LPCTSTR)strFilter, L"%I64i-%I64i", &nLower, &nUpper );
			return nSize >= nLower && nSize <= nUpper;
		}

		CString strCompare;
		strCompare.Format( L"size:%s:%I64i", pszExt, pFile->m_nSize );
		return strCompare == (CString)m_pContent;
	}

	if ( m_nType == srContentHash )
	{
		LPCTSTR pszHash = m_pContent;
		if ( m_nContentLength < 30 || _tcsnicmp( pszHash, L"urn:", 4 ) != 0 )
			return FALSE;

		return
			( pFile->m_oSHA1  && pFile->m_oSHA1.toUrn() == pszHash ) ||		// Not Match( pFile->m_oSHA1.toUrn() )
			( pFile->m_oTiger && pFile->m_oTiger.toUrn() == pszHash ) ||
			( pFile->m_oED2K  && pFile->m_oED2K.toUrn() == pszHash ) ||
			( pFile->m_oBTH   && pFile->m_oBTH.toUrn() == pszHash ) ||
			( pFile->m_oMD5   && pFile->m_oMD5.toUrn() == pszHash );
	}

	return Match( pFile->m_sName );
}
Example #18
0
BOOL IBNTO_MESSAGE::Parse(LPCTSTR szURL)
{
	BOOL ret = FALSE;
	LPCTSTR szIbnTo = _T("ibnto:");
	CString str = szURL;
	str.MakeLower();
	int n = str.Find(szIbnTo);
	if(n >= 0)
	{
		LPCTSTR szBegin = szURL + n + _tcslen(szIbnTo);
		LPCTSTR szEnd = szURL + _tcslen(szURL);
		LPCTSTR sz = szBegin;
		// Get login and domain
		while(sz < szEnd && *sz != _T('?'))
			sz++;
		str = CString(szBegin, sz-szBegin);

		CStringArray	MailboxArray;

		int CommaIndex	=	-1;
		while((CommaIndex = str.Find(_T(",")))>0)
		{
			MailboxArray.Add(str.Mid(0,CommaIndex));
			str = str.Mid(CommaIndex+1);
		}
		if(str.GetLength()>0)
			MailboxArray.Add(str);

		for(int MailboxArrayIndex = 0 ; MailboxArrayIndex<MailboxArray.GetSize();MailboxArrayIndex++)
		{
			str = MailboxArray[MailboxArrayIndex];
			
			n = str.ReverseFind(_T('@'));
			if(n > 0)
			{
				CString strLogin = str.Left(n);
				Unescape(&strLogin);
				CString strDomain = str.Mid(n+1);
				Unescape(&strDomain);
				
				Logins.Add(LoginItem(strLogin,strDomain));
			}
		}

		sz++;
		szBegin = sz;
		// Get message body
		while(sz < szEnd)
			sz++;
		Message = CString(szBegin, sz-szBegin);
		Unescape(&Message);
		ret = TRUE;
	}
	return ret;
}
Example #19
0
static void splitString(const CString& str,
	CStringArray& parts, TCHAR sep = _T('|'))
{
	int pos, ofs = 0;
	while ((pos = str.Find(sep, ofs)) > 0)
	{
		parts.Add(str.Mid(ofs, pos-ofs));
		ofs = pos+1;
	}
	parts.Add(str.Mid(ofs));
}
/*-----------------------------------------------------------------------------
	Take a crack at modifying custom headers
-----------------------------------------------------------------------------*/
void CWinInetEvents::OnHttpAddRequestHeaders(HINTERNET hRequest, CString &headers, DWORD &dwModifiers)
{
    if( active )
    {
        if( !userAgent.IsEmpty() )
        {
            CString lcase = headers;
            lcase.MakeLower();
            int offset = lcase.Find(_T("user-agent"));
            if( offset >= 0 )
            {
                offset = lcase.Find(_T(":"), offset);
                if( offset >= 0 )
                {
                    int end = lcase.Find(_T('\n'), offset);
                    if( end >= -1 )
                    {
                        // insert it in the middle of the string
                        headers = headers.Left(offset + 2) + userAgent + headers.Mid(end);
                    }
                }
            }
        }
        else if( script_modifyUserAgent && !keepua )
        {
            // modify the user agent string if it was passed as a custom header (IE8)
            CString agent;
            agent.Format(_T("; PTST 2.%d"), build);
            if( headers.Find(agent) == -1 )
            {
                CString lcase = headers;
                lcase.MakeLower();
                int offset = lcase.Find(_T("user-agent"));
                if( offset >= 0 )
                {
                    int end = lcase.Find(_T('\n'), offset);
                    if( end >= -1 )
                    {
                        // now scan backwards for the end parenthesis
                        CString left = lcase.Left(end);
                        int end2 = left.ReverseFind(_T(')'));
                        if( end2 >= 0 )
                            end = end2;

                        // insert it in the middle of the string
                        headers = headers.Left(end) + agent + headers.Mid(end);
                    }
                }
            }
        }
    }
}
Example #21
0
/////////////////////////////////////////////////////////////////////////////
// CZWEIII メッセージ ハンドラ
void CED5::OnDblclkList1() 
{
	// TODO: この位置にコントロール通知ハンドラ用のコードを追加してください
	CString s;	s=tied5[m_list.GetItemData(m_list.GetCurSel())];
	ret=s.Left(8); ret.TrimRight();
	ret2=m_list.GetCurSel();
	if(s.Left(2)=="★"){
		fnn=s.Mid(2);
	}else{
		fnn=s.Mid(9);
	}
	EndDialog(1567);
}
void CMenuSkin::DrawMenuItemText(CDCHandle dc, UINT uMenuRes, WORD wMenuID, const CString &lpszMenuString, const RECT &rect, CBitmapHandle hBitmap, CBitmapHandle hBitmapMask, bool bEnabled, bool bBold)
{
	if (hBitmap == (HBITMAP)-1 || hBitmap == (HBITMAP)-2)
	{
		int iWidth = m_imgMenuIcon.GetWidth() / 2;
		int iBegin = iWidth * (-(int)(HBITMAP)hBitmap - 1);
		int iY = (rect.bottom - rect.top - ICON_WIDTH) / 2;
		RECT rcDest = { rect.left + iY + 1, rect.top + iY, rect.left + iY + iWidth + 1, rect.top + iY + iWidth };
		RECT rcSrc = { iBegin, 0, iBegin + iWidth, m_imgMenuIcon.GetHeight() };
		m_imgMenuIcon.Draw(dc, rcDest, rcSrc);
	}
	else if ( (hBitmap && ::GetObjectType(hBitmap) == OBJ_BITMAP) || 
              (hBitmapMask && ::GetObjectType(hBitmapMask) == OBJ_BITMAP) )
	{
		ICONINFO ii = { TRUE, 8, 8, hBitmapMask, hBitmap };
		CIcon ico;
		ico.CreateIconIndirect(&ii);

		int iY = (rect.bottom - rect.top - ICON_WIDTH) / 2;
		ico.DrawIconEx(dc, rect.left + iY + 1, rect.top + iY, ICON_WIDTH, ICON_WIDTH);
	}

	CString strMenuText = lpszMenuString;
	int n = strMenuText.Find('\n');
	if (n >= 0)
		strMenuText = strMenuText.Mid(0, n);

	TCHAR szAcc[128] = { 0 };
	n = strMenuText.Find('\t');
	if (n >= 0)
	{
		_tcscpy_s(szAcc, strMenuText.Mid(n + 1));
		strMenuText = strMenuText.Mid(0, n);
	}

	RECT rcText = rect;
	rcText.left += ICON_WIDTH + 6;
	rcText.right -= 5;

	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(CSkinProperty::GetColor(bEnabled ? Skin_Property_Menu_Text_Color : Skin_Property_Menu_Disabled_Text_Color));
	dc.SelectFont(bBold ? s()->Common()->GetBoldFont() : s()->Common()->GetDefaultFont());
	dc.DrawText(strMenuText, strMenuText.GetLength(), &rcText, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);

	if (szAcc[0])
	{
		dc.SetTextColor(CSkinProperty::GetColor(Skin_Property_Menu_Shortcut_Text_Color));
		dc.SelectFont(s()->Common()->GetMenuAccFont());
		dc.DrawText(szAcc, -1, &rcText, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
	}
}
Example #23
0
BOOL CSpecialApp::CleanQQLive(int iType,LPCTSTR lpcszAppPath)
{	
	
	CString strPath = lpcszAppPath;
	g_regClean.ConvetPath(strPath);
	int iIndex = strPath.Find(_T("*"));
	
	if (iIndex>0)
	{
		CString strTempPath1 = strPath.Mid(0,iIndex);
		CString strTempPath2 = strPath.Mid(iIndex+1);
		
		CSimpleArray<CString> vec_folder;
		m_fileOpt.DoFileFolder(strTempPath1,vec_folder,FALSE,TRUE);

		for (int i=0;i<vec_folder.GetSize();i++)
		{
			CString strFullPath = vec_folder[i];
			strFullPath.Append(strTempPath2);
			
			int iCount = strFullPath.ReverseFind('\\');
			if (iCount>0) //将文件名与路径分离
			{
				CString strTmp = strFullPath.Mid(0,iCount);
				CString strTmp2 =strFullPath.Mid(iCount+1);

				CSimpleArray<CString> vec_Exts;
				vec_Exts.Add(strTmp2);

				m_appHistory.CommfunFile(iType,strTmp,vec_Exts);
				
			}

		}

	}


	//TCHAR szPath[MAX_PATH*2]={0};
	//CString strAppPath = lpcszAppPath;
	//g_regClean.ConvetPath(strAppPath);

	//if (NULL !=GetPrivateProfileString(_T("Cache"),_T("Directory"),NULL,szPath,MAX_PATH*2-1,strAppPath))
	//{
	//	CSimpleArray<CString>  vec_file;
	//	m_appHistory.CommfunFile(iType,szPath,vec_file);
	//}
	
	return TRUE;
}
Example #24
0
	CString Directory::GetFolderPath(const CString& strFolderPath)
	{
        int n1 = strFolderPath.ReverseFind('\\');
        if (n1 < 0 )
		{
			n1 = strFolderPath.ReverseFind('/');
			if (n1 < 0 )
			{           
				return _T("");
			}
			return strFolderPath.Mid(0,n1);
		}
        return strFolderPath.Mid(0,n1);
	}
void Split(CString source, CStringArray& dest, CString division)
{
	int len=source.GetLength();
	dest.RemoveAll();
	int pos = 0;
	int pre_pos = 0;
	while( -1 != pos )
	{
		pre_pos = pos+1;
		pos = source.Find(division,(pos+1));
		if(-1==pos)
			dest.Add(source.Mid(pre_pos,(len-pre_pos)));
		dest.Add(source.Mid(pre_pos,(pos-pre_pos)));
	}
}
void CBuildLightAnalysisDoc::OnFileSaveAs()
{
	CString FilePathName;
	CFileDialog dlg(FALSE, //FALSE为SAVE AS对话框
		NULL, 
		NULL,
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		(LPCTSTR)_TEXT("BLA Files (*.bla)|*.bla|All Files (*.*)|*.*||"),
		NULL);
	if(dlg.DoModal()==IDOK)
	{
		FilePathName=dlg.GetPathName(); //文件名保存在了FilePathName里
		int pos = FilePathName.ReverseFind('.');
		CString lxq = FilePathName.Mid(pos+1);
		if (pos == -1 || FilePathName.Mid(pos+1) != _T("bla"))
		{
			CString strMsg;
			strMsg.Format (_T("保存项目文件\"%s\"失败,后缀错误"), FilePathName); 
			AfxMessageBox(strMsg);
			return; 
		}

		int pos_ = FilePathName.ReverseFind('\\');

		m_projectLocation = FilePathName.Left(pos_);
		m_projectName = FilePathName.Mid(pos_+1, pos - 1 - pos_);

		CString cPath;
		cPath.Format(_T("%s\\%s.bla"), m_projectLocation, m_projectName);
		string path = CStringToString(cPath);

		ofstream outFile(path, ios::binary|ios::ate);
		if (!outFile.is_open())
		{
			CString strMsg;
			strMsg.Format (_T("保存项目文件\"%s\"失败"), cPath); 
			AfxMessageBox(strMsg);
			return; 
		}
		//写入文件
		save(outFile);
		SetTitle(m_projectName);//设置文档名称
	}
	else
	{
		return;
	}
}
Example #27
0
const CString COXUNC::Extension(BOOL bIncludeDot /* = TRUE */) const
	{
	CString sFile = File();
	int nDotPos = sFile.ReverseFind(m_cDot);
	if (0 <= nDotPos)
		{
		if (bIncludeDot)
			// ... Include the leading dot
			return sFile.Mid(nDotPos);
		else
			// ... Exclude the leading dot
			return sFile.Mid(nDotPos + 1);
		}
	else
		return _T("");
	}
Example #28
0
CString ExtractKeyword(CString line) // "  function(..)     " will return "function"
{
	int length = line.GetLength();
	int start = -1;
	int end = length;

	for(int a = 0; a < length; a++)
	{
		if(KeywordLetter(line.GetAt(a)))
		{
			start = a;
			a = length;
		}
	}

	if(start == -1)
		return CString("");

	for(int a = start; a < length; a++)
	{
		if(!KeywordLetter(line.GetAt(a)))
		{
			end = a;
			a = length;
		}
	}
	return line.Mid(start, end-start);
}
void CEditPropExternalsValue::OnBnClickedBrowse()
{
    SVNRev rev = SVNRev::REV_HEAD;
    CAppUtils::BrowseRepository(m_URLCombo, this, rev, false, m_RepoRoot.GetSVNPathString(), m_URL.GetSVNPathString());

    // if possible, create a repository-root relative url
    CString strURLs;
    m_URLCombo.GetWindowText(strURLs);
    if (strURLs.IsEmpty())
        strURLs = m_URLCombo.GetString();
    strURLs.Replace('\\', '/');
    strURLs.Replace(L"%", L"%25");

    CString root = m_RepoRoot.GetSVNPathString();
    int rootlength = root.GetLength();
    if (strURLs.Left(rootlength).Compare(root)==0)
    {
        if ((strURLs.GetLength() > rootlength) && (strURLs.GetAt(rootlength) == '/'))
        {
            strURLs = L"^/" + strURLs.Mid(rootlength);
            strURLs.Replace(L"^//", L"^/");
            m_URLCombo.SetWindowText(strURLs);
        }
    }
}
Example #30
0
CString CCommonAppUtils::GetAbsoluteUrlFromRelativeUrl(const CString& root, const CString& url)
{
    // is the URL a relative one?
    if (url.Left(2).Compare(L"^/") == 0)
    {
        // URL is relative to the repository root
        CString url1 = root + url.Mid(1);
        TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
        DWORD len = url.GetLength();
        if (UrlCanonicalize((LPCTSTR)url1, buf, &len, 0) == S_OK)
            return CString(buf, len);
        return url1;
    }
    else if (url[0] == '/')
    {
        // URL is relative to the server's hostname
        CString sHost;
        // find the server's hostname
        int schemepos = root.Find(L"//");
        if (schemepos >= 0)
        {
            sHost = root.Left(root.Find('/', schemepos+3));
            CString url1 = sHost + url;
            TCHAR buf[INTERNET_MAX_URL_LENGTH] = { 0 };
            DWORD len = url.GetLength();
            if (UrlCanonicalize((LPCTSTR)url, buf, &len, 0) == S_OK)
                return CString(buf, len);
            return url1;
        }
    }
    return url;
}