本文整理汇总了C++中CAtlList类的典型用法代码示例。如果您正苦于以下问题:C++ CAtlList类的具体用法?C++ CAtlList怎么用?C++ CAtlList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAtlList类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPath
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"));
//.........这里部分代码省略.........
示例2: m_pMainFrame
CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
: m_pMainFrame(pMainFrame)
, m_nPort(nPort)
{
if(m_internalpages.IsEmpty())
{
m_internalpages[_T("/")] = &CWebClientSocket::OnIndex;
m_internalpages[_T("/index.html")] = &CWebClientSocket::OnIndex;
m_internalpages[_T("/browser.html")] = &CWebClientSocket::OnBrowser;
m_internalpages[_T("/controls.html")] = &CWebClientSocket::OnControls;
m_internalpages[_T("/command.html")] = &CWebClientSocket::OnCommand;
m_internalpages[_T("/status.html")] = &CWebClientSocket::OnStatus;
m_internalpages[_T("/player.html")] = &CWebClientSocket::OnPlayer;
m_internalpages[_T("/snapshot.jpg")] = &CWebClientSocket::OnSnapShotJpeg;
m_internalpages[_T("/404.html")] = &CWebClientSocket::OnError404;
m_internalpages[_T("/convres.html")] = &CWebClientSocket::OnConvRes;
}
if(m_downloads.IsEmpty())
{
m_downloads[_T("/default.css")] = IDF_DEFAULT_CSS;
m_downloads[_T("/vbg.gif")] = IDF_VBR_GIF;
m_downloads[_T("/vbs.gif")] = IDF_VBS_GIF;
m_downloads[_T("/sliderbar.gif")] = IDF_SLIDERBAR_GIF;
m_downloads[_T("/slidergrip.gif")] = IDF_SLIDERGRIP_GIF;
m_downloads[_T("/sliderback.gif")] = IDF_SLIDERBACK_GIF;
m_downloads[_T("/1pix.gif")] = IDF_1PIX_GIF;
m_downloads[_T("/headericon.png")] = IDF_HEADERICON_PNG;
m_downloads[_T("/headerback.png")] = IDF_HEADERBACK_PNG;
m_downloads[_T("/headerclose.png")] = IDF_HEADERCLOSE_PNG;
m_downloads[_T("/leftside.png")] = IDF_LEFTSIDE_PNG;
m_downloads[_T("/rightside.png")] = IDF_RIGHTSIDE_PNG;
m_downloads[_T("/bottomside.png")] = IDF_BOTTOMSIDE_PNG;
m_downloads[_T("/leftbottomside.png")] = IDF_LEFTBOTTOMSIDE_PNG;
m_downloads[_T("/rightbottomside.png")] = IDF_RIGHTBOTTOMSIDE_PNG;
m_downloads[_T("/seekbarleft.png")] = IDF_SEEKBARLEFT_PNG;
m_downloads[_T("/seekbarmid.png")] = IDF_SEEKBARMID_PNG;
m_downloads[_T("/seekbarright.png")] = IDF_SEEKBARRIGHT_PNG;
m_downloads[_T("/seekbargrip.png")] = IDF_SEEKBARGRIP_PNG;
m_downloads[_T("/logo.png")] = IDF_LOGO7;
m_downloads[_T("/controlback.png")] = IDF_CONTROLBACK_PNG;
m_downloads[_T("/controlbuttonplay.png")] = IDF_CONTROLBUTTONPLAY_PNG;
m_downloads[_T("/controlbuttonpause.png")] = IDF_CONTROLBUTTONPAUSE_PNG;
m_downloads[_T("/controlbuttonstop.png")] = IDF_CONTROLBUTTONSTOP_PNG;
m_downloads[_T("/controlbuttonskipback.png")] = IDF_CONTROLBUTTONSKIPBACK_PNG;
m_downloads[_T("/controlbuttondecrate.png")] = IDF_CONTROLBUTTONDECRATE_PNG;
m_downloads[_T("/controlbuttonincrate.png")] = IDF_CONTROLBUTTONINCRATE_PNG;
m_downloads[_T("/controlbuttonskipforward.png")] = IDF_CONTROLBUTTONSKIPFORWARD_PNG;
m_downloads[_T("/controlbuttonstep.png")] = IDF_CONTROLBUTTONSTEP_PNG;
m_downloads[_T("/controlvolumeon.png")] = IDF_CONTROLVOLUMEON_PNG;
m_downloads[_T("/controlvolumeoff.png")] = IDF_CONTROLVOLUMEOFF_PNG;
m_downloads[_T("/controlvolumebar.png")] = IDF_CONTROLVOLUMEBAR_PNG;
m_downloads[_T("/controlvolumegrip.png")] = IDF_CONTROLVOLUMEGRIP_PNG;
}
CRegKey key;
CString str(_T("MIME\\Database\\Content Type"));
if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
{
TCHAR buff[256];
DWORD len = countof(buff);
for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++, len = countof(buff))
{
CRegKey mime;
TCHAR ext[64];
ULONG len = countof(ext);
if(ERROR_SUCCESS == mime.Open(HKEY_CLASSES_ROOT, str + _T("\\") + buff, KEY_READ)
&& ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len))
m_mimes[CStringA(ext).MakeLower()] = CStringA(buff).MakeLower();
}
}
m_mimes[".html"] = "text/html";
m_mimes[".txt"] = "text/plain";
m_mimes[".css"] = "text/css";
m_mimes[".gif"] = "image/gif";
m_mimes[".jpeg"] = "image/jpeg";
m_mimes[".jpg"] = "image/jpeg";
m_mimes[".png"] = "image/png";
GetModuleFileName(AfxGetInstanceHandle(), str.GetBuffer(MAX_PATH), MAX_PATH);
str.ReleaseBuffer();
m_webroot = CPath(str);
m_webroot.RemoveFileSpec();
CString WebRoot = AfxGetAppSettings().WebRoot;
WebRoot.Replace('/', '\\');
WebRoot.Trim();
CPath p(WebRoot);
if(WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) m_webroot.Append(WebRoot);
else m_webroot = p;
m_webroot.Canonicalize();
m_webroot.MakePretty();
if(!m_webroot.IsDirectory()) m_webroot = CPath();
CAtlList<CString> sl;
Explode(AfxGetAppSettings().WebServerCGI, sl, ';');
POSITION pos = sl.GetHeadPosition();
while(pos)
{
//.........这里部分代码省略.........
示例3: p
void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& body)
{
CPath p(pClient->m_path);
CStringA ext = p.GetExtension().MakeLower();
CStringA mime;
if(ext.IsEmpty()) mime = "text/html";
else m_mimes.Lookup(ext, mime);
hdr = "HTTP/1.0 200 OK\r\n";
bool fHandled = false, fCGI = false;
if(!fHandled && m_webroot.IsDirectory())
{
CStringA tmphdr;
fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime);
if(fHandled)
{
tmphdr.Replace("\r\n", "\n");
CAtlList<CStringA> hdrlines;
ExplodeMin(tmphdr, hdrlines, '\n');
POSITION pos = hdrlines.GetHeadPosition();
while(pos)
{
POSITION cur = pos;
CAtlList<CStringA> sl;
CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2);
if(sl.GetCount() < 2) continue;
key.Trim().MakeLower();
if(key == "content-type") {mime = sl.GetTail().Trim(); hdrlines.RemoveAt(cur);}
else if(key == "content-length") {hdrlines.RemoveAt(cur);}
}
tmphdr = Implode(hdrlines, '\n');
tmphdr.Replace("\n", "\r\n");
hdr += tmphdr + "\r\n";
}
}
RequestHandler rh = NULL;
if(!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime))
{
if(mime.IsEmpty()) mime = "text/html";
CString redir;
if(pClient->m_get.Lookup(_T("redir"), redir)
|| pClient->m_post.Lookup(_T("redir"), redir))
{
if(redir.IsEmpty()) redir = '/';
hdr =
"HTTP/1.0 302 Found\r\n"
"Location: " + CStringA(redir) + "\r\n";
return;
}
fHandled = true;
}
if(!fHandled && m_webroot.IsDirectory())
{
fHandled = LoadPage(0, body, pClient->m_path);
}
UINT resid;
CStringA res;
if(!fHandled && m_downloads.Lookup(pClient->m_path, resid) && LoadResource(resid, res, _T("FILE")))
{
if(mime.IsEmpty()) mime = "application/octet-stream";
memcpy(body.GetBufferSetLength(res.GetLength()), res.GetBuffer(), res.GetLength());
fHandled = true;
}
if(!fHandled)
{
hdr = mime == "text/html"
? "HTTP/1.0 301 Moved Permanently\r\n" "Location: /404.html\r\n"
: "HTTP/1.0 404 Not Found\r\n";
return;
}
if(mime == "text/html" && !fCGI)
{
hdr +=
"Expires: Thu, 19 Nov 1981 08:52:00 GMT\r\n"
"Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n"
"Pragma: no-cache\r\n";
CStringA debug;
if(AfxGetAppSettings().fWebServerPrintDebugInfo)
{
debug += "<hr>\r\n";
CString key, value;
POSITION pos;
pos = pClient->m_hdrlines.GetStartPosition();
while(pos) {pClient->m_hdrlines.GetNextAssoc(pos, key, value); debug += "HEADER[" + key + "] = " + value + "<br>\r\n";}
debug += "cmd: " + pClient->m_cmd + "<br>\r\n";
debug += "path: " + pClient->m_path + "<br>\r\n";
debug += "ver: " + pClient->m_ver + "<br>\r\n";
pos = pClient->m_get.GetStartPosition();
//.........这里部分代码省略.........
示例4: Parse
bool CSubtitleDlDlg::Parse()
{
// Parse raw list
isdb_movie m;
isdb_subtitle sub;
CAtlList<CStringA> sl;
Explode(m_pTA->raw_list, sl, '\n');
CString str;
POSITION pos = sl.GetHeadPosition();
while (pos) {
str = sl.GetNext(pos);
CStringA param = str.Left(max(0, str.Find('=')));
CStringA value = str.Mid(str.Find('=') + 1);
if (param == "ticket") {
m_pTA->ticket = value;
} else if (param == "movie") {
m.reset();
Explode(value, m.titles, '|');
} else if (param == "subtitle") {
sub.reset();
sub.id = atoi(value);
} else if (param == "name") {
sub.name = value;
} else if (param == "discs") {
sub.discs = atoi(value);
} else if (param == "disc_no") {
sub.disc_no = atoi(value);
} else if (param == "format") {
sub.format = value;
} else if (param == "iso639_2") {
sub.iso639_2 = value;
} else if (param == "language") {
sub.language = value;
} else if (param == "nick") {
sub.nick = value;
} else if (param == "email") {
sub.email = value;
} else if (param == "" && value == "endsubtitle") {
m.subs.AddTail(sub);
} else if (param == "" && value == "endmovie") {
m_pTA->raw_movies.AddTail(m);
} else if (param == "" && value == "end") {
break;
}
}
// Parse movies
pos = m_pTA->raw_movies.GetHeadPosition();
while (pos) {
isdb_movie& raw_movie = m_pTA->raw_movies.GetNext(pos);
isdb_movie_parsed p;
CStringA titlesA = Implode(raw_movie.titles, '|');
titlesA.Replace("|", ", ");
p.titles = UTF8To16(titlesA);
p.checked = false;
POSITION pos2 = raw_movie.subs.GetHeadPosition();
while (pos2) {
const isdb_subtitle& s = raw_movie.subs.GetNext(pos2);
p.name = UTF8To16(s.name);
p.language = s.language;
p.format = s.format;
p.disc.Format(_T("%d/%d"), s.disc_no, s.discs);
p.ptr = reinterpret_cast<DWORD_PTR>(&s);
m_parsed_movies.Add(p);
}
}
bool ret = true;
if (m_parsed_movies.GetCount() == 0) {
ret = false;
}
return ret;
}