Skip to content
Snippets Groups Projects
Commit 7df76d2f authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Use portable inet_pton() for all Win32 builds.

Rename the portable inet_pton() to xp_inet_pton() and define a wrapper macro (for all Widows builds) to use it instead of inet_pton() as not all supported Windows systems (e.g. WinXP) have an inet_pton() implementation.

This allows the HAProxy mod to be re-enabled by default without preventing executing on WinXP.
parent 60e1e6c3
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #934 passed
/* sockwrap.c */
/* Berkley/WinSock socket API wrappers */ /* Berkley/WinSock socket API wrappers */
/* $Id: sockwrap.c,v 1.74 2020/08/09 02:13:57 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html * * Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This library is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * * as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. * * of the License, or (at your option) any later version. *
* See the GNU Lesser General Public License for more details: lgpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/lesser.html * * http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* * * *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -524,8 +508,7 @@ DLLEXPORT char* socket_strerror(int error_number, char* buf, size_t buflen) ...@@ -524,8 +508,7 @@ DLLEXPORT char* socket_strerror(int error_number, char* buf, size_t buflen)
#endif #endif
} }
#if defined(_WIN32) && !defined(_MSC_VER) DLLEXPORT int xp_inet_pton(int af, const char *src, void *dst)
DLLEXPORT int inet_pton(int af, const char *src, void *dst)
{ {
struct addrinfo hints = {0}; struct addrinfo hints = {0};
struct addrinfo *res, *cur; struct addrinfo *res, *cur;
...@@ -558,4 +541,3 @@ DLLEXPORT int inet_pton(int af, const char *src, void *dst) ...@@ -558,4 +541,3 @@ DLLEXPORT int inet_pton(int af, const char *src, void *dst)
freeaddrinfo(res); freeaddrinfo(res);
return 1; return 1;
} }
#endif
/* sockwrap.h */
/* Berkley/WinSock socket API wrappers */ /* Berkley/WinSock socket API wrappers */
/* $Id: sockwrap.h,v 1.61 2020/08/08 23:26:38 rswindell Exp $ */
/**************************************************************************** /****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html * * Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This library is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 * * as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. * * of the License, or (at your option) any later version. *
* See the GNU Lesser General Public License for more details: lgpl.txt or * * See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/lesser.html * * http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* * * *
* For Synchronet coding style and modification guidelines, see * * For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html * * http://www.synchro.net/source.html *
* * * *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. * * Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/ ****************************************************************************/
...@@ -240,9 +224,9 @@ DLLEXPORT uint16_t inet_addrport(union xp_sockaddr *addr); ...@@ -240,9 +224,9 @@ DLLEXPORT uint16_t inet_addrport(union xp_sockaddr *addr);
DLLEXPORT void inet_setaddrport(union xp_sockaddr *addr, uint16_t port); DLLEXPORT void inet_setaddrport(union xp_sockaddr *addr, uint16_t port);
DLLEXPORT BOOL inet_addrmatch(union xp_sockaddr* addr1, union xp_sockaddr* addr2); DLLEXPORT BOOL inet_addrmatch(union xp_sockaddr* addr1, union xp_sockaddr* addr2);
DLLEXPORT char* socket_strerror(int, char*, size_t); DLLEXPORT char* socket_strerror(int, char*, size_t);
DLLEXPORT int xp_inet_pton(int af, const char *src, void *dst);
#if defined(_WIN32) && !defined(_MSC_VER) #if defined(_WIN32) // mingw and WinXP's WS2_32.DLL don't have inet_pton():
DLLEXPORT int inet_pton(int af, const char *src, void *dst); #define inet_pton xp_inet_pton
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment