Add "extern C {...} to header files for C++ builds.
authorAlan T. DeKok <aland@freeradius.org>
Sat, 9 Oct 2010 11:53:44 +0000 (13:53 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 9 Oct 2010 11:58:10 +0000 (13:58 +0200)
Also renamed "operator" to "op_token" for C++ builds.  This doesn't affect
the server core, but it should allow C++ modules to build.  It should
also allow C++ applications to use libfreeradius-radius

27 files changed:
src/include/conffile.h
src/include/detail.h
src/include/dhcp.h
src/include/event.h
src/include/hash.h
src/include/heap.h
src/include/ident.h
src/include/libradius.h
src/include/md4.h
src/include/md5.h
src/include/missing.h
src/include/modcall.h
src/include/modpriv.h
src/include/modules.h
src/include/packet.h
src/include/rad_assert.h
src/include/radiusd.h
src/include/radutmp.h
src/include/realms.h
src/include/sha1.h
src/include/soh.h
src/include/stats.h
src/include/sysutmp.h
src/include/token.h
src/include/udpfromto.h
src/include/vmps.h
src/include/vqp.h

index 40a400e..55d4177 100644 (file)
@@ -14,6 +14,10 @@ RCSIDH(conffile_h, "$Id$")
 #include <stddef.h>
 #include <freeradius-devel/token.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * Export the minimum amount of information about these structs
  */
@@ -123,4 +127,8 @@ extern int cf_section2file(FILE *fp, const CONF_SECTION *cs);
  */
 int cf_section_migrate(CONF_SECTION *dst, CONF_SECTION *src);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _CONFFILE_H */
index c781619..e3c13ee 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(detail_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef enum detail_state_t {
   STATE_UNOPENED = 0,
   STATE_UNLOCKED,
@@ -56,4 +60,8 @@ int detail_encode(UNUSED rad_listen_t *this, UNUSED REQUEST *request);
 int detail_decode(UNUSED rad_listen_t *this, UNUSED REQUEST *request);
 int detail_parse(CONF_SECTION *cs, rad_listen_t *this);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* DETAIL_H */
index 0f7e6f1..2d66ca0 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(dhcp_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  *     Not for production use.
  */
@@ -60,4 +64,8 @@ int fr_dhcp_decode(RADIUS_PACKET *packet);
 #define DHCP_BASE_ATTR(x) (x & 0xff)
 #define DHCP_UNPACK_OPTION1(x) (((x) & 0xff00) >> 8)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_DHCP_H */
index bc21ba0..a62dc01 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(event_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct fr_event_list_t fr_event_list_t;
 typedef struct fr_event_t fr_event_t;
 
@@ -54,4 +58,8 @@ int fr_event_fd_delete(fr_event_list_t *el, int type, int fd);
 int fr_event_loop(fr_event_list_t *el);
 void fr_event_loop_exit(fr_event_list_t *el, int code);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_HASH_H */
index 847ff03..3324138 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(hash_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  *     Fast hash, which isn't too bad.  Don't use for cryptography,
  *     just for hashing internal data.
@@ -61,4 +65,9 @@ int           fr_hash_table_num_elements(fr_hash_table_t *ht);
 int            fr_hash_table_walk(fr_hash_table_t *ht,
                                     fr_hash_table_walk_t callback,
                                     void *ctx);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_HASH_H */
index fdefd05..1f47449 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(heap_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef int (*fr_heap_cmp_t)(const void *, const void *);
 
 typedef struct fr_heap_t fr_heap_t;
@@ -36,4 +40,8 @@ int fr_heap_extract(fr_heap_t *hp, void *data);
 void *fr_heap_peek(fr_heap_t *hp);
 int fr_heap_num_elements(fr_heap_t *hp);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* LRAD_HEAP_H */
index 4c26578..5a2a273 100644 (file)
 #ifndef IDENT_H
 #define IDENT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(__GNUC__)
 /* force inclusion of ident keywords in the face of optimization */
 #define RCSID(id) static const char rcsid[] __attribute__ ((used)) = id;
@@ -35,4 +39,8 @@
 #define RCSIDH(h, id)
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* IDENT_H */
index bbf5e79..5423583 100644 (file)
@@ -57,6 +57,10 @@ RCSIDH(libradius_h, "$Id$")
 #define WITH_TCP (1)
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define EAP_START               2
 
 #define AUTH_VECTOR_LEN                16
@@ -164,7 +168,16 @@ typedef struct value_pair {
        unsigned int            vendor;
        int                     type;
        size_t                  length; /* of data */
+#ifdef __cplusplus
+       /*
+        *      C++ hackery.  The server and modules are all C, so
+        *      the defs here don't affect them.  But any C++ code
+        *      gets excited over "operator", so we change the name.
+        */
+       FR_TOKEN                op_token;
+#else
        FR_TOKEN                operator;
+#endif
         ATTR_FLAGS              flags;
        struct value_pair       *next;
        uint32_t                lvalue;
@@ -483,6 +496,10 @@ void *fr_fifo_pop(fr_fifo_t *fi);
 void *fr_fifo_peek(fr_fifo_t *fi);
 int fr_fifo_num_elements(fr_fifo_t *fi);
 
+#ifdef __cplusplus
+}
+#endif
+
 #include <freeradius-devel/packet.h>
 
 #ifdef WITH_TCP
index bd71e48..348d7bb 100644 (file)
@@ -26,6 +26,14 @@ RCSIDH(md4_h, "$Id$")
 
 #include <string.h>
 
+#ifdef WITH_OPENSSL_MD4
+#include <openssl/md4.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 void fr_md4_calc (unsigned char *, const unsigned char *, unsigned int);
 
 #ifndef WITH_OPENSSL_MD4
@@ -66,8 +74,6 @@ typedef struct FR_MD4Context {
        uint8_t buffer[MD4_BLOCK_LENGTH];       /* input buffer */
 } FR_MD4_CTX;
 
-/*#include <sys/cdefs.h>*/
-
 /*__BEGIN_DECLS*/
 void    fr_MD4Init(FR_MD4_CTX *);
 void    fr_MD4Update(FR_MD4_CTX *, const uint8_t *, size_t)
@@ -80,8 +86,6 @@ void   fr_MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
 /*__END_DECLS*/
 #else  /* WITH_OPENSSL_MD4 */
 
-#include <openssl/md4.h>
-
 #define FR_MD4_CTX     MD4_CTX
 #define fr_MD4Init     MD4_Init
 #define fr_MD4Update   MD4_Update
@@ -89,4 +93,8 @@ void   fr_MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH])
 #define fr_MD4Transform MD4_Transform
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FR_MD4_H */
index 27767e6..fec196e 100644 (file)
@@ -26,6 +26,14 @@ RCSIDH(md5_h, "$Id$")
 
 #include <string.h>
 
+#ifdef WITH_OPENSSL_MD5
+#include <openssl/md5.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef WITH_OPENSSL_MD5
 /*  The below was retrieved from
  *  http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/crypto/md5.h?rev=1.1
@@ -70,8 +78,6 @@ void   fr_MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH])
 
 #else  /* WITH_OPENSSL_HASH */
 
-#include <openssl/md5.h>
-
 #define FR_MD5_CTX     MD5_CTX
 #define fr_MD5Init     MD5_Init
 #define fr_MD5Update   MD5_Update
@@ -79,4 +85,8 @@ void   fr_MD5Transform(uint32_t [4], const uint8_t [MD5_BLOCK_LENGTH])
 #define fr_MD5Transform MD5_Transform
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FR_MD5_H */
index de82dd9..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
  */
@@ -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
 
@@ -382,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. */
@@ -399,4 +408,8 @@ int gettimeofday (struct timeval *tv, void *tz);
 void timeval2ntp(const struct timeval *tv, uint8_t *ntp);
 void ntp2timeval(struct timeval *tv, const char *ntp);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FR_MISSING_H */
index 89ec4dc..9a95565 100644 (file)
@@ -1,3 +1,6 @@
+#ifndef FR_MODCALL_H
+#define FR_MODCALL_H
+
 /* modcall.h: the outside interface to the module-calling tree. Includes
  * functions to build the tree from the config file, and to call it by
  * feeding it REQUESTs.
@@ -6,6 +9,10 @@
 
 #include <freeradius-devel/conffile.h> /* Need CONF_* definitions */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  *     For each authorize/authtype/etc, we have an ordered
  *     tree of instances to call.  This data structure keeps track
@@ -32,3 +39,9 @@ void add_to_modcallable(modcallable **parent, modcallable *this,
 
 /* Free a tree returned by compile_modgroup or compile_modsingle */
 void modcallable_free(modcallable **pc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index a79e4cb..43a414d 100644 (file)
 
 #ifndef WITHOUT_LIBLTDL
 #include "ltdl.h"
-#else
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef WITHOUT_LIBLTDL
 typedef void *lt_dlhandle;
 
 lt_dlhandle lt_dlopenext(const char *name);
@@ -62,4 +68,9 @@ typedef struct module_instance_t {
 module_instance_t *find_module_instance(CONF_SECTION *, const char *instname,
                                        int do_link);
 int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_MODPRIV_H */
index 074cc44..dbb17f3 100644 (file)
@@ -13,6 +13,10 @@ RCSIDH(modules_h, "$Id$")
 
 #include <freeradius-devel/conffile.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef int (*packetmethod)(void *instance, REQUEST *request);
 
 enum {
@@ -87,5 +91,8 @@ int indexed_modcall(int comp, int idx, REQUEST *request);
 int virtual_servers_load(CONF_SECTION *config);
 void virtual_servers_free(time_t when);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif /* RADIUS_MODULES_H */
index a700541..4b455db 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(packet_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 uint32_t fr_request_packet_hash(const RADIUS_PACKET *packet);
 uint32_t fr_reply_packet_hash(const RADIUS_PACKET *packet);
 int fr_packet_cmp(const RADIUS_PACKET *a, const RADIUS_PACKET *b);
@@ -76,4 +80,9 @@ int fr_packet_list_num_outgoing(fr_packet_list_t *pl);
  *     required type.
  */
 # define fr_packet2myptr(TYPE, MEMBER, PTR) (TYPE *) (((char *)PTR) - offsetof(TYPE, MEMBER))
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_PACKET_H */
index 3802783..a0b513b 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(rad_assert_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 extern void rad_assert_fail (const char *file, unsigned int line, const char *expr);
 
 #ifdef NDEBUG
@@ -40,4 +44,8 @@ extern void rad_assert_fail (const char *file, unsigned int line, const char *ex
 #define rad_assert assert
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index e26af57..92a363b 100644 (file)
@@ -104,6 +104,9 @@ typedef struct auth_req REQUEST;
 #include <freeradius-devel/stats.h>
 #include <freeradius-devel/realms.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
  *     See util.c
@@ -706,4 +709,9 @@ int radius_update_attrlist(REQUEST *request, CONF_SECTION *cs,
                           VALUE_PAIR *input_vps, const char *name);
 void radius_pairmove(REQUEST *request, VALUE_PAIR **to, VALUE_PAIR *from);
 int radius_get_vp(REQUEST *request, const char *name, VALUE_PAIR **vp_p);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /*RADIUSD_H*/
index 997c9ea..165a620 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(radutmp_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  *      Types of connection.
  */
@@ -55,4 +59,8 @@ struct radutmp {
 #define RUT_NAMESIZE sizeof(((struct radutmp *) NULL)->login)
 #define RUT_SESSSIZE sizeof(((struct radutmp *) NULL)->session_id)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _RADUTMP_H */
index 9a590e9..0b00a1b 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(realms_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define HOME_TYPE_INVALID (0)
 #define HOME_TYPE_AUTH    (1)
 #define HOME_TYPE_ACCT    (2)
@@ -146,4 +150,8 @@ home_server *home_server_bynumber(int number);
 #endif
 home_pool_t *home_pool_byname(const char *name, int type);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* REALMS_H */
index 2880ac3..0a431a8 100644 (file)
@@ -1,6 +1,14 @@
 #ifndef _FR_SHA1_H
 #define _FR_SHA1_H
 
+#ifdef WITH_OPENSSL_SHA1
+#include <openssl/sha.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef WITH_OPENSSL_SHA1
 typedef struct {
     uint32_t state[5];
@@ -23,8 +31,6 @@ void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context);
 
 #else  /* WITH_OPENSSL_SHA1 */
 
-#include <openssl/sha.h>
-
 #define fr_SHA1_CTX    SHA_CTX
 #define fr_SHA1Init    SHA1_Init
 #define fr_SHA1Update  SHA1_Update
@@ -40,4 +46,8 @@ void fr_SHA1FinalNoLen(uint8_t digest[20], fr_SHA1_CTX* context);
  */
 extern void fips186_2prf(uint8_t mk[20], uint8_t finalkey[160]);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _FR_SHA1_H */
index 8585e64..7dc17f9 100644 (file)
@@ -28,9 +28,17 @@ RCSIDH(soh_h, "$Id$")
 
 #include <freeradius-devel/libradius.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int soh_verify(VALUE_PAIR *sohvp, const uint8_t *data, unsigned int data_len);
 uint16_t soh_pull_be_16(const uint8_t *p);
 uint32_t soh_pull_be_24(const uint8_t *p);
 uint32_t soh_pull_be_32(const uint8_t *p);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index 44d17cc..a781eb7 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(stats_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef WITH_STATS_64BIT
 typedef uint64_t fr_uint_t;
 #else
@@ -101,4 +105,8 @@ void radius_stats_ema(fr_stats_ema_t *ema,
 
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_STATS_H */
index f56e5d6..27d5cdd 100644 (file)
@@ -37,6 +37,10 @@ RCSIDH(sysutmp_h, "$Id$")
 #  include <utmp.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __osf__
 #  define UT_NAMESIZE  32
 #  define UT_LINESIZE  32
@@ -98,4 +102,8 @@ struct utmp {
 
 #endif /* HAVE_UTMP_H */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* SYSUTMP_H_INCLUDED */
index 3a71d18..8b5c24d 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(token_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef enum fr_token_t {
   T_OP_INVALID = 0,            /* invalid token */
   T_EOL,                       /* end of line */
@@ -76,4 +80,8 @@ int           getbareword (const char **ptr, char *buf, int buflen);
 FR_TOKEN       gettoken(const char **ptr, char *buf, int buflen);
 FR_TOKEN       getstring(const char **ptr, char *buf, int buflen);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_TOKEN_H */
index 1c37048..525df38 100644 (file)
@@ -11,6 +11,10 @@ RCSIDH(udpfromtoh, "$Id$")
 #include <freeradius-devel/autoconf.h>
 #include <freeradius-devel/libradius.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef WITH_UDPFROMTO
 int udpfromto_init(int s);
 int recvfromto(int s, void *buf, size_t len, int flags,
@@ -21,4 +25,8 @@ int sendfromto(int s, void *buf, size_t len, int flags,
               struct sockaddr *to, socklen_t tolen);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index fbfee65..ff44766 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(vmps_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 int vqp_socket_recv(rad_listen_t *listener,
                    RAD_REQUEST_FUNP *pfun, REQUEST **prequest);
 int vqp_socket_send(rad_listen_t *listener, REQUEST *request);
@@ -17,4 +21,8 @@ int vqp_socket_encode(UNUSED rad_listen_t *listener, REQUEST *request);
 int vqp_socket_decode(UNUSED rad_listen_t *listener, REQUEST *request);
 int vmps_process(REQUEST *request);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* VMPS_H */
index 7ff5552..9cb96ab 100644 (file)
 #include <freeradius-devel/ident.h>
 RCSIDH(vqp_h, "$Id$")
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 RADIUS_PACKET *vqp_recv(int sockfd);
 int vqp_send(RADIUS_PACKET *packet);
 int vqp_decode(RADIUS_PACKET *packet);
 int vqp_encode(RADIUS_PACKET *packet, RADIUS_PACKET *original);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FR_VQP_H */