Example #1
0
CString GetSIPURI(CString str, bool isSimple, bool isLocal)
{
	CString rab = str;
	rab.MakeLower();
	int pos = rab.Find(_T("sip:"));
	if (pos==-1)
	{
		str=_T("sip:")+str;
	}
	if (!isLocal) {
		pos = str.Find(_T("@"));
		if (accountSettings.accountId && pos==-1) {
			str.Append(_T("@")+accountSettings.account.domain);
		}
	}
	if (str.GetAt(str.GetLength()-1)=='>')
	{
		str = str.Left(str.GetLength()-1);
		if (!isSimple) {
			if (!isLocal || !accountSettings.accountId) {
				AddTransportSuffix(str);
			}
		}
		str += _T(">");
	} else {
		if (!isSimple) {
			if (!isLocal || !accountSettings.accountId) {
				AddTransportSuffix(str);
			}
		}
		str = _T("<") + str + _T(">");
	}
	return str;
}
void CIncrementSystemBFDlg::DocumentCompleteExplorerSelectItem(LPDISPATCH pDisp, VARIANT* URL)
{
	CString url = URL->bstrVal;

	if (url.Find(cUrls.Logon) > 0){
		TRACE("UnLoadhook");
		unloadhook();
		isLogon = true;
	}
	if (isLogon){
		if (url.Find(cUrls.Http1) > 0){
			TRACE("Loadhook");
			loadhook();
			isLogon = false;
		}
	}
    IUnknown*  pUnk;  
    LPDISPATCH lpWBDisp;  
    HRESULT    hr;  
 
    pUnk = m_MyIE.GetControlUnknown();  
    ASSERT(pUnk);  
 
    hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);  
    ASSERT(SUCCEEDED(hr));  
 
    if (pDisp == lpWBDisp )  
    {
        //TRACE("Web document is finished downloading/n");//这里就是最佳获取时机的判断
    }
    pUnk->Release();
    lpWBDisp->Release();
}
Example #3
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 #4
0
// CLogWindow message handlers
void CLogWindow::onReceiveRemoteLog(std::string str)
{
	if(str.size() <= 0)
		return;
	
	CString s;
	wchar_t* wstr = KBEngine::strutil::char2wchar(str.c_str());
	s = wstr;
	free(wstr);
	s.Replace(L"\n", L"");
	s.Replace(L"\r\n", L"");
	s.Replace(L"\n\r", L"");
	s.Replace(L"\r", L"");

	if(s.Find(L"WARNING") >= 0)
		m_loglist.AddString(s, RGB(0, 0, 0), RGB(255, 165, 0));
	else if(s.Find(L"ERROR") >= 0)
		m_loglist.AddString(s, RGB(0, 0, 0), RGB(255, 0, 0));
	else if(s.Find(L"CRITICAL") >= 0)
		m_loglist.AddString(s, RGB(0, 0, 0), RGB(100, 149, 237));
	else if(s.Find(L"SCRIPT") >= 0)
		m_loglist.AddString(s, RGB(0, 0, 0), RGB(237, 237,237));
	else
		m_loglist.AddString(s, RGB(80, 80, 80), RGB(237, 237,237));

	::SendMessage(m_loglist.m_hWnd, WM_VSCROLL, SB_BOTTOM, 0);
}
bool MyUPnP::GetDescription()
{
	if(!Valid())return false;
	CString post, host, addr;
	int port = 0;
	addr = NGetAddressFromUrl(m_description, post, host, port);
	if(addr.IsEmpty())return false;
	CString request = CString(_T("GET ")) + post + _T(" HTTP/1.1\r\nHOST: ") + host + _T("\r\nACCEPT-LANGUAGE: en\r\n\r\n");
	CString response;
	if (!SOAP_action(addr, (uint16)port, request, response)) return false;
	CString result;
	if (!parseHTTPResponse(response, result)) return false;

	m_friendlyname = getProperty(result, _T("friendlyName"));
	m_modelname = getProperty(result, _T("modelName"));
	m_baseurl = getProperty(result, _T("URLBase"));
	if(m_baseurl.IsEmpty())m_baseurl = CString(_T("http://")) + host + _T("/");
	if(m_baseurl[m_baseurl.GetLength() - 1]!='/')m_baseurl += _T("/");
	
	CString serviceType = _T("<serviceType>") + m_name + _T("</serviceType>");
	int pos = result.Find(serviceType);
	if (pos >= 0) {
		result.Delete(0, pos + serviceType.GetLength());
		pos = result.Find(_T("</service>"));
		if (pos >= 0) {
			result = result.Mid(0, pos);
			m_controlurl = getProperty(result, _T("controlURL"));
			if (!m_controlurl.IsEmpty() && m_controlurl[0] == '/') {
				m_controlurl = m_baseurl + m_controlurl.Mid(1);
			}
		}
	}

	return isComplete();
}
bool GitAdminDir::IsAdminDirPath(const CString& path) const
{
	if (path.IsEmpty())
		return false;
	bool bIsAdminDir = false;
	CString lowerpath = path;
	lowerpath.MakeLower();
	int ind1 = 0;
	while ((ind1 = lowerpath.Find(_T("\\.git"), ind1))>=0)
	{
		int ind = ind1++;
		if (ind == (lowerpath.GetLength() - 5))
		{
			bIsAdminDir = true;
			break;
		}
		else if (lowerpath.Find(_T("\\.git\\"), ind)>=0)
		{
			bIsAdminDir = true;
			break;
		}
	}

	return bIsAdminDir;
}
Example #7
0
engine_t CMediaFormats::GetEngine(CString path) const
{
    path.Trim().MakeLower();

    if (!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
        return m_iRtspHandler;
    }

    CString ext = CPath(path).GetExtension();
    ext.MakeLower();
    if (!ext.IsEmpty()) {
        if (path.Find(_T("rtsp://")) == 0) {
            if (ext == _T(".ram") || ext == _T(".rm") || ext == _T(".ra")) {
                return RealMedia;
            }
            if (ext == _T(".qt") || ext == _T(".mov")) {
                return QuickTime;
            }
        }

        for (size_t i = 0; i < GetCount(); i++) {
            const CMediaFormatCategory& mfc = GetAt(i);
            if (mfc.FindExt(ext)) {
                return mfc.GetEngineType();
            }
        }
    }

    if (m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
        return m_iRtspHandler;
    }

    return DirectShow;
}
Example #8
0
int CWebBase::ConvertData(CString strReponseHead,CString &strError,CString &strData)
{
	int nStringLen = -1;
	strReponseHead.MakeLower();
	//是被压缩过的, 要解压
	if(strReponseHead.Find("gzip" ) != -1) 
	{                        
		nStringLen = strData.GetLength();
		if( gzuncompress(strData, nStringLen ) != 0 )
		{
			strError = "解压失败";
			return -5;
		}
	}
	if (g_iUtfFlag == 1)
	{
		ConvertUtf8ToGBK(m_strWorkBuf);
		return 0;
	}
	if( strReponseHead.Find("utf-8") != -1 && strReponseHead.Find("jpeg" ) == -1 )
	{                        
		ConvertUtf8ToGBK( strData );
	}
	return 0;
}
Example #9
0
// returns NULL if error, else usable (local) path...
//
static LPCSTR Skins_ModelNameToSkinPath(LPCSTR psModelFilename)
{
	static CString str;
			str = psModelFilename;
			str.MakeLower();
 	while  (str.Replace('\\','/')){}	

	// special case for anything in the "objects" dir...
	//
	int i = str.Find("models/objects/");
	if (i>=0)
	{
		str = str.Left(i+strlen("models/objects/"));
		str+= "skins";
		return (LPCSTR) str;
	}

	// or anything else...
	//
	i = str.Find("models/");
	if (i>=0)
	{
		str = str.Left(i+strlen("models/"));
		str+= "characters/skins";		
		return (LPCSTR) str;
	}

	return NULL;
}
Example #10
0
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 "";
}
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 #12
0
char CRegisterDlg::GetFatherPath(CString& strFullPath)
{
	char bToken;
	if(!strFullPath.Find("HKEY_CLASSES_ROOT"))	//判断主键
	{

		bToken=MHKEY_CLASSES_ROOT;
		strFullPath.Delete(0,sizeof("HKEY_CLASSES_ROOT"));
	}else if(!strFullPath.Find("HKEY_CURRENT_USER"))
	{
		bToken=MHKEY_CURRENT_USER;
		strFullPath.Delete(0,sizeof("HKEY_CURRENT_USER"));

	}else if(!strFullPath.Find("HKEY_LOCAL_MACHINE"))
	{
		bToken=MHKEY_LOCAL_MACHINE;
		strFullPath.Delete(0,sizeof("HKEY_LOCAL_MACHINE"));

	}else if(!strFullPath.Find("HKEY_USERS"))
	{
		bToken=MHKEY_USERS;
		strFullPath.Delete(0,sizeof("HKEY_USERS"));

	}else if(!strFullPath.Find("HKEY_CURRENT_CONFIG"))
	{
		bToken=MHKEY_CURRENT_CONFIG;
		strFullPath.Delete(0,sizeof("HKEY_CURRENT_CONFIG"));

	}
	return bToken;
}
Example #13
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);
		}
	}
}
Example #14
0
bool CCommonAppUtils::AddClipboardUrlToWindow( HWND hWnd )
{
    if (IsClipboardFormatAvailable(CF_UNICODETEXT))
    {
        CClipboardHelper clipboard;
        clipboard.Open(hWnd);
        HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
        if (hglb)
        {
            LPCWSTR lpstr = (LPCWSTR)GlobalLock(hglb);
            CString sUrl = lpstr;
            GlobalUnlock(hglb);

            sUrl.Trim();
            CString sLowerCaseUrl = sUrl;
            sLowerCaseUrl.MakeLower();
            // check for illegal chars: they might be allowed in a regular url, e.g. '?',
            // but not in an url to an svn repository!
            if (sLowerCaseUrl.FindOneOf(L"\n\r?;=+$,<>#") >= 0)
                return false;

            if ((sLowerCaseUrl.Find(L"http://")==0) ||
                (sLowerCaseUrl.Find(L"https://")==0) ||
                (sLowerCaseUrl.Find(L"svn://")==0) ||
                (sLowerCaseUrl.Find(L"svn+ssh://")==0) ||
                (sLowerCaseUrl.Find(L"file://")==0))
            {
                ::SetWindowText(hWnd, (LPCTSTR)sUrl);
                return true;
            }
        }
    }
    return false;
}
Example #15
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 #16
0
int CSpecialApp::SplitCString1(CString strIn, CSimpleArray<CString>& vec_String, TCHAR division) 
{ 
	vec_String.RemoveAll(); 
	if (!strIn.IsEmpty()) 
	{ 
		int nCount = 0; 
		int nPos = -1; 
		nPos = strIn.Find(division); 
		CString strTemp = strIn; 
		while (nPos != -1) 
		{ 
			CString strSubString = strTemp.Left(nPos);  
			strTemp = strTemp.Right(strTemp.GetLength() - nPos-1);  
			nPos = strTemp.Find(division); 
			nCount++; 
			vec_String.Add(strSubString); 
		} 

		if (nCount == vec_String.GetSize()) 
		{ 
			CString str; 
			int nSize = strIn.ReverseFind(division); 
			str = strIn.Right(strIn.GetLength()-nSize-1); 
			vec_String.Add(str); 
		} 
	} 

	return vec_String.GetSize(); 
} 
Example #17
0
void CCopyTagBlkDlg::BldTreeSelList(HTREEITEM h, char* TagPrefix, int& Cnt, CSVector& List)
  {
  CString s;
  int i;
  while (h)
    {
    BOOL b = m_CopyTree.GetItemSelected(h);
    if (b)
      {
      //rAccNdData d = AW.Data[LOWORD(dw)];
      //s = d.sFullTag();
      s = m_CopyTree.GetItemText(h);
      i = s.Find(" (");
      if (i>=0)
        s = s.Left(i);
      List[Cnt].Set("%s%s", TagPrefix, (const char*)s);
      Cnt++;
      }
    if (m_CopyTree.ItemHasChildren(h))
      {
      if (!b)
        {
        s = m_CopyTree.GetItemText(h);
        i = s.Find(" (");
        if (i>=0)
          s = s.Left(i);
        }
      Strng ss;
      ss.Set("%s%s.", TagPrefix, (const char*)s);
      BldTreeSelList(m_CopyTree.GetChildItem(h), ss(), Cnt, List);
      }
    h = m_CopyTree.GetNextSiblingItem(h);
    }
  }
Example #18
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 #19
0
CString FileMisc::GetFullPath(const CString& sFilePath, const CString& sRelativeToFolder)
{
	if (!::PathIsRelative(sFilePath))
	{
		// special case: filename has no drive letter and is not UNC
		if (sFilePath.Find(_T(":\\")) == -1 && sFilePath.Find(_T("\\\\")) == -1)
		{
			CString sFullPath, sDrive;

			SplitPath(sRelativeToFolder, &sDrive);
			return MakePath(sFullPath, sDrive, NULL, sFilePath);
		}

		// else
		return sFilePath;
	}

	CString sSrcPath(sRelativeToFolder);
	FileMisc::TerminatePath(sSrcPath);
	sSrcPath += sFilePath;

	TCHAR szFullPath[MAX_PATH + 1];
	BOOL bRes = ::PathCanonicalize(szFullPath, sSrcPath);

	return bRes ? CString(szFullPath) : sSrcPath;
}
Example #20
0
BOOL DeviceSelect::OnInitDialog()
{
	CDialog::OnInitDialog();

	listControl.SetExtendedStyle(listControl.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT  );
	listControl.ModifyStyle(LVS_SINGLESEL , 0);
	listControl.InsertColumn(0, _T("Device ID"), LVCFMT_LEFT, 100);
	listControl.InsertColumn(1, _T("Device Name"), LVCFMT_LEFT, 206);

	int pos;
	int count = 0;
	CString id;
	pos = deviceList.Find(",",0);
	CString device;
	while(pos >= 0)
	{
		device = deviceList.Left(pos);
		deviceList.Delete(0,pos + 1);
		pos = deviceList.Find(",",0);
		id = deviceList.Left(pos);
		deviceList.Delete(0,pos + 1);
		char * temp = (char *)malloc(100);
		itoa(count,temp,10);
		CString str(temp);
		int nIndex = listControl.InsertItem(count, str);
		listControl.SetItemText(nIndex, 1, _T(device));
		pos = deviceList.Find(",",0);
		count++;
	}
	listControl.SetFocus();
	listControl.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED ); 
	selectedDevice = device;
	return true;
}
Example #21
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;
}
Example #22
0
// 设置图片
BOOL CControlBaseFont::SetImage(CString strImage)
{
	if(strImage.Find(_T(".")) != -1)	// 加载图片文件
	{
		CString strImgFile = strImage;
		if(strImage.Find(_T(":")) != -1)
		{
			strImgFile = strImage;
		}
		if(!SetBitmap(strImgFile))
		{
			return FALSE;
		}
	}else	// 加载图片资源
	{
		UINT nResourceID = _ttoi(strImage);
		if(!SetBitmap(nResourceID, TEXT("PNG")))
		{
			if(!SetBitmap(nResourceID, TEXT("BMP")))
			{
				return FALSE;
			}
		}
	}

	return TRUE;
}
Example #23
0
bool GitAdminDir::HasAdminDir(const CString& path, bool bDir, CString* ProjectTopDir, bool* IsAdminDirPath)
{
	if (path.IsEmpty())
		return false;
	CString sDirName = path;
	if (!bDir)
	{
		// e.g "C:\"
		if (path.GetLength() <= 3)
			return false;
		sDirName.Truncate(max(0, sDirName.ReverseFind(L'\\')));
	}

	// a .git dir or anything inside it should be left out, only interested in working copy files -- Myagi
	int n = 0;
	for (;;)
	{
		n = sDirName.Find(L"\\.git", n);
		if (n < 0)
			break;

		// check for actual .git dir (and not .gitignore or something else), continue search if false match
		n += 5;
		if (sDirName[n] == L'\\' || sDirName[n] == 0)
		{
			if (IsAdminDirPath)
				*IsAdminDirPath = true;
			return false;
		}
	}

	for (;;)
	{
		if (CGit::GitPathFileExists(sDirName + L"\\.git"))
		{
			if(ProjectTopDir)
			{
				*ProjectTopDir=sDirName;
				// Make sure to add the trailing slash to root paths such as 'C:'
				if (sDirName.GetLength() == 2 && sDirName[1] == L':')
					(*ProjectTopDir) += L'\\';
			}
			return true;
		}
		else if (IsBareRepo(sDirName))
			return false;

		int x = sDirName.ReverseFind(L'\\');
		if (x < 2)
			break;

		sDirName.Truncate(x);
		// don't check for \\COMPUTERNAME\.git
		if (sDirName[0] == L'\\' && sDirName[1] == L'\\' && sDirName.Find(L'\\', 2) < 0)
			break;
	}

	return false;
}
Example #24
0
BOOL CDlgSaveTrig::IsValid(CString str)
{
	if (str.Find("(") != -1 || str.Find(")") != -1)//名称不能包含括号
	{
		return FALSE;
	}
	return TRUE;
}
Example #25
0
CString CNumSpinCtrl::FormatValue (double val)
{
    CString str;

    if (m_NumDecPlaces == -1) // no precision specified
    {
        str.Format (_T("%g"), val);
        return str;
    }

    CString fstr;

    /// Check which format to use ('e' or 'f')
    bool bExponential;
    fstr.Format (_T("%g"), val);
    if (fstr.Find (_T('e')) != -1)
    {
        fstr.Format (_T("%%.%de"), m_NumDecPlaces);
        bExponential = true;
    }
    else
    {
        fstr.Format (_T("%%.%df"), m_NumDecPlaces);
        bExponential = false;
    }

    /// Output the number with given format
    str.Format (fstr, val);

    /// Check for trailing zeros and remove them
    if (m_bTrimTrailingZeros)
    {
        if (bExponential)
        {
            // separate base and exponent
            CString strBase, strExponent;
            int e_pos = str.Find (_T('e'));
            strBase = str.Left (e_pos);
            strExponent = str.Right (str.GetLength () - e_pos);

            if (str.Find (m_DecSymbol) != -1) {
                strBase.TrimRight (_T('0'));
                strBase.TrimRight (m_DecSymbol); // if dot is all that's left
            }

            str = strBase + strExponent; //reconstruct
        }
        else
        {
            if (str.Find (m_DecSymbol) != -1) {
                str.TrimRight (_T('0'));
                str.TrimRight (m_DecSymbol); // if dot is all that's left
            }
        }
    }

    return str;
}
Example #26
0
bool CSyncDlg::IsURL()
{
	CString str;
	this->m_ctrlURL.GetWindowText(str);
	if(str.Find(_T('\\'))>=0 || str.Find(_T('/'))>=0)
		return true;
	else
		return false;
}
Example #27
0
void CKademliaWnd::OnBnClickedBootstrapbutton()
{
	CString strIP;
	uint16 nPort = 0;

	if (IsDlgButtonChecked(IDC_RADIP) != 0)
	{
		GetDlgItem(IDC_BOOTSTRAPIP)->GetWindowText(strIP);
		strIP.Trim();

		// auto-handle ip:port
		int iPos;
		if ((iPos = strIP.Find(_T(':'))) != -1)
		{
			GetDlgItem(IDC_BOOTSTRAPPORT)->SetWindowText(strIP.Mid(iPos+1));
			strIP = strIP.Left(iPos);
			GetDlgItem(IDC_BOOTSTRAPIP)->SetWindowText(strIP);
		}

		CString strPort;
		GetDlgItem(IDC_BOOTSTRAPPORT)->GetWindowText(strPort);
		strPort.Trim();
		nPort = (uint16)_ttoi(strPort);

		// invalid IP/Port
		if (strIP.GetLength()<7 || nPort==0)
			return;

		if (m_pacONBSIPs && m_pacONBSIPs->IsBound())
			m_pacONBSIPs->AddItem(strIP + _T(":") + strPort, 0);
		if( !Kademlia::CKademlia::IsRunning() )
		{
			Kademlia::CKademlia::Start();
			theApp.emuledlg->ShowConnectionState();
		}
		Kademlia::CKademlia::Bootstrap(strIP, nPort);
	}
	else if (IsDlgButtonChecked(IDC_RADNODESURL) != 0)
	{
		CString strURL;
		GetDlgItemText(IDC_BOOTSTRAPURL, strURL);
		if (strURL.IsEmpty() || (strURL.Find(_T("://")) == -1)) {
			// not a valid URL
			LogError(LOG_STATUSBAR, GetResString(IDS_INVALIDURL) );
			return;
		}
		UpdateNodesDatFromURL(strURL);
	}
	else
	{
		if( !Kademlia::CKademlia::IsRunning() )
		{
			Kademlia::CKademlia::Start();
			theApp.emuledlg->ShowConnectionState();
		}
	}
}
Example #28
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_);
	}

}
// (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 #30
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 );
}