Esempio n. 1
0
void CCaHtmlParse::__GetPriceAndRamainTicket(UINT *pPrice, UINT *pRemainTicket, const TidyDoc & tdoc, const TidyNode & tdNode)
{
	CStringA straRet;
	*pPrice = 0;
	*pRemainTicket = 0;

	TidyBuffer text = {0};
	tidyBufInit(&text);
	TidyNodeType type = tidyNodeGetType(tdNode);
	tidyNodeGetText(tdoc, tdNode, &text);
	straRet.Format("%s",text.bp);
	straRet.TrimLeft();

	CStringA straKey("</font>");
	int iPos = straRet.Find(straKey);
	int iEndPos = straRet.Find("</strong>");
	int iStartPos = iPos+straKey.GetLength();
	CStringA straPrice = straRet.Mid(iStartPos, iEndPos-iStartPos);
	straPrice.Remove(0x0d);//去掉回车
	straPrice.Remove(0x0a);//去掉换行
	*pPrice = atoi(straPrice.GetBuffer(0));
	straPrice.ReleaseBuffer();

	//剩余座位
	straKey = ":";
	iPos = straRet.Find(straKey);
	iEndPos = straRet.Find("</td>");
	iStartPos = iPos+straKey.GetLength();
	CStringA straRemainSeat = straRet.Mid(iStartPos, iEndPos-iStartPos);
	*pRemainTicket = atoi(straRemainSeat.GetBuffer(0));
	straRemainSeat.ReleaseBuffer();

	tidyBufFree(&text);
}
Esempio n. 2
0
void CCaHtmlParse::__GetAirPortCode(CStringA & straDCode, CStringA & straACode, const TidyDoc & tdoc, const TidyNode & tdNode)
{
	CStringA straRet;
	CStringA straSha("上海虹桥");
	CStringA straPvg("上海浦东");
	CStringA straPek("北京首都");
	CStringA straNay("北京南苑");

	straDCode = "";
	straACode = "";

	TidyBuffer text = {0};
	tidyBufInit(&text);
	TidyNodeType type = tidyNodeGetType(tdNode);
	tidyNodeGetText(tdoc, tdNode, &text);
	straRet.Format("%s",text.bp);
	straRet.TrimLeft();

	CStringA straKey("<br />");//<br />后有回车换行符
	int iPos = straRet.Find(straKey);
	CStringA straDCity = straRet.Mid(4, iPos-4);
	if (-1 != straDCity.Find(straSha))
		straDCode = "SHA";
	else if (-1 != straDCity.Find(straPvg))
		straDCode = "PVG";
	else if (-1 != straDCity.Find(straPek))
		straDCode = "PEK";
	else if(-1 != straDCity.Find(straNay))
		straDCode = "NAY";
	else
	{

	}

	//取到达机场,<br />后有回车换行符
	straRet = straRet.Mid(iPos+straKey.GetLength());
	straRet.Remove(0x0d);//去掉回车
	straRet.Remove(0x0a);//去掉换行
	int iEndPos = straRet.Find("</td>");
	CStringA straACity = straRet.Left(iEndPos);
	if (-1 != straACity.Find(straSha))
		straACode = "SHA";
	else if (-1 != straACity.Find(straPvg))
		straACode = "PVG";
	else if (-1 != straACity.Find(straPek))
		straACode = "PEK";
	else if(-1 != straACity.Find(straNay))
		straACode = "NAY";
	else
	{

	}

	tidyBufFree(&text);
}
Esempio n. 3
0
BOOL CCookie::ParseExpires(LPCSTR lpszExpires, __time64_t& tmExpires)
{
	int iLength = (int)strlen(lpszExpires);

	if(iLength == 0 || iLength > 50)
		return FALSE;

	char szMonth[10];
	char szZone[10];

	tm t = {0};

	if(sscanf(	lpszExpires, "%*[^, ]%*[, ]%2d%*[-/ ]%8[^-/ ]%*[-/ ]%4d %2d:%2d:%2d %8c", 
				&t.tm_mday, szMonth, &t.tm_year, &t.tm_hour, &t.tm_min, &t.tm_sec, szZone) != 7)
		return FALSE;

	if(t.tm_year < 70)
		t.tm_year += 100;
	else if (t.tm_year > 100)
		t.tm_year -= 1900;

	int i	 = 0;
	int size = _countof(s_short_month);

	for(; i < size; i++)
	{
		if(strnicmp(szMonth, s_short_month[i], 3) == 0)
			break;
	}

	if(i == size)
		return FALSE;

	t.tm_mon = i;

	CStringA strZone = szZone;

	int iZone	= 0;
	int iMix	= 0;
	int iPos	= strZone.Find('+');

	if(iPos >= 0)
		iMix = 1;
	else
	{
		iPos = strZone.Find('-');

		if(iPos >= 0)
			iMix = -1;
	}

	if(iPos >= 0)
	{
		strZone = strZone.Mid(iPos + 1);
		strZone.Remove(':');

		int val = atoi(strZone);

		if(val > 0)
		{
			int minutes	= val % 100;
			int hours	= val / 100;

			iZone = iMix * (minutes * 60 + hours * 3600);
		}
	}

	tmExpires = GetUTCTime(t, iZone);

	return tmExpires >= 0;
}
Esempio n. 4
0
bool UnIgnoreCommand::Execute()
{
	CString filelist;
	BOOL err = FALSE;
	for (int nPath = 0; nPath < pathList.GetCount(); ++nPath)
	{
		CString name = CPathUtils::PathPatternEscape(pathList[nPath].GetFileOrDirectoryName());
		if (parser.HasKey(L"onlymask"))
			name = L'*' + pathList[nPath].GetFileExtension();
		filelist += name + L'\n';
		CTSVNPath parentfolder = pathList[nPath].GetContainingDirectory();
		SVNProperties props(parentfolder, SVNRev::REV_WC, false);
		CStringA value;
		for (int i = 0; i < props.GetCount(); ++i)
		{
			CString propname(props.GetItemName(i).c_str());
			if (propname.CompareNoCase(L"svn:ignore") == 0)
			{
				//treat values as normal text even if they're not
				value = (char *)props.GetItemValue(i).c_str();
				break;
			}
		}
		value = value.Trim("\n\r");
		value += '\n';
		value.Remove('\r');
		value.Replace("\n\n", "\n");

		// Delete all occurrences of 'name'
		// "\n" is temporarily prepended to make the algorithm easier
		value = "\n" + value;
		value.Replace("\n" + CUnicodeUtils::GetUTF8(name) + "\n", "\n");
		value = value.Mid(1);

		CStringA sTrimmedvalue = value;
		sTrimmedvalue.Trim();
		if (sTrimmedvalue.IsEmpty())
		{
			if (!props.Remove(L"svn:ignore"))
			{
				CString temp;
				temp.Format(IDS_ERR_FAILEDUNIGNOREPROPERTY, (LPCTSTR)name);
				CMessageBox::Show(hwndExplorer, temp, L"TortoiseGit", MB_ICONERROR);
				err = TRUE;
				break;
			}
		}
		else
		{
			if (!props.Add(L"svn:ignore", (LPCSTR)value))
			{
				CString temp;
				temp.Format(IDS_ERR_FAILEDUNIGNOREPROPERTY, (LPCTSTR)name);
				CMessageBox::Show(hwndExplorer, temp, L"TortoiseGit", MB_ICONERROR);
				err = TRUE;
				break;
			}
		}
	}
	if (err == FALSE)
	{
		CString temp;
		temp.Format(IDS_PROC_UNIGNORESUCCESS, (LPCTSTR)filelist);
		CMessageBox::Show(hwndExplorer, temp, L"TortoiseGit", MB_ICONINFORMATION);
		return true;
	}
	return false;
}