Compiling Yahoo Pop in VS2005
YPOPs emulates a POP3/SMTP server running on localhost, providing POP3 access to Yahoo Mail users who do not have a premium account. The source code of YahooPop downloaded here was created using Visual Studio 6. Some modifications are required to compile the code under VS2005.
1. Additional packages must be downloaded. Notice that you must downloaded the correct version which was originally used.
- MimePP
- OpenSSL headers and pre-compiled LIB files. The download links are from a third-party website as the OpenSSL source code from official website was not developed in VS and takes some efforts to make it compile under VS.
- Curl headers and pre-compiled libcurl_imp.lib. Although Curl has several LIB files, YPops source code only uses libcurl_imp.lib.
- Re-Lib: regular expression Library in C++ (included in source code package)
2. Compiling process:
- Load the project under VS2005 and choose to upgrade from VS6 to VS2005 project
- Choose to build the project. There are initially some errors about missing include files and/or linker errors. Fixing these errors should be obvious; most of the time it’s just about some hard-coded include paths which are no longer valid, or some .LIB files which are different between VS6 and VS2005.
- The not-so-obvious errors which must be fixed are listed below:
Error 1: String conversion
//Original: WORD wszWideString[MAX_PATH];
//Change to:
LPWSTR wszWideString = new wchar_t[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, lpszDestination, -1, wszWideString, MAX_PATH);
Error 2: MessageMap incompatibilities, see http://blog.voidnish.com/?p=91
BEGIN_MESSAGE_MAP(CHyperLink, CStatic)
//{{AFX_MSG_MAP(CHyperLink)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_SETCURSOR()
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
ON_WM_SETFOCUS()
ON_WM_KILLFOCUS()
ON_WM_KEYDOWN()
//ON_WM_NCHITTEST() //commented out
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
Error 3: Constant char pointer and normal char pointer
//Original: char *ptr = strstr(str, startstr)
//Change to:
const char *ptr = strstr(str, startstr);
Error 4: VS6 function prototype doesn’t require return type, but VS2005 does
//Original: Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth = FALSE);
BOOL Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth = FALSE);
- Tell the linker to link using correct library files (.lib) for OpenSSL, Curl and MimePP. For MimePP, download the makefile from its website and compile it using nmake:
nmake /F makefile-vc
- Copy extra DLL libraries for OpenSSL, curl, mimepp to the same directory as the executable output and choose to Start debugging.
- Upon startup, there will be runtime error.
Access violation (WebBrowser.cpp) at line 2388. Stack around variable ‘wdir’ was corrupted.
Reasons: Attempt to modify an uninitialized array:
Luckily, this is easily to fix:
//Original: char wdir[_MAX_PATH];
//fixed:
char *wdir = new char[_MAX_PATH];
//code that follows (not modified)
if (getcwd(wdir, _MAX_PATH – 1) != NULL)
{
wdir[_MAX_PATH] = ‘?';
logdir = CStringEx(wdir);
}