]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - win/inspircd_win32wrapper.cpp
Fix problem where in certain cases a \0 would be sent out. Thx to network Hak5IRC...
[user/henk/code/inspircd.git] / win / inspircd_win32wrapper.cpp
index 017ed4808d2a7cd03dbb051c14fe0e18e0206f19..d2dcd7456fb6aa3d7901c81ea94a38a05fb1519c 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+\r
+ *       | Inspire Internet Relay Chat Daemon |\r
+ *       +------------------------------------+\r
+ *\r
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team\r
+ * See: http://www.inspircd.org/wiki/index.php/Credits\r
+ *\r
+ * This program is free but copyrighted software; see\r
+ *            the file COPYING for details.\r
+ *\r
+ * ---------------------------------------------------\r
+ */\r
+\r
 #include "inspircd_win32wrapper.h"\r
 #include "inspircd.h"\r
 #include <string>\r
@@ -9,7 +22,6 @@ using namespace std;
 #define INADDR_NONE 0xffffffff\r
 #endif\r
 \r
-\r
 HANDLE hIPCPipe;\r
 \r
 int inet_aton(const char *cp, struct in_addr *addr)\r
@@ -53,6 +65,13 @@ int inet_pton(int af, const char *src, void *dst)
        sockaddr_in sa;\r
        int len = sizeof(SOCKADDR);\r
        int rv = WSAStringToAddress((LPSTR)src, af, NULL, (LPSOCKADDR)&sa, &len);\r
+       if(rv >= 0)\r
+       {\r
+               if(WSAGetLastError() == 10022)                  // Invalid Argument\r
+                       rv = 0;\r
+               else\r
+                       rv = 1;\r
+       }\r
        memcpy(dst, &sa.sin_addr, sizeof(struct in_addr));\r
        return rv;\r
 }\r
@@ -438,3 +457,34 @@ std::string FindNameServerWin()
        return returnval;\r
 }\r
 \r
+\r
+void ClearConsole()\r
+{\r
+       COORD coordScreen = { 0, 0 };    /* here's where we'll home the cursor */\r
+       HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);\r
+       DWORD cCharsWritten;\r
+       CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */ \r
+       DWORD dwConSize;                 /* number of character cells in the current buffer */ \r
+\r
+       /* get the number of character cells in the current buffer */ \r
+\r
+       if (GetConsoleScreenBufferInfo( hConsole, &csbi ))\r
+       {\r
+               dwConSize = csbi.dwSize.X * csbi.dwSize.Y;\r
+               /* fill the entire screen with blanks */ \r
+               if (FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten ))\r
+               {\r
+                       /* get the current text attribute */ \r
+                       if (GetConsoleScreenBufferInfo( hConsole, &csbi ))\r
+                       {\r
+                               /* now set the buffer's attributes accordingly */\r
+                               if (FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten ))\r
+                               {\r
+                                       /* put the cursor at (0, 0) */\r
+                                       SetConsoleCursorPosition( hConsole, coordScreen );\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+       return;\r
+}\r