Add "extern C {...} to header files for C++ builds.
[freeradius.git] / src / include / missing.h
index cd0dd0b..7c7b37f 100644 (file)
@@ -8,6 +8,101 @@
  * Version:    $Id$
  *
  */
+
+#include <freeradius-devel/ident.h>
+RCSIDH(missing_h, "$Id$")
+
+#include <freeradius-devel/autoconf.h>
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include       <netinet/in.h>
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+#include       <arpa/inet.h>
+#endif
+
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#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.
+ */
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+/*
+ *     Don't look for winsock.h if we're on cygwin.
+ */
+#ifndef __CYGWIN__
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+
+#ifdef __APPLE__
+#undef DARWIN
+#define DARWIN (1)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *     Functions from missing.c
+ */
+
 #ifndef HAVE_STRNCASECMP
 extern int strncasecmp(char *s1, char *s2, int n);
 #endif
@@ -21,6 +116,7 @@ extern char *strsep(char **stringp, const char *delim);
 #endif
 
 #ifndef HAVE_LOCALTIME_R
+struct tm;
 struct tm *localtime_r(const time_t *l_clock, struct tm *result);
 #endif
 
@@ -28,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
 
@@ -40,13 +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);
-#endif
-
-#ifdef NEED_DECLARATION_GETHOSTNAME
-int gethostname(char *name, int len);
+int inet_aton(const char *cp, struct in_addr *inp);
 #endif
 
 #ifndef HAVE_SETLINEBUF
@@ -81,6 +173,10 @@ void endusershell(void);
 #define INADDR_NONE     ((uint32_t) 0xffffffff)
 #endif
 
+#ifndef INADDRSZ
+#define INADDRSZ 4
+#endif
+
 #ifndef INET_ADDRSTRLEN
 #define INET_ADDRSTRLEN 16
 #endif
@@ -106,6 +202,10 @@ struct in6_addr
 #define s6_addr32              in6_u.u6_addr32
 };
 
+#ifndef IN6ADDRSZ
+#define IN6ADDRSZ 16
+#endif
+
 #ifndef INET6_ADDRSTRLEN
 #define INET6_ADDRSTRLEN 46
 #endif
@@ -114,7 +214,7 @@ struct in6_addr
 #define IN6ADDR_ANY_INIT       {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}}
 #endif
 
-#ifndef IN6ADDR_LOOPBACK_INIT 
+#ifndef IN6ADDR_LOOPBACK_INIT
 #define IN6ADDR_LOOPBACK_INIT  {{{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}}
 #endif
 
@@ -175,6 +275,10 @@ struct in6_addr
 
 #endif /* HAVE_STRUCT_IN6_ADDR */
 
+/*
+ *     Functions from getaddrinfo.c
+ */
+
 #ifndef HAVE_STRUCT_SOCKADDR_STORAGE
 struct sockaddr_storage
 {
@@ -230,15 +334,82 @@ 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. */
 #ifndef HAVE_GETNAMEINFO
 extern int getnameinfo (const struct sockaddr *__sa,
                        socklen_t __salen, char *__host,
-                       socklen_t __hostlen, char *__serv,
-                       socklen_t __servlen, unsigned int __flags);
+                       size_t __hostlen, char *__serv,
+                       size_t __servlen, unsigned int __flags);
+#endif
+
+/*
+ *     Functions from snprintf.c
+ */
+
+#ifndef HAVE_VSNPRINTF
+extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
+#endif
+
+#ifndef HAVE_SNPRINTF
+extern int snprintf(char *str, size_t count, const char *fmt, ...);
+#endif
+
+/*
+ *     Functions from strl{cat,cpy}.c
+ */
+
+#ifndef HAVE_STRLCPY
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+#endif
+
+#ifndef HAVE_STRLCAT
+extern size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#ifndef INT16SZ
+#define INT16SZ (2)
+#endif
+
+#ifndef HAVE_GMTIME_R
+struct tm *gmtime_r(const time_t *l_clock, struct tm *result);
+#endif
+
+#ifndef HAVE_GETTIMEOFDAY
+int gettimeofday (struct timeval *tv, void *tz);
+#endif
+
+#ifdef WIN32
+#undef interface
+#undef mkdir
+#define mkdir(_d, _p) mkdir(_d)
+#define FR_DIR_SEP '\\'
+#define FR_DIR_IS_RELATIVE(p) ((*p && (p[1] != ':')) || ((*p != '\\') && (*p != '\\')))
+#else
+#define FR_DIR_SEP '/'
+#define FR_DIR_IS_RELATIVE(p) ((*p) != '/')
+#endif
+
+#ifdef HAVE_SYS_LOCKING_H
+#define lockf _locking
+
+#define F_ULOCK _LK_UNLCK /* Unlock locked sections. */
+#define F_LOCK  _LK_LOCK  /* Lock a section for exclusive use. */
+#define F_TLOCK _LK_NBLCK /* Test and lock a section for exclusive use */
+#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 */