diff include/freeDiameter/libfreeDiameter.h @ 235:8773740401a5

Centralized signal handlers management in the library
author Sebastien Decugis <sdecugis@nict.go.jp>
date Fri, 05 Mar 2010 19:01:48 +0900
parents c07f9692b537
children 60f34df3e025
line wrap: on
line diff
--- a/include/freeDiameter/libfreeDiameter.h	Thu Mar 04 17:32:00 2010 +0900
+++ b/include/freeDiameter/libfreeDiameter.h	Fri Mar 05 19:01:48 2010 +0900
@@ -75,6 +75,22 @@
 #include <libgen.h>	/* for basename if --dbg_file is specified */
 #endif /* DEBUG */
 
+
+/*============================================================*/
+/*                          INIT                              */
+/*============================================================*/
+
+/* This function must be called first, before any call to another library function */
+/* If the parameter is not 0, the support for signals (fd_sig_register) is enabled, otherwise it is disabled */
+/* The function must be called while the application is single-threaded to enable support for signals */
+int fd_lib_init(int support_signals);
+
+/* Call this one when the application terminates, to destroy internal threads */
+void fd_lib_fini(void);
+
+
+
+
 /*============================================================*/
 /*                          DEBUG                             */
 /*============================================================*/
@@ -558,6 +574,31 @@
 
 
 /*============================================================*/
+/*                          SIGNALS                           */
+/*============================================================*/
+
+/* Register a new callback to be called on reception of a given signal (it receives the signal as parameter) */
+/* EALREADY will be returned if there is already a callback registered on this signal */
+/* NOTE: the signal handler will be called from a new detached thread */
+int fd_sig_register(int signal, char * modname, void (*callback)(int signal));
+
+/* Remove the handler for a given signal */
+int fd_sig_unregister(int signal);
+
+/* Dump list of handlers */
+void fd_sig_dump(int level, int indent);
+
+/* Name of signals */
+#ifdef HAVE_SIGNALENT_H
+extern const char *const fd_sig_str[];
+extern const int fd_sig_nstr;
+# define SIGNALSTR(sig) (((sig) < fd_sig_nstr) ? fd_sig_str[(sig)] : "[unknown signal]")
+#else /* HAVE_SIGNALENT_H */
+# define SIGNALSTR(sig) ("[no sig names]")
+#endif /* HAVE_SIGNALENT_H */
+
+
+/*============================================================*/
 /*                          LISTS                             */
 /*============================================================*/
 
"Welcome to our mercurial repository"