6 #define UTF8(str) UTF16To8(TToW(str))
7 #define UTF8Arg(str) UrlEncode(UTF8(str))
9 #define CMD_SETPOS "-1"
10 #define CMD_SETVOLUME "-2"
13 class CWebServerSocket
;
14 class CWebClientSocket
;
19 CMainFrame
* m_pMainFrame
;
23 static DWORD WINAPI
StaticThreadProc(LPVOID lpParam
);
27 CAutoPtrList
<CWebClientSocket
> m_clients
;
29 typedef bool (CWebClientSocket::*RequestHandler
)(CStringA
& hdr
, CStringA
& body
, CStringA
& mime
);
30 static CAtlStringMap
<RequestHandler
> m_internalpages
;
31 static CAtlStringMap
<UINT
> m_downloads
;
32 static CAtlStringMap
<CStringA
, CStringA
> m_mimes
;
35 CAtlStringMap
<> m_cgi
;
36 bool CallCGI(CWebClientSocket
* pClient
, CStringA
& hdr
, CStringA
& body
, CStringA
& mime
);
39 CWebServer(CMainFrame
* pMainFrame
, int nPort
= 13579);
40 virtual ~CWebServer();
42 static void Deploy(CString dir
);
44 bool ToLocalPath(CString
& path
, CString
& redir
);
45 bool LoadPage(UINT resid
, CStringA
& str
, CString path
= _T(""));
47 void OnAccept(CWebServerSocket
* pServer
);
48 void OnClose(CWebClientSocket
* pClient
);
49 void OnRequest(CWebClientSocket
* pClient
, CStringA
& reshdr
, CStringA
& resbody
);