- [[[ Broken commit ]]]

Committing partial new Warshall work because it is getting too big.
This commit is contained in:
ccremers
2006-02-26 15:00:58 +00:00
parent 8995bc4d28
commit 0ce88af6ac
20 changed files with 1136 additions and 1007 deletions

View File

@@ -62,20 +62,20 @@ latexInit (const System sys, int argc, char **argv)
{
int i;
printf ("%%\n");
printf ("%% LaTeX output generated by %s\n", progname);
printf ("%% Input:\n");
eprintf ("%%\n");
eprintf ("%% LaTeX output generated by %s\n", progname);
eprintf ("%% Input:\n");
/* print command line */
printf ("%% $");
eprintf ("%% $");
for (i = 0; i < argc; i++)
printf (" %s", argv[i]);
printf ("\n");
eprintf (" %s", argv[i]);
eprintf ("\n");
printf ("%%\n");
eprintf ("%%\n");
/* comment macro (used for debugging) */
printf ("\\newcommand{\\comment}[1]{}\n");
eprintf ("\\newcommand{\\comment}[1]{}\n");
}
//! Close up any LaTeX output.
@@ -102,7 +102,7 @@ latexTermPrint (Term term, Termlist highlight)
{
if (term == NULL)
{
printf ("Empty term");
eprintf ("Empty term");
return;
}
#ifdef DEBUG
@@ -116,27 +116,27 @@ latexTermPrint (Term term, Termlist highlight)
if (realTermLeaf (term))
{
if (inTermlist (highlight, term))
printf ("\\mathbf{");
eprintf ("\\mathbf{");
symbolPrint (TermSymb (term));
if (realTermVariable (term))
printf ("V");
eprintf ("V");
if (TermRunid (term) >= 0)
{
printf ("\\sharp%i", TermRunid (term));
eprintf ("\\sharp%i", TermRunid (term));
}
if (term->subst != NULL)
{
printf ("\\rightarrow");
eprintf ("\\rightarrow");
latexTermPrint (term->subst, highlight);
}
if (inTermlist (highlight, term))
printf ("}");
eprintf ("}");
}
if (realTermTuple (term))
{
printf ("(");
eprintf ("(");
latexTermTuplePrint (term, highlight);
printf (")");
eprintf (")");
return;
}
if (realTermEncrypt (term))
@@ -146,18 +146,18 @@ latexTermPrint (Term term, Termlist highlight)
{
/* function application */
latexTermPrint (TermKey (term), highlight);
printf ("(");
eprintf ("(");
latexTermTuplePrint (TermOp (term), highlight);
printf (")");
eprintf (")");
}
else
{
/* normal encryption */
printf ("\\{");
eprintf ("\\{");
latexTermTuplePrint (TermOp (term), highlight);
printf ("\\}_{");
eprintf ("\\}_{");
latexTermPrint (TermKey (term), highlight);
printf ("}");
eprintf ("}");
}
}
}
@@ -173,7 +173,7 @@ latexTermTuplePrint (Term term, Termlist hl)
{
if (term == NULL)
{
printf ("Empty term");
eprintf ("Empty term");
return;
}
term = deVar (term);
@@ -181,7 +181,7 @@ latexTermTuplePrint (Term term, Termlist hl)
{
// To remove any brackets, change this into latexTermTuplePrint.
latexTermPrint (TermOp1 (term), hl);
printf (",");
eprintf (",");
term = deVar (TermOp2 (term));
}
latexTermPrint (term, hl);
@@ -201,7 +201,7 @@ latexTermlistPrint (Termlist tl, Termlist highlight)
{
if (tl == NULL)
{
printf ("\\emptyset");
eprintf ("\\emptyset");
return;
}
while (tl != NULL)
@@ -209,7 +209,7 @@ latexTermlistPrint (Termlist tl, Termlist highlight)
latexTermPrint (tl->term, highlight);
tl = tl->next;
if (tl != NULL)
printf (", ");
eprintf (", ");
}
}
@@ -233,11 +233,11 @@ void
latexMSCStart (Termlist protocolnames)
{
if (landscape)
printf ("\\begin{landscape}\n");
eprintf ("\\begin{landscape}\n");
printf ("\\begin{msc}{attack on $");
eprintf ("\\begin{msc}{attack on $");
termlistPrint (protocolnames);
printf ("$}\n");
eprintf ("$}\n");
}
//! Close drawing MSC
@@ -245,10 +245,10 @@ latexMSCStart (Termlist protocolnames)
void
latexMSCEnd ()
{
printf ("\\end{msc}\n");
eprintf ("\\end{msc}\n");
if (landscape)
printf ("\\end{landscape}\n");
eprintf ("\\end{landscape}\n");
}
@@ -272,43 +272,43 @@ latexDeclInst (const System sys, int run)
myRole = sys->runs[run].role->nameterm;
if (pass == 1)
{
printf ("\\maxlength{\\maxmscinst}{");
eprintf ("\\maxlength{\\maxmscinst}{");
}
else
{
printf ("\\declinst{run%i}{", run);
eprintf ("\\declinst{run%i}{", run);
}
/* display above assumptions */
roles = sys->runs[run].protocol->rolenames;
if (pass == 2)
{
printf ("assumes $");
eprintf ("assumes $");
first = 1;
while (roles != NULL)
{
if (!isTermEqual (myRole, roles->term))
{
if (!first)
printf (", ");
eprintf (", ");
else
first = 0;
termPrint (agentOfRunRole (sys, run, roles->term));
printf (": ");
eprintf (": ");
termPrint (roles->term);
}
roles = roles->next;
}
printf ("$}{");
eprintf ("$}{");
}
/* display agent and role */
printf ("$\\mathbf{");
eprintf ("$\\mathbf{");
termPrint (myAgent);
printf ("}: ");
eprintf ("}: ");
termPrint (myRole);
printf ("$}\n");
eprintf ("$}\n");
/* cleanup */
termDelete (myAgent);
@@ -332,9 +332,9 @@ latexEventSpace (int amount)
return;
}
//printf("%% number of newlines: %d\n",amount);
//eprintf("%% number of newlines: %d\n",amount);
for (i = 0; i < EVENTSPACE * amount; i++)
printf ("\\nextlevel\n");
eprintf ("\\nextlevel\n");
}
//! MSC message print.
@@ -371,36 +371,36 @@ latexMessagePrint (struct tracebuf *tb, int from, int to)
if (from == -1 && to != -1)
{
/* message from intruder into system */
printf ("\\mess{$");
eprintf ("\\mess{$");
termPrint (readTerm);
printf ("$}{eve}{run%d}\n", tb->run[to]);
eprintf ("$}{eve}{run%d}\n", tb->run[to]);
}
else if (from != -1 && to == -1)
{
/* message from system to intruder */
printf ("\\mess{$");
eprintf ("\\mess{$");
termPrint (sendTerm);
printf ("$}{run%d}{eve}\n", tb->run[from]);
eprintf ("$}{run%d}{eve}\n", tb->run[from]);
}
else if (from != -1 && to != -1)
{
/* message from one agent to another, possibly transformed */
printf ("\\mess{$");
eprintf ("\\mess{$");
termPrint (sendTerm);
if (!isTermEqual (sendTerm, readTerm))
{
printf ("\\rightarrow");
eprintf ("\\rightarrow");
termPrint (readTerm);
}
printf ("$}{run%d", tb->run[from]);
printf ("}{run%d}[%d]", tb->run[to],
EVENTSPACE * (tinfo[to].position - tinfo[from].position));
eprintf ("$}{run%d", tb->run[from]);
eprintf ("}{run%d}[%d]", tb->run[to],
EVENTSPACE * (tinfo[to].position - tinfo[from].position));
printf ("\n");
eprintf ("\n");
}
}
@@ -438,34 +438,34 @@ latexMessagePrintHighlight (struct tracebuf *tb, int from, int to,
if (from == -1 && to != -1)
{
/* TODO redundant */
printf ("\\found{$");
eprintf ("\\found{$");
latexTermPrint (readTerm, highlight);
printf ("$}{}{run%d}\n", tb->run[to]);
eprintf ("$}{}{run%d}\n", tb->run[to]);
}
else if (from != -1 && to == -1)
{
printf ("\\mess{$");
eprintf ("\\mess{$");
latexTermPrint (sendTerm, highlight);
printf ("$}{run%d}{eve}\n", tb->run[from]);
eprintf ("$}{run%d}{eve}\n", tb->run[from]);
}
else if (from != -1 && to != -1)
{
printf ("\\mess{$");
eprintf ("\\mess{$");
latexTermPrint (sendTerm, highlight);
if (!isTermEqual (sendTerm, readTerm))
{
printf ("\\rightarrow");
eprintf ("\\rightarrow");
latexTermPrint (readTerm, highlight);
}
printf ("$}{run%d", tb->run[from]);
printf ("}{run%d}[%d]", tb->run[to],
EVENTSPACE * (tinfo[to].position - tinfo[from].position));
eprintf ("$}{run%d", tb->run[from]);
eprintf ("}{run%d}[%d]", tb->run[to],
EVENTSPACE * (tinfo[to].position - tinfo[from].position));
printf ("\n");
eprintf ("\n");
}
}
@@ -479,22 +479,22 @@ latexClaim (struct tracebuf *tb, int run, Termlist tl)
{
if (pass == 1)
{
printf ("\\maxlength{\\maxmsccondition}{");
eprintf ("\\maxlength{\\maxmsccondition}{");
}
else
{
printf ("\\condition{");
eprintf ("\\condition{");
}
printf ("$\\neg secret ");
eprintf ("$\\neg secret ");
termlistPrint (tl);
printf ("$}");
eprintf ("$}");
if (pass == 1)
{
printf ("\n");
eprintf ("\n");
}
else
{
printf ("{run%d}\n", run);
eprintf ("{run%d}\n", run);
}
}
@@ -547,7 +547,7 @@ latexCorrespondingSend (struct tracebuf *tb, int rd)
{
/* bingo! success on all matches */
//printf("Found perfect match: %d\n", s);
//eprintf("Found perfect match: %d\n", s);
bestSendEvent = sendEvent;
break;
}
@@ -604,7 +604,7 @@ latexCorrespondingSend (struct tracebuf *tb, int rd)
if (bestSendEvent == -1)
{
printf ("%% Could not find a matching SEND\n");
eprintf ("%% Could not find a matching SEND\n");
}
return bestSendEvent;
}
@@ -628,9 +628,9 @@ latexCorrespondingSend2 (struct tracebuf *tb, int readEvent)
if (!inKnowledge (tb->know[u], tb->event[readEvent]->message))
{
/*
printf("%% term[");
printf("]#%d is introduced at traceEvent[%d] ",readEvent,u);
printf("\n");
eprintf("%% term[");
eprintf("]#%d is introduced at traceEvent[%d] ",readEvent,u);
eprintf("\n");
*/
return u;
}
@@ -650,7 +650,7 @@ knowledgePrintLatex (Knowledge know)
if (know == NULL)
{
printf ("\\emptyset");
eprintf ("\\emptyset");
}
else
{
@@ -681,7 +681,7 @@ attackDisplayLatex (const System sys)
tb = sys->attack;
if (tb == NULL)
{
printf ("Attack pointer empty: nothing to display.\n");
eprintf ("Attack pointer empty: nothing to display.\n");
exit (1);
}
/* set variables */
@@ -692,49 +692,49 @@ attackDisplayLatex (const System sys)
tracebufRebuildKnow (tb);
/* Make a comment in which the trace is displayed, for debugging etc. */
printf ("\n\\comment{ TRACE\n\n");
printf ("Length: %i\n", tb->length);
printf ("Reallength: %i\n", tb->reallength);
printf ("\n");
eprintf ("\n\\comment{ TRACE\n\n");
eprintf ("Length: %i\n", tb->length);
eprintf ("Reallength: %i\n", tb->reallength);
eprintf ("\n");
i = 0;
while (i <= tb->length)
{
printf ("Knowledge %i:\n", i);
eprintf ("Knowledge %i:\n", i);
knowledgePrint (tb->know[i]);
printf (" [Inverses]: ");
eprintf (" [Inverses]: ");
knowledgeInversesPrint (tb->know[i]);
printf ("\n\n");
eprintf ("\n\n");
if (i < tb->length)
{
printf ("Event %i\t[", i);
eprintf ("Event %i\t[", i);
switch (tb->status[i])
{
case S_UNK:
printf ("?");
eprintf ("?");
break;
case S_RED:
printf ("redundant");
eprintf ("redundant");
break;
case S_TOD:
printf ("to do");
eprintf ("to do");
break;
case S_OKE:
printf ("okay");
eprintf ("okay");
break;
default:
printf ("illegal status code");
eprintf ("illegal status code");
break;
}
printf ("]\t");
eprintf ("]\t");
termPrint (tb->event[i]->message);
printf ("\t#%i", tb->run[i]);
printf ("\n");
eprintf ("\t#%i", tb->run[i]);
eprintf ("\n");
roledefPrint (tb->event[i]);
printf ("\n\n");
eprintf ("\n\n");
}
i++;
}
printf ("}\n\n");
eprintf ("}\n\n");
tinfo =
(struct traceinfo *) memAlloc ((tb->length + 1) *
@@ -786,7 +786,7 @@ attackDisplayLatex (const System sys)
if (tb->event[i]->type == READ && !tb->event[i]->internal)
{
bestSend = latexCorrespondingSend2 (tb, i);
printf ("%% match: %d <-> %d\n", i, bestSend);
eprintf ("%% match: %d <-> %d\n", i, bestSend);
if (bestSend == -1)
continue; // TODO major ugliness
@@ -801,9 +801,9 @@ attackDisplayLatex (const System sys)
}
}
}
printf ("\\comment{ claimDetails :\n");
eprintf ("\\comment{ claimDetails :\n");
termlistPrint (claimDetails);
printf ("\n}\n");
eprintf ("\n}\n");
// landscape = (width > 4); // not for the time being
@@ -844,16 +844,16 @@ attackDisplayLatex (const System sys)
if (runPosition[currRun] <= tinfo[tb->link[i]].position
&& currRun != tb->run[tb->link[i]])
{
printf ("\\comment{\n");
eprintf ("\\comment{\n");
termPrint (tb->event[i]->message);
printf ("\n");
eprintf ("\n");
termPrint (tb->event[tb->link[i]]->message);
printf ("\n");
printf ("%% termDistance: %f\n",
termDistance (tb->event[i]->message,
tb->event[tb->link[i]]->
message));
printf ("}\n");
eprintf ("\n");
eprintf ("%% termDistance: %f\n",
termDistance (tb->event[i]->message,
tb->event[tb->link[i]]->
message));
eprintf ("}\n");
tinfo[i].position = tinfo[tb->link[i]].position;
eventSize = 0;
}
@@ -879,7 +879,7 @@ attackDisplayLatex (const System sys)
}
if (!(tb->event[i]->type == READ && tb->event[i]->internal))
runPosition[currRun] = tinfo[i].position + eventSize;
/* printf("%% Event %d at %d\n", i, position); */
/* eprintf("%% Event %d at %d\n", i, position); */
position += eventSize;
}
}
@@ -896,12 +896,12 @@ attackDisplayLatex (const System sys)
for (pass = 1; pass <= 2; pass++)
{
printf ("%% Pass %i\n\n", pass);
eprintf ("%% Pass %i\n\n", pass);
if (pass == 1)
{
printf ("\\maxlength{\\maxmscaction}{knows}\n");
printf ("\\maxlength{\\maxmscaction}{creates}\n");
eprintf ("\\maxlength{\\maxmscaction}{knows}\n");
eprintf ("\\maxlength{\\maxmscaction}{creates}\n");
}
else
{
@@ -909,18 +909,18 @@ attackDisplayLatex (const System sys)
Term pname;
/* slightly stretch measurements */
printf ("\\addtolength{\\maxmscall}{2\\mscspacer}\n");
printf ("\\addtolength{\\maxmscaction}{\\mscspacer}\n");
printf ("\\addtolength{\\maxmscinst}{\\mscspacer}\n");
printf ("\\addtolength{\\maxmsccondition}{\\mscspacer}\n");
eprintf ("\\addtolength{\\maxmscall}{2\\mscspacer}\n");
eprintf ("\\addtolength{\\maxmscaction}{\\mscspacer}\n");
eprintf ("\\addtolength{\\maxmscinst}{\\mscspacer}\n");
eprintf ("\\addtolength{\\maxmsccondition}{\\mscspacer}\n");
/* put out computed widths */
printf ("\\setlength{\\envinstdist}{0.7\\maxmscall}\n");
printf ("\\setlength{\\instdist}{\\maxmscall}\n");
printf ("\\setlength{\\actionwidth}{\\maxmscaction}\n");
printf ("\\setlength{\\instwidth}{\\maxmscinst}\n");
printf ("\\setlength{\\conditionoverlap}{0.5\\maxmsccondition}\n");
eprintf ("\\setlength{\\envinstdist}{0.7\\maxmscall}\n");
eprintf ("\\setlength{\\instdist}{\\maxmscall}\n");
eprintf ("\\setlength{\\actionwidth}{\\maxmscaction}\n");
eprintf ("\\setlength{\\instwidth}{\\maxmscinst}\n");
eprintf ("\\setlength{\\conditionoverlap}{0.5\\maxmsccondition}\n");
/* create MSC title, involving protocol names and such. */
@@ -949,10 +949,10 @@ attackDisplayLatex (const System sys)
}
/* Add the intruder instance */
if (pass == 2)
printf ("\\declinst{eve}{}{");
eprintf ("\\declinst{eve}{}{");
else
printf ("\\maxlength{\\maxmscinst}{");
printf ("{\\bf Eve}: Intruder}\n\n");
eprintf ("\\maxlength{\\maxmscinst}{");
eprintf ("{\\bf Eve}: Intruder}\n\n");
/* Print the local constants for each instance */
@@ -971,14 +971,14 @@ attackDisplayLatex (const System sys)
if (first)
{
if (pass == 1)
printf ("\\maxlength{\\maxmscaction}{$");
eprintf ("\\maxlength{\\maxmscaction}{$");
else
printf ("\\ActionBox{creates \\\\\n$");
eprintf ("\\ActionBox{creates \\\\\n$");
first = 0;
}
else
{
printf (", ");
eprintf (", ");
}
termPrint (tl->term);
}
@@ -987,9 +987,9 @@ attackDisplayLatex (const System sys)
if (!first)
{
if (pass == 1)
printf ("$}\n");
eprintf ("$}\n");
else
printf ("$}{run%i}\n", i);
eprintf ("$}{run%i}\n", i);
}
}
}
@@ -998,13 +998,13 @@ attackDisplayLatex (const System sys)
if (pass == 2)
{
printf ("\\ActionBox{");
printf ("knows \\\\\n$");
eprintf ("\\ActionBox{");
eprintf ("knows \\\\\n$");
knowledgePrintLatex (tb->know[0]);
printf ("$}");
printf ("{eve}\n");
printf ("\\nextlevel[3]\n");
printf ("\n");
eprintf ("$}");
eprintf ("{eve}\n");
eprintf ("\\nextlevel[3]\n");
eprintf ("\n");
}
/* print the events in the attack */
@@ -1059,25 +1059,25 @@ attackDisplayLatex (const System sys)
if (pass == 1)
{
printf ("\\maxlength{\\maxmscaction}{");
eprintf ("\\maxlength{\\maxmscaction}{");
}
else
{
printf ("\\nextlevel[1]\n");
printf ("\\ActionBox{learns \\\\\n");
eprintf ("\\nextlevel[1]\n");
eprintf ("\\ActionBox{learns \\\\\n");
}
printf ("$");
eprintf ("$");
cKnowledge++;
latexTermlistPrint (newtl, highlights);
printf ("$}");
eprintf ("$}");
if (pass == 1)
{
printf ("\n");
eprintf ("\n");
}
else
{
printf ("{eve}\n");
printf ("\\nextlevel[2]\n");
eprintf ("{eve}\n");
eprintf ("\\nextlevel[2]\n");
}
}