From 7e287f591380d57626dc50bb2617fb0f6afe4dac Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 13 Feb 2021 21:52:15 +0100 Subject: [PATCH 1/2] Create log file if it does not exist already. --- src/rinetd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rinetd.c b/src/rinetd.c index cbe1bff..e613823 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -1,6 +1,6 @@ /* Copyright © 1997—1999 Thomas Boutell and Boutell.Com, Inc. - © 2003—2019 Sam Hocevar + © 2003—2021 Sam Hocevar This software is released for free use under the terms of the GNU Public License, version 2 or higher. NO WARRANTY @@ -238,7 +238,7 @@ static void readConfiguration(char const *file) { logFile = NULL; } if (logFileName) { - logFile = fopen(logFileName, "a"); + logFile = fopen(logFileName, "a+"); if (logFile) { setvbuf(logFile, NULL, _IONBF, 0); } else { From 5a70f2bf4e78ee63ba75de6cdfae5f3f9d810c95 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 13 Feb 2021 23:02:03 +0100 Subject: [PATCH 2/2] Allow to build application with Visual Studio. --- .gitignore | 5 +++ configure.ac | 2 + rinetd.vcxproj | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ src/net.h | 8 +++- src/rinetd.c | 11 ++++- 5 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 rinetd.vcxproj diff --git a/.gitignore b/.gitignore index 2f7f075..0b61f76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .auto .deps +.dirstamp Makefile Makefile.in stamp-* @@ -13,4 +14,8 @@ configure *.o rinetd +rinetd.exe +*.vcxproj.user +Debug +Release diff --git a/configure.ac b/configure.ac index bb95e21..c006b7a 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,8 @@ AC_CHECK_HEADERS([arpa/inet.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h stri AC_C_CONST AC_HEADER_TIME AC_STRUCT_TM +AC_CHECK_TYPES(ssize_t, [], [], + [#include ]) AC_CHECK_TYPES(socklen_t, [], [], [#include #include ]) diff --git a/rinetd.vcxproj b/rinetd.vcxproj new file mode 100644 index 0000000..2bca0e6 --- /dev/null +++ b/rinetd.vcxproj @@ -0,0 +1,107 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + 15.0 + {3F1D9D58-3205-48E9-9C93-557291A45D74} + Win32Proj + rinetd + 10.0 + + + + Application + v142 + Unicode + + + true + + + false + true + + + + + + + + + + + + true + + + false + + + + NotUsing + Level3 + true + CompileAsC + true + _CONSOLE;PACKAGE_VERSION="0.70";_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + ws2_32.lib;%(AdditionalDependencies) + true + + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + + + + + MaxSpeed + NDEBUG;%(PreprocessorDefinitions) + true + true + + + true + true + + + + + + diff --git a/src/net.h b/src/net.h index 11b1ea9..7835d88 100644 --- a/src/net.h +++ b/src/net.h @@ -1,6 +1,6 @@ /* Copyright © 1997—1999 Thomas Boutell and Boutell.Com, Inc. - © 2003—2017 Sam Hocevar + © 2003—2021 Sam Hocevar This software is released for free use under the terms of the GNU Public License, version 2 or higher. NO WARRANTY @@ -36,6 +36,12 @@ # include #endif /* FIONBIO */ +#if HAVE_SSIZE_T +# define SSIZE_T ssize_t +#else +# define SSIZE_T int +#endif + #if HAVE_SOCKLEN_T # define SOCKLEN_T socklen_t #else diff --git a/src/rinetd.c b/src/rinetd.c index e613823..3da6d2e 100644 --- a/src/rinetd.c +++ b/src/rinetd.c @@ -14,6 +14,10 @@ # define RETSIGTYPE void #endif +#ifdef _MSC_VER +# include +#endif + #if _WIN32 # include "getopt.h" #else @@ -439,7 +443,12 @@ static void selectPass(void) timeout.tv_sec = timeout.tv_usec = 0; time_t now = time(NULL); +#ifdef _MSC_VER + fd_set* readfds = (fd_set*)alloca(sizeof(*readfds) * fdSetCount); + fd_set* writefds = (fd_set*)alloca(sizeof(*writefds) * fdSetCount); +#else fd_set readfds[fdSetCount], writefds[fdSetCount]; +#endif FD_ZERO_EXT(readfds); FD_ZERO_EXT(writefds); /* Server sockets */ @@ -657,7 +666,7 @@ static void handleAccept(ServerInfo const *srv) to read a lot of data otherwise the datagram contents may be lost later. */ nfd = srv->fd; - ssize_t ret = recvfrom(nfd, globalUdpBuffer, + SSIZE_T ret = recvfrom(nfd, globalUdpBuffer, sizeof(globalUdpBuffer), 0, &addr, &addrlen); if (ret < 0) { if (GetLastError() == WSAEWOULDBLOCK) {