X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fcompat.h;h=bf4cb2e298df68aa1892f692beec3739f1058692;hb=80d9ed728be4b02ac483f3339cbb184f6602d15b;hp=85712597e36b1a4bcf20360f1ddc5facbc16ff2e;hpb=222e1b0003536cf7b47858961d4b56d45c6d6606;p=srvx.git diff --git a/src/compat.h b/src/compat.h index 8571259..bf4cb2e 100644 --- a/src/compat.h +++ b/src/compat.h @@ -53,10 +53,37 @@ char *alloca(); #include #endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +#ifdef HAVE_NETDB_H +#include +#endif + +#ifdef HAVE_WINSOCK2_H +/* Windows XP+ only -- older versions lack getaddrinfo() etc. */ +# define _WIN32_WINNT 0x0501 +# include +#endif + +#ifdef HAVE_WS2TCPIP_H +# include +#endif + #ifdef HAVE_UNISTD_H #include #endif +/* Cygwin (for example) doesn't define LINE_MAX, although mingw does. */ +#if !defined(LINE_MAX) +# define LINE_MAX 2048 +#endif + #ifdef HAVE_VA_COPY #define VA_COPY(DEST, SRC) va_copy(DEST, SRC) #elif HAVE___VA_COPY @@ -66,9 +93,14 @@ char *alloca(); #endif #ifndef HAVE_GETTIMEOFDAY +struct timezone; extern int gettimeofday(struct timeval * tv, struct timezone * tz); #endif +#ifndef HAVE_LOCALTIME_R +extern struct tm *localtime_r(const time_t *timep, struct tm *result); +#endif + #ifndef HAVE_MEMCPY /* this should use size_t, but some systems don't define it */ extern void * memcpy(void * dest, void const * src, unsigned long n); @@ -87,4 +119,62 @@ extern char * strdup(char const * str); extern char const * strerror(int errornum); #endif +#ifndef HAVE_STRUCT_ADDRINFO + +struct addrinfo { + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +#define AI_PASSIVE 1 +#define AI_CANONNAME 2 +#define AI_NUMERICHOST 4 + +#endif /* !defined(HAVE_STRUCT_ADDRINFO) */ + +#ifndef HAVE_GETADDRINFO +int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res); +void freeaddrinfo(struct addrinfo *res); +#endif + +#ifndef HAVE_GAI_STRERROR +const char *gai_strerror(int errcode); +#endif + +#ifndef EAI_FAMILY +# define EAI_FAMILY -1 +# define EAI_NONAME -2 +# define EAI_OVERFLOW -3 +# define EAI_FAIL -4 +# define EAI_AGAIN -5 +#endif + +#ifndef HAVE_GETNAMEINFO + +#define NI_NUMERICHOST 1 + +int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); + +#endif + +#ifndef EINPROGRESS +# ifdef WSAEINPROGRESS +# define EINPROGRESS WSAEINPROGRESS +# define EHOSTUNREACH WSAEHOSTUNREACH +# define ECONNREFUSED WSAECONNREFUSED +# define ECONNRESET WSAECONNRESET +# define ETIMEDOUT WSAETIMEDOUT +# endif +#endif + +#ifndef SIGCHLD +# define SIGCHLD SIGCLD +#endif + #endif /* COMPAT_H */