Add "extern C {...} to header files for C++ builds.
[freeradius.git] / src / include / missing.h
index 75a8454..7c7b37f 100644 (file)
@@ -58,6 +58,14 @@ RCSIDH(missing_h, "$Id$")
 #include <unistd.h>
 #endif
 
+#ifndef HAVE_VSNPRINTF
+#include <stdarg.h>
+#endif
+
+#ifdef HAVE_SYS_LOCKING_H
+#include <sys/locking.h>
+#endif
+
 /*
  *  Check for inclusion of <time.h>, versus <sys/time.h>
  *  Taken verbatim from the autoconf manual.
@@ -87,6 +95,10 @@ RCSIDH(missing_h, "$Id$")
 #define DARWIN (1)
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  *     Functions from missing.c
  */
@@ -112,7 +124,7 @@ struct tm *localtime_r(const time_t *l_clock, struct tm *result);
 char *ctime_r(const time_t *l_clock, char *l_buf);
 #endif
 
-#ifdef NEED_DECLARATION_CRYPT
+#if defined(NEED_DECLARATION_CRYPT) || !defined(HAVE_CRYPT)
 char *crypt(char *key, char *salt);
 #endif
 
@@ -124,9 +136,9 @@ int strncasecmp(char *s1, char *s2, int n);
 int strcasecmp(char *s1, char *s2);
 #endif
 
-#ifdef NEED_DECLARATION_INET_ATON
+#if defined(NEED_DECLARATION_INET_ATON) || !defined(HAVE_INET_ATON)
 struct in_addr;
-int inet_aton(char *cp, struct in_addr *inp);
+int inet_aton(const char *cp, struct in_addr *inp);
 #endif
 
 #ifndef HAVE_SETLINEBUF
@@ -322,7 +334,7 @@ extern int getaddrinfo (const char *__name,
 extern void freeaddrinfo (struct addrinfo *__ai);
 
 /* Convert error return from getaddrinfo() to a string.  */
-extern char *gai_strerror (int __ecode);
+extern const char *gai_strerror (int __ecode);
 #endif
 
 /* Translate a socket address to a location and service name. */
@@ -338,7 +350,6 @@ extern int getnameinfo (const struct sockaddr *__sa,
  */
 
 #ifndef HAVE_VSNPRINTF
-#include <stdarg.h>
 extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
 #endif
 
@@ -371,6 +382,7 @@ int gettimeofday (struct timeval *tv, void *tz);
 #endif
 
 #ifdef WIN32
+#undef interface
 #undef mkdir
 #define mkdir(_d, _p) mkdir(_d)
 #define FR_DIR_SEP '\\'
@@ -381,8 +393,6 @@ int gettimeofday (struct timeval *tv, void *tz);
 #endif
 
 #ifdef HAVE_SYS_LOCKING_H
-#include <sys/locking.h>
-
 #define lockf _locking
 
 #define F_ULOCK _LK_UNLCK /* Unlock locked sections. */
@@ -391,4 +401,15 @@ int gettimeofday (struct timeval *tv, void *tz);
 #define F_TEST  _LK_RLCK  /* Test section for locks by other processes. */
 #endif
 
+#ifndef offsetof
+# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+void timeval2ntp(const struct timeval *tv, uint8_t *ntp);
+void ntp2timeval(struct timeval *tv, const char *ntp);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FR_MISSING_H */