# HG changeset patch # User Sebastien Decugis # Date 1370024635 -7200 # Node ID 11724ff7863834a8e7534c7cc096b8564509b99f # Parent a4604f98adae5616004777051ba2a3921de9583e Some cleanups in dbg_interactive extension diff -r a4604f98adae -r 11724ff78638 doc/dbg_interactive.py.sample --- 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 ############ diff -r a4604f98adae -r 11724ff78638 extensions/dbg_interactive/dbg_interactive.c --- 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; diff -r a4604f98adae -r 11724ff78638 extensions/dbg_interactive/dbg_interactive.i --- 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; diff -r a4604f98adae -r 11724ff78638 include/freeDiameter/libfdcore.h --- 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); diff -r a4604f98adae -r 11724ff78638 include/freeDiameter/libfdproto.h --- 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 */