]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - win/inspircd_win32wrapper.cpp
Merge pull request #461 from SaberUK/master+header-cleanup
[user/henk/code/inspircd.git] / win / inspircd_win32wrapper.cpp
index 26d1548986b7745399c607f24fe8fb92ec7e0d61..7a07868f90907fe3f545901731163445e72d9dd1 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd_win32wrapper.h"
 #include "inspircd.h"
 #include "configreader.h"
-#include "colors.h"
 #include <string>
 #include <errno.h>
 #include <assert.h>
-#include <mmsystem.h>
-#pragma comment(lib, "Winmm.lib")
 
 CoreExport const char *insp_inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
 {
@@ -183,8 +181,30 @@ int getopt_long(int ___argc, char *const *___argv, const char *__shortopts, cons
        return 1;
 }
 
+CWin32Exception::CWin32Exception() : exception()
+{
+       dwErrorCode = GetLastError();
+       if( FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), NULL) == 0 )
+               sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode);
+}
+
+CWin32Exception::CWin32Exception(const CWin32Exception& other)
+{
+       strcpy_s(szErrorString, _countof(szErrorString), other.szErrorString);
+}
+
+const char* CWin32Exception::what() const throw()
+{
+       return szErrorString;
+}
+
+DWORD CWin32Exception::GetErrorCode()
+{
+       return dwErrorCode;
+}
+
 #include "../src/modules/m_spanningtree/link.h"
-#include "../src/modules/ssl.h"
+#include "modules/ssl.h"
 template class reference<Link>;
 template class reference<Autoconnect>;
 template class reference<ssl_cert>;