diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/CMakeLists.txt | 43 | ||||
-rw-r--r-- | win/config.h.cmake | 15 | ||||
-rw-r--r-- | win/inspircd.rc.cmake | 10 | ||||
-rw-r--r-- | win/inspircd_win32wrapper.cpp | 13 | ||||
-rw-r--r-- | win/inspircd_win32wrapper.h | 35 | ||||
-rw-r--r-- | win/make_gnutls_cert.bat | 26 | ||||
-rw-r--r-- | win/modules/CMakeLists.txt | 2 |
7 files changed, 85 insertions, 59 deletions
diff --git a/win/CMakeLists.txt b/win/CMakeLists.txt index a9c58bcfc..b5812b0c2 100644 --- a/win/CMakeLists.txt +++ b/win/CMakeLists.txt @@ -2,16 +2,19 @@ cmake_minimum_required(VERSION 2.8) project(InspIRCd CXX) -set(CONF_PATH "conf" CACHE PATH "Configuration file path") -set(MODULE_PATH "modules" CACHE PATH "Module path") -set(DATA_PATH "data" CACHE PATH "Data path") -set(LOG_PATH "logs" CACHE PATH "Log file path") +set(CONFIG_DIR "conf" CACHE PATH "Configuration file path") +set(MODULE_DIR "modules" CACHE PATH "Module path") +set(DATA_DIR "data" CACHE PATH "Data path") +set(LOG_DIR "logs" CACHE PATH "Log file path") set(EXTRA_INCLUDES "" CACHE PATH "Extra include paths") set(EXTRA_LIBS "" CACHE PATH "Extra library paths") set(INSPIRCD_BASE "${CMAKE_CURRENT_SOURCE_DIR}/../") +set(SYSTEM_NAME_VERSION ${CMAKE_SYSTEM}) +set(SOCKETENGINE "select") + # Build with multiple processes set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") @@ -20,10 +23,9 @@ set(CMAKE_MODULE_PATH "${INSPIRCD_BASE}/win") # Grab version info from version.sh file(STRINGS "${INSPIRCD_BASE}/src/version.sh" VERSIONSH) -string(REGEX REPLACE ".*InspIRCd-([0-9]*).*" "\\1" MAJOR_VERSION "${VERSIONSH}") -string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.([0-9]*).*" "\\1" MINOR_VERSION "${VERSIONSH}") -string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.[0-9]*\\.([0-9]*).*" "\\1" PATCH_VERSION "${VERSIONSH}") -set(FULL_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") +string(REGEX REPLACE ".*InspIRCd-([0-9]*).*" "\\1" VERSION_MAJOR "${VERSIONSH}") +string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.([0-9]*).*" "\\1" VERSION_MINOR "${VERSIONSH}") +string(REGEX REPLACE ".*InspIRCd-[0-9]*\\.[0-9]*\\.([0-9]*).*" "\\1" VERSION_PATCH "${VERSIONSH}") if(MSVC) # Without /SAFESEH:NO old libraries compiled with VS 2010 or older won't link correctly to VS2012 (eg, extra module libs) @@ -59,7 +61,7 @@ if(MSVC) endif(MSVC) configure_file("${INSPIRCD_BASE}/win/inspircd.rc.cmake" "${INSPIRCD_BASE}/win/inspircd.rc") -configure_file("${INSPIRCD_BASE}/win/config.h.cmake" "${INSPIRCD_BASE}/win/config.h") +configure_file("${INSPIRCD_BASE}/make/template/config.h" "${INSPIRCD_BASE}/include/config.h") add_executable(inspircd ${INSPIRCD_SOURCES} "${INSPIRCD_BASE}/win/inspircd.rc") target_link_libraries(inspircd win32_memory) @@ -76,21 +78,26 @@ install(FILES ${EXTRA_DLLS} DESTINATION .) file(GLOB_RECURSE EXAMPLE_CONFIGS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/docs/conf/*.example") install(FILES ${EXAMPLE_CONFIGS} DESTINATION conf) +# Install nationalchars files +file(GLOB_RECURSE EXAMPLE_LOCALES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/locales/*") +install(FILES ${EXAMPLE_LOCALES} DESTINATION locales) + # Create an empty data and logs directory and install them -file(MAKE_DIRECTORY ${DATA_PATH}) -install(DIRECTORY ${DATA_PATH} DESTINATION .) -file(MAKE_DIRECTORY ${LOG_PATH}) -install(DIRECTORY ${LOG_PATH} DESTINATION .) +file(MAKE_DIRECTORY ${DATA_DIR}) +install(DIRECTORY ${DATA_DIR} DESTINATION .) +file(MAKE_DIRECTORY ${LOG_DIR}) +install(DIRECTORY ${LOG_DIR} DESTINATION .) if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") + set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".") # place runtime libraries next to InspIRCd binary include(InstallRequiredSystemLibraries) set(CPACK_PACKAGE_NAME "InspIRCd IRC Daemon") set(CPACK_PACKAGE_VENDOR "InspIRCd Development Team") - set(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION}) - set(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION}) - set(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}) - set(CPACK_PACKAGE_FILE_NAME "InspIRCd-${FULL_VERSION}") + set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) + set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) + set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH}) + set(CPACK_PACKAGE_FILE_NAME "InspIRCd-${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/../docs/COPYING") set(CPACK_GENERATOR "NSIS") @@ -101,7 +108,7 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") set(CPACK_NSIS_MUI_UNIICON "${INSPIRCD_BASE}/win\\\\inspircd.ico") set(CPACK_NSIS_INSTALLED_ICON_NAME "inspircd.exe") set(CPACK_NSIS_URL_INFO_ABOUT "http://www.inspircd.org/") - set(CPACK_NSIS_COMPRESSOR "/SOLID lzma") + set(CPACK_NSIS_COMPRESSOR "/SOLID zlib") include(CPack) endif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") diff --git a/win/config.h.cmake b/win/config.h.cmake deleted file mode 100644 index 3a34a706b..000000000 --- a/win/config.h.cmake +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once
-
-#define BRANCH "@MAJOR_VERSION@.@MINOR_VERSION@"
-#define VERSION "@FULL_VERSION@"
-#define REVISION "release"
-#define SYSTEM "@CMAKE_SYSTEM@"
-#define INSPIRCD_SOCKETENGINE_NAME "select"
-
-#define CONFIG_PATH "@CONF_PATH@"
-#define MOD_PATH "@MODULE_PATH@"
-#define DATA_PATH "@DATA_PATH@"
-#define LOG_PATH "@LOG_PATH@"
-
-#include "inspircd_win32wrapper.h"
-#include "threadengines/threadengine_win32.h"
diff --git a/win/inspircd.rc.cmake b/win/inspircd.rc.cmake index cd0adc580..06012b3f5 100644 --- a/win/inspircd.rc.cmake +++ b/win/inspircd.rc.cmake @@ -1,8 +1,8 @@ 101 ICON "inspircd.ico"
1 VERSIONINFO
- FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@
- PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@
+ FILEVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@
+ PRODUCTVERSION @VERSION_MAJOR@,@VERSION_MINOR@,@VERSION_PATCH@
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -17,14 +17,14 @@ BEGIN BEGIN
BLOCK "040904b0"
BEGIN
- VALUE "Comments", "InspIRCd @MAJOR_VERSION@.@MINOR_VERSION@ IRC Daemon"
+ VALUE "Comments", "InspIRCd @VERSION_MAJOR@.@VERSION_MINOR@ IRC Daemon"
VALUE "CompanyName", "InspIRCd Development Team"
VALUE "FileDescription", "InspIRCd"
VALUE "FileVersion", "@FULL_VERSION@"
VALUE "InternalName", "InspIRCd"
- VALUE "LegalCopyright", "Copyright (c) 2013 InspIRCd Development Team"
+ VALUE "LegalCopyright", "Copyright (c) 2015 InspIRCd Development Team"
VALUE "OriginalFilename", "inspircd.exe"
- VALUE "ProductName", "InspIRCd - The Inspire IRC Daemon"
+ VALUE "ProductName", "InspIRCd - Internet Relay Chat Daemon"
VALUE "ProductVersion", "@FULL_VERSION@"
END
END
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp index eba18dca3..3e0a264a5 100644 --- a/win/inspircd_win32wrapper.cpp +++ b/win/inspircd_win32wrapper.cpp @@ -39,8 +39,8 @@ CoreExport const char *insp_inet_ntop(int af, const void *src, char *dst, sockle memset(&in, 0, sizeof(in)); in.sin_family = AF_INET; memcpy(&in.sin_addr, src, sizeof(struct in_addr)); - getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST); - return dst; + if (getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in), dst, cnt, NULL, 0, NI_NUMERICHOST) == 0) + return dst; } else if (af == AF_INET6) { @@ -48,8 +48,8 @@ CoreExport const char *insp_inet_ntop(int af, const void *src, char *dst, sockle memset(&in, 0, sizeof(in)); in.sin6_family = AF_INET6; memcpy(&in.sin6_addr, src, sizeof(struct in_addr6)); - getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST); - return dst; + if (getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6), dst, cnt, NULL, 0, NI_NUMERICHOST) == 0) + return dst; } return NULL; } @@ -206,6 +206,11 @@ 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); + for (size_t i = 0; i < _countof(szErrorString); i++) + { + if ((szErrorString[i] == '\r') || (szErrorString[i] == '\n')) + szErrorString[i] = 0; + } } CWin32Exception::CWin32Exception(const CWin32Exception& other) diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h index 9e6724126..d65d4eb92 100644 --- a/win/inspircd_win32wrapper.h +++ b/win/inspircd_win32wrapper.h @@ -58,6 +58,7 @@ /* Disable the deprecation warnings.. it spams :P */ #define _CRT_SECURE_NO_DEPRECATE +#define _WINSOCK_DEPRECATED_NO_WARNINGS /* Normal windows (platform-specific) includes */ #include <winsock2.h> @@ -84,6 +85,8 @@ #define strcasecmp _stricmp #define strncasecmp _strnicmp +typedef int ssize_t; + /* Convert formatted (xxx.xxx.xxx.xxx) string to in_addr struct */ CoreExport int insp_inet_pton(int af, const char * src, void * dst); @@ -94,9 +97,11 @@ CoreExport const char * insp_inet_ntop(int af, const void * src, char * dst, soc #define inet_pton insp_inet_pton #define inet_ntop insp_inet_ntop -/* Safe printf functions aren't defined in VC++ */ +/* Safe printf functions aren't defined in VC++ releases older than v14 */ +#if _MSC_VER <= 1800 #define snprintf _snprintf #define vsnprintf _vsnprintf +#endif #ifndef va_copy #define va_copy(dest, src) (dest = src) @@ -147,11 +152,13 @@ struct DIR bool first; }; +#if _MSC_VER <= 1800 struct timespec { time_t tv_sec; long tv_nsec; }; +#endif CoreExport DIR * opendir(const char * path); CoreExport dirent * readdir(DIR * handle); @@ -197,8 +204,6 @@ CoreExport void closedir(DIR * handle); void * ::operator new(size_t iSize); void ::operator delete(void * ptr); -#define DISABLE_WRITEV - #include <exception> class CWin32Exception : public std::exception @@ -216,3 +221,27 @@ private: // Same value as EXIT_STATUS_FORK (EXIT_STATUS_FORK is unused on Windows) #define EXIT_STATUS_SERVICE 4 + +// POSIX iovec +struct iovec +{ + void* iov_base; // Starting address + size_t iov_len; // Number of bytes to transfer +}; + +// Windows WSABUF with POSIX field names +struct WindowsIOVec +{ + // POSIX iovec has iov_base then iov_len, WSABUF in Windows has the fields in reverse order + u_long iov_len; // Number of bytes to transfer + char FAR* iov_base; // Starting address +}; + +inline ssize_t writev(int fd, const WindowsIOVec* iov, int count) +{ + DWORD sent; + int ret = WSASend(fd, reinterpret_cast<LPWSABUF>(const_cast<WindowsIOVec*>(iov)), count, &sent, 0, NULL, NULL); + if (ret == 0) + return sent; + return -1; +} diff --git a/win/make_gnutls_cert.bat b/win/make_gnutls_cert.bat index 97792cc29..159cd1012 100644 --- a/win/make_gnutls_cert.bat +++ b/win/make_gnutls_cert.bat @@ -1,14 +1,14 @@ -@echo off
-
-echo This program will generate SSL certificates for m_ssl_gnutls.so
-echo Ensure certtool.exe is in your system path. It can be downloaded
-echo at ftp://ftp.gnu.org/gnu/gnutls/w32/. If you do not know the answer
-echo to one of the questions just press enter.
-echo.
-
-pause
-
-certtool --generate-privkey --outfile conf/key.pem
-certtool --generate-self-signed --load-privkey conf/key.pem --outfile conf/cert.pem
-
+@echo off + +echo This program will generate SSL certificates for m_ssl_gnutls.so +echo Ensure certtool.exe is in your system path. It can be downloaded +echo at ftp://ftp.gnu.org/gnu/gnutls/w32/. If you do not know the answer +echo to one of the questions just press enter. +echo. + +pause + +certtool --generate-privkey --outfile conf/key.pem +certtool --generate-self-signed --load-privkey conf/key.pem --outfile conf/cert.pem + pause
\ No newline at end of file diff --git a/win/modules/CMakeLists.txt b/win/modules/CMakeLists.txt index b3e59de61..2c2617e2b 100644 --- a/win/modules/CMakeLists.txt +++ b/win/modules/CMakeLists.txt @@ -38,5 +38,5 @@ foreach(MODULE_NAME ${INSPIRCD_MODULES}) )
# Set the module to be installed to the module directory
- install(TARGETS ${SO_NAME} DESTINATION modules)
+ install(TARGETS ${SO_NAME} DESTINATION ${MODULE_DIR})
endforeach(MODULE_NAME ${INSPIRCD_MODULES})
|