- Huge modification, now allowing for parbox constructions. Nearly all

overlap is gone now.
This commit is contained in:
ccremers 2004-05-13 14:49:04 +00:00
parent 47a96937ac
commit c53bff4f39
2 changed files with 309 additions and 141 deletions

View File

@ -1,12 +1,56 @@
\documentclass{article}
\usepackage{a4wide}
\usepackage{msc}
\usepackage{ifthen}
\setlength{\instwidth}{3.0cm}
\setlength{\instdist}{4cm}
\setlength{\actionwidth}{3.6cm}
\setlength{\conditionoverlap}{1.9cm}
% Action macro from MSC documentation
\newsavebox{\labelbox}
\newlength{\oldwd}
\newlength{\oldht}
\newcommand{\Action}[2]{%
\setlength{\oldwd}{\actionwidth}%
\setlength{\oldht}{\actionheight}%
\savebox{\labelbox}{#1}%
\setlength{\actionwidth}{\wd\labelbox + 2\labeldist}%
\setlength{\actionheight}{\ht\labelbox + \dp\labelbox + 2\labeldist}%
\action{\usebox{\labelbox}}{#2}%
\setlength{\actionwidth}{\oldwd}%
\setlength{\actionheight}{\oldht}%
}
\newlength{\mscspacer}
\setlength{\mscspacer}{1ex}
\newcommand{\ActionBox}[2]{%
\Action{\parbox{\maxmscaction - 2\mscspacer}{\centering #1}}{#2}
}
\newlength{\maxtemp}
\newcommand{\maxlength}[2]{
\settowidth{\maxtemp}{#2}
\ifthenelse{\lengthtest{#1 < \maxtemp}}{\setlength{#1}{\maxtemp}}{}
\ifthenelse{\lengthtest{\maxmscall < \maxtemp}}{\setlength{\maxmscall}{\maxtemp}}{}
}
\newlength{\maxmscall}
\newlength{\maxmscinst}
\newlength{\maxmscaction}
\newlength{\maxmsccondition}
\setlength{\maxmscall}{\mscspacer}
\setlength{\maxmscinst}{\mscspacer}
\setlength{\maxmscaction}{\mscspacer}
\setlength{\maxmsccondition}{\mscspacer}
\begin{document}
\input{attack}

View File

@ -35,6 +35,7 @@ struct traceinfo *tinfo;
int width;
int landscape = 0;
int *runPerm;
int pass;
/* code */
@ -293,10 +294,19 @@ latexDeclInst (const System sys, int run)
myAgent = agentOfRun (sys, run);
myRole = sys->runs[run].role->nameterm;
if (pass == 1)
{
printf ("\\maxlength{\\maxmscinst}{");
}
else
{
printf ("\\declinst{run%i}{", run);
}
/* display above assumptions */
roles = sys->runs[run].protocol->rolenames;
if (pass == 2)
{
printf ("assumes $");
first = 1;
while (roles != NULL)
@ -313,10 +323,11 @@ latexDeclInst (const System sys, int run)
}
roles = roles->next;
}
printf ("$}{$");
printf ("$}{");
}
/* display agent and role */
printf ("\\mathbf{");
printf ("$\\mathbf{");
termPrint (myAgent);
printf("}: ");
termPrint (myRole);
@ -336,6 +347,12 @@ latexDeclInst (const System sys, int run)
void
latexEventSpace (int amount)
{
if (pass < 2)
{
/* not printing */
return;
}
int i;
//printf("%% number of newlines: %d\n",amount);
for (i = 0; i < EVENTSPACE * amount; i++)
@ -354,6 +371,12 @@ latexMessagePrint (struct tracebuf *tb, int from, int to)
Term sendTerm = NULL;
Term readTerm = NULL;
if (pass < 2)
{
/* no measurement of messages yet */
return;
}
if (from == -1 && to == -1)
{
return;
@ -415,6 +438,12 @@ latexMessagePrintHighlight (struct tracebuf *tb, int from, int to,
Term sendTerm = NULL;
Term readTerm = NULL;
if (pass < 2)
{
/* no measurements on message width yet */
return;
}
if (from == -1 && to == -1)
{
return;
@ -429,6 +458,7 @@ latexMessagePrintHighlight (struct tracebuf *tb, int from, int to,
}
if (from == -1 && to != -1)
{
/* TODO redundant */
printf ("\\found{$");
latexTermPrint (readTerm, highlight);
printf ("$}{}{run%d}\n", tb->run[to]);
@ -482,10 +512,25 @@ latexAction (struct tracebuf *tb, int te)
void
latexClaim (struct tracebuf *tb, int run, Termlist tl)
{
printf ("\\condition{$");
printf ("\\neg secret ");
if (pass == 1)
{
printf ("\\maxlength{\\maxmsccondition}{");
}
else
{
printf ("\\condition{");
}
printf ("$\\neg secret ");
termlistPrint (tl);
printf ("$}{run%d}\n", run);
printf ("$}");
if (pass == 1)
{
printf ("\n");
}
else
{
printf ("{run%d}\n", run);
}
}
/*
@ -915,6 +960,41 @@ attackDisplayLatex (System sys)
}
}
/* ------------------------------------------------------
*
* Start of MSC creation (2-phase)
*
*
* ------------------------------------------------------
*/
/* 2 pass for widths */
for (pass = 1; pass <= 2; pass++)
{
printf ("%% Pass %i\n\n",pass);
if (pass == 1)
{
printf ("\\maxlength{\\maxmscaction}{knows}\n");
printf ("\\maxlength{\\maxmscaction}{creates}\n");
}
else
{
/* slightly stretch measurements */
printf ("\\addtolength{\\maxmscall}{2\\mscspacer}\n");
printf ("\\addtolength{\\maxmscaction}{\\mscspacer}\n");
printf ("\\addtolength{\\maxmscinst}{\\mscspacer}\n");
printf ("\\addtolength{\\maxmsccondition}{\\mscspacer}\n");
/* put out computed widths */
printf ("\\setlength{\\envinstdist}{0.5\\maxmscall}\n");
printf ("\\setlength{\\instdist}{\\maxmscall}\n");
printf ("\\setlength{\\actionwidth}{\\maxmscaction}\n");
printf ("\\setlength{\\instwidth}{\\maxmscinst}\n");
printf ("\\setlength{\\conditionoverlap}{0.5\\maxmsccondition}\n");
/* create MSC title, involving protocol names and such. */
Termlist protocolnames = NULL;
@ -932,6 +1012,7 @@ attackDisplayLatex (System sys)
}
latexMSCStart (protocolnames);
termlistDelete (protocolnames);
}
/* declare instances */
@ -941,8 +1022,11 @@ attackDisplayLatex (System sys)
latexDeclInst (sys, i);
}
/* Add the intruder instance */
printf ("\\declinst{eve}{}{{\\bf Eve}: Intruder}\n");
printf ("\n\n");
if (pass == 2)
printf ("\\declinst{eve}{}{");
else
printf ("\\maxlength{\\maxmscinst}{");
printf ("{\\bf Eve}: Intruder}\n\n");
/* Print the local constants for each instance */
@ -960,7 +1044,10 @@ attackDisplayLatex (System sys)
{
if (first)
{
printf ("\\action{creates $");
if (pass == 1)
printf ("\\maxlength{\\maxmscaction}{$");
else
printf ("\\ActionBox{creates \\\\\n$");
first = 0;
}
else
@ -973,6 +1060,9 @@ attackDisplayLatex (System sys)
}
if (!first)
{
if (pass == 1)
printf ("$}\n");
else
printf ("$}{run%i}\n", i);
}
}
@ -980,10 +1070,16 @@ attackDisplayLatex (System sys)
/* Print the initial intruder knowledge */
printf ("\\action{knows $");
if (pass == 2)
{
printf ("\\ActionBox{");
printf ("knows \\\\\n$");
knowledgePrintLatex (tb->know[0]);
printf ("$}{eve}\n");
printf ("\\nextlevel[2]\n\n");
printf ("$}");
printf ("{eve}\n");
printf ("\\nextlevel[3]\n");
printf ("\n");
}
/* print the events in the attack */
@ -1034,12 +1130,28 @@ attackDisplayLatex (System sys)
{
/* print what was learned */
if (pass == 1)
{
printf ("\\maxlength{\\maxmscaction}{");
}
else
{
printf ("\\nextlevel[1]\n");
printf ("\\action{learns $");
printf ("\\ActionBox{learns \\\\\n");
}
printf ("$");
cKnowledge++;
latexTermlistPrint (newtl, highlights);
printf ("$}{eve}\n");
printf ("\\nextlevel[1]\n");
printf ("$}");
if (pass == 1)
{
printf ("\n");
}
else
{
printf ("{eve}\n");
printf ("\\nextlevel[2]\n");
}
}
termlistDelete (highlights);
@ -1065,8 +1177,20 @@ attackDisplayLatex (System sys)
}
}
}
}
/*
* close up diagrams
*/
latexEventSpace (2);
latexMSCEnd ();
/*
* free used memory
*/
memFree (runPosition, width * sizeof (int));
memFree (tinfo, (tb->length + 1) * sizeof (struct traceinfo));
}