changeset 1169:11724ff78638

Some cleanups in dbg_interactive extension
author Sebastien Decugis <sdecugis@freediameter.net>
date Fri, 31 May 2013 20:23:55 +0200
parents a4604f98adae
children 9c9f2b75bf95
files doc/dbg_interactive.py.sample extensions/dbg_interactive/dbg_interactive.c extensions/dbg_interactive/dbg_interactive.i include/freeDiameter/libfdcore.h include/freeDiameter/libfdproto.h
diffstat 5 files changed, 36 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/doc/dbg_interactive.py.sample	Fri May 31 18:29:33 2013 +0200
+++ b/doc/dbg_interactive.py.sample	Fri May 31 20:23:55 2013 +0200
@@ -29,8 +29,9 @@
 #
 
 # The remaining of this file gives some examples of how to use the python interpreter.
-# Note that the support is not yet totally usable. You'll probably have to extend some classes
-# or write some typemaps in the source code of the extension to do what you want.
+# Note that at the moment not 100% of the framework is usable. 
+# You may have to extend some classes or write some typemaps in the source code 
+# of the extension to do what you want.
 
 
 ############# Compilation-time constants (from freeDiameter-host.h) ############
@@ -42,7 +43,7 @@
 ############# Debug ############
 
 # Change the global debug level of the framework (cvar contains all global variables)
-cvar.fd_g_debug_lvl = FULL
+cvar.fd_g_debug_lvl = 1
 
 
 # Turn on debug for a specific function (if framework compiled with DEBUG support)
@@ -52,13 +53,16 @@
 # Print messages to freeDiameter's debug facility
 # Note: the python version does not support printf-like argument list. The formating should be done in python.
 #       See SWIG documentation about varargs functions for more information.
-fd_log_debug_fstr(None, "3 + 4 = %d" % (7))
+fd_log(FD_LOG_NOTICE, "3 + 4 = %d" % (7))
 
 
 # Display some framework state information
-r = fd_event_send(cvar.fd_g_config.cnf_main_ev, FDEV_DUMP_PEERS, 0, None)
-r = fd_event_send(cvar.fd_g_config.cnf_main_ev, FDEV_DUMP_SERV, 0, None)
-r = fd_event_send(cvar.fd_g_config.cnf_main_ev, FDEV_DUMP_EXT, 0, None)
+conf = fd_conf_dump();
+print conf;
+
+fd_peer_dump_list(0)
+fd_servers_dump(0)
+fd_ext_dump(0)
 
 
 ############# Global variables ############
@@ -658,6 +662,9 @@
 del myqueue
 
 
+############# HOOKS ############
+
+# TODO
 
 ############# PEERS ############
 
--- a/extensions/dbg_interactive/dbg_interactive.c	Fri May 31 18:29:33 2013 +0200
+++ b/extensions/dbg_interactive/dbg_interactive.c	Fri May 31 20:23:55 2013 +0200
@@ -79,7 +79,7 @@
 end:	
 	/* Upon exit, issue the order of terminating to fD, if the interpreter was started without a file */
 	if (!arg) {
-		CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
+		(void)fd_core_shutdown();
 	}
 
 	return NULL;
--- a/extensions/dbg_interactive/dbg_interactive.i	Fri May 31 18:29:33 2013 +0200
+++ b/extensions/dbg_interactive/dbg_interactive.i	Fri May 31 20:23:55 2013 +0200
@@ -121,6 +121,18 @@
 	%append_output(SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
 }
 
+/* Case of the fd_*_dump functions */
+%typemap(in,noblock=1,numinputs=0) (char ** buf, size_t *len, size_t *offset) ($*1_ltype temp = NULL, $*2_ltype tempn) {
+	$1 = &temp; $2 = &tempn; $3 = NULL;
+}
+%typemap(freearg,match="in") (char ** buf, size_t *len, size_t *offset) "";
+%typemap(argout,noblock=1,fragment="SWIG_FromCharPtr")(char ** buf, size_t *len, size_t *offset) { 
+  if (*$1) {
+    %append_output(SWIG_FromCharPtr(*$1));
+    free(*$1);					  	     
+  }					  	     
+}							     
+
 /* Typemap to return a boolean value as output parameter */
 %typemap(in, numinputs=0,noblock=1) int * BOOL_OUT (int temp) {
 	$1 = &temp;
--- a/include/freeDiameter/libfdcore.h	Fri May 31 18:29:33 2013 +0200
+++ b/include/freeDiameter/libfdcore.h	Fri May 31 20:23:55 2013 +0200
@@ -807,9 +807,12 @@
 
 /* The "old" FD_EV_DUMP_* events are replaced with direct calls to the following dump functions */
 DECLARE_FD_DUMP_PROTOTYPE(fd_conf_dump);
+#else /* SWIG */
+DECLARE_FD_DUMP_PROTOTYPE_simple(fd_event_trig_dump);
+DECLARE_FD_DUMP_PROTOTYPE_simple(fd_conf_dump);
+#endif /* SWIG */
 DECLARE_FD_DUMP_PROTOTYPE(fd_ext_dump, int indent_next);
 DECLARE_FD_DUMP_PROTOTYPE(fd_servers_dump, int details);
-#endif /* SWIG */
 DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump_list, int details);
 DECLARE_FD_DUMP_PROTOTYPE(fd_peer_dump, struct peer_hdr * p, int details);
 
--- a/include/freeDiameter/libfdproto.h	Fri May 31 18:29:33 2013 +0200
+++ b/include/freeDiameter/libfdproto.h	Fri May 31 20:23:55 2013 +0200
@@ -238,6 +238,11 @@
  */
 #define DECLARE_FD_DUMP_PROTOTYPE( function_name, args... )	\
 	char * function_name(char ** buf, size_t *len, size_t *offset, ##args)
+
+#ifdef SWIG
+#define DECLARE_FD_DUMP_PROTOTYPE_simple( function_name )	\
+	char * function_name(char ** buf, size_t *len, size_t *offset)
+#endif /* SWIG */
 	
 
 /* Helper functions for the *dump functions that add into a buffer */
"Welcome to our mercurial repository"