- Re-indented the output and latex files.

This commit is contained in:
ccremers 2004-04-23 11:03:07 +00:00
parent 0f4e6a5aba
commit 6efcbdea62
2 changed files with 1111 additions and 983 deletions

View File

@ -23,7 +23,8 @@ extern Term TERM_Function;
/* struct for additional info */ /* struct for additional info */
struct traceinfo { struct traceinfo
{
int match; int match;
int position; int position;
}; };
@ -37,7 +38,8 @@ int *runPerm;
/* code */ /* code */
void latexInit(const System sys, int argc, char **argv) void
latexInit (const System sys, int argc, char **argv)
{ {
int i; int i;
@ -63,7 +65,8 @@ void latexInit(const System sys, int argc, char **argv)
printf ("\\input{preamble}\n"); printf ("\\input{preamble}\n");
} }
void latexDone(const System sys) void
latexDone (const System sys)
{ {
printf ("\\input{postamble}\n"); printf ("\\input{postamble}\n");
printf ("\n\\end{document}\n\n"); printf ("\n\\end{document}\n\n");
@ -161,9 +164,11 @@ latexTermlistPrint (Termlist tl, Termlist highlight)
printf ("]"); printf ("]");
} }
void latexTimers(const System sys) void
latexTimers (const System sys)
{
void endline (void)
{ {
void endline(void) {
printf ("\\\\ \\hline\n"); printf ("\\\\ \\hline\n");
} }
@ -193,9 +198,12 @@ void latexTimers(const System sys)
* NoClaim no claims * NoClaim no claims
*/ */
if (sys->claims == 0) { if (sys->claims == 0)
{
printf ("NoClaim & "); printf ("NoClaim & ");
} else { }
else
{
if (sys->failed > 0) if (sys->failed > 0)
printf ("L:%i & ", attackLength (sys->attack)); printf ("L:%i & ", attackLength (sys->attack));
else else
@ -211,11 +219,14 @@ void latexTimers(const System sys)
/* states per second */ /* states per second */
if (seconds > 0) { if (seconds > 0)
{
printf ("$%.3e$ ", printf ("$%.3e$ ",
(double) (sys->statesLow + (double) (sys->statesLow +
(sys->statesHigh * ULONG_MAX)) / seconds); (sys->statesHigh * ULONG_MAX)) / seconds);
} else { }
else
{
printf ("$\\infty$ "); printf ("$\\infty$ ");
} }
endline (); endline ();
@ -223,7 +234,8 @@ void latexTimers(const System sys)
printf ("\\end{tabular}\n\n"); printf ("\\end{tabular}\n\n");
} }
void latexMSCStart() void
latexMSCStart ()
{ {
if (landscape) if (landscape)
printf ("\\begin{landscape}\n"); printf ("\\begin{landscape}\n");
@ -231,7 +243,8 @@ void latexMSCStart()
printf ("\\begin{msc}{attack}\n"); printf ("\\begin{msc}{attack}\n");
} }
void latexMSCEnd() void
latexMSCEnd ()
{ {
printf ("\\end{msc}\n"); printf ("\\end{msc}\n");
@ -240,7 +253,8 @@ void latexMSCEnd()
} }
void latexDeclInst(const System sys, int run) void
latexDeclInst (const System sys, int run)
{ {
Term bar = NULL; Term bar = NULL;
@ -252,7 +266,8 @@ void latexDeclInst(const System sys, int run)
printf ("$}\n"); printf ("$}\n");
} }
void latexEventSpace(int amount) void
latexEventSpace (int amount)
{ {
int i; int i;
//printf("%% number of newlines: %d\n",amount); //printf("%% number of newlines: %d\n",amount);
@ -261,100 +276,120 @@ void latexEventSpace(int amount)
} }
void latexMessagePrint(struct tracebuf *tb, int from, int to) void
latexMessagePrint (struct tracebuf *tb, int from, int to)
{ {
Term sendTerm = NULL; Term sendTerm = NULL;
Term readTerm = NULL; Term readTerm = NULL;
if (from == -1 && to == -1) { if (from == -1 && to == -1)
{
return; return;
} }
if (from != -1) { if (from != -1)
{
sendTerm = tb->event[from]->message; sendTerm = tb->event[from]->message;
} }
if (to != -1) { if (to != -1)
{
readTerm = tb->event[to]->message; readTerm = tb->event[to]->message;
} }
if (from == -1 && to != -1) { if (from == -1 && to != -1)
{
printf ("\\found{$"); printf ("\\found{$");
termPrint (readTerm); termPrint (readTerm);
printf ("$}{}{run%d}\n", tb->run[to]); printf ("$}{}{run%d}\n", tb->run[to]);
} else if (from != -1 && to == -1) { }
else if (from != -1 && to == -1)
{
printf ("\\lost{$"); printf ("\\lost{$");
termPrint (sendTerm); termPrint (sendTerm);
printf ("$}{}{run%d}\n", tb->run[from]); printf ("$}{}{run%d}\n", tb->run[from]);
} else if (from != -1 && to != -1) { }
else if (from != -1 && to != -1)
{
printf ("\\mess{$"); printf ("\\mess{$");
termPrint (sendTerm); termPrint (sendTerm);
if (!isTermEqual(sendTerm, readTerm)) { if (!isTermEqual (sendTerm, readTerm))
{
printf ("\\rightarrow"); printf ("\\rightarrow");
termPrint (readTerm); termPrint (readTerm);
} }
printf ("$}{run%d", tb->run[from]); printf ("$}{run%d", tb->run[from]);
printf ("}{run%d}[%d]", tb->run[to], printf ("}{run%d}[%d]", tb->run[to],
EVENTSPACE * (tinfo[to].position - EVENTSPACE * (tinfo[to].position - tinfo[from].position));
tinfo[from].position));
printf ("\n"); printf ("\n");
} }
} }
void latexMessagePrintHighlight(struct tracebuf *tb, int from, int to, Termlist highlight) void
latexMessagePrintHighlight (struct tracebuf *tb, int from, int to,
Termlist highlight)
{ {
Term sendTerm = NULL; Term sendTerm = NULL;
Term readTerm = NULL; Term readTerm = NULL;
if (from == -1 && to == -1) { if (from == -1 && to == -1)
{
return; return;
} }
if (from != -1) { if (from != -1)
{
sendTerm = tb->event[from]->message; sendTerm = tb->event[from]->message;
} }
if (to != -1) { if (to != -1)
{
readTerm = tb->event[to]->message; readTerm = tb->event[to]->message;
} }
if (from == -1 && to != -1) { if (from == -1 && to != -1)
{
printf ("\\found{$"); printf ("\\found{$");
latexTermPrint (readTerm, highlight); latexTermPrint (readTerm, highlight);
printf ("$}{}{run%d}\n", tb->run[to]); printf ("$}{}{run%d}\n", tb->run[to]);
} else if (from != -1 && to == -1) { }
else if (from != -1 && to == -1)
{
printf ("\\lost{$"); printf ("\\lost{$");
latexTermPrint (sendTerm, highlight); latexTermPrint (sendTerm, highlight);
printf ("$}{}{run%d}\n", tb->run[from]); printf ("$}{}{run%d}\n", tb->run[from]);
} else if (from != -1 && to != -1) { }
else if (from != -1 && to != -1)
{
printf ("\\mess{$"); printf ("\\mess{$");
latexTermPrint (sendTerm, highlight); latexTermPrint (sendTerm, highlight);
if (!isTermEqual(sendTerm, readTerm)) { if (!isTermEqual (sendTerm, readTerm))
{
printf ("\\rightarrow"); printf ("\\rightarrow");
latexTermPrint (readTerm, highlight); latexTermPrint (readTerm, highlight);
} }
printf ("$}{run%d", tb->run[from]); printf ("$}{run%d", tb->run[from]);
printf ("}{run%d}[%d]", tb->run[to], printf ("}{run%d}[%d]", tb->run[to],
EVENTSPACE * (tinfo[to].position - EVENTSPACE * (tinfo[to].position - tinfo[from].position));
tinfo[from].position));
printf ("\n"); printf ("\n");
} }
} }
void latexLearnComment(struct tracebuf *tb, int index, Termlist tl) void
latexLearnComment (struct tracebuf *tb, int index, Termlist tl)
{ {
printf("\\msccomment[4ex]{$I_%d=I_%d\\oplus ", index + 1, printf ("\\msccomment[4ex]{$I_%d=I_%d\\oplus ", index + 1, index);
index);
termlistPrint (tl); termlistPrint (tl);
printf ("$}{envright}\n"); printf ("$}{envright}\n");
} }
void latexAction(struct tracebuf *tb, int te) void
latexAction (struct tracebuf *tb, int te)
{ {
printf ("\\action{$"); printf ("\\action{$");
termPrint (tb->event[te]->message); termPrint (tb->event[te]->message);
@ -362,7 +397,8 @@ void latexAction(struct tracebuf *tb, int te)
//printf("\\nextlevel\n"); //printf("\\nextlevel\n");
} }
void latexClaim(struct tracebuf *tb, int run, Termlist tl) void
latexClaim (struct tracebuf *tb, int run, Termlist tl)
{ {
printf ("\\condition{$"); printf ("\\condition{$");
printf ("\\neg secret "); printf ("\\neg secret ");
@ -370,7 +406,8 @@ void latexClaim(struct tracebuf *tb, int run, Termlist tl)
printf ("$}{run%d}\n", run); printf ("$}{run%d}\n", run);
} }
int latexCorrespondingSend(struct tracebuf *tb, int rd) int
latexCorrespondingSend (struct tracebuf *tb, int rd)
{ {
int labelMatch = 0; int labelMatch = 0;
@ -385,16 +422,17 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
int sendEvent = -1; int sendEvent = -1;
int bestSendEvent = -1; int bestSendEvent = -1;
for (sendEvent = readEvent; sendEvent >= 0; sendEvent--) { for (sendEvent = readEvent; sendEvent >= 0; sendEvent--)
if (tb->event[sendEvent]->type == SEND) { {
if (tb->event[sendEvent]->type == SEND)
{
/* do all the different kind of matchings first */ /* do all the different kind of matchings first */
labelMatch = labelMatch =
isTermEqual (tb->event[sendEvent]->label, isTermEqual (tb->event[sendEvent]->label,
tb->event[readEvent]->label); tb->event[readEvent]->label);
toMatch = toMatch =
isTermEqual(tb->event[sendEvent]->to, isTermEqual (tb->event[sendEvent]->to, tb->event[readEvent]->to);
tb->event[readEvent]->to);
fromMatch = fromMatch =
isTermEqual (tb->event[sendEvent]->from, isTermEqual (tb->event[sendEvent]->from,
tb->event[readEvent]->from); tb->event[readEvent]->from);
@ -407,27 +445,34 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
nMatches = labelMatch + tofromMatch + messageMatch; nMatches = labelMatch + tofromMatch + messageMatch;
if (nMatches == 3) { if (nMatches == 3)
{
/* bingo! success on all matches */ /* bingo! success on all matches */
//printf("Found perfect match: %d\n", s); //printf("Found perfect match: %d\n", s);
bestSendEvent = sendEvent; bestSendEvent = sendEvent;
break; break;
} }
if (nMatches > maxNMatches) { if (nMatches > maxNMatches)
if (labelMatch && messageMatch) { {
if (labelMatch && messageMatch)
{
/* strongest restriction: message and label should match */ /* strongest restriction: message and label should match */
maxNMatches = nMatches; maxNMatches = nMatches;
bestSendEvent = sendEvent; bestSendEvent = sendEvent;
} else if (messageMatch) { }
else if (messageMatch)
{
/* if label AND message don't match: */ /* if label AND message don't match: */
/* at least message should match */ /* at least message should match */
maxNMatches = nMatches; maxNMatches = nMatches;
bestSendEvent = sendEvent; bestSendEvent = sendEvent;
} else if (labelMatch) { }
else if (labelMatch)
{
/* if message doesn't match */ /* if message doesn't match */
/* the label should matches */ /* the label should matches */
@ -439,15 +484,19 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
} }
//bestSendEvent = NULL; //bestSendEvent = NULL;
if (bestSendEvent == -1) { if (bestSendEvent == -1)
{
int u; int u;
for (u = 0; u < rd; u++) { for (u = 0; u < rd; u++)
if (tb->event[u]->type == SEND) { {
if (tb->event[u]->type == SEND)
{
//knowledgePrint(sys->traceKnow[u]); //knowledgePrint(sys->traceKnow[u]);
if (inKnowledge if (inKnowledge
(tb->know[u + 1], tb->event[readEvent]->message)) { (tb->know[u + 1], tb->event[readEvent]->message))
{
bestSendEvent = u; bestSendEvent = u;
break; break;
} }
@ -455,7 +504,8 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
} }
} }
if (bestSendEvent == -1) { if (bestSendEvent == -1)
{
printf ("%% Could not find a matching SEND\n"); printf ("%% Could not find a matching SEND\n");
} }
return bestSendEvent; return bestSendEvent;
@ -493,7 +543,8 @@ newInKnowledge (const Knowledge know, Term term)
return 0; /* unrecognized term type, weird */ return 0; /* unrecognized term type, weird */
} }
int latexCorrespondingSend2(struct tracebuf *tb, int readEvent) int
latexCorrespondingSend2 (struct tracebuf *tb, int readEvent)
{ {
int u; int u;
@ -521,7 +572,8 @@ int latexCorrespondingSend2(struct tracebuf *tb, int readEvent)
* Display knowledge in LaTeX format. * Display knowledge in LaTeX format.
*/ */
void knowledgePrintLatex(Knowledge know) void
knowledgePrintLatex (Knowledge know)
{ {
Termlist tl; Termlist tl;
@ -537,7 +589,8 @@ void knowledgePrintLatex(Knowledge know)
} }
} }
void attackDisplayLatex(System sys) void
attackDisplayLatex (System sys)
{ {
int i; int i;
struct tracebuf *tb; struct tracebuf *tb;
@ -553,7 +606,8 @@ void attackDisplayLatex(System sys)
int bestSend; int bestSend;
tb = sys->attack; tb = sys->attack;
if (tb == NULL) { if (tb == NULL)
{
printf ("Attack pointer empty: nothing to display.\n"); printf ("Attack pointer empty: nothing to display.\n");
exit (1); exit (1);
} }
@ -619,12 +673,14 @@ void attackDisplayLatex(System sys)
sizeof (struct traceinfo)); sizeof (struct traceinfo));
width = 1; width = 1;
for (i = 0; i < tb->length; i++) { for (i = 0; i < tb->length; i++)
{
if (tb->run[i] >= width) if (tb->run[i] >= width)
width = tb->run[i] + 1; width = tb->run[i] + 1;
} }
for (i = 0; i < tb->length; i++) { for (i = 0; i < tb->length; i++)
{
tb->link[i] = -1; tb->link[i] = -1;
tinfo[i].match = -1; tinfo[i].match = -1;
tinfo[i].position = i; tinfo[i].position = i;
@ -633,7 +689,8 @@ void attackDisplayLatex(System sys)
tinfo[i].position = i; tinfo[i].position = i;
runPosition = (int *) memAlloc (width * sizeof (int)); runPosition = (int *) memAlloc (width * sizeof (int));
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
runPosition[i] = 0; runPosition[i] = 0;
} }
for (i = tb->length - 1; i >= 0; i--) for (i = tb->length - 1; i >= 0; i--)
@ -652,7 +709,9 @@ void attackDisplayLatex(System sys)
} }
if (tb->event[i]->type == CLAIM) if (tb->event[i]->type == CLAIM)
{ {
claimDetails = claimViolationDetails(sys, tb->run[i], tb->event[i], tb->know[i]); claimDetails =
claimViolationDetails (sys, tb->run[i], tb->event[i],
tb->know[i]);
} }
} }
} }
@ -673,21 +732,27 @@ void attackDisplayLatex(System sys)
eventSize = 1; eventSize = 1;
currRun = tb->run[i]; currRun = tb->run[i];
switch (tb->event[i]->type) { switch (tb->event[i]->type)
{
case SEND: case SEND:
position++; position++;
tinfo[i].position++; tinfo[i].position++;
break; break;
case READ: case READ:
if (tb->link[i] != -1) { if (tb->link[i] != -1)
if (termDistance(tb->event[i]->message,tb->event[tb->link[i]]->message) < LINKTHRESHOLD) {
if (termDistance
(tb->event[i]->message,
tb->event[tb->link[i]]->message) < LINKTHRESHOLD)
{ {
/* disconnect read-send */ /* disconnect read-send */
tb->link[tb->link[i]] = -1; tb->link[tb->link[i]] = -1;
tb->link[i] = -1; tb->link[i] = -1;
} else { }
if (runPosition[currRun] <= tinfo[tb->link[i]].position && else
currRun != tb->run[tb->link[i]]) {
if (runPosition[currRun] <= tinfo[tb->link[i]].position
&& currRun != tb->run[tb->link[i]])
{ {
printf ("\\comment{\n"); printf ("\\comment{\n");
termPrint (tb->event[i]->message); termPrint (tb->event[i]->message);
@ -696,21 +761,26 @@ void attackDisplayLatex(System sys)
printf ("\n"); printf ("\n");
printf ("%% termDistance: %f\n", printf ("%% termDistance: %f\n",
termDistance (tb->event[i]->message, termDistance (tb->event[i]->message,
tb->event[tb->link[i]]->message)); tb->event[tb->link[i]]->
message));
printf ("}\n"); printf ("}\n");
tinfo[i].position = tinfo[tb->link[i]].position; tinfo[i].position = tinfo[tb->link[i]].position;
eventSize = 0; eventSize = 0;
} }
} }
} }
if (tb->event[i]->internal) { if (tb->event[i]->internal)
{
eventSize = 0; eventSize = 0;
} }
break; break;
case CLAIM: case CLAIM:
if (claimDetails != NULL && claimDetails != (Termlist) -1) { if (claimDetails != NULL && claimDetails != (Termlist) - 1)
{
eventSize = 2; eventSize = 2;
} else { }
else
{
eventSize = 0; eventSize = 0;
} }
break; break;
@ -725,7 +795,8 @@ void attackDisplayLatex(System sys)
} }
latexMSCStart (); latexMSCStart ();
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
if (runPosition[i] > 0) if (runPosition[i] > 0)
latexDeclInst (sys, i); latexDeclInst (sys, i);
} }
@ -742,7 +813,8 @@ void attackDisplayLatex(System sys)
{ {
position = tinfo[i].position; position = tinfo[i].position;
} }
switch (tb->event[i]->type) { switch (tb->event[i]->type)
{
case SEND: case SEND:
newtl = knowledgeNew (tb->know[i], tb->know[i + 1]); newtl = knowledgeNew (tb->know[i], tb->know[i + 1]);
highlights = NULL; highlights = NULL;
@ -759,29 +831,36 @@ void attackDisplayLatex(System sys)
} }
tl = tl->next; tl = tl->next;
} }
printf("\\msccomment[4ex]{$I_%d=I_%d\\oplus ", cKnowledge + 1, printf ("\\msccomment[4ex]{$I_%d=I_%d\\oplus ",
cKnowledge); cKnowledge + 1, cKnowledge);
cKnowledge++; cKnowledge++;
latexTermlistPrint (newtl, highlights); latexTermlistPrint (newtl, highlights);
printf ("$}{envright}\n"); printf ("$}{envright}\n");
} }
if (tb->link[i] != -1 && i < tb->length) { if (tb->link[i] != -1 && i < tb->length)
{
latexMessagePrintHighlight (tb, i, tb->link[i], highlights); latexMessagePrintHighlight (tb, i, tb->link[i], highlights);
} else { }
else
{
latexMessagePrintHighlight (tb, i, -1, highlights); //lost message latexMessagePrintHighlight (tb, i, -1, highlights); //lost message
} }
termlistDelete (highlights); termlistDelete (highlights);
break; break;
case READ: case READ:
if (tb->event[i]->internal) { if (tb->event[i]->internal)
} else if (tb->link[i] == -1) { {
}
else if (tb->link[i] == -1)
{
latexMessagePrint (tb, -1, i); //found message latexMessagePrint (tb, -1, i); //found message
} }
break; break;
case CLAIM: case CLAIM:
if (claimDetails != NULL && claimDetails != (Termlist) -1) { if (claimDetails != NULL && claimDetails != (Termlist) - 1)
{
latexClaim (tb, tb->run[i], claimDetails); latexClaim (tb, tb->run[i], claimDetails);
} }
break; break;

View File

@ -12,17 +12,20 @@
#include "latex.h" #include "latex.h"
void linePrint(int i) void
linePrint (int i)
{ {
indent (); indent ();
while (i > 0) { while (i > 0)
{
printf ("--------"); printf ("--------");
i--; i--;
} }
printf ("\n"); printf ("\n");
} }
int correspondingSend(System sys, int rd) int
correspondingSend (System sys, int rd)
{ {
int labelMatch = 0; int labelMatch = 0;
@ -37,8 +40,10 @@ int correspondingSend(System sys, int rd)
int sendEvent = -1; int sendEvent = -1;
int bestSendEvent = -1; int bestSendEvent = -1;
for (sendEvent = readEvent; sendEvent >= 0; sendEvent--) { for (sendEvent = readEvent; sendEvent >= 0; sendEvent--)
if (sys->traceEvent[sendEvent]->type == SEND) { {
if (sys->traceEvent[sendEvent]->type == SEND)
{
/* do all the different kind of matchings first */ /* do all the different kind of matchings first */
labelMatch = labelMatch =
@ -59,14 +64,16 @@ int correspondingSend(System sys, int rd)
nMatches = labelMatch + tofromMatch + messageMatch; nMatches = labelMatch + tofromMatch + messageMatch;
if (nMatches == 3) { if (nMatches == 3)
{
/* bingo! success on all matches */ /* bingo! success on all matches */
//printf("Found perfect match: %d\n", s); //printf("Found perfect match: %d\n", s);
bestSendEvent = sendEvent; bestSendEvent = sendEvent;
break; break;
} }
if (nMatches > maxNMatches) { if (nMatches > maxNMatches)
{
/* if we found a better candidate than we already had, we'll update */ /* if we found a better candidate than we already had, we'll update */
//printf("Comparing SEND #%d: ",s); //printf("Comparing SEND #%d: ",s);
@ -78,19 +85,24 @@ int correspondingSend(System sys, int rd)
/* however, we first want to be sure that at least some matches are successful */ /* however, we first want to be sure that at least some matches are successful */
if (labelMatch && messageMatch) { if (labelMatch && messageMatch)
{
/* strongest restriction: message and label should match */ /* strongest restriction: message and label should match */
maxNMatches = nMatches; maxNMatches = nMatches;
bestSendEvent = sendEvent; bestSendEvent = sendEvent;
} else if (messageMatch) { }
else if (messageMatch)
{
/* if label AND message don't match: */ /* if label AND message don't match: */
/* at least message should match */ /* at least message should match */
maxNMatches = nMatches; maxNMatches = nMatches;
bestSendEvent = sendEvent; bestSendEvent = sendEvent;
} else if (labelMatch) { }
else if (labelMatch)
{
/* if message doesn't match */ /* if message doesn't match */
/* the label should matches */ /* the label should matches */
@ -103,7 +115,8 @@ int correspondingSend(System sys, int rd)
} }
//bestSendEvent = NULL; //bestSendEvent = NULL;
if (bestSendEvent == -1) { if (bestSendEvent == -1)
{
/*Termlist tl; /*Termlist tl;
Term t; Term t;
@ -133,8 +146,10 @@ int correspondingSend(System sys, int rd)
int u; int u;
for (u = 0; u < rd; u++) { for (u = 0; u < rd; u++)
if (sys->traceEvent[u]->type == SEND) { {
if (sys->traceEvent[u]->type == SEND)
{
//termPrint(readEvent->message); //termPrint(readEvent->message);
@ -143,7 +158,8 @@ int correspondingSend(System sys, int rd)
//printf("Is received message in knowledge after SEND %d? %d\n", u, inKnowledge(sys->traceKnow[u+1],readEvent->message)); //printf("Is received message in knowledge after SEND %d? %d\n", u, inKnowledge(sys->traceKnow[u+1],readEvent->message));
if (inKnowledge if (inKnowledge
(sys->traceKnow[u + 1], (sys->traceKnow[u + 1],
sys->traceEvent[readEvent]->message)) { sys->traceEvent[readEvent]->message))
{
bestSendEvent = u; bestSendEvent = u;
break; break;
} }
@ -151,22 +167,27 @@ int correspondingSend(System sys, int rd)
} }
} }
if (bestSendEvent == -1) { if (bestSendEvent == -1)
{
printf ("!! Could not find a matching SEND\n"); printf ("!! Could not find a matching SEND\n");
} else { }
else
{
//latexMessagePrint(sys, bestSendEvent, readEvent); //latexMessagePrint(sys, bestSendEvent, readEvent);
//printf("Latex: "); //printf("Latex: ");
//termPrint(bestSendEvent->from); //termPrint(bestSendEvent->from);
//printf(" -> "); //printf(" -> ");
if (!isTermEqualFn if (!isTermEqualFn
(sys->traceEvent[bestSendEvent]->to, (sys->traceEvent[bestSendEvent]->to,
sys->traceEvent[readEvent]->to)) { sys->traceEvent[readEvent]->to))
{
//termPrint(bestSendEvent->to); //termPrint(bestSendEvent->to);
//printf(" -> "); //printf(" -> ");
} }
if (!isTermEqualFn if (!isTermEqualFn
(sys->traceEvent[bestSendEvent]->from, (sys->traceEvent[bestSendEvent]->from,
sys->traceEvent[readEvent]->from)) { sys->traceEvent[readEvent]->from))
{
//termPrint(readEvent->from); //termPrint(readEvent->from);
//printf(" -> "); //printf(" -> ");
} }
@ -176,9 +197,11 @@ int correspondingSend(System sys, int rd)
return bestSendEvent; return bestSendEvent;
} }
void tracePrint(System sys) void
tracePrint (System sys)
{
if (sys->latex)
{ {
if (sys->latex) {
//latexTracePrint(sys); //latexTracePrint(sys);
return; return;
} }
@ -197,7 +220,8 @@ void tracePrint(System sys)
/* how wide is the trace? */ /* how wide is the trace? */
width = 0; width = 0;
for (i = 0; i <= sys->step; i++) { for (i = 0; i <= sys->step; i++)
{
if (sys->traceRun[i] >= width) if (sys->traceRun[i] >= width)
width = sys->traceRun[i] + 1; width = sys->traceRun[i] + 1;
} }
@ -224,18 +248,21 @@ void tracePrint(System sys)
linePrint (width); linePrint (width);
indent (); indent ();
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
termPrint (sys->runs[i].role->nameterm); termPrint (sys->runs[i].role->nameterm);
printf ("#%i\t", i); printf ("#%i\t", i);
} }
printf ("\n"); printf ("\n");
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
termPrint (agentOfRun (sys, i)); termPrint (agentOfRun (sys, i));
printf ("\t"); printf ("\t");
} }
printf ("\n"); printf ("\n");
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
agentsOfRunPrint (sys, i); agentsOfRunPrint (sys, i);
printf ("\t"); printf ("\t");
} }
@ -243,25 +270,30 @@ void tracePrint(System sys)
/* now we print the actual trace */ /* now we print the actual trace */
void sticks(int i) { void sticks (int i)
while (i > 0) { {
while (i > 0)
{
printf ("|\t"); printf ("|\t");
i--; i--;
} }
} }
void sticksLine(void) { void sticksLine (void)
{
sticks (width); sticks (width);
printf ("\n"); printf ("\n");
} }
linePrint (width); linePrint (width);
lastrid = -1; lastrid = -1;
for (i = 0; i <= sys->step; i++) { for (i = 0; i <= sys->step; i++)
{
/* yields extra newlines between switching of runs */ /* yields extra newlines between switching of runs */
j = sys->traceRun[i]; j = sys->traceRun[i];
if (j != lastrid) { if (j != lastrid)
{
sticksLine (); sticksLine ();
lastrid = j; lastrid = j;
} }
@ -283,7 +315,8 @@ void tracePrint(System sys)
/* have we learnt anything new? */ /* have we learnt anything new? */
newtl = knowledgeNew (sys->traceKnow[i], sys->traceKnow[i + 1]); newtl = knowledgeNew (sys->traceKnow[i], sys->traceKnow[i + 1]);
if (newtl != NULL) { if (newtl != NULL)
{
printf ("\n"); printf ("\n");
sticksLine (); sticksLine ();
sticks (width); sticks (width);
@ -298,7 +331,8 @@ void tracePrint(System sys)
printf ("\n"); printf ("\n");
} }
switch (sys->clp) { switch (sys->clp)
{
case 1: case 1:
indent (); indent ();
printf ("---[ constraints ]-----\n"); printf ("---[ constraints ]-----\n");
@ -312,7 +346,8 @@ void tracePrint(System sys)
void attackDisplayAscii(System sys) void
attackDisplayAscii (System sys)
{ {
int i, j; int i, j;
int length; int length;
@ -330,7 +365,8 @@ void attackDisplayAscii(System sys)
/* how wide is the trace? */ /* how wide is the trace? */
width = 0; width = 0;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++)
{
if (tb->run[i] >= width) if (tb->run[i] >= width)
width = tb->run[i] + 1; width = tb->run[i] + 1;
} }
@ -355,18 +391,21 @@ void attackDisplayAscii(System sys)
linePrint (width); linePrint (width);
indent (); indent ();
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
termPrint (sys->runs[i].role->nameterm); termPrint (sys->runs[i].role->nameterm);
printf ("#%i\t", i); printf ("#%i\t", i);
} }
printf ("\n"); printf ("\n");
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
termPrint (agentOfRun (sys, i)); termPrint (agentOfRun (sys, i));
printf ("\t"); printf ("\t");
} }
printf ("\n"); printf ("\n");
for (i = 0; i < width; i++) { for (i = 0; i < width; i++)
{
agentsOfRunPrint (sys, i); agentsOfRunPrint (sys, i);
printf ("\t"); printf ("\t");
} }
@ -374,25 +413,30 @@ void attackDisplayAscii(System sys)
/* now we print the actual trace */ /* now we print the actual trace */
void sticks(int i) { void sticks (int i)
while (i > 0) { {
while (i > 0)
{
printf ("|\t"); printf ("|\t");
i--; i--;
} }
} }
void sticksLine(void) { void sticksLine (void)
{
sticks (width); sticks (width);
printf ("\n"); printf ("\n");
} }
linePrint (width); linePrint (width);
lastrid = -1; lastrid = -1;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++)
{
/* yields extra newlines between switching of runs */ /* yields extra newlines between switching of runs */
j = tb->run[i]; j = tb->run[i];
if (j != lastrid) { if (j != lastrid)
{
sticksLine (); sticksLine ();
lastrid = j; lastrid = j;
} }
@ -414,7 +458,8 @@ void attackDisplayAscii(System sys)
/* have we learnt anything new? */ /* have we learnt anything new? */
newtl = knowledgeNew (tb->know[i], tb->know[i + 1]); newtl = knowledgeNew (tb->know[i], tb->know[i + 1]);
if (newtl != NULL) { if (newtl != NULL)
{
printf ("\n"); printf ("\n");
sticksLine (); sticksLine ();
sticks (width); sticks (width);
@ -433,11 +478,15 @@ void attackDisplayAscii(System sys)
} }
void attackDisplay(System sys) void
attackDisplay (System sys)
{
if (sys->latex)
{ {
if (sys->latex) {
attackDisplayLatex (sys); attackDisplayLatex (sys);
} else { }
else
{
attackDisplayAscii (sys); attackDisplayAscii (sys);
} }
} }