Annotation of pkgsrc/games/doomlegacy/patches/patch-src_mserv.c, Revision 1.2
1.1 micha 1: $NetBSD$
2:
3: Use native inet_aton() on Solaris.
1.2 ! micha 4: Use portable fcntl() instead of ioctl() for non-blocking mode by default.
1.1 micha 5:
1.2 ! micha 6: --- src/mserv.c.orig 2020-06-16 09:17:35.000000000 +0000
1.1 micha 7: +++ src/mserv.c
1.2 ! micha 8: @@ -122,12 +122,13 @@
! 9: #else
! 10: # include <unistd.h>
! 11: # ifdef __OS2__
! 12: -# include <sys/types.h>
! 13: +# include <sys/types.h> // [MB] 2020-06-16: Maybe required for old Unix too
! 14: # endif
! 15: # include <sys/socket.h> // socket(),...
! 16: # include <sys/time.h> // timeval,... (TIMEOUT)
! 17: # include <netinet/in.h> // sockaddr_in
! 18: # include <arpa/inet.h> // inet_addr(),...
! 19: +# include <fcntl.h> // [MB] 2020-06-16: For fcntl()
! 20: # include <netdb.h> // gethostbyname(),...
! 21: # include <sys/ioctl.h>
! 22: # include <errno.h>
! 23: @@ -210,7 +211,9 @@ struct Copy_CVarMS_t
1.1 micha 24: #define close closesocket
25: #endif
26:
27: -#if defined( WIN32) || defined( __OS2__) || defined( SOLARIS)
1.2 ! micha 28: +// [MB] 2020-06-16: Use native inet_aton() on Solaris
1.1 micha 29: +// Solaris has inet_aton() in libresolv since version 2.6 from 1997
30: +#if defined( WIN32) || defined( __OS2__) // || defined( SOLARIS)
31: // it seems windows doesn't define that... maybe some other OS? OS/2
32: static inline
33: int inet_aton(const char *hostname,
1.2 ! micha 34: @@ -643,9 +646,19 @@ static int MS_Connect(char *ip_addr, cha
! 35: // winsock.h: int ioctlsocket(SOCKET,long,u_long *);
! 36: u_long test = 1; // [smite] I have no idea what this type is supposed to be
! 37: ioctlsocket(ms_socket_fd, FIONBIO, &test);
! 38: -#else
! 39: +#elif defined(__OS2__)
! 40: res = 1; // non-blocking true
! 41: ioctl(ms_socket_fd, FIONBIO, &res);
! 42: +#else
! 43: + // [MB] 2020-06-16: Use portable POSIX way to enable non-blocking mode
! 44: + // https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html
! 45: + res = fcntl(ms_socket_fd, F_SETFL, O_NONBLOCK);
! 46: + if(-1 == res)
! 47: + {
! 48: + con_state = MSCS_FAILED;
! 49: + MS_Close_socket();
! 50: + return MS_CONNECT_ERROR;
! 51: + }
! 52: #endif
! 53: res = connect(ms_socket_fd, (struct sockaddr *) &ms_addr, sizeof(ms_addr));
! 54: if (res < 0)
CVSweb <webmaster@jp.NetBSD.org>