diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2026-08-24 11:16:07 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2026-08-24 11:16:07 +0200 |
| commit | c068f22329d5cc722622a2183bbb22eef2093df7 (patch) | |
| tree | 12d56c1aede67988a55e241364606bfbb4dba933 /src/libparsec/include/net_wrap.h | |
| download | openparsec-main.tar.xz openparsec-main.zip | |
Diffstat (limited to 'src/libparsec/include/net_wrap.h')
| -rw-r--r-- | src/libparsec/include/net_wrap.h | 114 |
1 files changed, 114 insertions, 0 deletions
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 <winsock2.h> + #include <ws2tcpip.h> + #include <io.h> +#else + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/time.h> + #include <time.h> + #include <netinet/in.h> + #include <arpa/inet.h> + #include <errno.h> + #include <fcntl.h> + #include <netdb.h> + #include <signal.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <sys/stat.h> + #include <sys/uio.h> + #include <unistd.h> + #include <sys/wait.h> + #include <net/if.h> + #include <sys/un.h> + #include <sys/ioctl.h> +#endif +/* +#elif defined( SYSTEM_MACOSX_UNUSED ) + #include <sys/types.h> + #include <sys/socket.h> + #include <sys/time.h> + #include <time.h> + #include <netinet/in.h> + #include <arpa/inet.h> + #include <errno.h> + #include <fcntl.h> + #include <netdb.h> + #include <signal.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <sys/stat.h> + #include <sys/uio.h> + #include <unistd.h> + #include <sys/wait.h> + #include <net/if.h> + #include <sys/un.h> + #include <sys/sockio.h> + #include <sys/ioctl.h> + + #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_ + + |
