- Many ansi updates.
This commit is contained in:
parent
b5ddd75d95
commit
ca01a09377
@ -267,6 +267,8 @@ knowledgeSetInverses (Knowledge know, Termlist tl)
|
|||||||
int
|
int
|
||||||
inKnowledge (const Knowledge know, Term term)
|
inKnowledge (const Knowledge know, Term term)
|
||||||
{
|
{
|
||||||
|
mindwipe (know, inKnowledge (know, term));
|
||||||
|
|
||||||
/* if there is no term, then it's okay 'fur sure' */
|
/* if there is no term, then it's okay 'fur sure' */
|
||||||
if (term == NULL)
|
if (term == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
@ -274,8 +276,6 @@ inKnowledge (const Knowledge know, Term term)
|
|||||||
if (know == NULL)
|
if (know == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mindwipe (know, inKnowledge (know, term));
|
|
||||||
|
|
||||||
term = deVar (term);
|
term = deVar (term);
|
||||||
if (isTermLeaf (term))
|
if (isTermLeaf (term))
|
||||||
{
|
{
|
||||||
@ -489,8 +489,6 @@ knowledgeNew (const Knowledge oldk, const Knowledge newk)
|
|||||||
{
|
{
|
||||||
Termlist newtl;
|
Termlist newtl;
|
||||||
|
|
||||||
newtl = NULL;
|
|
||||||
|
|
||||||
void addNewStuff (Termlist tl)
|
void addNewStuff (Termlist tl)
|
||||||
{
|
{
|
||||||
while (tl != NULL)
|
while (tl != NULL)
|
||||||
@ -502,6 +500,8 @@ knowledgeNew (const Knowledge oldk, const Knowledge newk)
|
|||||||
tl = tl->next;
|
tl = tl->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newtl = NULL;
|
||||||
addNewStuff (newk->basic);
|
addNewStuff (newk->basic);
|
||||||
addNewStuff (newk->encrypt);
|
addNewStuff (newk->encrypt);
|
||||||
return newtl;
|
return newtl;
|
||||||
|
@ -324,13 +324,14 @@ latexDeclInst (const System sys, int run)
|
|||||||
void
|
void
|
||||||
latexEventSpace (int amount)
|
latexEventSpace (int amount)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
if (pass < 2)
|
if (pass < 2)
|
||||||
{
|
{
|
||||||
/* not printing */
|
/* not printing */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
|
||||||
//printf("%% number of newlines: %d\n",amount);
|
//printf("%% number of newlines: %d\n",amount);
|
||||||
for (i = 0; i < EVENTSPACE * amount; i++)
|
for (i = 0; i < EVENTSPACE * amount; i++)
|
||||||
printf ("\\nextlevel\n");
|
printf ("\\nextlevel\n");
|
||||||
@ -904,6 +905,9 @@ attackDisplayLatex (System sys)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Termlist protocolnames;
|
||||||
|
Term pname;
|
||||||
|
|
||||||
/* slightly stretch measurements */
|
/* slightly stretch measurements */
|
||||||
printf ("\\addtolength{\\maxmscall}{2\\mscspacer}\n");
|
printf ("\\addtolength{\\maxmscall}{2\\mscspacer}\n");
|
||||||
printf ("\\addtolength{\\maxmscaction}{\\mscspacer}\n");
|
printf ("\\addtolength{\\maxmscaction}{\\mscspacer}\n");
|
||||||
@ -920,8 +924,7 @@ attackDisplayLatex (System sys)
|
|||||||
|
|
||||||
/* create MSC title, involving protocol names and such. */
|
/* create MSC title, involving protocol names and such. */
|
||||||
|
|
||||||
Termlist protocolnames = NULL;
|
protocolnames = NULL;
|
||||||
Term pname;
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
if (runPosition[i] > 0)
|
if (runPosition[i] > 0)
|
||||||
|
22
src/main.c
22
src/main.c
@ -407,8 +407,12 @@ exit:
|
|||||||
void
|
void
|
||||||
timersPrint (const System sys)
|
timersPrint (const System sys)
|
||||||
{
|
{
|
||||||
/* display stats, header first */
|
#define NOTIMERS
|
||||||
|
|
||||||
|
/* display stats, header first */
|
||||||
|
#ifdef NOTIMERS
|
||||||
|
fprintf (stderr, "States\t\tAttack\n");
|
||||||
|
#else
|
||||||
fprintf (stderr, "Time\t\tStates\t\tAttack\t\tst/sec\n");
|
fprintf (stderr, "Time\t\tStates\t\tAttack\t\tst/sec\n");
|
||||||
|
|
||||||
/* print time */
|
/* print time */
|
||||||
@ -416,6 +420,7 @@ timersPrint (const System sys)
|
|||||||
double seconds;
|
double seconds;
|
||||||
seconds = (double) clock () / CLOCKS_PER_SEC;
|
seconds = (double) clock () / CLOCKS_PER_SEC;
|
||||||
fprintf (stderr, "%.3e\t", seconds);
|
fprintf (stderr, "%.3e\t", seconds);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* states traversed */
|
/* states traversed */
|
||||||
|
|
||||||
@ -441,13 +446,9 @@ timersPrint (const System sys)
|
|||||||
fprintf (stderr, "None\t\t");
|
fprintf (stderr, "None\t\t");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#ifdef NOTIMERS
|
||||||
printf("%.3e (%li) claims encountered.\n",(double)
|
fprintf (stderr, "\n");
|
||||||
sys->claims, sys->claims);
|
#else
|
||||||
printf("%.3e (%li) claims failed.\n",(double)
|
|
||||||
sys->failed, sys->failed);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* states per second */
|
/* states per second */
|
||||||
|
|
||||||
if (seconds > 0)
|
if (seconds > 0)
|
||||||
@ -462,6 +463,7 @@ timersPrint (const System sys)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fprintf (stderr, "\n");
|
fprintf (stderr, "\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Analyse the model by incremental runs.
|
//! Analyse the model by incremental runs.
|
||||||
@ -527,6 +529,8 @@ MC_incTraces (const System sys)
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
tracestep = 3; /* what is a sensible stepping size? */
|
tracestep = 3; /* what is a sensible stepping size? */
|
||||||
|
flag = 1;
|
||||||
|
|
||||||
maxtracelen = getMaxTraceLength (sys);
|
maxtracelen = getMaxTraceLength (sys);
|
||||||
tracelen = maxtracelen - tracestep;
|
tracelen = maxtracelen - tracestep;
|
||||||
while (tracelen > 6) /* what is a reasonable minimum? */
|
while (tracelen > 6) /* what is a reasonable minimum? */
|
||||||
@ -589,3 +593,5 @@ modelCheck (const System sys)
|
|||||||
timersPrint (sys);
|
timersPrint (sys);
|
||||||
return (sys->failed);
|
return (sys->failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@ matchRead_basic (const System sys, const int run,
|
|||||||
Roledef rd;
|
Roledef rd;
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
struct fvpass fp;
|
struct fvpass fp;
|
||||||
|
Termlist varlist;
|
||||||
|
|
||||||
int solution (struct fvpass fp, Knowledge know)
|
int solution (struct fvpass fp, Knowledge know)
|
||||||
{
|
{
|
||||||
@ -222,7 +223,7 @@ matchRead_basic (const System sys, const int run,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rd = runPointerGet (sys, run);
|
rd = runPointerGet (sys, run);
|
||||||
Termlist varlist = termlistAddVariables (NULL, rd->message);
|
varlist = termlistAddVariables (NULL, rd->message);
|
||||||
|
|
||||||
fp.sys = sys;
|
fp.sys = sys;
|
||||||
fp.run = run;
|
fp.run = run;
|
||||||
@ -237,8 +238,10 @@ matchRead_basic (const System sys, const int run,
|
|||||||
printf ("{\n");
|
printf ("{\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
flag = fixVariablelist (fp, sys->know, varlist, rd->message);
|
flag = fixVariablelist (fp, sys->know, varlist, rd->message);
|
||||||
termlistDelete (varlist);
|
termlistDelete (varlist);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (DEBUGL (5))
|
if (DEBUGL (5))
|
||||||
{
|
{
|
||||||
|
120
src/match_clp.c
120
src/match_clp.c
@ -105,11 +105,13 @@ solve (const struct solvepass sp, Constraintlist solvecons)
|
|||||||
|
|
||||||
if (tlres != NULL)
|
if (tlres != NULL)
|
||||||
{
|
{
|
||||||
|
Constraintlist cl;
|
||||||
|
|
||||||
copied = 1;
|
copied = 1;
|
||||||
/* sometimes not needed, when no substitutions took place */
|
/* sometimes not needed, when no substitutions took place */
|
||||||
oldcl = solvecons;
|
oldcl = solvecons;
|
||||||
solvecons = constraintlistDuplicate (solvecons);
|
solvecons = constraintlistDuplicate (solvecons);
|
||||||
Constraintlist cl = solvecons;
|
cl = solvecons;
|
||||||
while (cl != NULL)
|
while (cl != NULL)
|
||||||
{
|
{
|
||||||
cl->constraint->know =
|
cl->constraint->know =
|
||||||
@ -220,6 +222,38 @@ matchRead_clp (const System sys, const int run, int (*proceed) (System, int))
|
|||||||
Constraint co;
|
Constraint co;
|
||||||
Roledef runPoint;
|
Roledef runPoint;
|
||||||
int flag;
|
int flag;
|
||||||
|
struct solvepass sp;
|
||||||
|
|
||||||
|
/* check solvability */
|
||||||
|
int solution (const struct solvepass sp, const Constraintlist cl)
|
||||||
|
{
|
||||||
|
Knowledge oldknow;
|
||||||
|
int flag;
|
||||||
|
int copied;
|
||||||
|
Constraintlist oldcl;
|
||||||
|
|
||||||
|
oldknow = NULL;
|
||||||
|
flag = 0;
|
||||||
|
copied = 0;
|
||||||
|
oldcl = sys->constraints;
|
||||||
|
|
||||||
|
sys->constraints = cl;
|
||||||
|
if (knowledgeSubstNeeded (sys->know))
|
||||||
|
{
|
||||||
|
copied = 1;
|
||||||
|
oldknow = sys->know;
|
||||||
|
sys->know = knowledgeSubstDo (sys->know);
|
||||||
|
}
|
||||||
|
flag = sp.proceed (sys, run);
|
||||||
|
if (copied)
|
||||||
|
{
|
||||||
|
knowledgeDelete (sys->know);
|
||||||
|
sys->know = oldknow;
|
||||||
|
knowledgeSubstUndo (sys->know);
|
||||||
|
}
|
||||||
|
sys->constraints = oldcl;
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* save old state */
|
/* save old state */
|
||||||
@ -241,33 +275,6 @@ matchRead_clp (const System sys, const int run, int (*proceed) (System, int))
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check solvability */
|
|
||||||
int solution (const struct solvepass sp, const Constraintlist cl)
|
|
||||||
{
|
|
||||||
Knowledge oldknow = NULL;
|
|
||||||
Constraintlist oldcl = sys->constraints;
|
|
||||||
int flag = 0;
|
|
||||||
int copied = 0;
|
|
||||||
|
|
||||||
sys->constraints = cl;
|
|
||||||
if (knowledgeSubstNeeded (sys->know))
|
|
||||||
{
|
|
||||||
copied = 1;
|
|
||||||
oldknow = sys->know;
|
|
||||||
sys->know = knowledgeSubstDo (sys->know);
|
|
||||||
}
|
|
||||||
flag = sp.proceed (sys, run);
|
|
||||||
if (copied)
|
|
||||||
{
|
|
||||||
knowledgeDelete (sys->know);
|
|
||||||
sys->know = oldknow;
|
|
||||||
knowledgeSubstUndo (sys->know);
|
|
||||||
}
|
|
||||||
sys->constraints = oldcl;
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct solvepass sp;
|
|
||||||
sp.solution = solution;
|
sp.solution = solution;
|
||||||
sp.sys = sys;
|
sp.sys = sys;
|
||||||
sp.run = run;
|
sp.run = run;
|
||||||
@ -300,6 +307,7 @@ secret_clp (const System sys, const Term t)
|
|||||||
Constraintlist oldcl, newcl;
|
Constraintlist oldcl, newcl;
|
||||||
Constraint co;
|
Constraint co;
|
||||||
int flag;
|
int flag;
|
||||||
|
struct solvepass sp;
|
||||||
|
|
||||||
/* save old state */
|
/* save old state */
|
||||||
oldcl = sys->constraints;
|
oldcl = sys->constraints;
|
||||||
@ -312,7 +320,6 @@ secret_clp (const System sys, const Term t)
|
|||||||
|
|
||||||
/* check solvability */
|
/* check solvability */
|
||||||
|
|
||||||
struct solvepass sp;
|
|
||||||
sp.solution = NULL;
|
sp.solution = NULL;
|
||||||
sp.sys = sys;
|
sp.sys = sys;
|
||||||
flag = !solve (sp, sys->constraints);
|
flag = !solve (sp, sys->constraints);
|
||||||
@ -377,10 +384,13 @@ sendAdd_clp (const System sys, const int run, const Termlist tl)
|
|||||||
{
|
{
|
||||||
/* difficult case: variable in inverse
|
/* difficult case: variable in inverse
|
||||||
* key. We have to branch. */
|
* key. We have to branch. */
|
||||||
|
Knowledge oldknow;
|
||||||
|
Constraint co;
|
||||||
|
Constraintlist clold, clbuf;
|
||||||
|
|
||||||
/* branch 1 : invkey not in knowledge */
|
/* branch 1 : invkey not in knowledge */
|
||||||
/* TODO this yields a negative constraint, which we omit for the time being */
|
/* TODO this yields a negative constraint, which we omit for the time being */
|
||||||
Knowledge oldknow = knowledgeDuplicate (sys->know);
|
oldknow = knowledgeDuplicate (sys->know);
|
||||||
|
|
||||||
knowledgeAddTerm (sys->know, t);
|
knowledgeAddTerm (sys->know, t);
|
||||||
sendAdd_clp (sys, run, tl->next);
|
sendAdd_clp (sys, run, tl->next);
|
||||||
@ -390,11 +400,11 @@ sendAdd_clp (const System sys, const int run, const Termlist tl)
|
|||||||
|
|
||||||
/* branch 2 : invkey in knowledge */
|
/* branch 2 : invkey in knowledge */
|
||||||
oldknow = knowledgeDuplicate (sys->know);
|
oldknow = knowledgeDuplicate (sys->know);
|
||||||
Constraintlist clold = sys->constraints;
|
clold = sys->constraints;
|
||||||
Constraintlist clbuf = constraintlistShallow (clold);
|
clbuf = constraintlistShallow (clold);
|
||||||
tl2 = termlistShallow (tl->next);
|
tl2 = termlistShallow (tl->next);
|
||||||
|
|
||||||
Constraint co = makeConstraint (invkey, sys->know);
|
co = makeConstraint (invkey, sys->know);
|
||||||
sys->constraints = constraintlistAdd (clbuf, co);
|
sys->constraints = constraintlistAdd (clbuf, co);
|
||||||
/* we _could_ explore first if this is solveable */
|
/* we _could_ explore first if this is solveable */
|
||||||
knowledgeAddTerm (sys->know, t);
|
knowledgeAddTerm (sys->know, t);
|
||||||
@ -426,10 +436,12 @@ send_clp (const System sys, const int run)
|
|||||||
{
|
{
|
||||||
/* new knowledge, must store old state */
|
/* new knowledge, must store old state */
|
||||||
Knowledge oldknow;
|
Knowledge oldknow;
|
||||||
|
Termlist tl;
|
||||||
|
|
||||||
oldknow = sys->know;
|
oldknow = sys->know;
|
||||||
sys->know = knowledgeDuplicate (sys->know);
|
sys->know = knowledgeDuplicate (sys->know);
|
||||||
|
|
||||||
Termlist tl = termlistAdd (NULL, rd->message);
|
tl = termlistAdd (NULL, rd->message);
|
||||||
sendAdd_clp (sys, run, tl);
|
sendAdd_clp (sys, run, tl);
|
||||||
termlistDelete (tl);
|
termlistDelete (tl);
|
||||||
|
|
||||||
@ -447,26 +459,20 @@ isPossible_clp (const System sys, const int run, int
|
|||||||
Constraint co;
|
Constraint co;
|
||||||
Roledef runPoint;
|
Roledef runPoint;
|
||||||
int flag;
|
int flag;
|
||||||
|
struct solvepass sp;
|
||||||
/* save old state */
|
|
||||||
oldcl = sys->constraints;
|
|
||||||
newcl = constraintlistShallow (oldcl);
|
|
||||||
|
|
||||||
/* creat new state */
|
|
||||||
runPoint = runPointerGet (sys, run);
|
|
||||||
|
|
||||||
/* add the new constraint */
|
|
||||||
co = makeConstraint (t, k);
|
|
||||||
newcl = constraintlistAdd (newcl, co);
|
|
||||||
sys->constraints = newcl;
|
|
||||||
|
|
||||||
/* check solvability */
|
/* check solvability */
|
||||||
int solution (const struct solvepass sp, const Constraintlist cl)
|
int solution (const struct solvepass sp, const Constraintlist cl)
|
||||||
{
|
{
|
||||||
Knowledge oldknow = NULL;
|
Knowledge oldknow;
|
||||||
Constraintlist oldcl = sys->constraints;
|
Constraintlist oldcl;
|
||||||
int flag = 0;
|
int flag;
|
||||||
int copied = 0;
|
int copied;
|
||||||
|
|
||||||
|
oldknow = NULL;
|
||||||
|
oldcl = sys->constraints;
|
||||||
|
flag = 0;
|
||||||
|
copied = 0;
|
||||||
|
|
||||||
sys->constraints = cl;
|
sys->constraints = cl;
|
||||||
if (knowledgeSubstNeeded (sys->know))
|
if (knowledgeSubstNeeded (sys->know))
|
||||||
@ -486,7 +492,19 @@ isPossible_clp (const System sys, const int run, int
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct solvepass sp;
|
|
||||||
|
/* save old state */
|
||||||
|
oldcl = sys->constraints;
|
||||||
|
newcl = constraintlistShallow (oldcl);
|
||||||
|
|
||||||
|
/* creat new state */
|
||||||
|
runPoint = runPointerGet (sys, run);
|
||||||
|
|
||||||
|
/* add the new constraint */
|
||||||
|
co = makeConstraint (t, k);
|
||||||
|
newcl = constraintlistAdd (newcl, co);
|
||||||
|
sys->constraints = newcl;
|
||||||
|
|
||||||
sp.solution = solution;
|
sp.solution = solution;
|
||||||
sp.sys = sys;
|
sp.sys = sys;
|
||||||
sp.run = run;
|
sp.run = run;
|
||||||
|
70
src/output.c
70
src/output.c
@ -200,17 +200,32 @@ correspondingSend (System sys, int rd)
|
|||||||
void
|
void
|
||||||
tracePrint (System sys)
|
tracePrint (System sys)
|
||||||
{
|
{
|
||||||
|
int i, j;
|
||||||
|
int lastrid;
|
||||||
|
int width;
|
||||||
|
Termlist newtl;
|
||||||
|
|
||||||
|
void sticks (int i)
|
||||||
|
{
|
||||||
|
while (i > 0)
|
||||||
|
{
|
||||||
|
printf ("|\t");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sticksLine (void)
|
||||||
|
{
|
||||||
|
sticks (width);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (sys->latex)
|
if (sys->latex)
|
||||||
{
|
{
|
||||||
//latexTracePrint(sys);
|
//latexTracePrint(sys);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i, j;
|
|
||||||
int lastrid;
|
|
||||||
int width;
|
|
||||||
Termlist newtl;
|
|
||||||
|
|
||||||
/* fix the 'next' knowledge, this is required because sometimes
|
/* fix the 'next' knowledge, this is required because sometimes
|
||||||
* when calling this function, the next knowledge is not stored
|
* when calling this function, the next knowledge is not stored
|
||||||
* yet, but required for the general form of the output . */
|
* yet, but required for the general form of the output . */
|
||||||
@ -270,21 +285,6 @@ tracePrint (System sys)
|
|||||||
|
|
||||||
/* now we print the actual trace */
|
/* now we print the actual trace */
|
||||||
|
|
||||||
void sticks (int i)
|
|
||||||
{
|
|
||||||
while (i > 0)
|
|
||||||
{
|
|
||||||
printf ("|\t");
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sticksLine (void)
|
|
||||||
{
|
|
||||||
sticks (width);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
linePrint (width);
|
linePrint (width);
|
||||||
lastrid = -1;
|
lastrid = -1;
|
||||||
for (i = 0; i <= sys->step; i++)
|
for (i = 0; i <= sys->step; i++)
|
||||||
@ -356,6 +356,21 @@ attackDisplayAscii (System sys)
|
|||||||
Termlist newtl;
|
Termlist newtl;
|
||||||
struct tracebuf *tb;
|
struct tracebuf *tb;
|
||||||
|
|
||||||
|
void sticks (int i)
|
||||||
|
{
|
||||||
|
while (i > 0)
|
||||||
|
{
|
||||||
|
printf ("|\t");
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void sticksLine (void)
|
||||||
|
{
|
||||||
|
sticks (width);
|
||||||
|
printf ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* attack trace buffer */
|
/* attack trace buffer */
|
||||||
tb = sys->attack;
|
tb = sys->attack;
|
||||||
length = sys->attack->length;
|
length = sys->attack->length;
|
||||||
@ -413,21 +428,6 @@ attackDisplayAscii (System sys)
|
|||||||
|
|
||||||
/* now we print the actual trace */
|
/* now we print the actual trace */
|
||||||
|
|
||||||
void sticks (int i)
|
|
||||||
{
|
|
||||||
while (i > 0)
|
|
||||||
{
|
|
||||||
printf ("|\t");
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sticksLine (void)
|
|
||||||
{
|
|
||||||
sticks (width);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
linePrint (width);
|
linePrint (width);
|
||||||
lastrid = -1;
|
lastrid = -1;
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
|
15
src/runs.c
15
src/runs.c
@ -404,9 +404,11 @@ agentOfRun (const System sys, const int run)
|
|||||||
Roledef
|
Roledef
|
||||||
roledefDuplicate1 (const Roledef rd)
|
roledefDuplicate1 (const Roledef rd)
|
||||||
{
|
{
|
||||||
|
Roledef newrd;
|
||||||
|
|
||||||
if (rd == NULL)
|
if (rd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Roledef newrd = makeRoledef ();
|
newrd = makeRoledef ();
|
||||||
memcpy (newrd, rd, sizeof (struct roledef));
|
memcpy (newrd, rd, sizeof (struct roledef));
|
||||||
newrd->next = NULL;
|
newrd->next = NULL;
|
||||||
return newrd;
|
return newrd;
|
||||||
@ -419,9 +421,11 @@ roledefDuplicate1 (const Roledef rd)
|
|||||||
Roledef
|
Roledef
|
||||||
roledefDuplicate (Roledef rd)
|
roledefDuplicate (Roledef rd)
|
||||||
{
|
{
|
||||||
|
Roledef newrd;
|
||||||
|
|
||||||
if (rd == NULL)
|
if (rd == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
Roledef newrd = roledefDuplicate1 (rd);
|
newrd = roledefDuplicate1 (rd);
|
||||||
newrd->next = roledefDuplicate (rd->next);
|
newrd->next = roledefDuplicate (rd->next);
|
||||||
return newrd;
|
return newrd;
|
||||||
}
|
}
|
||||||
@ -472,6 +476,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
Termlist fromlist = NULL;
|
Termlist fromlist = NULL;
|
||||||
Termlist tolist = NULL;
|
Termlist tolist = NULL;
|
||||||
Term extterm = NULL;
|
Term extterm = NULL;
|
||||||
|
Term newvar;
|
||||||
|
|
||||||
/* claim runid, allocate space */
|
/* claim runid, allocate space */
|
||||||
rid = sys->maxruns;
|
rid = sys->maxruns;
|
||||||
@ -493,7 +498,7 @@ roleInstance (const System sys, const Protocol protocol, const Role role,
|
|||||||
{
|
{
|
||||||
/* There is a TYPE constant in the parameter list.
|
/* There is a TYPE constant in the parameter list.
|
||||||
* Generate a new local variable for this run, with this type */
|
* Generate a new local variable for this run, with this type */
|
||||||
Term newvar = makeTermType (VARIABLE, scanfrom->term->left.symb, rid);
|
newvar = makeTermType (VARIABLE, scanfrom->term->left.symb, rid);
|
||||||
sys->variables = termlistAdd (sys->variables, newvar);
|
sys->variables = termlistAdd (sys->variables, newvar);
|
||||||
newvar->stype = termlistAdd (NULL, scanto->term);
|
newvar->stype = termlistAdd (NULL, scanto->term);
|
||||||
tolist = termlistAdd (tolist, newvar);
|
tolist = termlistAdd (tolist, newvar);
|
||||||
@ -785,6 +790,8 @@ protocolsPrint (Protocol p)
|
|||||||
void
|
void
|
||||||
rolePrint (Role r)
|
rolePrint (Role r)
|
||||||
{
|
{
|
||||||
|
Roledef rd;
|
||||||
|
|
||||||
if (r == NULL)
|
if (r == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -794,7 +801,7 @@ rolePrint (Role r)
|
|||||||
printf ("]]\n");
|
printf ("]]\n");
|
||||||
locVarPrint (r->locals);
|
locVarPrint (r->locals);
|
||||||
|
|
||||||
Roledef rd = r->roledef;
|
rd = r->roledef;
|
||||||
while (rd != NULL)
|
while (rd != NULL)
|
||||||
{
|
{
|
||||||
roledefPrint (rd);
|
roledefPrint (rd);
|
||||||
|
@ -209,11 +209,13 @@ substitutionlistConcat (Substitutionlist sl1, Substitutionlist sl2)
|
|||||||
Termlist
|
Termlist
|
||||||
substitutionBatch (Termlist tl, Substitutionlist sl)
|
substitutionBatch (Termlist tl, Substitutionlist sl)
|
||||||
{
|
{
|
||||||
|
Termlist newtl;
|
||||||
|
|
||||||
if (tl == NULL)
|
if (tl == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (sl == NULL)
|
if (sl == NULL)
|
||||||
return termlistDuplicate (tl);
|
return termlistDuplicate (tl);
|
||||||
Termlist newtl = NULL;
|
newtl = NULL;
|
||||||
while (tl != NULL)
|
while (tl != NULL)
|
||||||
{
|
{
|
||||||
newtl = termlistAdd (newtl, termSubstituteList (tl->term, sl));
|
newtl = termlistAdd (newtl, termSubstituteList (tl->term, sl));
|
||||||
|
@ -104,10 +104,12 @@ hash (char *s)
|
|||||||
void
|
void
|
||||||
insert (Symbol s)
|
insert (Symbol s)
|
||||||
{
|
{
|
||||||
|
int hv;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return; /* illegal insertion of empty stuff */
|
return; /* illegal insertion of empty stuff */
|
||||||
|
|
||||||
int hv = hash (s->text);
|
hv = hash (s->text);
|
||||||
s->next = symbtab[hv];
|
s->next = symbtab[hv];
|
||||||
symbtab[hv] = s;
|
symbtab[hv] = s;
|
||||||
}
|
}
|
||||||
@ -116,11 +118,14 @@ insert (Symbol s)
|
|||||||
Symbol
|
Symbol
|
||||||
lookup (char *s)
|
lookup (char *s)
|
||||||
{
|
{
|
||||||
|
int hv;
|
||||||
|
Symbol t;
|
||||||
|
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
int hv = hash (s);
|
hv = hash (s);
|
||||||
Symbol t = symbtab[hv];
|
t = symbtab[hv];
|
||||||
|
|
||||||
while (t != NULL)
|
while (t != NULL)
|
||||||
{
|
{
|
||||||
|
@ -220,12 +220,14 @@ termlistAppend (const Termlist tl, const Term term)
|
|||||||
Termlist
|
Termlist
|
||||||
termlistConcat (Termlist tl1, Termlist tl2)
|
termlistConcat (Termlist tl1, Termlist tl2)
|
||||||
{
|
{
|
||||||
|
Termlist scan;
|
||||||
|
|
||||||
if (tl1 == NULL)
|
if (tl1 == NULL)
|
||||||
return tl2;
|
return tl2;
|
||||||
if (tl2 == NULL)
|
if (tl2 == NULL)
|
||||||
return tl1;
|
return tl1;
|
||||||
|
|
||||||
Termlist scan = tl1;
|
scan = tl1;
|
||||||
while (scan->next != NULL)
|
while (scan->next != NULL)
|
||||||
scan = scan->next;
|
scan = scan->next;
|
||||||
scan->next = tl2;
|
scan->next = tl2;
|
||||||
|
@ -90,8 +90,10 @@ makeTermTuple (Term t1, Term t2)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return t2;
|
return t2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (t2 == NULL)
|
if (t2 == NULL)
|
||||||
{
|
{
|
||||||
return t1;
|
return t1;
|
||||||
|
@ -104,13 +104,13 @@ tracebufInit (void)
|
|||||||
void
|
void
|
||||||
tracebufDone (struct tracebuf *tb)
|
tracebufDone (struct tracebuf *tb)
|
||||||
{
|
{
|
||||||
|
Roledef rd;
|
||||||
|
|
||||||
if (tb == NULL)
|
if (tb == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Roledef rd;
|
|
||||||
|
|
||||||
varbufDone (tb->variables);
|
varbufDone (tb->variables);
|
||||||
if (tb->length > 0)
|
if (tb->length > 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user