Пример #1
0
void CVODFilesFormView::OnBtnPrevPathClicked()
{
	CString strNewPath;
	m_comboAddressBar.GetWindowText(strNewPath);
	
	if (strNewPath.GetLength())
	{
		KillSpelicalChar((LPSTR)(LPCSTR)strNewPath, '\\');
		int nPos = strNewPath.ReverseFind('\\');
		if(nPos != -1)
			strNewPath.SetAt(nPos, '\0');
		CString strRootPath = m_shellTree.GetRootPath();
		KillSpelicalChar((LPSTR)(LPCSTR)strRootPath, '\\');	
		if(StrFind((LPSTR)(LPCSTR)strNewPath, (LPSTR)(LPCSTR)strRootPath))
		{
			TCHAR sztmpPath[2048];
			_tcscpy(sztmpPath, (LPCSTR)strNewPath);
			_tcscat(sztmpPath, "\\");
			m_shellTree.TunnelTree(sztmpPath);
		}
	}
}
Пример #2
0
/**
desc:				在字符串中获取属性值

strSrc:				源字符串
strProfileName:		要获取的属性名
strProfileValue:	保存获取到的属性值

return:				成功,返回 TRUE;否则,返回 FALSE
*/
BOOL CommonStrMethod::StrGetProfileStr(CString strSrc, 
									   CString strProfileName, 
									   CString& strProfileValue,
									   WCHAR wchSplitNameValue, 
									   WCHAR wchSplitProfile)
{
	strProfileName.AppendFormat(_T("%c"), wchSplitNameValue);
	int nStartIndex = StrFind(strSrc, strProfileName);
	if(nStartIndex == -1)
	{
		strProfileValue = _T("");
		return FALSE;
	}
	nStartIndex += strProfileName.GetLength();
	int nEndIndex = strSrc.Find(wchSplitProfile, nStartIndex);
	if(nEndIndex == -1)
	{
		nEndIndex = strSrc.GetLength();
	}
	strProfileValue = strSrc.Mid(nStartIndex, nEndIndex-nStartIndex);
	return TRUE;
}
Пример #3
0
http_data * http_parse(cvm_common_wqe_t * swp, State status)
{
		http_data * http = (http_data *) cvmx_phys_to_ptr(cvm_common_alloc_fpa_buffer_sync(CVMX_FPA_PACKET_POOL));
		if(http == NULL)
				return http;
		memset(http, 0, sizeof(http_data));
		char * ptr = (char *)cvmx_phys_to_ptr(swp->hw_wqe.packet_ptr.s.addr);
		int res = -1;
		int pos = 54;

		//Client->Server
		if(swp->hw_wqe.ipprt < portbase + portnum)
		{
				if(StrFind(ptr+pos, 3, "GET") != -1 || StrFind(ptr+pos, 3, "PUT") != -1 || StrFind(ptr+pos, 4, "HTTP") != -1 || StrFind(ptr+pos, 4, "HEAD") != -1 || StrFind(ptr+pos, 6, "DELETE") != -1)
				{
					http->is_http = true;
				}
				return http;
				if(status == S0)
				{
						//16 is the length of "GET / HTTP/1.1\r\n"
						res = StrFind(ptr+pos, 16, "GET / HTTP/1.1\r\n");
						if(res == -1)
								return http;
						//printf("GET / HTTP/1.1	%d\n", res);
						pos += 16;

						//cut a line to find Auth
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "\r\n");
						//printf("/r/n  %d\n", res);
						if(res == -1)
								return http;
						pos += res+2;
						//Find Auth
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "\r\n");
						//printf("/r/n  %d\n", res);
						if(res == -1)
								return http;
						int i = 0;
						for(i=res-1;i>=0;i--)
						{
								if(ptr[pos+i] == ':')
								{
										break;
								}					
						}
						//19 is the length of "Authorization: AWS "
						//printf("%X,		%X,		%d\n", http->username, ptr, i);
						//printf("%d\n", swp->hw_wqe.len);
						res = StrFind(ptr+pos, 19, "Authorization: AWS ");
						if(i < 0 || res == -1)
						{
								//memset(http, 0, sizeof(http_data));
								return http;
						}
						else
						{
								memcpy(http->username, ptr+pos+19, i-19);									
								http->login = true;
								return http;
						}
				}
				else if(status == S2)
				{
						res = StrFind(ptr+pos, 3, "PUT");
						if(res == -1)
								return http;
						pos += 3;
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "HTTP/1.1\r\n");
						if(res == -1)
								return http;			
						pos += res + 10;
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "\r\n\r\n");
						http->put_content = true;
						if(res == -1)
								return http;
						pos += 4 + res;			
						if(swp->hw_wqe.len - pos > 0)
						{
								http->there_is_data = true;
								printf("swp->hw_wqe.len: %d  pos: %d\n",swp->hw_wqe.len ,pos);
								http->pos = pos;
						}
						return http;
				}
				/*
				else if(status != S3 && status != S4)
				{
						printf("Waring:Client->Server, State is %d\n", status);
				} 
				*/
		}
		//Server->Client
		else
		{
				res = StrFind(ptr+pos, 8, "HTTP/1.1");
				if(res != -1)
					http->is_http = true;
				else 
					return http;
				if(status == S1)
				{			
						//17 is the length of "HTTP/1.1 200 OK\r\n"		
						res = StrFind(ptr+pos, 17, "HTTP/1.1 200 OK\r\n");							
						if(res == -1)
								return http;
						http->login_done = true;
						return http;							
				}
				else if(status == S2)
				{
						//17 is the length of "HTTP/1.1 200 OK\r\n"
						res = StrFind(ptr+pos, 17, "HTTP/1.1 200 OK\r\n");
						if(res == -1)
								return http;
						pos += 17;

						//cut a line to find Auth
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "\r\n");
						if(res == -1)
								return http;
						pos += res+2;
						//Find Content-Length
						res = StrFind(ptr+pos, 16, "Content-Length: ");
						if(res == -1)
								return http;
						pos += 16;
						if(ptr[pos] == '0')
								return http;
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "\r\n");
						if(res == -1)
								return http;
						pos += res+2;
						res = StrFind(ptr+pos, 4, "Etag");
						if(res == -1)
								return http;			
						res = StrFind(ptr+pos, swp->hw_wqe.len-pos, "\r\n\r\n");
						http->get_content = true;
						if(res == -1)
								return http;
						pos += 4 + res;			
						if(swp->hw_wqe.len - pos > 0)
						{
								http->there_is_data = true;
								http->pos = pos;
						}
						return http;			
				}
				else if(status == S3)
				{
						//17 is the length of "HTTP/1.1 200 OK\r\n"
						res = StrFind(ptr+pos, 17, "HTTP/1.1 200 OK\r\n");
						if(res == -1)
								return http;
						http->put_done = true;
						return http;	
				}
				else if(status == S4)
				{
						//8 is the length of "HTTP/1.1"
						res = StrFind(ptr+pos, 8, "HTTP/1.1");
						if(res == -1)
								return http;
						http->get_done = true;
						return http;	
				}
				/*
				else if(status != S0)
				{
						printf("Waring:Server->Clinet, State is %d\n", status);	
				}
				*/
		}
		return http;
}