- Re-indented the output and latex files.
This commit is contained in:
parent
0f4e6a5aba
commit
6efcbdea62
543
src/latex.c
543
src/latex.c
@ -23,7 +23,8 @@ extern Term TERM_Function;
|
||||
|
||||
/* struct for additional info */
|
||||
|
||||
struct traceinfo {
|
||||
struct traceinfo
|
||||
{
|
||||
int match;
|
||||
int position;
|
||||
};
|
||||
@ -37,36 +38,38 @@ int *runPerm;
|
||||
|
||||
/* code */
|
||||
|
||||
void latexInit(const System sys, int argc, char **argv)
|
||||
void
|
||||
latexInit (const System sys, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("\\documentclass{article}\n");
|
||||
printf("\\usepackage{msc}\n");
|
||||
printf("%%\n");
|
||||
printf("%% LaTeX output generated by %s\n", progname);
|
||||
printf("%% Input:\n");
|
||||
printf ("\\documentclass{article}\n");
|
||||
printf ("\\usepackage{msc}\n");
|
||||
printf ("%%\n");
|
||||
printf ("%% LaTeX output generated by %s\n", progname);
|
||||
printf ("%% Input:\n");
|
||||
|
||||
/* print command line */
|
||||
printf("%% $");
|
||||
printf ("%% $");
|
||||
for (i = 0; i < argc; i++)
|
||||
printf(" %s", argv[i]);
|
||||
printf("\n");
|
||||
printf (" %s", argv[i]);
|
||||
printf ("\n");
|
||||
|
||||
printf("%%\n");
|
||||
printf("\\begin{document}\n\n");
|
||||
printf ("%%\n");
|
||||
printf ("\\begin{document}\n\n");
|
||||
|
||||
/* comment macro (used for debugging) */
|
||||
printf("\\newcommand{\\comment}[1]{}\n");
|
||||
printf ("\\newcommand{\\comment}[1]{}\n");
|
||||
|
||||
/* preamble */
|
||||
printf("\\input{preamble}\n");
|
||||
printf ("\\input{preamble}\n");
|
||||
}
|
||||
|
||||
void latexDone(const System sys)
|
||||
void
|
||||
latexDone (const System sys)
|
||||
{
|
||||
printf("\\input{postamble}\n");
|
||||
printf("\n\\end{document}\n\n");
|
||||
printf ("\\input{postamble}\n");
|
||||
printf ("\n\\end{document}\n\n");
|
||||
}
|
||||
|
||||
void
|
||||
@ -87,8 +90,8 @@ latexTermPrint (Term term, Termlist highlight)
|
||||
#endif
|
||||
if (realTermLeaf (term))
|
||||
{
|
||||
if (inTermlist(highlight, term))
|
||||
printf("\\mathbf{");
|
||||
if (inTermlist (highlight, term))
|
||||
printf ("\\mathbf{");
|
||||
symbolPrint (term->symb);
|
||||
if (realTermVariable (term))
|
||||
printf ("V");
|
||||
@ -101,8 +104,8 @@ latexTermPrint (Term term, Termlist highlight)
|
||||
printf ("\\rightarrow");
|
||||
latexTermPrint (term->subst, highlight);
|
||||
}
|
||||
if (inTermlist(highlight, term))
|
||||
printf("}");
|
||||
if (inTermlist (highlight, term))
|
||||
printf ("}");
|
||||
}
|
||||
if (realTermTuple (term))
|
||||
{
|
||||
@ -156,35 +159,37 @@ latexTermlistPrint (Termlist tl, Termlist highlight)
|
||||
latexTermPrint (tl->term, highlight);
|
||||
tl = tl->next;
|
||||
if (tl != NULL)
|
||||
printf(", ");
|
||||
printf (", ");
|
||||
}
|
||||
printf ("]");
|
||||
}
|
||||
|
||||
void latexTimers(const System sys)
|
||||
void
|
||||
latexTimers (const System sys)
|
||||
{
|
||||
void endline(void) {
|
||||
printf("\\\\ \\hline\n");
|
||||
void endline (void)
|
||||
{
|
||||
printf ("\\\\ \\hline\n");
|
||||
}
|
||||
|
||||
printf("\\begin{tabular}{|r|r|c|r|} \\hline\n");
|
||||
printf ("\\begin{tabular}{|r|r|c|r|} \\hline\n");
|
||||
|
||||
/* display stats, header first */
|
||||
|
||||
printf("Time & States & Attack & st/sec");
|
||||
endline();
|
||||
printf ("Time & States & Attack & st/sec");
|
||||
endline ();
|
||||
|
||||
/* print time */
|
||||
|
||||
double seconds;
|
||||
seconds = (double) clock() / CLOCKS_PER_SEC;
|
||||
printf("$%.3e$ &", seconds);
|
||||
seconds = (double) clock () / CLOCKS_PER_SEC;
|
||||
printf ("$%.3e$ &", seconds);
|
||||
|
||||
/* states traversed */
|
||||
|
||||
printf("$");
|
||||
statesPrintShort(sys);
|
||||
printf("$ &");
|
||||
printf ("$");
|
||||
statesPrintShort (sys);
|
||||
printf ("$ &");
|
||||
|
||||
/* flag
|
||||
*
|
||||
@ -193,13 +198,16 @@ void latexTimers(const System sys)
|
||||
* NoClaim no claims
|
||||
*/
|
||||
|
||||
if (sys->claims == 0) {
|
||||
printf("NoClaim & ");
|
||||
} else {
|
||||
if (sys->failed > 0)
|
||||
printf("L:%i & ", attackLength(sys->attack));
|
||||
if (sys->claims == 0)
|
||||
{
|
||||
printf ("NoClaim & ");
|
||||
}
|
||||
else
|
||||
printf("None & ");
|
||||
{
|
||||
if (sys->failed > 0)
|
||||
printf ("L:%i & ", attackLength (sys->attack));
|
||||
else
|
||||
printf ("None & ");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -211,166 +219,195 @@ void latexTimers(const System sys)
|
||||
|
||||
/* states per second */
|
||||
|
||||
if (seconds > 0) {
|
||||
printf("$%.3e$ ",
|
||||
if (seconds > 0)
|
||||
{
|
||||
printf ("$%.3e$ ",
|
||||
(double) (sys->statesLow +
|
||||
(sys->statesHigh * ULONG_MAX)) / seconds);
|
||||
} else {
|
||||
printf("$\\infty$ ");
|
||||
}
|
||||
endline();
|
||||
else
|
||||
{
|
||||
printf ("$\\infty$ ");
|
||||
}
|
||||
endline ();
|
||||
|
||||
printf("\\end{tabular}\n\n");
|
||||
printf ("\\end{tabular}\n\n");
|
||||
}
|
||||
|
||||
void latexMSCStart()
|
||||
void
|
||||
latexMSCStart ()
|
||||
{
|
||||
if (landscape)
|
||||
printf("\\begin{landscape}\n");
|
||||
printf ("\\begin{landscape}\n");
|
||||
|
||||
printf("\\begin{msc}{attack}\n");
|
||||
printf ("\\begin{msc}{attack}\n");
|
||||
}
|
||||
|
||||
void latexMSCEnd()
|
||||
void
|
||||
latexMSCEnd ()
|
||||
{
|
||||
printf("\\end{msc}\n");
|
||||
printf ("\\end{msc}\n");
|
||||
|
||||
if (landscape)
|
||||
printf("\\end{landscape}\n");
|
||||
printf ("\\end{landscape}\n");
|
||||
|
||||
}
|
||||
|
||||
void latexDeclInst(const System sys, int run)
|
||||
void
|
||||
latexDeclInst (const System sys, int run)
|
||||
{
|
||||
Term bar = NULL;
|
||||
|
||||
bar = agentOfRun(sys, run);
|
||||
printf("\\declinst{run%d}{$", run);
|
||||
termPrint(bar);
|
||||
printf("\\sharp%i$}{$", run);
|
||||
agentsOfRunPrint(sys, run);
|
||||
printf("$}\n");
|
||||
bar = agentOfRun (sys, run);
|
||||
printf ("\\declinst{run%d}{$", run);
|
||||
termPrint (bar);
|
||||
printf ("\\sharp%i$}{$", run);
|
||||
agentsOfRunPrint (sys, run);
|
||||
printf ("$}\n");
|
||||
}
|
||||
|
||||
void latexEventSpace(int amount)
|
||||
void
|
||||
latexEventSpace (int amount)
|
||||
{
|
||||
int i;
|
||||
//printf("%% number of newlines: %d\n",amount);
|
||||
for (i = 0; i < EVENTSPACE * amount; i++)
|
||||
printf("\\nextlevel\n");
|
||||
printf ("\\nextlevel\n");
|
||||
}
|
||||
|
||||
|
||||
void latexMessagePrint(struct tracebuf *tb, int from, int to)
|
||||
void
|
||||
latexMessagePrint (struct tracebuf *tb, int from, int to)
|
||||
{
|
||||
|
||||
Term sendTerm = NULL;
|
||||
Term readTerm = NULL;
|
||||
|
||||
if (from == -1 && to == -1) {
|
||||
if (from == -1 && to == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (from != -1) {
|
||||
if (from != -1)
|
||||
{
|
||||
sendTerm = tb->event[from]->message;
|
||||
}
|
||||
if (to != -1) {
|
||||
if (to != -1)
|
||||
{
|
||||
readTerm = tb->event[to]->message;
|
||||
}
|
||||
if (from == -1 && to != -1) {
|
||||
printf("\\found{$");
|
||||
termPrint(readTerm);
|
||||
printf("$}{}{run%d}\n", tb->run[to]);
|
||||
} else if (from != -1 && to == -1) {
|
||||
printf("\\lost{$");
|
||||
termPrint(sendTerm);
|
||||
printf("$}{}{run%d}\n", tb->run[from]);
|
||||
} else if (from != -1 && to != -1) {
|
||||
if (from == -1 && to != -1)
|
||||
{
|
||||
printf ("\\found{$");
|
||||
termPrint (readTerm);
|
||||
printf ("$}{}{run%d}\n", tb->run[to]);
|
||||
}
|
||||
else if (from != -1 && to == -1)
|
||||
{
|
||||
printf ("\\lost{$");
|
||||
termPrint (sendTerm);
|
||||
printf ("$}{}{run%d}\n", tb->run[from]);
|
||||
}
|
||||
else if (from != -1 && to != -1)
|
||||
{
|
||||
|
||||
printf("\\mess{$");
|
||||
printf ("\\mess{$");
|
||||
|
||||
termPrint(sendTerm);
|
||||
termPrint (sendTerm);
|
||||
|
||||
if (!isTermEqual(sendTerm, readTerm)) {
|
||||
printf("\\rightarrow");
|
||||
termPrint(readTerm);
|
||||
if (!isTermEqual (sendTerm, readTerm))
|
||||
{
|
||||
printf ("\\rightarrow");
|
||||
termPrint (readTerm);
|
||||
}
|
||||
|
||||
printf("$}{run%d", tb->run[from]);
|
||||
printf("}{run%d}[%d]", tb->run[to],
|
||||
EVENTSPACE * (tinfo[to].position -
|
||||
tinfo[from].position));
|
||||
printf ("$}{run%d", tb->run[from]);
|
||||
printf ("}{run%d}[%d]", tb->run[to],
|
||||
EVENTSPACE * (tinfo[to].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 readTerm = NULL;
|
||||
|
||||
if (from == -1 && to == -1) {
|
||||
if (from == -1 && to == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (from != -1) {
|
||||
if (from != -1)
|
||||
{
|
||||
sendTerm = tb->event[from]->message;
|
||||
}
|
||||
if (to != -1) {
|
||||
if (to != -1)
|
||||
{
|
||||
readTerm = tb->event[to]->message;
|
||||
}
|
||||
if (from == -1 && to != -1) {
|
||||
printf("\\found{$");
|
||||
latexTermPrint(readTerm, highlight);
|
||||
printf("$}{}{run%d}\n", tb->run[to]);
|
||||
} else if (from != -1 && to == -1) {
|
||||
printf("\\lost{$");
|
||||
latexTermPrint(sendTerm, highlight);
|
||||
printf("$}{}{run%d}\n", tb->run[from]);
|
||||
} else if (from != -1 && to != -1) {
|
||||
if (from == -1 && to != -1)
|
||||
{
|
||||
printf ("\\found{$");
|
||||
latexTermPrint (readTerm, highlight);
|
||||
printf ("$}{}{run%d}\n", tb->run[to]);
|
||||
}
|
||||
else if (from != -1 && to == -1)
|
||||
{
|
||||
printf ("\\lost{$");
|
||||
latexTermPrint (sendTerm, highlight);
|
||||
printf ("$}{}{run%d}\n", tb->run[from]);
|
||||
}
|
||||
else if (from != -1 && to != -1)
|
||||
{
|
||||
|
||||
printf("\\mess{$");
|
||||
printf ("\\mess{$");
|
||||
|
||||
latexTermPrint(sendTerm, highlight);
|
||||
latexTermPrint (sendTerm, highlight);
|
||||
|
||||
if (!isTermEqual(sendTerm, readTerm)) {
|
||||
printf("\\rightarrow");
|
||||
latexTermPrint(readTerm, highlight);
|
||||
if (!isTermEqual (sendTerm, readTerm))
|
||||
{
|
||||
printf ("\\rightarrow");
|
||||
latexTermPrint (readTerm, highlight);
|
||||
}
|
||||
|
||||
printf("$}{run%d", tb->run[from]);
|
||||
printf("}{run%d}[%d]", tb->run[to],
|
||||
EVENTSPACE * (tinfo[to].position -
|
||||
tinfo[from].position));
|
||||
printf ("$}{run%d", tb->run[from]);
|
||||
printf ("}{run%d}[%d]", tb->run[to],
|
||||
EVENTSPACE * (tinfo[to].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,
|
||||
index);
|
||||
termlistPrint(tl);
|
||||
printf("$}{envright}\n");
|
||||
printf ("\\msccomment[4ex]{$I_%d=I_%d\\oplus ", index + 1, index);
|
||||
termlistPrint (tl);
|
||||
printf ("$}{envright}\n");
|
||||
}
|
||||
|
||||
void latexAction(struct tracebuf *tb, int te)
|
||||
void
|
||||
latexAction (struct tracebuf *tb, int te)
|
||||
{
|
||||
printf("\\action{$");
|
||||
termPrint(tb->event[te]->message);
|
||||
printf("$}{run%d}\n", tb->run[te]);
|
||||
printf ("\\action{$");
|
||||
termPrint (tb->event[te]->message);
|
||||
printf ("$}{run%d}\n", tb->run[te]);
|
||||
//printf("\\nextlevel\n");
|
||||
}
|
||||
|
||||
void latexClaim(struct tracebuf *tb, int run, Termlist tl)
|
||||
void
|
||||
latexClaim (struct tracebuf *tb, int run, Termlist tl)
|
||||
{
|
||||
printf("\\condition{$");
|
||||
printf("\\neg secret ");
|
||||
termlistPrint(tl);
|
||||
printf("$}{run%d}\n", run);
|
||||
printf ("\\condition{$");
|
||||
printf ("\\neg secret ");
|
||||
termlistPrint (tl);
|
||||
printf ("$}{run%d}\n", run);
|
||||
}
|
||||
|
||||
int latexCorrespondingSend(struct tracebuf *tb, int rd)
|
||||
int
|
||||
latexCorrespondingSend (struct tracebuf *tb, int rd)
|
||||
{
|
||||
|
||||
int labelMatch = 0;
|
||||
@ -385,49 +422,57 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
|
||||
int sendEvent = -1;
|
||||
int bestSendEvent = -1;
|
||||
|
||||
for (sendEvent = readEvent; sendEvent >= 0; sendEvent--) {
|
||||
if (tb->event[sendEvent]->type == SEND) {
|
||||
for (sendEvent = readEvent; sendEvent >= 0; sendEvent--)
|
||||
{
|
||||
if (tb->event[sendEvent]->type == SEND)
|
||||
{
|
||||
/* do all the different kind of matchings first */
|
||||
|
||||
labelMatch =
|
||||
isTermEqual(tb->event[sendEvent]->label,
|
||||
isTermEqual (tb->event[sendEvent]->label,
|
||||
tb->event[readEvent]->label);
|
||||
toMatch =
|
||||
isTermEqual(tb->event[sendEvent]->to,
|
||||
tb->event[readEvent]->to);
|
||||
isTermEqual (tb->event[sendEvent]->to, tb->event[readEvent]->to);
|
||||
fromMatch =
|
||||
isTermEqual(tb->event[sendEvent]->from,
|
||||
isTermEqual (tb->event[sendEvent]->from,
|
||||
tb->event[readEvent]->from);
|
||||
tofromMatch = toMatch || fromMatch;
|
||||
messageMatch =
|
||||
isTermEqual(tb->event[sendEvent]->message,
|
||||
isTermEqual (tb->event[sendEvent]->message,
|
||||
tb->event[readEvent]->message);
|
||||
|
||||
/* calculate the score */
|
||||
|
||||
nMatches = labelMatch + tofromMatch + messageMatch;
|
||||
|
||||
if (nMatches == 3) {
|
||||
if (nMatches == 3)
|
||||
{
|
||||
/* bingo! success on all matches */
|
||||
|
||||
//printf("Found perfect match: %d\n", s);
|
||||
bestSendEvent = sendEvent;
|
||||
break;
|
||||
}
|
||||
if (nMatches > maxNMatches) {
|
||||
if (labelMatch && messageMatch) {
|
||||
if (nMatches > maxNMatches)
|
||||
{
|
||||
if (labelMatch && messageMatch)
|
||||
{
|
||||
/* strongest restriction: message and label should match */
|
||||
|
||||
maxNMatches = nMatches;
|
||||
bestSendEvent = sendEvent;
|
||||
|
||||
} else if (messageMatch) {
|
||||
}
|
||||
else if (messageMatch)
|
||||
{
|
||||
/* if label AND message don't match: */
|
||||
/* at least message should match */
|
||||
|
||||
maxNMatches = nMatches;
|
||||
bestSendEvent = sendEvent;
|
||||
} else if (labelMatch) {
|
||||
}
|
||||
else if (labelMatch)
|
||||
{
|
||||
/* if message doesn't match */
|
||||
/* the label should matches */
|
||||
|
||||
@ -439,15 +484,19 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
|
||||
}
|
||||
|
||||
//bestSendEvent = NULL;
|
||||
if (bestSendEvent == -1) {
|
||||
if (bestSendEvent == -1)
|
||||
{
|
||||
|
||||
int u;
|
||||
|
||||
for (u = 0; u < rd; u++) {
|
||||
if (tb->event[u]->type == SEND) {
|
||||
for (u = 0; u < rd; u++)
|
||||
{
|
||||
if (tb->event[u]->type == SEND)
|
||||
{
|
||||
//knowledgePrint(sys->traceKnow[u]);
|
||||
if (inKnowledge
|
||||
(tb->know[u + 1], tb->event[readEvent]->message)) {
|
||||
(tb->know[u + 1], tb->event[readEvent]->message))
|
||||
{
|
||||
bestSendEvent = u;
|
||||
break;
|
||||
}
|
||||
@ -455,8 +504,9 @@ int latexCorrespondingSend(struct tracebuf *tb, int rd)
|
||||
}
|
||||
}
|
||||
|
||||
if (bestSendEvent == -1) {
|
||||
printf("%% Could not find a matching SEND\n");
|
||||
if (bestSendEvent == -1)
|
||||
{
|
||||
printf ("%% Could not find a matching SEND\n");
|
||||
}
|
||||
return bestSendEvent;
|
||||
}
|
||||
@ -493,11 +543,12 @@ newInKnowledge (const Knowledge know, Term term)
|
||||
return 0; /* unrecognized term type, weird */
|
||||
}
|
||||
|
||||
int latexCorrespondingSend2(struct tracebuf *tb, int readEvent)
|
||||
int
|
||||
latexCorrespondingSend2 (struct tracebuf *tb, int readEvent)
|
||||
{
|
||||
int u;
|
||||
|
||||
for (u = tb->length - 1; u>=0 ; u--)
|
||||
for (u = tb->length - 1; u >= 0; u--)
|
||||
{
|
||||
if (tb->event[u]->type == SEND)
|
||||
{
|
||||
@ -521,23 +572,25 @@ int latexCorrespondingSend2(struct tracebuf *tb, int readEvent)
|
||||
* Display knowledge in LaTeX format.
|
||||
*/
|
||||
|
||||
void knowledgePrintLatex(Knowledge know)
|
||||
void
|
||||
knowledgePrintLatex (Knowledge know)
|
||||
{
|
||||
Termlist tl;
|
||||
|
||||
if (know == NULL)
|
||||
{
|
||||
printf("\\emptyset");
|
||||
printf ("\\emptyset");
|
||||
}
|
||||
else
|
||||
{
|
||||
tl = knowledgeSet(know);
|
||||
termlistPrint(tl);
|
||||
termlistDelete(tl);
|
||||
tl = knowledgeSet (know);
|
||||
termlistPrint (tl);
|
||||
termlistDelete (tl);
|
||||
}
|
||||
}
|
||||
|
||||
void attackDisplayLatex(System sys)
|
||||
void
|
||||
attackDisplayLatex (System sys)
|
||||
{
|
||||
int i;
|
||||
struct tracebuf *tb;
|
||||
@ -553,78 +606,81 @@ void attackDisplayLatex(System sys)
|
||||
int bestSend;
|
||||
|
||||
tb = sys->attack;
|
||||
if (tb == NULL) {
|
||||
printf("Attack pointer empty: nothing to display.\n");
|
||||
exit(1);
|
||||
if (tb == NULL)
|
||||
{
|
||||
printf ("Attack pointer empty: nothing to display.\n");
|
||||
exit (1);
|
||||
}
|
||||
/* set variables */
|
||||
varbufSet (sys, tb->variables);
|
||||
|
||||
/* Rebuild knowledge. Strange, this ought to be good.
|
||||
* Maybe reconstruct dependencies as well. */
|
||||
tracebufRebuildKnow(tb);
|
||||
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");
|
||||
printf ("\n\\comment{ TRACE\n\n");
|
||||
printf ("Length: %i\n", tb->length);
|
||||
printf ("Reallength: %i\n", tb->reallength);
|
||||
printf ("\n");
|
||||
i = 0;
|
||||
while (i <= tb->length)
|
||||
{
|
||||
printf("Knowledge %i:\n",i);
|
||||
knowledgePrint(tb->know[i]);
|
||||
printf(" [Inverses]: ");
|
||||
knowledgeInversesPrint(tb->know[i]);
|
||||
printf("\n\n");
|
||||
printf ("Knowledge %i:\n", i);
|
||||
knowledgePrint (tb->know[i]);
|
||||
printf (" [Inverses]: ");
|
||||
knowledgeInversesPrint (tb->know[i]);
|
||||
printf ("\n\n");
|
||||
if (i < tb->length)
|
||||
{
|
||||
printf("Event %i\t[",i);
|
||||
printf ("Event %i\t[", i);
|
||||
switch (tb->status[i])
|
||||
{
|
||||
case S_UNK:
|
||||
printf("?");
|
||||
printf ("?");
|
||||
break;
|
||||
case S_RED:
|
||||
printf("redundant");
|
||||
printf ("redundant");
|
||||
break;
|
||||
case S_TOD:
|
||||
printf("to do");
|
||||
printf ("to do");
|
||||
break;
|
||||
case S_OKE:
|
||||
printf("okay");
|
||||
printf ("okay");
|
||||
break;
|
||||
default:
|
||||
printf("illegal status code");
|
||||
printf ("illegal status code");
|
||||
break;
|
||||
}
|
||||
printf("]\t");
|
||||
termPrint(tb->event[i]->message);
|
||||
printf("\t#%i",tb->run[i]);
|
||||
printf("\n");
|
||||
roledefPrint(tb->event[i]);
|
||||
printf("\n\n");
|
||||
printf ("]\t");
|
||||
termPrint (tb->event[i]->message);
|
||||
printf ("\t#%i", tb->run[i]);
|
||||
printf ("\n");
|
||||
roledefPrint (tb->event[i]);
|
||||
printf ("\n\n");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
printf("}\n\n");
|
||||
printf ("}\n\n");
|
||||
|
||||
/* display initial knowledge */
|
||||
printf("$I_0 = \\emptyset \\oplus ");
|
||||
knowledgePrintLatex(tb->know[0]);
|
||||
printf("$\n\n");
|
||||
printf ("$I_0 = \\emptyset \\oplus ");
|
||||
knowledgePrintLatex (tb->know[0]);
|
||||
printf ("$\n\n");
|
||||
|
||||
tinfo =
|
||||
(struct traceinfo *) memAlloc((tb->length+1) *
|
||||
sizeof(struct traceinfo));
|
||||
(struct traceinfo *) memAlloc ((tb->length + 1) *
|
||||
sizeof (struct traceinfo));
|
||||
|
||||
width = 1;
|
||||
for (i = 0; i < tb->length; i++) {
|
||||
for (i = 0; i < tb->length; i++)
|
||||
{
|
||||
if (tb->run[i] >= width)
|
||||
width = tb->run[i] + 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < tb->length; i++) {
|
||||
for (i = 0; i < tb->length; i++)
|
||||
{
|
||||
tb->link[i] = -1;
|
||||
tinfo[i].match = -1;
|
||||
tinfo[i].position = i;
|
||||
@ -632,8 +688,9 @@ void attackDisplayLatex(System sys)
|
||||
tinfo[i].match = -1;
|
||||
tinfo[i].position = i;
|
||||
|
||||
runPosition = (int *) memAlloc(width * sizeof(int));
|
||||
for (i = 0; i < width; i++) {
|
||||
runPosition = (int *) memAlloc (width * sizeof (int));
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
runPosition[i] = 0;
|
||||
}
|
||||
for (i = tb->length - 1; i >= 0; i--)
|
||||
@ -642,8 +699,8 @@ void attackDisplayLatex(System sys)
|
||||
{
|
||||
if (tb->event[i]->type == READ && !tb->event[i]->internal)
|
||||
{
|
||||
bestSend = latexCorrespondingSend2(tb, i);
|
||||
printf("%% match: %d <-> %d\n",i, bestSend);
|
||||
bestSend = latexCorrespondingSend2 (tb, i);
|
||||
printf ("%% match: %d <-> %d\n", i, bestSend);
|
||||
if (bestSend == -1)
|
||||
continue;
|
||||
|
||||
@ -652,13 +709,15 @@ void attackDisplayLatex(System sys)
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\\comment{ claimDetails :\n");
|
||||
termlistPrint(claimDetails);
|
||||
printf("\n}\n");
|
||||
printf ("\\comment{ claimDetails :\n");
|
||||
termlistPrint (claimDetails);
|
||||
printf ("\n}\n");
|
||||
|
||||
// landscape = (width > 4); // not for the time being
|
||||
|
||||
@ -673,44 +732,55 @@ void attackDisplayLatex(System sys)
|
||||
eventSize = 1;
|
||||
currRun = tb->run[i];
|
||||
|
||||
switch (tb->event[i]->type) {
|
||||
switch (tb->event[i]->type)
|
||||
{
|
||||
case SEND:
|
||||
position++;
|
||||
tinfo[i].position++;
|
||||
break;
|
||||
case READ:
|
||||
if (tb->link[i] != -1) {
|
||||
if (termDistance(tb->event[i]->message,tb->event[tb->link[i]]->message) < LINKTHRESHOLD)
|
||||
if (tb->link[i] != -1)
|
||||
{
|
||||
if (termDistance
|
||||
(tb->event[i]->message,
|
||||
tb->event[tb->link[i]]->message) < LINKTHRESHOLD)
|
||||
{
|
||||
/* disconnect read-send */
|
||||
tb->link[tb->link[i]] = -1;
|
||||
tb->link[i] = -1;
|
||||
} else {
|
||||
if (runPosition[currRun] <= tinfo[tb->link[i]].position &&
|
||||
currRun != tb->run[tb->link[i]])
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\\comment{\n");
|
||||
termPrint(tb->event[i]->message);
|
||||
printf("\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");
|
||||
if (runPosition[currRun] <= tinfo[tb->link[i]].position
|
||||
&& currRun != tb->run[tb->link[i]])
|
||||
{
|
||||
printf ("\\comment{\n");
|
||||
termPrint (tb->event[i]->message);
|
||||
printf ("\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");
|
||||
tinfo[i].position = tinfo[tb->link[i]].position;
|
||||
eventSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tb->event[i]->internal) {
|
||||
if (tb->event[i]->internal)
|
||||
{
|
||||
eventSize = 0;
|
||||
}
|
||||
break;
|
||||
case CLAIM:
|
||||
if (claimDetails != NULL && claimDetails != (Termlist) -1) {
|
||||
if (claimDetails != NULL && claimDetails != (Termlist) - 1)
|
||||
{
|
||||
eventSize = 2;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
eventSize = 0;
|
||||
}
|
||||
break;
|
||||
@ -724,10 +794,11 @@ void attackDisplayLatex(System sys)
|
||||
}
|
||||
}
|
||||
|
||||
latexMSCStart();
|
||||
for (i = 0; i < width; i++) {
|
||||
latexMSCStart ();
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
if (runPosition[i] > 0)
|
||||
latexDeclInst(sys, i);
|
||||
latexDeclInst (sys, i);
|
||||
}
|
||||
|
||||
//for (j=-1; j<=sys->step; j++)
|
||||
@ -737,14 +808,15 @@ void attackDisplayLatex(System sys)
|
||||
{
|
||||
if (tb->status[i] != S_RED)
|
||||
{
|
||||
latexEventSpace(tinfo[i].position - position);
|
||||
latexEventSpace (tinfo[i].position - position);
|
||||
if (tinfo[i].position >= position)
|
||||
{
|
||||
position = tinfo[i].position;
|
||||
}
|
||||
switch (tb->event[i]->type) {
|
||||
switch (tb->event[i]->type)
|
||||
{
|
||||
case SEND:
|
||||
newtl = knowledgeNew(tb->know[i], tb->know[i + 1]);
|
||||
newtl = knowledgeNew (tb->know[i], tb->know[i + 1]);
|
||||
highlights = NULL;
|
||||
/* Build a Termlist of terms that from the claimViolationDetails,
|
||||
that appear in the knowledge */
|
||||
@ -753,36 +825,43 @@ void attackDisplayLatex(System sys)
|
||||
tl = claimDetails;
|
||||
while (tl != NULL)
|
||||
{
|
||||
if (inTermlist(newtl, tl->term))
|
||||
if (inTermlist (newtl, tl->term))
|
||||
{
|
||||
highlights = termlistAdd(highlights, tl->term);
|
||||
highlights = termlistAdd (highlights, tl->term);
|
||||
}
|
||||
tl = tl->next;
|
||||
}
|
||||
printf("\\msccomment[4ex]{$I_%d=I_%d\\oplus ", cKnowledge + 1,
|
||||
cKnowledge);
|
||||
printf ("\\msccomment[4ex]{$I_%d=I_%d\\oplus ",
|
||||
cKnowledge + 1, cKnowledge);
|
||||
cKnowledge++;
|
||||
latexTermlistPrint(newtl, highlights);
|
||||
printf("$}{envright}\n");
|
||||
latexTermlistPrint (newtl, highlights);
|
||||
printf ("$}{envright}\n");
|
||||
}
|
||||
|
||||
if (tb->link[i] != -1 && i < tb->length) {
|
||||
latexMessagePrintHighlight(tb, i, tb->link[i], highlights);
|
||||
} else {
|
||||
latexMessagePrintHighlight(tb, i, -1, highlights); //lost message
|
||||
if (tb->link[i] != -1 && i < tb->length)
|
||||
{
|
||||
latexMessagePrintHighlight (tb, i, tb->link[i], highlights);
|
||||
}
|
||||
termlistDelete(highlights);
|
||||
else
|
||||
{
|
||||
latexMessagePrintHighlight (tb, i, -1, highlights); //lost message
|
||||
}
|
||||
termlistDelete (highlights);
|
||||
|
||||
break;
|
||||
case READ:
|
||||
if (tb->event[i]->internal) {
|
||||
} else if (tb->link[i] == -1) {
|
||||
latexMessagePrint(tb, -1, i); //found message
|
||||
if (tb->event[i]->internal)
|
||||
{
|
||||
}
|
||||
else if (tb->link[i] == -1)
|
||||
{
|
||||
latexMessagePrint (tb, -1, i); //found message
|
||||
}
|
||||
break;
|
||||
case CLAIM:
|
||||
if (claimDetails != NULL && claimDetails != (Termlist) -1) {
|
||||
latexClaim(tb, tb->run[i], claimDetails);
|
||||
if (claimDetails != NULL && claimDetails != (Termlist) - 1)
|
||||
{
|
||||
latexClaim (tb, tb->run[i], claimDetails);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -790,8 +869,8 @@ void attackDisplayLatex(System sys)
|
||||
}
|
||||
}
|
||||
}
|
||||
latexEventSpace(2);
|
||||
latexMSCEnd();
|
||||
memFree(runPosition, width * sizeof(int));
|
||||
memFree(tinfo, (tb->length+1) * sizeof(struct traceinfo));
|
||||
latexEventSpace (2);
|
||||
latexMSCEnd ();
|
||||
memFree (runPosition, width * sizeof (int));
|
||||
memFree (tinfo, (tb->length + 1) * sizeof (struct traceinfo));
|
||||
}
|
||||
|
311
src/output.c
311
src/output.c
@ -12,17 +12,20 @@
|
||||
#include "latex.h"
|
||||
|
||||
|
||||
void linePrint(int i)
|
||||
void
|
||||
linePrint (int i)
|
||||
{
|
||||
indent();
|
||||
while (i > 0) {
|
||||
printf("--------");
|
||||
indent ();
|
||||
while (i > 0)
|
||||
{
|
||||
printf ("--------");
|
||||
i--;
|
||||
}
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
int correspondingSend(System sys, int rd)
|
||||
int
|
||||
correspondingSend (System sys, int rd)
|
||||
{
|
||||
|
||||
int labelMatch = 0;
|
||||
@ -37,36 +40,40 @@ int correspondingSend(System sys, int rd)
|
||||
int sendEvent = -1;
|
||||
int bestSendEvent = -1;
|
||||
|
||||
for (sendEvent = readEvent; sendEvent >= 0; sendEvent--) {
|
||||
if (sys->traceEvent[sendEvent]->type == SEND) {
|
||||
for (sendEvent = readEvent; sendEvent >= 0; sendEvent--)
|
||||
{
|
||||
if (sys->traceEvent[sendEvent]->type == SEND)
|
||||
{
|
||||
/* do all the different kind of matchings first */
|
||||
|
||||
labelMatch =
|
||||
isTermEqualFn(sys->traceEvent[sendEvent]->label,
|
||||
isTermEqualFn (sys->traceEvent[sendEvent]->label,
|
||||
sys->traceEvent[readEvent]->label);
|
||||
toMatch =
|
||||
isTermEqualFn(sys->traceEvent[sendEvent]->to,
|
||||
isTermEqualFn (sys->traceEvent[sendEvent]->to,
|
||||
sys->traceEvent[readEvent]->to);
|
||||
fromMatch =
|
||||
isTermEqualFn(sys->traceEvent[sendEvent]->from,
|
||||
isTermEqualFn (sys->traceEvent[sendEvent]->from,
|
||||
sys->traceEvent[readEvent]->from);
|
||||
tofromMatch = toMatch || fromMatch;
|
||||
messageMatch =
|
||||
isTermEqualFn(sys->traceEvent[sendEvent]->message,
|
||||
isTermEqualFn (sys->traceEvent[sendEvent]->message,
|
||||
sys->traceEvent[readEvent]->message);
|
||||
|
||||
/* calculate the score */
|
||||
|
||||
nMatches = labelMatch + tofromMatch + messageMatch;
|
||||
|
||||
if (nMatches == 3) {
|
||||
if (nMatches == 3)
|
||||
{
|
||||
/* bingo! success on all matches */
|
||||
|
||||
//printf("Found perfect match: %d\n", s);
|
||||
bestSendEvent = sendEvent;
|
||||
break;
|
||||
}
|
||||
if (nMatches > maxNMatches) {
|
||||
if (nMatches > maxNMatches)
|
||||
{
|
||||
/* if we found a better candidate than we already had, we'll update */
|
||||
|
||||
//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 */
|
||||
|
||||
if (labelMatch && messageMatch) {
|
||||
if (labelMatch && messageMatch)
|
||||
{
|
||||
/* strongest restriction: message and label should match */
|
||||
|
||||
maxNMatches = nMatches;
|
||||
bestSendEvent = sendEvent;
|
||||
|
||||
} else if (messageMatch) {
|
||||
}
|
||||
else if (messageMatch)
|
||||
{
|
||||
/* if label AND message don't match: */
|
||||
/* at least message should match */
|
||||
|
||||
maxNMatches = nMatches;
|
||||
bestSendEvent = sendEvent;
|
||||
} else if (labelMatch) {
|
||||
}
|
||||
else if (labelMatch)
|
||||
{
|
||||
/* if message doesn't match */
|
||||
/* the label should matches */
|
||||
|
||||
@ -103,7 +115,8 @@ int correspondingSend(System sys, int rd)
|
||||
}
|
||||
|
||||
//bestSendEvent = NULL;
|
||||
if (bestSendEvent == -1) {
|
||||
if (bestSendEvent == -1)
|
||||
{
|
||||
/*Termlist tl;
|
||||
Term t;
|
||||
|
||||
@ -133,17 +146,20 @@ int correspondingSend(System sys, int rd)
|
||||
|
||||
int u;
|
||||
|
||||
for (u = 0; u < rd; u++) {
|
||||
if (sys->traceEvent[u]->type == SEND) {
|
||||
for (u = 0; u < rd; u++)
|
||||
{
|
||||
if (sys->traceEvent[u]->type == SEND)
|
||||
{
|
||||
|
||||
|
||||
//termPrint(readEvent->message);
|
||||
//printf("\n");
|
||||
knowledgePrint(sys->traceKnow[u]);
|
||||
knowledgePrint (sys->traceKnow[u]);
|
||||
//printf("Is received message in knowledge after SEND %d? %d\n", u, inKnowledge(sys->traceKnow[u+1],readEvent->message));
|
||||
if (inKnowledge
|
||||
(sys->traceKnow[u + 1],
|
||||
sys->traceEvent[readEvent]->message)) {
|
||||
sys->traceEvent[readEvent]->message))
|
||||
{
|
||||
bestSendEvent = u;
|
||||
break;
|
||||
}
|
||||
@ -151,22 +167,27 @@ int correspondingSend(System sys, int rd)
|
||||
}
|
||||
}
|
||||
|
||||
if (bestSendEvent == -1) {
|
||||
printf("!! Could not find a matching SEND\n");
|
||||
} else {
|
||||
if (bestSendEvent == -1)
|
||||
{
|
||||
printf ("!! Could not find a matching SEND\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//latexMessagePrint(sys, bestSendEvent, readEvent);
|
||||
//printf("Latex: ");
|
||||
//termPrint(bestSendEvent->from);
|
||||
//printf(" -> ");
|
||||
if (!isTermEqualFn
|
||||
(sys->traceEvent[bestSendEvent]->to,
|
||||
sys->traceEvent[readEvent]->to)) {
|
||||
sys->traceEvent[readEvent]->to))
|
||||
{
|
||||
//termPrint(bestSendEvent->to);
|
||||
//printf(" -> ");
|
||||
}
|
||||
if (!isTermEqualFn
|
||||
(sys->traceEvent[bestSendEvent]->from,
|
||||
sys->traceEvent[readEvent]->from)) {
|
||||
sys->traceEvent[readEvent]->from))
|
||||
{
|
||||
//termPrint(readEvent->from);
|
||||
//printf(" -> ");
|
||||
}
|
||||
@ -176,9 +197,11 @@ int correspondingSend(System sys, int rd)
|
||||
return bestSendEvent;
|
||||
}
|
||||
|
||||
void tracePrint(System sys)
|
||||
void
|
||||
tracePrint (System sys)
|
||||
{
|
||||
if (sys->latex) {
|
||||
if (sys->latex)
|
||||
{
|
||||
//latexTracePrint(sys);
|
||||
return;
|
||||
}
|
||||
@ -197,80 +220,89 @@ void tracePrint(System sys)
|
||||
|
||||
/* how wide is the trace? */
|
||||
width = 0;
|
||||
for (i = 0; i <= sys->step; i++) {
|
||||
for (i = 0; i <= sys->step; i++)
|
||||
{
|
||||
if (sys->traceRun[i] >= width)
|
||||
width = sys->traceRun[i] + 1;
|
||||
}
|
||||
|
||||
linePrint(width);
|
||||
indent();
|
||||
printf("Dumping trace:\n");
|
||||
linePrint(width);
|
||||
linePrint (width);
|
||||
indent ();
|
||||
printf ("Dumping trace:\n");
|
||||
linePrint (width);
|
||||
|
||||
/* first some parameter issues */
|
||||
|
||||
knowledgePrint(sys->traceKnow[0]);
|
||||
knowledgePrint (sys->traceKnow[0]);
|
||||
/* also print inverses */
|
||||
indent();
|
||||
printf("Inverses: ");
|
||||
knowledgeInversesPrint(sys->traceKnow[0]);
|
||||
printf("\n");
|
||||
indent ();
|
||||
printf ("Inverses: ");
|
||||
knowledgeInversesPrint (sys->traceKnow[0]);
|
||||
printf ("\n");
|
||||
|
||||
/* Trace columns header. First the run identifier and role. On the
|
||||
* second line we have the perceived agents for each partner role.
|
||||
* These are printed in the same order as the role specification in the
|
||||
* protocol. */
|
||||
|
||||
linePrint(width);
|
||||
indent();
|
||||
linePrint (width);
|
||||
indent ();
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
termPrint(sys->runs[i].role->nameterm);
|
||||
printf("#%i\t", i);
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
termPrint (sys->runs[i].role->nameterm);
|
||||
printf ("#%i\t", i);
|
||||
}
|
||||
printf("\n");
|
||||
for (i = 0; i < width; i++) {
|
||||
termPrint(agentOfRun(sys, i));
|
||||
printf("\t");
|
||||
printf ("\n");
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
termPrint (agentOfRun (sys, i));
|
||||
printf ("\t");
|
||||
}
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
agentsOfRunPrint(sys, i);
|
||||
printf("\t");
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
agentsOfRunPrint (sys, i);
|
||||
printf ("\t");
|
||||
}
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
|
||||
/* now we print the actual trace */
|
||||
|
||||
void sticks(int i) {
|
||||
while (i > 0) {
|
||||
printf("|\t");
|
||||
void sticks (int i)
|
||||
{
|
||||
while (i > 0)
|
||||
{
|
||||
printf ("|\t");
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
void sticksLine(void) {
|
||||
sticks(width);
|
||||
printf("\n");
|
||||
void sticksLine (void)
|
||||
{
|
||||
sticks (width);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
linePrint(width);
|
||||
linePrint (width);
|
||||
lastrid = -1;
|
||||
for (i = 0; i <= sys->step; i++) {
|
||||
for (i = 0; i <= sys->step; i++)
|
||||
{
|
||||
/* yields extra newlines between switching of runs */
|
||||
|
||||
j = sys->traceRun[i];
|
||||
if (j != lastrid) {
|
||||
sticksLine();
|
||||
if (j != lastrid)
|
||||
{
|
||||
sticksLine ();
|
||||
lastrid = j;
|
||||
}
|
||||
|
||||
/* print the actual event */
|
||||
|
||||
indent();
|
||||
sticks(j);
|
||||
roledefPrint(sys->traceEvent[i]);
|
||||
indent ();
|
||||
sticks (j);
|
||||
roledefPrint (sys->traceEvent[i]);
|
||||
|
||||
//if (sys->traceEvent[i]->type == READ && !sys->traceEvent[i]->internal)
|
||||
//{
|
||||
@ -282,37 +314,40 @@ void tracePrint(System sys)
|
||||
//}
|
||||
|
||||
/* have we learnt anything new? */
|
||||
newtl = knowledgeNew(sys->traceKnow[i], sys->traceKnow[i + 1]);
|
||||
if (newtl != NULL) {
|
||||
printf("\n");
|
||||
sticksLine();
|
||||
sticks(width);
|
||||
printf("/* Intruder learns ");
|
||||
termlistPrint(newtl);
|
||||
termlistDelete(newtl);
|
||||
printf(" */");
|
||||
newtl = knowledgeNew (sys->traceKnow[i], sys->traceKnow[i + 1]);
|
||||
if (newtl != NULL)
|
||||
{
|
||||
printf ("\n");
|
||||
sticksLine ();
|
||||
sticks (width);
|
||||
printf ("/* Intruder learns ");
|
||||
termlistPrint (newtl);
|
||||
termlistDelete (newtl);
|
||||
printf (" */");
|
||||
lastrid = -1;
|
||||
}
|
||||
|
||||
/* new line */
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
switch (sys->clp) {
|
||||
switch (sys->clp)
|
||||
{
|
||||
case 1:
|
||||
indent();
|
||||
printf("---[ constraints ]-----\n");
|
||||
constraintlistPrint(sys->constraints);
|
||||
indent ();
|
||||
printf ("---[ constraints ]-----\n");
|
||||
constraintlistPrint (sys->constraints);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
linePrint(width);
|
||||
linePrint (width);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void attackDisplayAscii(System sys)
|
||||
void
|
||||
attackDisplayAscii (System sys)
|
||||
{
|
||||
int i, j;
|
||||
int length;
|
||||
@ -330,19 +365,20 @@ void attackDisplayAscii(System sys)
|
||||
|
||||
/* how wide is the trace? */
|
||||
width = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
if (tb->run[i] >= width)
|
||||
width = tb->run[i] + 1;
|
||||
}
|
||||
|
||||
linePrint(width);
|
||||
indent();
|
||||
printf("Dumping trace:\n");
|
||||
linePrint(width);
|
||||
linePrint (width);
|
||||
indent ();
|
||||
printf ("Dumping trace:\n");
|
||||
linePrint (width);
|
||||
|
||||
/* first some parameter issues */
|
||||
|
||||
knowledgePrint(tb->know[0]);
|
||||
knowledgePrint (tb->know[0]);
|
||||
printf ("Variables: ");
|
||||
termlistPrint (sys->variables);
|
||||
printf ("\n");
|
||||
@ -352,56 +388,64 @@ void attackDisplayAscii(System sys)
|
||||
* These are printed in the same order as the role specification in the
|
||||
* protocol. */
|
||||
|
||||
linePrint(width);
|
||||
indent();
|
||||
linePrint (width);
|
||||
indent ();
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
termPrint(sys->runs[i].role->nameterm);
|
||||
printf("#%i\t", i);
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
termPrint (sys->runs[i].role->nameterm);
|
||||
printf ("#%i\t", i);
|
||||
}
|
||||
printf("\n");
|
||||
for (i = 0; i < width; i++) {
|
||||
termPrint(agentOfRun(sys, i));
|
||||
printf("\t");
|
||||
printf ("\n");
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
termPrint (agentOfRun (sys, i));
|
||||
printf ("\t");
|
||||
}
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
|
||||
for (i = 0; i < width; i++) {
|
||||
agentsOfRunPrint(sys, i);
|
||||
printf("\t");
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
agentsOfRunPrint (sys, i);
|
||||
printf ("\t");
|
||||
}
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
|
||||
/* now we print the actual trace */
|
||||
|
||||
void sticks(int i) {
|
||||
while (i > 0) {
|
||||
printf("|\t");
|
||||
void sticks (int i)
|
||||
{
|
||||
while (i > 0)
|
||||
{
|
||||
printf ("|\t");
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
void sticksLine(void) {
|
||||
sticks(width);
|
||||
printf("\n");
|
||||
void sticksLine (void)
|
||||
{
|
||||
sticks (width);
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
linePrint(width);
|
||||
linePrint (width);
|
||||
lastrid = -1;
|
||||
for (i = 0; i < length; i++) {
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
/* yields extra newlines between switching of runs */
|
||||
|
||||
j = tb->run[i];
|
||||
if (j != lastrid) {
|
||||
sticksLine();
|
||||
if (j != lastrid)
|
||||
{
|
||||
sticksLine ();
|
||||
lastrid = j;
|
||||
}
|
||||
|
||||
/* print the actual event */
|
||||
|
||||
indent();
|
||||
sticks(j);
|
||||
roledefPrint(tb->event[i]);
|
||||
indent ();
|
||||
sticks (j);
|
||||
roledefPrint (tb->event[i]);
|
||||
|
||||
//if (sys->traceEvent[i]->type == READ && !sys->traceEvent[i]->internal)
|
||||
//{
|
||||
@ -413,31 +457,36 @@ void attackDisplayAscii(System sys)
|
||||
//}
|
||||
|
||||
/* have we learnt anything new? */
|
||||
newtl = knowledgeNew(tb->know[i], tb->know[i + 1]);
|
||||
if (newtl != NULL) {
|
||||
printf("\n");
|
||||
sticksLine();
|
||||
sticks(width);
|
||||
printf("/* Intruder learns ");
|
||||
termlistPrint(newtl);
|
||||
termlistDelete(newtl);
|
||||
printf(" */");
|
||||
newtl = knowledgeNew (tb->know[i], tb->know[i + 1]);
|
||||
if (newtl != NULL)
|
||||
{
|
||||
printf ("\n");
|
||||
sticksLine ();
|
||||
sticks (width);
|
||||
printf ("/* Intruder learns ");
|
||||
termlistPrint (newtl);
|
||||
termlistDelete (newtl);
|
||||
printf (" */");
|
||||
lastrid = -1;
|
||||
}
|
||||
|
||||
/* new line */
|
||||
printf("\n");
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
linePrint(width);
|
||||
linePrint (width);
|
||||
}
|
||||
|
||||
|
||||
void attackDisplay(System sys)
|
||||
void
|
||||
attackDisplay (System sys)
|
||||
{
|
||||
if (sys->latex) {
|
||||
attackDisplayLatex(sys);
|
||||
} else {
|
||||
attackDisplayAscii(sys);
|
||||
if (sys->latex)
|
||||
{
|
||||
attackDisplayLatex (sys);
|
||||
}
|
||||
else
|
||||
{
|
||||
attackDisplayAscii (sys);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user