fix possible crash on user deletion
[srvx.git] / src / compat.h
index 8a6e8e25ec4e3a328a937bef024fbabf1cc0d6e6..bf4cb2e298df68aa1892f692beec3739f1058692 100644 (file)
@@ -57,6 +57,10 @@ char *alloca();
 #include <sys/socket.h>
 #endif
 
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
@@ -75,6 +79,11 @@ char *alloca();
 #include <unistd.h>
 #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
@@ -88,7 +97,7 @@ struct timezone;
 extern int gettimeofday(struct timeval * tv, struct timezone * tz);
 #endif
 
-#ifndef HAVE_GETLOCALTIME_R
+#ifndef HAVE_LOCALTIME_R
 extern struct tm *localtime_r(const time_t *timep, struct tm *result);
 #endif
 
@@ -130,17 +139,30 @@ struct addrinfo {
 #endif /* !defined(HAVE_STRUCT_ADDRINFO) */
 
 #ifndef HAVE_GETADDRINFO
-
 int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res);
-int getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
 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
@@ -151,4 +173,8 @@ const char *gai_strerror(int errcode);
 # endif
 #endif
 
+#ifndef SIGCHLD
+# define SIGCHLD SIGCLD
+#endif
+
 #endif /* COMPAT_H */