]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - win/inspircd_win32wrapper.cpp
Replace our Windows getopt_long wrapper with ya_getopt.
[user/henk/code/inspircd.git] / win / inspircd_win32wrapper.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2011 Adam <Adam@anope.org>
5  *   Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
6  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
7  *   Copyright (C) 2007-2009 Craig Edwards <craigedwards@brainbox.cc>
8  *   Copyright (C) 2008 John Brooks <john.brooks@dereferenced.net>
9  *   Copyright (C) 2007 Burlex <???@???>
10  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
11  *
12  * This file is part of InspIRCd.  InspIRCd is free software: you can
13  * redistribute it and/or modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation, version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
19  * details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24
25
26 #include "inspircd_win32wrapper.h"
27 #include "inspircd.h"
28 #include "configreader.h"
29 #include <string>
30 #include "ya_getopt.c"
31
32 CWin32Exception::CWin32Exception() : exception()
33 {
34         dwErrorCode = GetLastError();
35         if( FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), NULL) == 0 )
36                 sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode);
37         for (size_t i = 0; i < _countof(szErrorString); i++)
38         {
39                 if ((szErrorString[i] == '\r') || (szErrorString[i] == '\n'))
40                         szErrorString[i] = 0;
41         }
42 }
43
44 CWin32Exception::CWin32Exception(const CWin32Exception& other)
45 {
46         strcpy_s(szErrorString, _countof(szErrorString), other.szErrorString);
47 }
48
49 const char* CWin32Exception::what() const throw()
50 {
51         return szErrorString;
52 }
53
54 DWORD CWin32Exception::GetErrorCode()
55 {
56         return dwErrorCode;
57 }