From 9cc323004c94f7dba6038c5a1232162b12163db4 Mon Sep 17 00:00:00 2001 From: Cas Cremers Date: Tue, 15 Apr 2014 22:12:43 +0100 Subject: [PATCH] Cleanup: Refactoring XML output code to facilitate introduction of protocol xml output. --- src/xmlout.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/src/xmlout.c b/src/xmlout.c index d90e046..26994a0 100644 --- a/src/xmlout.c +++ b/src/xmlout.c @@ -676,6 +676,30 @@ xmlRoleEventlist (const System sys, Roledef rd, int index) xmlPrint (""); } +//! Output a protocol description +void +xmlProtocol (const System sys, Protocol p) +{ + Role r; + + xmlPrint (""); + xmlindent++; + xmlOutTerm ("name", p->nameterm); + r = p->roles; + while (r != NULL) + { + xmlPrint (""); + xmlindent++; + xmlRoleTermPrint (r->nameterm); + xmlRoleEventlist (sys, r->roledef, 0); + xmlindent--; + xmlPrint (""); + r = r->next; + } + xmlindent--; + xmlPrint (""); +} + //! Show all protocol roles that are in the attack. void xmlInvolvedProtocolRoles (const System sys) @@ -687,24 +711,7 @@ xmlInvolvedProtocolRoles (const System sys) { if (isProtocolInvolved (sys, p)) { - Role r; - - xmlPrint (""); - xmlindent++; - xmlOutTerm ("name", p->nameterm); - r = p->roles; - while (r != NULL) - { - xmlPrint (""); - xmlindent++; - xmlRoleTermPrint (r->nameterm); - xmlRoleEventlist (sys, r->roledef, 0); - xmlindent--; - xmlPrint (""); - r = r->next; - } - xmlindent--; - xmlPrint (""); + xmlProtocol (sys, p); } p = p->next; }