changeset 904:b839a1b1c1da

Make freeDiameter headers more C++ friendly -- thank you Thomas
author Sebastien Decugis <sdecugis@freediameter.net>
date Sat, 15 Dec 2012 10:55:06 +0100
parents 4382d7420e65
children 9bf44ee1c748
files extensions/_sample/hello.cpp include/freeDiameter/extension.h include/freeDiameter/freeDiameter-host.h.in include/freeDiameter/libfdcore.h include/freeDiameter/libfdproto.h libfdproto/log.c
diffstat 6 files changed, 37 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/_sample/hello.cpp	Fri Dec 14 21:24:34 2012 +0100
+++ b/extensions/_sample/hello.cpp	Sat Dec 15 10:55:06 2012 +0100
@@ -36,10 +36,8 @@
 /* Sample file demonstrating how to write some C++ code */
 
 #include <iostream>
-extern "C" {
-   #include <freeDiameter/extension.h>
-   
-}
+
+#include <freeDiameter/extension.h>
 
 extern "C" void mycppfunc(); /* will be called from C code */
 
--- a/include/freeDiameter/extension.h	Fri Dec 14 21:24:34 2012 +0100
+++ b/include/freeDiameter/extension.h	Sat Dec 15 10:55:06 2012 +0100
@@ -36,6 +36,10 @@
 #ifndef _EXTENSION_H
 #define _EXTENSION_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Include definition of freeDiameter API */
 #include <freeDiameter/freeDiameter-host.h>
 #include <freeDiameter/libfdcore.h>
@@ -61,4 +65,8 @@
 	return (_function)(conffile);							\
 }														
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _EXTENSION_H */
--- a/include/freeDiameter/freeDiameter-host.h.in	Fri Dec 14 21:24:34 2012 +0100
+++ b/include/freeDiameter/freeDiameter-host.h.in	Sat Dec 15 10:55:06 2012 +0100
@@ -37,6 +37,10 @@
 #ifndef FD_IS_CONFIG
 #define FD_IS_CONFIG
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #cmakedefine HAVE_NTOHLL
 #cmakedefine HAVE_MALLOC_H
 #cmakedefine HAVE_SIGNALENT_H
@@ -88,4 +92,8 @@
 #define FD_DEFAULT_CONF_FILENAME "freeDiameter.conf"
 #endif /* FD_DEFAULT_CONF_FILENAME */
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* FD_IS_CONFIG */
--- a/include/freeDiameter/libfdcore.h	Fri Dec 14 21:24:34 2012 +0100
+++ b/include/freeDiameter/libfdcore.h	Sat Dec 15 10:55:06 2012 +0100
@@ -37,6 +37,10 @@
 #define _LIBFDCORE_H
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <freeDiameter/libfdproto.h>
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
@@ -823,4 +827,8 @@
 int fd_app_check_common(struct fd_list * list1, struct fd_list * list2, int * common_found);
 int fd_app_empty(struct fd_list * list);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LIBFDCORE_H */
--- a/include/freeDiameter/libfdproto.h	Fri Dec 14 21:24:34 2012 +0100
+++ b/include/freeDiameter/libfdproto.h	Sat Dec 15 10:55:06 2012 +0100
@@ -57,6 +57,10 @@
 #ifndef _LIBFDPROTO_H
 #define _LIBFDPROTO_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef FD_IS_CONFIG
 #error "You must include 'freeDiameter-host.h' before this file."
 #endif /* FD_IS_CONFIG */
@@ -145,7 +149,7 @@
  * RETURN VALUE:
  *  None.
  */
-void fd_log_threadname ( char * name );
+void fd_log_threadname ( const char * name );
 extern pthread_key_t	fd_log_thname;
 
 /*
@@ -3056,4 +3060,8 @@
 /* Dump a fifo list and optionally its inner elements -- beware of deadlocks! */
 void fd_fifo_dump(int level, char * name, struct fifo * queue, void (*dump_item)(int level, void * item));
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LIBFDPROTO_H */
--- a/libfdproto/log.c	Fri Dec 14 21:24:34 2012 +0100
+++ b/libfdproto/log.c	Sat Dec 15 10:55:06 2012 +0100
@@ -107,7 +107,7 @@
 }
 
 /* Function to set the thread's friendly name */
-void fd_log_threadname ( char * name )
+void fd_log_threadname ( const char * name )
 {
 	void * val = NULL;
 	
@@ -117,7 +117,7 @@
 	val = pthread_getspecific(fd_log_thname);
 	if (TRACE_BOOL(ANNOYING)) {
 		if (val) {
-			fd_log_debug("(Thread '%s' renamed to '%s')\n", (char *)val, name);
+			fd_log_debug("(Thread '%s' renamed to '%s')\n", (char *)val, name?:"(nil)");
 		} else {
 			fd_log_debug("(Thread %p named '%s')\n", pthread_self(), name?:"(nil)");
 		}
"Welcome to our mercurial repository"