diff --git a/Source/include/slikenet/linux_adapter.h b/Source/include/slikenet/linux_adapter.h index 32cf34141..b8a228f2d 100644 --- a/Source/include/slikenet/linux_adapter.h +++ b/Source/include/slikenet/linux_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, SLikeSoft UG (haftungsbeschränkt) + * Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code is licensed under the MIT-style license found in the * license.txt file in the root directory of this source tree. @@ -24,6 +24,7 @@ errno_t mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, con int sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...); errno_t strcat_s(char *strDestination, size_t numberOfElements, const char *strSource); errno_t strcpy_s(char* strDestination, size_t numberOfElements, const char *strSource); +errno_t strerror_s(char* buffer, size_t numberOfElements, int errnum); errno_t strncat_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count); errno_t strncpy_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count); int vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr); @@ -56,6 +57,11 @@ template errno_t strcpy_s(char (&strDestination)[BufferSize], return strcpy_s(strDestination, BufferSize, strSource); } +template errno_t strerror_s(char(&buffer)[BufferSize], int errnum) +{ + return strerror_s(buffer, BufferSize, errnum); +} + template errno_t strncat_s(char(&strDest)[BufferSize], const char *strSource, size_t count) { return strncat_s(strDest, BufferSize, strSource, count); diff --git a/Source/include/slikenet/osx_adapter.h b/Source/include/slikenet/osx_adapter.h index 7830f9af6..ebaafea2b 100644 --- a/Source/include/slikenet/osx_adapter.h +++ b/Source/include/slikenet/osx_adapter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, SLikeSoft UG (haftungsbeschränkt) + * Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code is licensed under the MIT-style license found in the * license.txt file in the root directory of this source tree. @@ -24,6 +24,7 @@ errno_t mbstowcs_s(size_t *pReturnValue, wchar_t *wcstr, size_t sizeInWords, con int sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...); errno_t strcat_s(char *strDestination, size_t numberOfElements, const char *strSource); errno_t strcpy_s(char* strDestination, size_t numberOfElements, const char *strSource); +errno_t strerror_s(char* buffer, size_t numberOfElements, int errnum); errno_t strncat_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count); errno_t strncpy_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count); int vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr); @@ -56,12 +57,17 @@ template errno_t strcpy_s(char (&strDestination)[BufferSize], return strcpy_s(strDestination, BufferSize, strSource); } -template errno_t strncat_s(char(&strDest)[BufferSize], const char *strSource, size_t count) +template errno_t strerror_s(char(&buffer)[BufferSize], int errnum) +{ + return strerror_s(buffer, BufferSize, errnum); +} + +template errno_t strncat_s(char (&strDest)[BufferSize], const char *strSource, size_t count) { return strncat_s(strDest, BufferSize, strSource, count); } -template errno_t strncpy_s(char(&strDest)[BufferSize], const char *strSource, size_t count) +template errno_t strncpy_s(char (&strDest)[BufferSize], const char *strSource, size_t count) { return strncpy_s(strDest, BufferSize, strSource, count); } diff --git a/Source/src/linux_adapter.cpp b/Source/src/linux_adapter.cpp index f137137e5..fe25abe96 100644 --- a/Source/src/linux_adapter.cpp +++ b/Source/src/linux_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt) + * Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code is licensed under the MIT-style license found in the * license.txt file in the root directory of this source tree. @@ -15,7 +15,7 @@ #include // for errno #include // for FILE, fopen, vsnprintf #include // for mbstowcs -#include // for strcat, strcpy, strncat, strncpy +#include // for strcat, strcpy, strerror, strncat, strncpy #include // for va_start, va_end, va_list #include // for localtime, time_t #include // for wcscat, wcscpy, wcslen @@ -171,6 +171,17 @@ errno_t strcpy_s(char* strDestination, size_t numberOfElements, const char *strS return 0; } +errno_t strerror_s(char* buffer, size_t numberOfElements, int errnum) +{ + // check valid parameters + if ((buffer == nullptr) || (numberOfElements == 0)) { + return 22; // error: EINVAL + } + + const char *errorMessage = strerror(errnum); + return strcpy_s(buffer, numberOfElements, errorMessage); +} + errno_t strncat_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count) { // check valid parameters diff --git a/Source/src/osx_adapter.cpp b/Source/src/osx_adapter.cpp index d72173024..f3a4a2827 100644 --- a/Source/src/osx_adapter.cpp +++ b/Source/src/osx_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, SLikeSoft UG (haftungsbeschränkt) + * Copyright (c) 2016-2019, SLikeSoft UG (haftungsbeschränkt) * * This source code is licensed under the MIT-style license found in the * license.txt file in the root directory of this source tree. @@ -15,7 +15,7 @@ #include // for errno #include // for FILE, fopen, vsnprintf #include // for mbstowcs -#include // for strcat, strcpy, strncat, strncpy +#include // for strcat, strcpy, strerror, strncat, strncpy #include // for va_start, va_end, va_list #include // for localtime, time_t #include // for wcscat, wcscpy, wcslen @@ -171,6 +171,17 @@ errno_t strcpy_s(char* strDestination, size_t numberOfElements, const char *strS return 0; } +errno_t strerror_s(char* buffer, size_t numberOfElements, int errnum) +{ + // check valid parameters + if ((buffer == nullptr) || (numberOfElements == 0)) { + return 22; // error: EINVAL + } + + const char *errorMessage = strerror(errnum); + return strcpy_s(buffer, numberOfElements, errorMessage); +} + errno_t strncat_s(char *strDest, size_t numberOfElements, const char *strSource, size_t count) { // check valid parameters diff --git a/changelog.txt b/changelog.txt index 9085afdee..f0ed7bffc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -111,6 +111,7 @@ Core: Building: General: * fixed compile errors when enabling IPv6 on Linux/OSX (#220) + * fixed compile error when enabling OPENSSL on Linux/OSX (#273) CrashReporter: * fixed compile error when compiling in RAKNET_COMPATIBILITY mode (#223) Lobby2: diff --git a/readme.txt b/readme.txt index 48ebbc379..d0dcaec74 100644 --- a/readme.txt +++ b/readme.txt @@ -1135,7 +1135,7 @@ Lib/prebuild/VS_xxxx/SLikeNet_DLL_[configuration]_[core|ext]_[platform].dll to the directory where the C# executable will be built to and rename it to SLikeNet.dll. On Linux you are required to build a shared library yourself since SLikeNet -isn't shipped with prebuilds for Linux. Simply follow the steps under 3.7.3.2 +doesn't ship with prebuilds for Linux. Simply follow the steps under 3.7.3.2 which will take care about building such library and put it into an appropriate directory.