本文整理匯總了C++中CAtlList::AddTail方法的典型用法代碼示例。如果您正苦於以下問題:C++ CAtlList::AddTail方法的具體用法?C++ CAtlList::AddTail怎麽用?C++ CAtlList::AddTail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CAtlList
的用法示例。
在下文中一共展示了CAtlList::AddTail方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CallCGI
bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& body, CStringA& mime)
{
CString path = pClient->m_path, redir = path;
if(!ToLocalPath(path, redir)) return false;
CString ext = CPath(path).GetExtension().MakeLower();
CPath dir(path);
dir.RemoveFileSpec();
CString cgi;
if(!m_cgi.Lookup(ext, cgi) || !CPath(cgi).FileExists())
return false;
HANDLE hProcess = GetCurrentProcess();
HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup = NULL;
HANDLE hChildStdoutRd, hChildStdoutWr, hChildStdoutRdDup = NULL;
SECURITY_ATTRIBUTES saAttr;
ZeroMemory(&saAttr, sizeof(saAttr));
saAttr.nLength = sizeof(saAttr);
saAttr.bInheritHandle = TRUE;
if(CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
{
BOOL fSuccess = DuplicateHandle(hProcess, hChildStdoutRd, hProcess, &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
CloseHandle(hChildStdoutRd);
}
if(CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
{
BOOL fSuccess = DuplicateHandle(hProcess, hChildStdinWr, hProcess, &hChildStdinWrDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
CloseHandle(hChildStdinWr);
}
STARTUPINFO siStartInfo;
ZeroMemory(&siStartInfo, sizeof(siStartInfo));
siStartInfo.cb = sizeof(siStartInfo);
siStartInfo.hStdError = hChildStdoutWr;
siStartInfo.hStdOutput = hChildStdoutWr;
siStartInfo.hStdInput = hChildStdinRd;
siStartInfo.dwFlags |= STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
siStartInfo.wShowWindow = SW_HIDE;
PROCESS_INFORMATION piProcInfo;
ZeroMemory(&piProcInfo, sizeof(piProcInfo));
CStringA envstr;
if(LPVOID lpvEnv = GetEnvironmentStrings())
{
CString str;
CAtlList<CString> env;
for(LPTSTR lpszVariable = (LPTSTR)lpvEnv; *lpszVariable; lpszVariable += _tcslen(lpszVariable)+1)
if(lpszVariable != (LPTSTR)lpvEnv)
env.AddTail(lpszVariable);
env.AddTail(_T("GATEWAY_INTERFACE=CGI/1.1"));
env.AddTail(_T("SERVER_SOFTWARE=Media Player Classic/6.4.x.y"));
env.AddTail(_T("SERVER_PROTOCOL=") + pClient->m_ver);
env.AddTail(_T("REQUEST_METHOD=") + pClient->m_cmd);
env.AddTail(_T("PATH_INFO=") + redir);
env.AddTail(_T("PATH_TRANSLATED=") + path);
env.AddTail(_T("SCRIPT_NAME=") + redir);
env.AddTail(_T("QUERY_STRING=") + pClient->m_query);
if(pClient->m_hdrlines.Lookup(_T("content-type"), str))
env.AddTail(_T("CONTENT_TYPE=") + str);
if(pClient->m_hdrlines.Lookup(_T("content-length"), str))
env.AddTail(_T("CONTENT_LENGTH=") + str);
POSITION pos = pClient->m_hdrlines.GetStartPosition();
while(pos)
{
CString key = pClient->m_hdrlines.GetKeyAt(pos);
CString value = pClient->m_hdrlines.GetNextValue(pos);
key.Replace(_T("-"), _T("_"));
key.MakeUpper();
env.AddTail(_T("HTTP_") + key + _T("=") + value);
}
CString name;
UINT port;
if(pClient->GetPeerName(name, port))
{
str.Format(_T("%d"), port);
env.AddTail(_T("REMOTE_ADDR=")+name);
env.AddTail(_T("REMOTE_HOST=")+name);
env.AddTail(_T("REMOTE_PORT=")+str);
}
if(pClient->GetSockName(name, port))
{
str.Format(_T("%d"), port);
env.AddTail(_T("SERVER_NAME=")+name);
env.AddTail(_T("SERVER_PORT=")+str);
}
env.AddTail(_T("\0"));
//.........這裏部分代碼省略.........