summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-07-15 22:55:02 -0400
committerAdam <Adam@anope.org>2010-07-15 22:55:02 -0400
commita22f8d3b2de88b9bb6f80f0c2780846ae23ab389 (patch)
treea2fdf570868896a787df8a1169951b0028e68d6b /src/win32
parent43b1e43afb85639485e36d24da351dc0f121be6e (diff)
Moved some files and diretories around, made cmake skip files it knows it can't compile because of missing dependices.
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/anope-icon.icobin0 -> 3774 bytes
-rw-r--r--src/win32/anope.bat3
-rw-r--r--src/win32/vsvars32.bat66
-rw-r--r--src/win32/win32.rc.cmake92
-rw-r--r--src/win32/win32_memory.cpp64
-rw-r--r--src/win32/windows.cpp106
6 files changed, 331 insertions, 0 deletions
diff --git a/src/win32/anope-icon.ico b/src/win32/anope-icon.ico
new file mode 100644
index 000000000..be735614a
--- /dev/null
+++ b/src/win32/anope-icon.ico
Binary files differ
diff --git a/src/win32/anope.bat b/src/win32/anope.bat
new file mode 100644
index 000000000..20cebfa9c
--- /dev/null
+++ b/src/win32/anope.bat
@@ -0,0 +1,3 @@
+@ECHO OFF
+anope.exe %1 %2 %3 %4 %5
+pause \ No newline at end of file
diff --git a/src/win32/vsvars32.bat b/src/win32/vsvars32.bat
new file mode 100644
index 000000000..f1aee215e
--- /dev/null
+++ b/src/win32/vsvars32.bat
@@ -0,0 +1,66 @@
+@SET VSINSTALLDIR=C:\Program Files\Microsoft Visual Studio 8
+@SET VCINSTALLDIR=%VSINSTALLDIR%\VC
+@SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
+@SET FrameworkVersion=v2.0.50727
+@SET FrameworkSDKDir=%VSINSTALLDIR%\SDK\v2.0
+@SET Framework35Version=v3.5
+@if "%VSINSTALLDIR%"=="" goto error_no_VSINSTALLDIR
+@if "%VCINSTALLDIR%"=="" goto error_no_VCINSTALLDIR
+
+@echo Setting environment for using Microsoft Visual Studio 2005 x86 tools.
+
+@call :GetWindowsSdkDir
+
+@if not "%WindowsSdkDir%" == "" (
+ set "PATH=%WindowsSdkDir%bin;%PATH%"
+ set "INCLUDE=%WindowsSdkDir%include;%INCLUDE%"
+ set "LIB=%WindowsSdkDir%lib;%LIB%"
+)
+
+@rem
+@rem Root of Visual Studio IDE installed files.
+@rem
+@set DevEnvDir=%VSINSTALLDIR%\Common7\IDE
+
+@set PATH=%VSINSTALLDIR%\Common7\IDE;%VCINSTALLDIR%\BIN;%VSINSTALLDIR%\Common7\Tools;C:\WINDOWS\Microsoft.NET\Framework\v3.5;%VSINSTALLDIR%\SDK\v2.0\bin;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;%VCINSTALLDIR%\VCPackages;%PATH%
+@set INCLUDE=%VCINSTALLDIR%\INCLUDE;%INCLUDE%
+@set LIB=%VCINSTALLDIR%\LIB;%VSINSTALLDIR%\SDK\v2.0\lib;%LIB%
+@set LIBPATH=C:\WINDOWS\Microsoft.NET\Framework\v3.5;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;%VCINSTALLDIR%\LIB;%LIBPATH%
+
+@goto end
+
+:GetWindowsSdkDir
+@call :GetWindowsSdk2008DirHelper HKLM > nul 2>&1
+@if errorlevel 1 call :GetWindowsSdk2003DirHelper HKLM > nul 2>&1
+@if errorlevel 1 call :GetWindowsSdk2008DirHelper HKCU > nul 2>&1
+@if errorlevel 1 call :GetWindowsSdk2003DirHelper HKCU > nul 2>&1
+@if errorlevel 1 set WindowsSdkDir=%VCINSTALLDIR%\PlatformSDK\
+@exit /B 0
+
+:GetWindowsSdk2008DirHelper
+@for /F "tokens=1,2*" %%i in ('reg query "%1\SOFTWARE\Microsoft\Microsoft SDKs\Windows" /v "CurrentInstallFolder"') DO (
+ if "%%i"=="CurrentInstallFolder" (
+ SET "WindowsSdkDir=%%k"
+ )
+)
+@if "%WindowsSdkDir%"=="" exit /B 1
+@exit /B 0
+
+:GetWindowsSdk2003DirHelper
+@for /F "tokens=1,2,3*" %%i in ('reg query "%1\SOFTWARE\Microsoft\MicrosoftSDK\InstalledSDKs\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1" /v "Install Dir"') DO (
+ if "%%i %%j"=="Install Dir" (
+ SET "WindowsSdkDir=%%l"
+ )
+)
+@if "%WindowsSdkDir%"=="" exit /B 1
+@exit /B 0
+
+:error_no_VSINSTALLDIR
+@echo ERROR: VSINSTALLDIR variable is not set.
+@goto end
+
+:error_no_VCINSTALLDIR
+@echo ERROR: VCINSTALLDIR variable is not set.
+@goto end
+
+:end
diff --git a/src/win32/win32.rc.cmake b/src/win32/win32.rc.cmake
new file mode 100644
index 000000000..e8434109f
--- /dev/null
+++ b/src/win32/win32.rc.cmake
@@ -0,0 +1,92 @@
+///Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include <windows.h>
+#undef APSTUDIO_HIDDEN_SYMBOLS
+#include "resource.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifndef _MAC
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VER_ANOPE VERSIONINFO
+ FILEVERSION @VERSION_COMMA@
+ PRODUCTVERSION @VERSION_COMMA@
+#ifndef MINGW
+ FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+#endif
+#ifdef _DEBUG
+ FILEFLAGS VS_FF_DEBUG
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS VOS_NT
+ FILETYPE VFT_APP
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Anope Team"
+ VALUE "FileDescription", "Anope IRC Services"
+ VALUE "FileVersion", "@VERSION_FULL@"
+ VALUE "InternalName", "Anope"
+ VALUE "LegalCopyright", "Copyright (C) 2003-2010 Anope Team"
+ VALUE "OriginalFilename", "anope.exe"
+ VALUE "ProductName", "Anope"
+ VALUE "ProductVersion", "@VERSION_DOTTED@"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+ICON_APP ICON "@Anope_SOURCE_DIR@/src/win32/anope-icon.ico"
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/src/win32/win32_memory.cpp b/src/win32/win32_memory.cpp
new file mode 100644
index 000000000..903be83e6
--- /dev/null
+++ b/src/win32/win32_memory.cpp
@@ -0,0 +1,64 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#ifdef _WIN32
+
+#include <windows.h>
+#include <exception>
+#include <new>
+#include <new.h>
+
+/** On windows, all dll files and executables have their own private heap,
+ * whereas on POSIX systems, shared objects loaded into an executable share
+ * the executable's heap. This means that if we pass an arbitrary pointer to
+ * a windows DLL which is not allocated in that dll, without some form of
+ * marshalling, we get a page fault. To fix this, these overrided operators
+ * new and delete use the windows HeapAlloc and HeapFree functions to claim
+ * memory from the windows global heap. This makes windows 'act like' POSIX
+ * when it comes to memory usage between dlls and exes.
+ */
+
+void *::operator new(size_t iSize)
+{
+ void *ptr = HeapAlloc(GetProcessHeap(), 0, iSize); /* zero memory for unix compatibility */
+ /* This is the correct behaviour according to C++ standards for out of memory,
+ * not returning null -- Brain
+ */
+ if (!ptr)
+ throw std::bad_alloc();
+ else
+ return ptr;
+}
+
+void ::operator delete(void *ptr)
+{
+ if (ptr)
+ HeapFree(GetProcessHeap(), 0, ptr);
+}
+
+void *operator new[](size_t iSize)
+{
+ void *ptr = HeapAlloc(GetProcessHeap(), 0, iSize); /* Why were we initializing the memory to zeros here? This is just a waste of cpu! */
+ if (!ptr)
+ throw std::bad_alloc();
+ else
+ return ptr;
+}
+
+void operator delete[](void *ptr)
+{
+ if (ptr)
+ HeapFree(GetProcessHeap(), 0, ptr);
+}
+
+#endif
diff --git a/src/win32/windows.cpp b/src/win32/windows.cpp
new file mode 100644
index 000000000..6568e860e
--- /dev/null
+++ b/src/win32/windows.cpp
@@ -0,0 +1,106 @@
+ /* POSIX emulation layer for Windows.
+ *
+ * Copyright (C) 2008 Robin Burchell <w00t@inspircd.org>
+ * Copyright (C) 2008 Anope Team <info@anope.org>
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ */
+
+#ifdef WIN32
+#include "services.h"
+
+const char *dlerror()
+{
+ static char errbuf[513];
+ DWORD err = GetLastError();
+ if (!err)
+ return NULL;
+ FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, errbuf, 512, NULL);
+ return errbuf;
+}
+
+/** This is inet_pton, but it works on Windows
+ * @param af The protocol type, AF_INET or AF_INET6
+ * @param src The address
+ * @param dst Struct to put results in
+ * @return 1 on sucess, -1 on error
+ */
+int inet_pton(int af, const char *src, void *dst)
+{
+ int address_length;
+ sockaddr_storage sa;
+ sockaddr_in *sin = reinterpret_cast<sockaddr_in *>(&sa);
+ sockaddr_in6 *sin6 = reinterpret_cast<sockaddr_in6 *>(&sa);
+
+ switch (af)
+ {
+ case AF_INET:
+ address_length = sizeof(sockaddr_in);
+ break;
+ case AF_INET6:
+ address_length = sizeof(sockaddr_in6);
+ break;
+ default:
+ return -1;
+ }
+
+ if (!WSAStringToAddress((LPSTR) src, af, NULL, reinterpret_cast<LPSOCKADDR>(&sa), &address_length))
+ {
+ switch (af)
+ {
+ case AF_INET:
+ memcpy(dst, &sin->sin_addr, sizeof(in_addr));
+ break;
+ case AF_INET6:
+ memcpy(dst, &sin6->sin6_addr, sizeof(in6_addr));
+ break;
+ }
+ return 1;
+ }
+
+ return 0;
+}
+
+/** This is inet_ntop, but it works on Windows
+ * @param af The protocol type, AF_INET or AF_INET6
+ * @param src Network address structure
+ * @param dst After converting put it here
+ * @param size sizeof the dest
+ * @return dst
+ */
+const char *inet_ntop(int af, const void *src, char *dst, size_t size)
+{
+ int address_length;
+ DWORD string_length = size;
+ sockaddr_storage sa;
+ sockaddr_in *sin = reinterpret_cast<sockaddr_in *>(&sa);
+ sockaddr_in6 *sin6 = reinterpret_cast<sockaddr_in6 *>(&sa);
+
+ memset(&sa, 0, sizeof(sa));
+
+ switch (af)
+ {
+ case AF_INET:
+ address_length = sizeof(sockaddr_in);
+ sin->sin_family = af;
+ memcpy(&sin->sin_addr, src, sizeof(in_addr));
+ break;
+ case AF_INET6:
+ address_length = sizeof(sockaddr_in6);
+ sin6->sin6_family = af;
+ memcpy(&sin6->sin6_addr, src, sizeof(in6_addr));
+ break;
+ default:
+ return NULL;
+ }
+
+ if (!WSAAddressToString(reinterpret_cast<LPSOCKADDR>(&sa), address_length, NULL, dst, &string_length))
+ return dst;
+
+ return NULL;
+}
+
+#endif