From c068f22329d5cc722622a2183bbb22eef2093df7 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 24 Aug 2026 11:16:07 +0200 Subject: initial import --- src/libparsec/include/net_wrap.h | 114 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/libparsec/include/net_wrap.h (limited to 'src/libparsec/include/net_wrap.h') diff --git a/src/libparsec/include/net_wrap.h b/src/libparsec/include/net_wrap.h new file mode 100644 index 0000000..0861404 --- /dev/null +++ b/src/libparsec/include/net_wrap.h @@ -0,0 +1,114 @@ +/* + * PARSEC HEADER: net_wrap.h + */ + +#ifndef _NET_UNP_H_ +#define _NET_UNP_H_ + +#if defined( SYSTEM_TARGET_WINDOWS ) && ( _WIN32_WINNT >= _WIN32_WINNT_VISTA ) + #include + #include + #include +#else + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#endif +/* +#elif defined( SYSTEM_MACOSX_UNUSED ) + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + #define socklen_t int +#endif +*/ + +// constants and macros used by the network code ------------------------------ +// +#define MAXLINE 4096 + +#define SA struct sockaddr + + +// windows uses closesocket, osx/linux use close +#ifdef SYSTEM_TARGET_WINDOWS +#define CLOSESOCKET closesocket +#else +#define CLOSESOCKET close +#endif + + +// define some macros to make error handling more readable -------------------- +// +#ifdef SYSTEM_TARGET_WINDOWS + #define ERRNO wsaerr + #define FETCH_ERRNO() int wsaerr = WSAGetLastError() + #define ERRNO_EWOULDBLOCK ( wsaerr == WSAEWOULDBLOCK ) + #define ERRNO_ECONNREFUSED ( wsaerr == WSAECONNREFUSED ) + #define ERRNO_ENETDOWN ( wsaerr == WSAENETDOWN ) + #define ERRNO_ECONNRESET ( wsaerr == WSAECONNRESET ) + //#define ERRNO_WSAEMSGSIZE ( wsaerr == WSAEMSGSIZE ) + + // UNP legacy stuff + #define ioctl( fd, request, arg ) ioctlsocket(fd, request, (unsigned long *) arg) + #define bzero(ptr,n) memset(ptr, 0, n) + + int inet_aton(const char *cp, struct in_addr *ap); + const char* hstrerror(int); +#if ( _WIN32_WINNT < _WIN32_WINNT_VISTA ) + const char* inet_ntop( int family, const void* addrptr, char* strptr, size_t len); +#endif +#else + #define ERRNO errno + #define FETCH_ERRNO() {} + #define ERRNO_EWOULDBLOCK ( errno == EWOULDBLOCK ) + #define ERRNO_ECONNREFUSED ( errno == ECONNREFUSED ) + #define ERRNO_ECONNRESET ( errno == ECONNRESET ) + #define ERRNO_ENETDOWN ( FALSE ) +#endif + + +#ifndef MAXHOSTNAMELEN + #define MAXHOSTNAMELEN 1024 +#endif + + +#endif // _NET_UNP_H_ + + -- cgit v1.2.3