- Large rewrite of switch code. Instead of having switch parameters in

the (monstrously large) system structure, there is now a global
  'switchdata' structure originating in switches.c. This makes it much
  easier to see what's happening.
  * Note: although this code has been tested, there might be some
    hiccups, because doing multiple search&replace actions over all
    files is bound to cause some problems.
This commit is contained in:
ccremers 2005-06-07 15:02:27 +00:00
parent c4fad31f25
commit 1bdaf7b5d9
17 changed files with 400 additions and 325 deletions

View File

@ -31,6 +31,7 @@
#include "warshall.h" #include "warshall.h"
#include "timer.h" #include "timer.h"
#include "type.h" #include "type.h"
#include "switches.h"
extern Term CLAIM_Secret; extern Term CLAIM_Secret;
extern Term CLAIM_Nisynch; extern Term CLAIM_Nisynch;
@ -170,7 +171,7 @@ arachneDone ()
void void
indentPrefixPrint (const int annotate, const int jumps) indentPrefixPrint (const int annotate, const int jumps)
{ {
if (sys->output == ATTACK && globalError == 0) if (switches.output == ATTACK && globalError == 0)
{ {
// Arachne, attack, not an error // Arachne, attack, not an error
// We assume that means DOT output // We assume that means DOT output
@ -409,7 +410,7 @@ add_read_goals (const int run, const int old, const int new)
{ {
if (rd->type == READ) if (rd->type == READ)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
if (count == 0) if (count == 0)
{ {
@ -427,7 +428,7 @@ add_read_goals (const int run, const int old, const int new)
rd = rd->next; rd = rd->next;
i++; i++;
} }
if ((count > 0) && sys->output == PROOF) if ((count > 0) && switches.output == PROOF)
{ {
eprintf ("\n"); eprintf ("\n");
} }
@ -522,7 +523,7 @@ role_name_print (const int run)
void void
proof_suppose_run (const int run, const int oldlength, const int newlength) proof_suppose_run (const int run, const int oldlength, const int newlength)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
int reallength; int reallength;
@ -553,7 +554,7 @@ proof_suppose_run (const int run, const int oldlength, const int newlength)
void void
proof_select_goal (Binding b) proof_select_goal (Binding b)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
Roledef rd; Roledef rd;
@ -573,7 +574,7 @@ proof_select_goal (Binding b)
void void
proof_cannot_bind (const Binding b, const int run, const int index) proof_cannot_bind (const Binding b, const int run, const int index)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -586,7 +587,7 @@ proof_cannot_bind (const Binding b, const int run, const int index)
void void
proof_suppose_binding (Binding b) proof_suppose_binding (Binding b)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
Roledef rd; Roledef rd;
@ -785,7 +786,7 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
printf ("\n"); printf ("\n");
} }
#endif #endif
if (cryptlist != NULL && sys->output == PROOF) if (cryptlist != NULL && switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -925,7 +926,7 @@ bind_existing_to_goal (const Binding b, const int run, const int index)
flag = termMguSubTerm (b->term, rd->message, flag = termMguSubTerm (b->term, rd->message,
subterm_iterate, sys->know->inverses, NULL); subterm_iterate, sys->know->inverses, NULL);
// Did it work? // Did it work?
if (found == 0 && sys->output == PROOF) if (found == 0 && switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Cannot bind "); eprintf ("Cannot bind ");
@ -954,7 +955,7 @@ bind_existing_run (const Binding b, const Protocol p, const Role r,
if (sys->runs[run].protocol == p && sys->runs[run].role == r) if (sys->runs[run].protocol == p && sys->runs[run].role == r)
{ {
found++; found++;
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
if (found == 1) if (found == 1)
{ {
@ -973,7 +974,7 @@ bind_existing_run (const Binding b, const Protocol p, const Role r,
indentDepth--; indentDepth--;
} }
} }
if (sys->output == PROOF && found == 0) if (switches.output == PROOF && found == 0)
{ {
indentPrint (); indentPrint ();
eprintf ("There is no existing run for "); eprintf ("There is no existing run for ");
@ -2033,10 +2034,10 @@ select_goal ()
int mode; int mode;
// mode bits local storage // mode bits local storage
mode = sys->switchGoalSelectMethod; mode = switches.arachneSelector;
// Find the most constrained goal // Find the most constrained goal
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Listing open goals that might be chosen: "); eprintf ("Listing open goals that might be chosen: ");
@ -2103,7 +2104,7 @@ select_goal ()
buf_constrain = 0; buf_constrain = 0;
buf_weight = 0; buf_weight = 0;
if (sys->output == PROOF && best != NULL) if (switches.output == PROOF && best != NULL)
eprintf (", "); eprintf (", ");
// We will shift this mode variable // We will shift this mode variable
@ -2129,10 +2130,10 @@ select_goal ()
{ {
min_constrain = buf_constrain; min_constrain = buf_constrain;
best = b; best = b;
if (sys->output == PROOF) if (switches.output == PROOF)
eprintf ("*"); eprintf ("*");
} }
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
termPrint (b->term); termPrint (b->term);
if (mode & 2) if (mode & 2)
@ -2145,7 +2146,7 @@ select_goal ()
} }
bl = bl->next; bl = bl->next;
} }
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
if (best == NULL) if (best == NULL)
eprintf ("none"); eprintf ("none");
@ -2219,7 +2220,7 @@ bind_goal_new_m0 (const Binding b)
{ {
found++; found++;
proof_suppose_binding (b); proof_suppose_binding (b);
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("* I.e. retrieving "); eprintf ("* I.e. retrieving ");
@ -2245,7 +2246,7 @@ bind_goal_new_m0 (const Binding b)
tl = tl->next; tl = tl->next;
} }
if (found == 0 && sys->output == PROOF) if (found == 0 && switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Term "); eprintf ("Term ");
@ -2302,7 +2303,7 @@ bind_goal_new_encrypt (const Binding b)
rd->next->next->message = termDuplicateUV (term); rd->next->next->message = termDuplicateUV (term);
index = 2; index = 2;
proof_suppose_run (run, 0, index + 1); proof_suppose_run (run, 0, index + 1);
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("* Encrypting "); eprintf ("* Encrypting ");
@ -2334,7 +2335,7 @@ bind_goal_new_encrypt (const Binding b)
if (!can_be_encrypted) if (!can_be_encrypted)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Term "); eprintf ("Term ");
@ -2357,7 +2358,7 @@ bind_goal_new_intruder_run (const Binding b)
{ {
int flag; int flag;
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Can we bind "); eprintf ("Can we bind ");
@ -2419,7 +2420,7 @@ bind_goal_regular_run (const Binding b)
// A good candidate // A good candidate
found++; found++;
if (sys->output == PROOF && found == 1) if (switches.output == PROOF && found == 1)
{ {
indentPrint (); indentPrint ();
eprintf ("The term ", found); eprintf ("The term ", found);
@ -2427,7 +2428,7 @@ bind_goal_regular_run (const Binding b)
eprintf eprintf
(" matches patterns from the role definitions. Investigate.\n"); (" matches patterns from the role definitions. Investigate.\n");
} }
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("%i. It matches the pattern ", found); eprintf ("%i. It matches the pattern ", found);
@ -2458,7 +2459,7 @@ bind_goal_regular_run (const Binding b)
// Bind to all possible sends of regular runs // Bind to all possible sends of regular runs
found = 0; found = 0;
flag = iterate_role_sends (bind_this_role_send); flag = iterate_role_sends (bind_this_role_send);
if (sys->output == PROOF && found == 0) if (switches.output == PROOF && found == 0)
{ {
indentPrint (); indentPrint ();
eprintf ("The term "); eprintf ("The term ");
@ -2493,7 +2494,7 @@ bind_goal_old_intruder_run (Binding b)
if (rd->type == SEND) if (rd->type == SEND)
{ {
found++; found++;
if (sys->output == PROOF && found == 1) if (switches.output == PROOF && found == 1)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -2508,7 +2509,7 @@ bind_goal_old_intruder_run (Binding b)
} }
} }
} }
if (sys->output == PROOF && found == 0) if (switches.output == PROOF && found == 0)
{ {
indentPrint (); indentPrint ();
eprintf ("No existing intruder runs to match to.\n"); eprintf ("No existing intruder runs to match to.\n");
@ -2538,7 +2539,7 @@ bind_goal (const Binding b)
// if (1 == 0) // if (1 == 0)
if (bind_old_goal (b)) if (bind_old_goal (b))
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Goal for term "); eprintf ("Goal for term ");
@ -2567,7 +2568,7 @@ bind_goal (const Binding b)
if (!inKnowledge (sys->know, function)) if (!inKnowledge (sys->know, function))
{ {
// Prune because we didn't know it before, and it is never subterm-sent // Prune because we didn't know it before, and it is never subterm-sent
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("* Because "); eprintf ("* Because ");
@ -2582,7 +2583,7 @@ bind_goal (const Binding b)
// Keylevel lemmas: improves on the previous one // Keylevel lemmas: improves on the previous one
if (!isPossiblySent (b->term)) if (!isPossiblySent (b->term))
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
eprintf eprintf
("Rejecting a term as a regular bind because key levels are off: "); ("Rejecting a term as a regular bind because key levels are off: ");
@ -2654,7 +2655,7 @@ prune_theorems ()
// Check all types of the local agents according to the matching type // Check all types of the local agents according to the matching type
if (!checkTypeLocals (sys)) if (!checkTypeLocals (sys))
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -2695,7 +2696,7 @@ prune_theorems ()
} }
else else
{ // real leaf { // real leaf
if (sys->match == 0 || !isTermVariable (agent)) if (switches.match == 0 || !isTermVariable (agent))
{ // either strict matching, or not a variable, so we should check matching types { // either strict matching, or not a variable, so we should check matching types
if (agent->stype == NULL) if (agent->stype == NULL)
{ // Too generic { // Too generic
@ -2713,7 +2714,7 @@ prune_theorems ()
if (!sensibleagent) if (!sensibleagent)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned because the agent "); eprintf ("Pruned because the agent ");
@ -2738,7 +2739,7 @@ prune_theorems ()
agent = deVar (tl->term); agent = deVar (tl->term);
if (!realTermVariable (agent) && inTermlist (sys->untrusted, agent)) if (!realTermVariable (agent) && inTermlist (sys->untrusted, agent))
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -2770,7 +2771,7 @@ prune_theorems ()
} }
if (inTermlist (sys->untrusted, actor)) if (inTermlist (sys->untrusted, actor))
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -2805,7 +2806,7 @@ prune_theorems ()
{ {
if (!bindings_c_minimal ()) if (!bindings_c_minimal ())
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned because this is not <=c-minimal.\n"); eprintf ("Pruned because this is not <=c-minimal.\n");
@ -2828,7 +2829,7 @@ prune_theorems ()
if (termInTerm (b->term, TERM_Hidden)) if (termInTerm (b->term, TERM_Hidden))
{ {
// Prune the state: we can never meet this // Prune the state: we can never meet this
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned because intruder can never construnct "); eprintf ("Pruned because intruder can never construnct ");
@ -2840,12 +2841,12 @@ prune_theorems ()
// Check for encryption levels // Check for encryption levels
/* /*
* if (sys->match < 2 * if (switches.match < 2
*/ */
if (term_encryption_level (b->term) > max_encryption_level) if (term_encryption_level (b->term) > max_encryption_level)
{ {
// Prune: we do not need to construct such terms // Prune: we do not need to construct such terms
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned because the encryption level of "); eprintf ("Pruned because the encryption level of ");
@ -2863,7 +2864,7 @@ prune_theorems ()
if (!inKnowledge (sys->know, b->term)) if (!inKnowledge (sys->know, b->term))
{ {
// Not in initial knowledge of the intruder // Not in initial knowledge of the intruder
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned because the function "); eprintf ("Pruned because the function ");
@ -2894,7 +2895,7 @@ prune_bounds ()
if (passed_time_limit ()) if (passed_time_limit ())
{ {
// Oh no, we ran out of time! // Oh no, we ran out of time!
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned: ran out of allowed time (-T %i switch)\n", eprintf ("Pruned: ran out of allowed time (-T %i switch)\n",
@ -2906,20 +2907,20 @@ prune_bounds ()
} }
/* prune for proof depth */ /* prune for proof depth */
if (proofDepth > sys->switch_maxproofdepth) if (proofDepth > switches.maxproofdepth)
{ {
// Hardcoded limit on proof tree depth // Hardcoded limit on proof tree depth
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned: proof tree too deep: %i (-d %i switch)\n", eprintf ("Pruned: proof tree too deep: %i (-d %i switch)\n",
proofDepth, sys->switch_maxproofdepth); proofDepth, switches.maxproofdepth);
} }
return 1; return 1;
} }
/* prune for trace length */ /* prune for trace length */
if (sys->switch_maxtracelength < INT_MAX) if (switches.maxtracelength < INT_MAX)
{ {
int tracelength; int tracelength;
int run; int run;
@ -2937,23 +2938,23 @@ prune_bounds ()
run++; run++;
} }
/* test */ /* test */
if (tracelength > sys->switch_maxtracelength) if (tracelength > switches.maxtracelength)
{ {
// Hardcoded limit on proof tree depth // Hardcoded limit on proof tree depth
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned: trace too long: %i (-l %i switch)\n", eprintf ("Pruned: trace too long: %i (-l %i switch)\n",
tracelength, sys->switch_maxtracelength); tracelength, switches.maxtracelength);
} }
return 1; return 1;
} }
} }
if (num_regular_runs > sys->switchRuns) if (num_regular_runs > switches.runs)
{ {
// Hardcoded limit on runs // Hardcoded limit on runs
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Pruned: too many regular runs (%i).\n", num_regular_runs); eprintf ("Pruned: too many regular runs (%i).\n", num_regular_runs);
@ -2963,12 +2964,12 @@ prune_bounds ()
// This needs some foundation. Probably * 2^max_encryption_level // This needs some foundation. Probably * 2^max_encryption_level
//!@todo Fix this bound //!@todo Fix this bound
if ((sys->match < 2) if ((switches.match < 2)
&& (num_intruder_runs > && (num_intruder_runs >
((double) sys->switchRuns * max_encryption_level * 8))) ((double) switches.runs * max_encryption_level * 8)))
{ {
// Hardcoded limit on iterations // Hardcoded limit on iterations
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -2979,9 +2980,9 @@ prune_bounds ()
} }
// Limit on exceeding any attack length // Limit on exceeding any attack length
if (sys->prune == 2 && get_semitrace_length () >= attack_length) if (switches.prune == 2 && get_semitrace_length () >= attack_length)
{ {
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -3010,7 +3011,7 @@ prune_claim_specifics ()
{ {
sys->current_claim->count = sys->current_claim->count =
statesIncrease (sys->current_claim->count); statesIncrease (sys->current_claim->count);
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -3025,7 +3026,7 @@ prune_claim_specifics ()
{ {
sys->current_claim->count = sys->current_claim->count =
statesIncrease (sys->current_claim->count); statesIncrease (sys->current_claim->count);
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf eprintf
@ -3045,7 +3046,7 @@ add_claim_specifics (const Claimlist cl, const Roledef rd)
/** /**
* Secrecy claim * Secrecy claim
*/ */
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("* To verify the secrecy claim, we add the term "); eprintf ("* To verify the secrecy claim, we add the term ");
@ -3093,15 +3094,15 @@ property_check ()
* By the way the claim is handled, this automatically means a flaw. * By the way the claim is handled, this automatically means a flaw.
*/ */
count_false (); count_false ();
if (sys->output == ATTACK) if (switches.output == ATTACK)
{ {
if (sys->switchXMLoutput) if (switches.xml)
{ {
xmlOutSemitrace (sys); xmlOutSemitrace (sys);
} }
else else
{ {
if (sys->latex == 1) if (switches.latex == 1)
{ {
latexSemiState (); latexSemiState ();
} }
@ -3117,7 +3118,7 @@ property_check ()
{ {
// Shortest attack // Shortest attack
attack_length = attack_this; attack_length = attack_this;
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("New shortest attack found with trace length %i.\n", eprintf ("New shortest attack found with trace length %i.\n",
@ -3157,7 +3158,7 @@ iterate ()
count = goal_add (b->term, b->run_to, b->ev_to, b->level); count = goal_add (b->term, b->run_to, b->ev_to, b->level);
// Show this in output // Show this in output
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Expanding tuple goal "); eprintf ("Expanding tuple goal ");
@ -3193,7 +3194,7 @@ iterate ()
/* /*
* all goals bound, check for property * all goals bound, check for property
*/ */
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("All goals are now bound.\n"); eprintf ("All goals are now bound.\n");
@ -3275,7 +3276,7 @@ arachne ()
* set up claim role(s) * set up claim role(s)
*/ */
if (sys->switchRuns == 0) if (switches.runs == 0)
{ {
// No real checking. // No real checking.
return; return;
@ -3311,8 +3312,7 @@ arachne ()
Protocol p; Protocol p;
Role r; Role r;
if (sys->switchClaimToCheck == NULL if (switches.filterClaim == NULL || switches.filterClaim == cl->type)
|| sys->switchClaimToCheck == cl->type)
{ {
int run; int run;
@ -3322,7 +3322,7 @@ arachne ()
p = (Protocol) cl->protocol; p = (Protocol) cl->protocol;
r = (Role) cl->role; r = (Role) cl->role;
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Testing Claim "); eprintf ("Testing Claim ");
@ -3365,7 +3365,7 @@ arachne ()
//! Indent back //! Indent back
indentDepth--; indentDepth--;
if (sys->output == PROOF) if (switches.output == PROOF)
{ {
indentPrint (); indentPrint ();
eprintf ("Proof complete for this claim.\n"); eprintf ("Proof complete for this claim.\n");

View File

@ -13,6 +13,7 @@
#include "term.h" #include "term.h"
#include "termmap.h" #include "termmap.h"
#include "arachne.h" #include "arachne.h"
#include "switches.h"
#include <malloc.h> #include <malloc.h>
static System sys; static System sys;
@ -295,7 +296,8 @@ goal_graph_create ()
else else
{ {
// It doesn't occur first in a READ, which shouldn't be happening // It doesn't occur first in a READ, which shouldn't be happening
if (sys->output == if (switches.
output ==
PROOF) PROOF)
{ {
eprintf eprintf

View File

@ -10,6 +10,7 @@
#include "symbol.h" #include "symbol.h"
#include "substitution.h" #include "substitution.h"
#include "compiler.h" #include "compiler.h"
#include "switches.h"
/* /*
Simple sys pointer as a global. Yields cleaner code although it's against programming standards. Simple sys pointer as a global. Yields cleaner code although it's against programming standards.
@ -481,7 +482,7 @@ commEvent (int event, Tac tc)
torole = claim; torole = claim;
/* check for ignored claim types */ /* check for ignored claim types */
if (sys->switchClaimToCheck != NULL && sys->switchClaimToCheck != claim) if (switches.filterClaim != NULL && switches.filterClaim != claim)
{ {
/* abort the construction of the node */ /* abort the construction of the node */
return; return;
@ -796,7 +797,7 @@ protocolCompile (Symbol prots, Tac tc, Tac tcroles)
Term rolename; Term rolename;
Role r; Role r;
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
rolename = levelVar (tcroles->t1.sym); rolename = levelVar (tcroles->t1.sym);
rolename->stype = termlistAdd (NULL, TERM_Agent); rolename->stype = termlistAdd (NULL, TERM_Agent);
@ -1426,7 +1427,7 @@ compute_prec_sets (const System sys)
#ifdef DEBUG #ifdef DEBUG
// Porparam = 100 (weirdness) [x][cc][debug] can turn of the synchronising label sets (override). // Porparam = 100 (weirdness) [x][cc][debug] can turn of the synchronising label sets (override).
if (sys->porparam == 100) if (switches.switchP == 100)
{ {
termlistDelete (sys->synchronising_labels); termlistDelete (sys->synchronising_labels);
sys->synchronising_labels = NULL; sys->synchronising_labels = NULL;

View File

@ -363,15 +363,15 @@ main (int argc, char **argv)
sys = systemInit (); sys = systemInit ();
if (switch_arachne->count > 0) if (switch_arachne->count > 0)
{ {
sys->engine = ARACHNE_ENGINE; switches.engine = ARACHNE_ENGINE;
bindingInit (sys); bindingInit (sys);
} }
/* init compiler for this system */ /* init compiler for this system */
compilerInit (sys); compilerInit (sys);
/* transfer command line */ /* transfer command line */
sys->argc = argc; switches.argc = argc;
sys->argv = argv; switches.argv = argv;
if (switch_echo->count > 0) if (switch_echo->count > 0)
{ {
@ -383,64 +383,64 @@ main (int argc, char **argv)
/* handle switches */ /* handle switches */
sys->switchRuns = switch_maximum_runs->ival[0]; /* maximum number of runs */ switches.runs = switch_maximum_runs->ival[0]; /* maximum number of runs */
if (switch_implicit_choose->count > 0) if (switch_implicit_choose->count > 0)
/* allow implicit chooses */ /* allow implicit chooses */
sys->switchForceChoose = 0; switches.forceChoose = 0;
if (switch_choose_first->count > 0) if (switch_choose_first->count > 0)
sys->switchChooseFirst = 1; /* priority to chooses */ switches.chooseFirst = 1; /* priority to chooses */
if (switch_enable_read_symmetries->count > 0) if (switch_enable_read_symmetries->count > 0)
{ {
if (switch_enable_symmetry_order->count > 0) if (switch_enable_symmetry_order->count > 0)
error error
("--read-symm and --symm-order cannot be used at the same time."); ("--read-symm and --symm-order cannot be used at the same time.");
sys->switchReadSymm = 1; switches.readSymmetries = 1;
} }
if (switch_enable_symmetry_order->count > 0) if (switch_enable_symmetry_order->count > 0)
sys->switchSymmOrder = 1; /* enable symmetry order */ switches.orderSymmetries = 1; /* enable symmetry order */
if (switch_disable_agent_symmetries->count > 0) if (switch_disable_agent_symmetries->count > 0)
sys->switchAgentSymm = 0; /* disable agent symmetry order */ switches.agentSymmetries = 0; /* disable agent symmetry order */
if (switch_disable_noclaims_reductions->count > 0) if (switch_disable_noclaims_reductions->count > 0)
sys->switchNomoreClaims = 0; /* disable no more claims cutter */ switches.pruneNomoreClaims = 0; /* disable no more claims cutter */
if (switch_disable_endgame_reductions->count > 0) if (switch_disable_endgame_reductions->count > 0)
sys->switchReduceEndgame = 0; /* disable endgame cutter */ switches.reduceEndgame = 0; /* disable endgame cutter */
if (switch_disable_claim_symmetry->count > 0) if (switch_disable_claim_symmetry->count > 0)
sys->switchReduceClaims = 0; /* disable claim symmetry cutter */ switches.reduceClaims = 0; /* disable claim symmetry cutter */
if (switch_summary->count > 0) if (switch_summary->count > 0)
sys->output = SUMMARY; /* report summary on stdout */ switches.output = SUMMARY; /* report summary on stdout */
if (switch_proof->count > 0) if (switch_proof->count > 0)
sys->output = PROOF; /* report proof on stdout (for arachne only) */ switches.output = PROOF; /* report proof on stdout (for arachne only) */
/* /*
* The scenario selector has an important side effect; when it is non-null, * The scenario selector has an important side effect; when it is non-null,
* any scenario traversing selects chooses first. * any scenario traversing selects chooses first.
*/ */
sys->switchScenario = switch_scenario->ival[0]; /* scenario selector */ switches.scenario = switch_scenario->ival[0]; /* scenario selector */
sys->switchScenarioSize = switch_scenario_size->ival[0]; /* scenario size */ switches.scenarioSize = switch_scenario_size->ival[0]; /* scenario size */
if (sys->switchScenario == 0 && sys->switchScenarioSize > 0) if (switches.scenario == 0 && switches.scenarioSize > 0)
{ {
/* no scenario, but a size is set. so override */ /* no scenario, but a size is set. so override */
#ifdef DEBUG #ifdef DEBUG
warning ("Scanning scenarios."); warning ("Scanning scenarios.");
#endif #endif
sys->switchScenario = -1; switches.scenario = -1;
} }
if (sys->switchScenario < 0) if (switches.scenario < 0)
{ {
sys->output = SCENARIOS; switches.output = SCENARIOS;
} }
if (sys->switchScenario != 0 && sys->switchScenarioSize == 0) if (switches.scenario != 0 && switches.scenarioSize == 0)
{ {
#ifdef DEBUG #ifdef DEBUG
warning warning
("Scenario selection without trace prefix length implies --choose-first."); ("Scenario selection without trace prefix length implies --choose-first.");
#endif #endif
sys->switchChooseFirst = 1; switches.chooseFirst = 1;
} }
#ifdef DEBUG #ifdef DEBUG
sys->porparam = switch_por_parameter->ival[0]; switches.switchP = switch_por_parameter->ival[0];
#endif #endif
sys->latex = switch_latex_output->count; switches.latex = switch_latex_output->count;
sys->know = emptyKnowledge (); sys->know = emptyKnowledge ();
@ -463,7 +463,7 @@ main (int argc, char **argv)
if (claim == NULL) if (claim == NULL)
error ("Unknown claim type to check."); error ("Unknown claim type to check.");
if (inTermlist (claim->stype, TERM_Claim)) if (inTermlist (claim->stype, TERM_Claim))
sys->switchClaimToCheck = claim; switches.filterClaim = claim;
else else
error ("Claim type to check is not a claim."); error ("Claim type to check is not a claim.");
} }
@ -478,7 +478,7 @@ main (int argc, char **argv)
/* compile */ /* compile */
if (sys->engine != ARACHNE_ENGINE) if (switches.engine != ARACHNE_ENGINE)
{ {
// Compile as many runs as possible // Compile as many runs as possible
compile (spdltac, switch_maximum_runs->ival[0]); compile (spdltac, switch_maximum_runs->ival[0]);
@ -518,42 +518,42 @@ main (int argc, char **argv)
/* add parameters to system */ /* add parameters to system */
sys->clp = (switch_clp->count > 0 ? 1 : 0); switches.clp = (switch_clp->count > 0 ? 1 : 0);
sys->traverse = switch_traversal_method->ival[0]; switches.traverse = switch_traversal_method->ival[0];
sys->match = switch_match_method->ival[0]; switches.match = switch_match_method->ival[0];
mgu_match = sys->match; mgu_match = switches.match;
sys->prune = switch_pruning_method->ival[0]; switches.prune = switch_pruning_method->ival[0];
time_limit_seconds = switch_timer->ival[0]; time_limit_seconds = switch_timer->ival[0];
set_time_limit (switch_timer->ival[0]); set_time_limit (switch_timer->ival[0]);
if (switch_progress_bar->count > 0) if (switch_progress_bar->count > 0)
/* enable progress display */ /* enable progress display */
sys->switchS = 50000; switches.reportStates = 50000;
else else
/* disable progress display */ /* disable progress display */
sys->switchS = 0; switches.reportStates = 0;
if (switch_state_space_graph->count > 0) if (switch_state_space_graph->count > 0)
{ {
/* enable state space graph output */ /* enable state space graph output */
sys->output = STATESPACE; //!< New method switches.output = STATESPACE; //!< New method
} }
if (switch_empty->count > 0) if (switch_empty->count > 0)
sys->output = EMPTY; switches.output = EMPTY;
if (switch_prune_proof_depth->ival[0] >= 0) if (switch_prune_proof_depth->ival[0] >= 0)
sys->switch_maxproofdepth = switch_prune_proof_depth->ival[0]; switches.maxproofdepth = switch_prune_proof_depth->ival[0];
if (switch_prune_trace_length->ival[0] >= 0) if (switch_prune_trace_length->ival[0] >= 0)
sys->switch_maxtracelength = switch_prune_trace_length->ival[0]; switches.maxtracelength = switch_prune_trace_length->ival[0];
if (switch_goal_select_method->ival[0] >= 0) if (switch_goal_select_method->ival[0] >= 0)
sys->switchGoalSelectMethod = switch_goal_select_method->ival[0]; switches.arachneSelector = switch_goal_select_method->ival[0];
#ifdef DEBUG #ifdef DEBUG
/* in debugging mode, some extra switches */ /* in debugging mode, some extra switches */
if (switch_debug_indent->count > 0) if (switch_debug_indent->count > 0)
indentActivate (); indentActivate ();
if (DEBUGL (1)) if (DEBUGL (1))
printf ("Using traversal method %i.\n", sys->traverse); printf ("Using traversal method %i.\n", switches.traverse);
#else #else
/* non-debug defaults */ /* non-debug defaults */
sys->switchM = 0; switches.reportMemory = 0;
#endif #endif
/* /*
@ -563,7 +563,7 @@ main (int argc, char **argv)
*/ */
/* Latex only makes sense for attacks */ /* Latex only makes sense for attacks */
if (sys->latex && sys->output != ATTACK) if (switches.latex && switches.output != ATTACK)
{ {
error ("Scyther can only generate LaTeX output for attacks."); error ("Scyther can only generate LaTeX output for attacks.");
} }
@ -571,7 +571,7 @@ main (int argc, char **argv)
if (switch_incremental_runs->count > 0 || if (switch_incremental_runs->count > 0 ||
switch_incremental_trace_length->count > 0) switch_incremental_trace_length->count > 0)
{ {
if (sys->output != ATTACK && sys->output != EMPTY) if (switches.output != ATTACK && switches.output != EMPTY)
{ {
error ("Incremental traversal only for empty or attack output."); error ("Incremental traversal only for empty or attack output.");
} }
@ -579,11 +579,11 @@ main (int argc, char **argv)
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (4)) if (DEBUGL (4))
{ {
warning ("Selected output method is %i", sys->output); warning ("Selected output method is %i", switches.output);
} }
#endif #endif
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
arachneInit (sys); arachneInit (sys);
} }
@ -594,7 +594,7 @@ main (int argc, char **argv)
*/ */
/* latex header? */ /* latex header? */
if (sys->latex) if (switches.latex)
latexInit (sys, argc, argv); latexInit (sys, argc, argv);
/* model check system */ /* model check system */
@ -628,7 +628,7 @@ main (int argc, char **argv)
if (sys->attack != NULL && sys->attack->length != 0) if (sys->attack != NULL && sys->attack->length != 0)
{ {
if (sys->output == ATTACK) if (switches.output == ATTACK)
{ {
attackDisplay (sys); attackDisplay (sys);
} }
@ -654,12 +654,12 @@ main (int argc, char **argv)
} }
/* latex closeup */ /* latex closeup */
if (sys->latex) if (switches.latex)
latexDone (sys); latexDone (sys);
/* Transfer any scenario counting to the exit code, /* Transfer any scenario counting to the exit code,
* assuming that there is no error. */ * assuming that there is no error. */
if (exitcode != EXIT_ERROR && sys->switchScenario < 0) if (exitcode != EXIT_ERROR && switches.scenario < 0)
{ {
exitcode = sys->countScenario; exitcode = sys->countScenario;
} }
@ -668,7 +668,7 @@ main (int argc, char **argv)
* Now we clean up any memory that was allocated. * Now we clean up any memory that was allocated.
*/ */
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
arachneDone (); arachneDone ();
bindingDone (); bindingDone ();
@ -710,7 +710,7 @@ timersPrint (const System sys)
// #define NOTIMERS // #define NOTIMERS
/* display stats */ /* display stats */
if (sys->output != SUMMARY) if (switches.output != SUMMARY)
{ {
globalError++; globalError++;
} }
@ -723,7 +723,7 @@ timersPrint (const System sys)
/* scenario info */ /* scenario info */
if (sys->switchScenario > 0) if (switches.scenario > 0)
{ {
eprintf ("scen_st\t"); eprintf ("scen_st\t");
statesFormat (sys->statesScenario); statesFormat (sys->statesScenario);
@ -845,7 +845,7 @@ timersPrint (const System sys)
} }
/* reset globalError */ /* reset globalError */
if (sys->output != SUMMARY) if (switches.output != SUMMARY)
{ {
globalError--; globalError--;
} }
@ -885,7 +885,7 @@ MC_incRuns (const System sys)
* the whole space, then we just continue. However, if * the whole space, then we just continue. However, if
* we're looking to prune, ``the buck stops here''. */ * we're looking to prune, ``the buck stops here''. */
if (sys->prune != 0) if (switches.prune != 0)
{ {
flag = 0; flag = 0;
} }
@ -942,7 +942,7 @@ MC_incTraces (const System sys)
* the whole space, then we just continue. However, if * the whole space, then we just continue. However, if
* we're looking to prune, ``the buck stops here''. */ * we're looking to prune, ``the buck stops here''. */
if (sys->prune != 0) if (switches.prune != 0)
{ {
flag = 0; flag = 0;
} }
@ -980,13 +980,13 @@ MC_single (const System sys)
int int
modelCheck (const System sys) modelCheck (const System sys)
{ {
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphInit (sys); graphInit (sys);
} }
/* modelcheck the system */ /* modelcheck the system */
switch (sys->engine) switch (switches.engine)
{ {
case POR_ENGINE: case POR_ENGINE:
traverse (sys); traverse (sys);
@ -995,25 +995,25 @@ modelCheck (const System sys)
arachne (); arachne ();
break; break;
default: default:
error ("Unknown engine type %i.", sys->engine); error ("Unknown engine type %i.", switches.engine);
} }
/* clean up any states display */ /* clean up any states display */
if (sys->switchS > 0) if (switches.reportStates > 0)
{ {
// States: 1.000e+06 // States: 1.000e+06
fprintf (stderr, " \r"); fprintf (stderr, " \r");
} }
timersPrint (sys); timersPrint (sys);
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphDone (sys); graphDone (sys);
} }
if (sys->switchScenario > 0) if (switches.scenario > 0)
{ {
/* Traversing a scenario. Maybe we ran out. */ /* Traversing a scenario. Maybe we ran out. */
if (sys->switchScenario > sys->countScenario) if (switches.scenario > sys->countScenario)
{ {
/* Signal as error */ /* Signal as error */
exit (1); exit (1);

View File

@ -100,11 +100,11 @@ main (int argc, char **argv)
* ------------------------------------------------ * ------------------------------------------------
*/ */
sys = systemInit (); /* process any command-line switches */
sys->argc = argc; switchesInit (argc, argv);
sys->argv = argv;
process_switches (sys); /* start system */
sys = systemInit ();
/* init compiler for this system */ /* init compiler for this system */
compilerInit (sys); compilerInit (sys);
@ -122,10 +122,10 @@ main (int argc, char **argv)
/* compile */ /* compile */
if (sys->engine != ARACHNE_ENGINE) if (switches.engine != ARACHNE_ENGINE)
{ {
// Compile as many runs as possible // Compile as many runs as possible
compile (spdltac, sys->switchRuns); compile (spdltac, switches.runs);
} }
else else
{ {
@ -170,18 +170,18 @@ main (int argc, char **argv)
*/ */
/* Latex only makes sense for attacks */ /* Latex only makes sense for attacks */
if (sys->latex && sys->output != ATTACK) if (switches.latex && switches.output != ATTACK)
{ {
error ("Scyther can only generate LaTeX output for attacks."); error ("Scyther can only generate LaTeX output for attacks.");
} }
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (4)) if (DEBUGL (4))
{ {
warning ("Selected output method is %i", sys->output); warning ("Selected output method is %i", switches.output);
} }
#endif #endif
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
arachneInit (sys); arachneInit (sys);
} }
@ -192,11 +192,11 @@ main (int argc, char **argv)
*/ */
/* xml init */ /* xml init */
if (sys->switchXMLoutput) if (switches.xml)
xmlOutInit (); xmlOutInit ();
/* latex header? */ /* latex header? */
if (sys->latex) if (switches.latex)
latexInit (sys, argc, argv); latexInit (sys, argc, argv);
/* model check system */ /* model check system */
@ -216,7 +216,7 @@ main (int argc, char **argv)
if (sys->attack != NULL && sys->attack->length != 0) if (sys->attack != NULL && sys->attack->length != 0)
{ {
if (sys->output == ATTACK) if (switches.output == ATTACK)
{ {
attackDisplay (sys); attackDisplay (sys);
} }
@ -242,16 +242,16 @@ main (int argc, char **argv)
} }
/* latex closeup */ /* latex closeup */
if (sys->latex) if (switches.latex)
latexDone (sys); latexDone (sys);
/* xml closeup */ /* xml closeup */
if (sys->switchXMLoutput) if (switches.xml)
xmlOutDone (); xmlOutDone ();
/* Transfer any scenario counting to the exit code, /* Transfer any scenario counting to the exit code,
* assuming that there is no error. */ * assuming that there is no error. */
if (exitcode != EXIT_ERROR && sys->switchScenario < 0) if (exitcode != EXIT_ERROR && switches.scenario < 0)
{ {
exitcode = sys->countScenario; exitcode = sys->countScenario;
} }
@ -260,7 +260,7 @@ main (int argc, char **argv)
* Now we clean up any memory that was allocated. * Now we clean up any memory that was allocated.
*/ */
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
arachneDone (); arachneDone ();
bindingDone (); bindingDone ();
@ -299,7 +299,7 @@ timersPrint (const System sys)
// #define NOTIMERS // #define NOTIMERS
/* display stats */ /* display stats */
if (sys->output != SUMMARY) if (switches.output != SUMMARY)
{ {
globalError++; globalError++;
} }
@ -312,7 +312,7 @@ timersPrint (const System sys)
/* scenario info */ /* scenario info */
if (sys->switchScenario > 0) if (switches.scenario > 0)
{ {
eprintf ("scen_st\t"); eprintf ("scen_st\t");
statesFormat (sys->statesScenario); statesFormat (sys->statesScenario);
@ -434,7 +434,7 @@ timersPrint (const System sys)
} }
/* reset globalError */ /* reset globalError */
if (sys->output != SUMMARY) if (switches.output != SUMMARY)
{ {
globalError--; globalError--;
} }
@ -474,7 +474,7 @@ MC_incRuns (const System sys)
* the whole space, then we just continue. However, if * the whole space, then we just continue. However, if
* we're looking to prune, ``the buck stops here''. */ * we're looking to prune, ``the buck stops here''. */
if (sys->prune != 0) if (switches.prune != 0)
{ {
flag = 0; flag = 0;
} }
@ -531,7 +531,7 @@ MC_incTraces (const System sys)
* the whole space, then we just continue. However, if * the whole space, then we just continue. However, if
* we're looking to prune, ``the buck stops here''. */ * we're looking to prune, ``the buck stops here''. */
if (sys->prune != 0) if (switches.prune != 0)
{ {
flag = 0; flag = 0;
} }
@ -569,13 +569,13 @@ MC_single (const System sys)
int int
modelCheck (const System sys) modelCheck (const System sys)
{ {
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphInit (sys); graphInit (sys);
} }
/* modelcheck the system */ /* modelcheck the system */
switch (sys->engine) switch (switches.engine)
{ {
case POR_ENGINE: case POR_ENGINE:
if (sys->maxruns > 0) if (sys->maxruns > 0)
@ -587,25 +587,25 @@ modelCheck (const System sys)
arachne (); arachne ();
break; break;
default: default:
error ("Unknown engine type %i.", sys->engine); error ("Unknown engine type %i.", switches.engine);
} }
/* clean up any states display */ /* clean up any states display */
if (sys->switchS > 0) if (switches.reportStates > 0)
{ {
// States: 1.000e+06 // States: 1.000e+06
fprintf (stderr, " \r"); fprintf (stderr, " \r");
} }
timersPrint (sys); timersPrint (sys);
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphDone (sys); graphDone (sys);
} }
if (sys->switchScenario > 0) if (switches.scenario > 0)
{ {
/* Traversing a scenario. Maybe we ran out. */ /* Traversing a scenario. Maybe we ran out. */
if (sys->switchScenario > sys->countScenario) if (switches.scenario > sys->countScenario)
{ {
/* Signal as error */ /* Signal as error */
exit (1); exit (1);

View File

@ -12,6 +12,7 @@
#include "system.h" #include "system.h"
#include "modelchecker.h" #include "modelchecker.h"
#include "match_basic.h" #include "match_basic.h"
#include "switches.h"
//! Get the candidates list for typeless basic stuff //! Get the candidates list for typeless basic stuff
__inline__ Termlist __inline__ Termlist
@ -132,7 +133,7 @@ fixVariablelist (const struct fvpass fp, const Knowledge know,
{ {
/* substitute */ /* substitute */
varlist->term->subst = tlscan->term; varlist->term->subst = tlscan->term;
if (validSubst (fp.sys->match, varlist->term)) if (validSubst (switches.match, varlist->term))
{ {
#ifdef DEBUG #ifdef DEBUG
if (DEBUGL (5)) if (DEBUGL (5))
@ -191,7 +192,7 @@ matchRead_basic (const System sys, const int run,
/* remove variable linkages */ /* remove variable linkages */
newterm = termDuplicateUV (fp.roledef->message); newterm = termDuplicateUV (fp.roledef->message);
/* a candidate, but if this is a t4 traversal, is it also an old one? */ /* a candidate, but if this is a t4 traversal, is it also an old one? */
if (fp.sys->traverse < 4 || if (switches.traverse < 4 ||
fp.roledef->forbidden == NULL || fp.roledef->forbidden == NULL ||
enabled_basic (fp.sys, fp.roledef->forbidden, newterm)) enabled_basic (fp.sys, fp.roledef->forbidden, newterm))
{ {

View File

@ -18,6 +18,7 @@
#include "debug.h" #include "debug.h"
#include "match_clp.h" #include "match_clp.h"
#include "modelchecker.h" #include "modelchecker.h"
#include "switches.h"
struct solvepass struct solvepass
{ {
@ -94,7 +95,7 @@ solve (const struct solvepass sp, Constraintlist solvecons)
tlscan = tlres; tlscan = tlres;
while (tlscan != NULL && tlres != MGUFAIL) while (tlscan != NULL && tlres != MGUFAIL)
{ {
if (validSubst (sp.sys->match, tlscan->term)) if (validSubst (switches.match, tlscan->term))
{ {
tlscan = tlscan->next; tlscan = tlscan->next;
} }

View File

@ -17,7 +17,7 @@
//! Internal constant. If true, typed checking //! Internal constant. If true, typed checking
/** /**
* Analoguous to sys->match * Analoguous to switches.match
* 0 typed * 0 typed
* 1 basic typeflaws * 1 basic typeflaws
* 2 all typeflaws * 2 all typeflaws
@ -26,7 +26,7 @@ static int mgu_match = 0;
extern Term TERM_Hidden; extern Term TERM_Hidden;
//! Set mgu mode (basically sys->match) //! Set mgu mode (basically switches.match)
void void
setMguMode (const int match) setMguMode (const int match)
{ {

View File

@ -20,6 +20,7 @@
#include "tracebuf.h" #include "tracebuf.h"
#include "attackminimize.h" #include "attackminimize.h"
#include "claim.h" #include "claim.h"
#include "switches.h"
/* /*
@ -107,14 +108,14 @@ int
traverse (const System sys) traverse (const System sys)
{ {
/* maybe chooses have precedence over _all_ methods */ /* maybe chooses have precedence over _all_ methods */
if (sys->switchChooseFirst) if (switches.chooseFirst)
{ {
if (traverse_chooses_first (sys)) if (traverse_chooses_first (sys))
return 1; return 1;
} }
/* branch for traversal methods */ /* branch for traversal methods */
switch (sys->traverse) switch (switches.traverse)
{ {
case 1: case 1:
return traverseSimple (sys); return traverseSimple (sys);
@ -125,7 +126,7 @@ traverse (const System sys)
case 5: case 5:
case 6: case 6:
case 7: case 7:
error ("%i is an obsolete traversal method.", sys->traverse); error ("%i is an obsolete traversal method.", switches.traverse);
case 8: case 8:
return traversePOR4 (sys); return traversePOR4 (sys);
case 9: case 9:
@ -137,7 +138,7 @@ traverse (const System sys)
case 12: case 12:
return traversePOR8 (sys); return traversePOR8 (sys);
default: default:
error ("%i is NOT an existing traversal method.", sys->traverse); error ("%i is NOT an existing traversal method.", switches.traverse);
} }
} }
@ -203,18 +204,18 @@ executeStep (const System sys, const int run)
sys->states = statesIncrease (sys->states); sys->states = statesIncrease (sys->states);
/* what about scenario exploration? */ /* what about scenario exploration? */
if (sys->switchScenario && sys->step + 1 > sys->switchScenarioSize) if (switches.scenario && sys->step + 1 > switches.scenarioSize)
{ {
/* count states within scenario */ /* count states within scenario */
sys->statesScenario = statesIncrease (sys->statesScenario); sys->statesScenario = statesIncrease (sys->statesScenario);
} }
/* show progression */ /* show progression */
if (sys->switchS > 0) if (switches.reportStates > 0)
{ {
sys->interval = statesIncrease (sys->interval); sys->interval = statesIncrease (sys->interval);
if (!statesSmallerThan if (!statesSmallerThan
(sys->interval, (unsigned long int) sys->switchS)) (sys->interval, (unsigned long int) switches.reportStates))
{ {
globalError++; globalError++;
sys->interval = STATES0; sys->interval = STATES0;
@ -228,7 +229,7 @@ executeStep (const System sys, const int run)
/* store new node numbder */ /* store new node numbder */
sys->traceNode[sys->step] = sys->states; sys->traceNode[sys->step] = sys->states;
/* the construction below always assumes MAX_GRAPH_STATES to be smaller than the unsigned long it, which seems realistic. */ /* the construction below always assumes MAX_GRAPH_STATES to be smaller than the unsigned long it, which seems realistic. */
if (sys->output == STATESPACE if (switches.output == STATESPACE
&& statesSmallerThan (sys->states, MAX_GRAPH_STATES)) && statesSmallerThan (sys->states, MAX_GRAPH_STATES))
{ {
/* display graph */ /* display graph */
@ -375,7 +376,7 @@ explorify (const System sys, const int run)
* further traversal. * further traversal.
*/ */
//!@todo This implementation relies on the fact that there are only secrecy, synchr and agreement properties. //!@todo This implementation relies on the fact that there are only secrecy, synchr and agreement properties.
if (sys->switchNomoreClaims && sys->secrets == NULL) if (switches.pruneNomoreClaims && sys->secrets == NULL)
{ /* there are no remaining secrecy claims to be checked */ { /* there are no remaining secrecy claims to be checked */
Roledef rdscan; Roledef rdscan;
int validclaim; int validclaim;
@ -416,7 +417,7 @@ explorify (const System sys, const int run)
* If the run we depend upon has already been activated (otherwise warn!) check for instance ordering * If the run we depend upon has already been activated (otherwise warn!) check for instance ordering
*/ */
if (sys->switchAgentSymm && sys->runs[run].prevSymmRun != -1) if (switches.agentSymmetries && sys->runs[run].prevSymmRun != -1)
{ {
/* there is such a run on which we depend */ /* there is such a run on which we depend */
int ridSymm; int ridSymm;
@ -442,7 +443,7 @@ explorify (const System sys, const int run)
/* we only explore the other half */ /* we only explore the other half */
return 0; return 0;
} }
if (order == 0 && sys->switchReduceClaims) if (order == 0 && switches.reduceClaims)
{ {
/* identical run; only the first would be checked for a claim */ /* identical run; only the first would be checked for a claim */
/* so we cut off this run, including claims, turning it into a dummy run */ /* so we cut off this run, including claims, turning it into a dummy run */
@ -454,7 +455,7 @@ explorify (const System sys, const int run)
/* Special check 3: if after choosing, this run is untrusted and ends on (read|skippedclaim)*, we can remove that part already. /* Special check 3: if after choosing, this run is untrusted and ends on (read|skippedclaim)*, we can remove that part already.
*/ */
if (sys->switchReduceEndgame && roleCap == NULL) if (switches.reduceEndgame && roleCap == NULL)
roleCap = removeIrrelevant (sys, run, rd); roleCap = removeIrrelevant (sys, run, rd);
/* Special check x: if all agents in each run send only encrypted stuff, and all agents are trusted, /* Special check x: if all agents in each run send only encrypted stuff, and all agents are trusted,
@ -479,7 +480,7 @@ explorify (const System sys, const int run)
* Special check b1: symmetry reduction part II on similar read events for equal roles. * Special check b1: symmetry reduction part II on similar read events for equal roles.
*/ */
if (sys->switchReadSymm) if (switches.readSymmetries)
{ {
if (sys->runs[run].firstNonAgentRead == myStep) if (sys->runs[run].firstNonAgentRead == myStep)
{ {
@ -539,7 +540,7 @@ explorify (const System sys, const int run)
* Depends on prevSymm, skipping chooses even. * Depends on prevSymm, skipping chooses even.
*/ */
if (sys->switchSymmOrder && myStep == sys->runs[run].firstReal) if (switches.orderSymmetries && myStep == sys->runs[run].firstReal)
{ {
if (sys->runs[run].prevSymmRun != -1) if (sys->runs[run].prevSymmRun != -1)
{ {
@ -571,10 +572,10 @@ explorify (const System sys, const int run)
* Note: any choose selection after this would result in empty scenarios, so this * Note: any choose selection after this would result in empty scenarios, so this
* should be the last special check. * should be the last special check.
*/ */
if (sys->switchScenario != 0) if (switches.scenario != 0)
{ {
/* two variants. If scenario size is 0, we operate on the old method involving chooses */ /* two variants. If scenario size is 0, we operate on the old method involving chooses */
if (sys->switchScenarioSize == 0) if (switches.scenarioSize == 0)
{ {
/* only after chooses */ /* only after chooses */
if (myStep == 0 && rd->type == READ) if (myStep == 0 && rd->type == READ)
@ -588,18 +589,18 @@ explorify (const System sys, const int run)
sys->countScenario++; sys->countScenario++;
} }
/* If we are displaying scenarios, print it */ /* If we are displaying scenarios, print it */
if (sys->output == SCENARIOS) if (switches.output == SCENARIOS)
{ {
printf ("%i\t", sys->countScenario); printf ("%i\t", sys->countScenario);
scenarioPrint (sys); scenarioPrint (sys);
printf ("\n"); printf ("\n");
} }
/* If it is not the selected one, abort */ /* If it is not the selected one, abort */
if (sys->switchScenario != sys->countScenario) if (switches.scenario != sys->countScenario)
{ {
/* this branch is not interesting */ /* this branch is not interesting */
/* unfortunately, it is also not drawn in the state graph because of this */ /* unfortunately, it is also not drawn in the state graph because of this */
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphScenario (sys, run, rd); graphScenario (sys, run, rd);
} }
@ -614,20 +615,20 @@ explorify (const System sys, const int run)
/* scenario size is not zero */ /* scenario size is not zero */
//!@todo Optimization: if the good scenario is already traversed, other trace prefixes need not be explored any further. //!@todo Optimization: if the good scenario is already traversed, other trace prefixes need not be explored any further.
if (sys->step + 1 == sys->switchScenarioSize) if (sys->step + 1 == switches.scenarioSize)
{ {
/* Now, the prefix has been set. Count it */ /* Now, the prefix has been set. Count it */
if (sys->countScenario < INT_MAX) if (sys->countScenario < INT_MAX)
{ {
sys->countScenario++; sys->countScenario++;
} }
if (sys->output == SCENARIOS) if (switches.output == SCENARIOS)
{ {
/* apparently we want the output */ /* apparently we want the output */
int index; int index;
eprintf ("%i\t", sys->countScenario); eprintf ("%i\t", sys->countScenario);
index = 0; index = 0;
while (index < sys->switchScenarioSize) while (index < switches.scenarioSize)
{ {
roledefPrint (sys->traceEvent[index]); roledefPrint (sys->traceEvent[index]);
eprintf ("#%i; ", sys->traceRun[index]); eprintf ("#%i; ", sys->traceRun[index]);
@ -636,10 +637,10 @@ explorify (const System sys, const int run)
eprintf ("\n"); eprintf ("\n");
} }
/* Is this the selected one? */ /* Is this the selected one? */
if (sys->switchScenario != sys->countScenario) if (switches.scenario != sys->countScenario)
{ {
/* unfortunately, it is also not drawn in the state graph because of this */ /* unfortunately, it is also not drawn in the state graph because of this */
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphScenario (sys, run, rd); graphScenario (sys, run, rd);
} }
@ -796,7 +797,7 @@ tryChoiceSend (const System sys, const int run, const Roledef rd)
/* It will possibly be unblocked by a corresponding read event, /* It will possibly be unblocked by a corresponding read event,
* the actual code would be in explorify, post instantiation of the read event. * the actual code would be in explorify, post instantiation of the read event.
*/ */
if (sys->clp) if (switches.clp)
{ {
block_clp (sys, run); block_clp (sys, run);
} }
@ -837,7 +838,7 @@ tryChoiceRead (const System sys, const int run, const Roledef rd)
int stackKnowPhase = rd->knowPhase; int stackKnowPhase = rd->knowPhase;
rd->knowPhase = sys->knowPhase; rd->knowPhase = sys->knowPhase;
if (sys->clp) if (switches.clp)
{ {
block_clp (sys, run); block_clp (sys, run);
} }
@ -913,8 +914,8 @@ lastActiveRun (const System sys)
{ {
/* there was a previous action, start scan from there */ /* there was a previous action, start scan from there */
#ifdef DEBUG #ifdef DEBUG
if (sys->porparam < 100) if (switches.switchP < 100)
return sys->traceRun[sys->step - 1] + sys->porparam; return sys->traceRun[sys->step - 1] + switches.switchP;
#endif #endif
return sys->traceRun[sys->step - 1]; return sys->traceRun[sys->step - 1];
} }
@ -1113,7 +1114,7 @@ propertyCheck (const System sys)
int int
isTermSecret (const System sys, const Term t) isTermSecret (const System sys, const Term t)
{ {
switch (sys->clp) switch (switches.clp)
{ {
case 0: case 0:
/* test for simple inclusion */ /* test for simple inclusion */
@ -1245,7 +1246,7 @@ violateClaim (const System sys, int length, int claimev, Termlist reqt)
clinfo->failed = statesIncrease (clinfo->failed); // note: for modelchecking secrecy, this can lead to more fails (at further events in branches of the tree) than claim encounters clinfo->failed = statesIncrease (clinfo->failed); // note: for modelchecking secrecy, this can lead to more fails (at further events in branches of the tree) than claim encounters
/* mark the path in the state graph? */ /* mark the path in the state graph? */
if (sys->output == STATESPACE) if (switches.output == STATESPACE)
{ {
graphPath (sys, length); graphPath (sys, length);
} }
@ -1260,7 +1261,7 @@ violateClaim (const System sys, int length, int claimev, Termlist reqt)
/* maybe there is some new pruning going on */ /* maybe there is some new pruning going on */
flag = 0; flag = 0;
switch (sys->prune) switch (switches.prune)
{ {
case 0: case 0:
flag = 1; flag = 1;
@ -1310,14 +1311,14 @@ executeTry (const System sys, int run)
#endif #endif
if (runPoint->type == READ) if (runPoint->type == READ)
{ {
if (sys->clp) if (switches.clp)
return matchRead_clp (sys, run, explorify); return matchRead_clp (sys, run, explorify);
else else
return matchRead_basic (sys, run, explorify); return matchRead_basic (sys, run, explorify);
} }
if (runPoint->type == SEND) if (runPoint->type == SEND)
{ {
if (sys->clp) if (switches.clp)
flag = send_clp (sys, run); flag = send_clp (sys, run);
else else
flag = send_basic (sys, run); flag = send_basic (sys, run);

View File

@ -10,6 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include "system.h" #include "system.h"
#include "latex.h" #include "latex.h"
#include "switches.h"
void void
@ -220,7 +221,7 @@ tracePrint (const System sys)
printf ("\n"); printf ("\n");
} }
if (sys->latex) if (switches.latex)
{ {
//latexTracePrint(sys); //latexTracePrint(sys);
return; return;
@ -331,7 +332,7 @@ tracePrint (const System sys)
printf ("\n"); printf ("\n");
} }
switch (sys->clp) switch (switches.clp)
{ {
case 1: case 1:
indent (); indent ();
@ -481,7 +482,7 @@ attackDisplayAscii (const System sys)
void void
attackDisplay (const System sys) attackDisplay (const System sys)
{ {
if (sys->latex) if (switches.latex)
{ {
attackDisplayLatex (sys); attackDisplayLatex (sys);
} }
@ -507,7 +508,7 @@ graphInit (const System sys)
/* label */ /* label */
printf ("\tcomment = \"$"); printf ("\tcomment = \"$");
commandlinePrint (stdout, sys); commandlinePrint (stdout);
printf ("\";\n"); printf ("\";\n");
/* fit stuff onto the page */ /* fit stuff onto the page */
@ -579,7 +580,7 @@ graphNode (const System sys)
else else
{ {
/* no added knowledge */ /* no added knowledge */
if (sys->switchScenario != 0 && if (switches.scenario != 0 &&
rd != NULL && rd != NULL &&
rd == sys->runs[run].start && rd == sys->runs[run].start &&
rd->type == READ && run == sys->lastChooseRun) rd->type == READ && run == sys->lastChooseRun)

View File

@ -4,6 +4,7 @@
#include "system.h" #include "system.h"
#include "debug.h" #include "debug.h"
#include "output.h" #include "output.h"
#include "switches.h"
extern int globalLatex; extern int globalLatex;
@ -12,7 +13,7 @@ void
reportQuit (const System sys) reportQuit (const System sys)
{ {
/* determine quit or not */ /* determine quit or not */
if (sys->prune >= 3) if (switches.prune >= 3)
{ {
indent (); indent ();
printf ("Quitting after %li claims, at the first violated claim.\n", printf ("Quitting after %li claims, at the first violated claim.\n",
@ -24,7 +25,7 @@ reportQuit (const System sys)
void void
reportStart (const System sys) reportStart (const System sys)
{ {
if (!sys->latex) if (!switches.latex)
{ {
indent (); indent ();
printf ("<REPORT>\n"); printf ("<REPORT>\n");
@ -47,7 +48,7 @@ reportMid (const System sys)
void void
reportEnd (const System sys) reportEnd (const System sys)
{ {
if (!sys->latex) if (!switches.latex)
{ {
indent (); indent ();
printf ("<REPORT>\n"); printf ("<REPORT>\n");
@ -58,7 +59,7 @@ reportEnd (const System sys)
void void
reportSecrecy (const System sys, Term t) reportSecrecy (const System sys, Term t)
{ {
if (sys->output != ATTACK) if (switches.output != ATTACK)
{ {
reportQuit (sys); reportQuit (sys);
return; return;

View File

@ -10,8 +10,10 @@
#include "debug.h" #include "debug.h"
#include "version.h" #include "version.h"
#include "timer.h" #include "timer.h"
#include "switches.h"
#include <limits.h>
extern System sys; struct switchdata switches;
extern struct tacnode *spdltac; extern struct tacnode *spdltac;
extern Term TERM_Claim; extern Term TERM_Claim;
@ -19,6 +21,73 @@ extern Term TERM_Claim;
const char *progname = "scyther"; const char *progname = "scyther";
const char *releasetag = SVNVERSION; const char *releasetag = SVNVERSION;
// Forward declarations
void process_switches ();
//! Init switches
/**
* Set them all to the default settings.
*/
void
switchesInit (int argc, char **argv)
{
// Command-line
switches.argc = argc;
switches.argv = argv;
// Methods
switches.engine = POR_ENGINE; // default is partial ordering engine
switches.match = 0; // default matching
switches.clp = 0;
// Pruning and Bounding
switches.prune = 2; // default pruning method
switches.maxproofdepth = INT_MAX;
switches.maxtracelength = INT_MAX;
switches.runs = INT_MAX;
switches.filterClaim = NULL; // default check all claims
// Modelchecker
switches.traverse = 12; // default traversal method
switches.forceChoose = 1; // force explicit chooses by default
switches.chooseFirst = 0; // no priority to chooses by default
switches.readSymmetries = 0; // don't force read symmetries by default
switches.agentSymmetries = 1; // default enable agent symmetry
switches.orderSymmetries = 0; // don't force symmetry order reduction by default
switches.pruneNomoreClaims = 1; // default cutter when there are no more claims
switches.reduceEndgame = 1; // default cutter of last events in a trace
switches.reduceClaims = 1; // default remove claims from duplicate instance choosers
// Parallellism
switches.scenario = 0;
switches.scenarioSize = 0;
// Arachne
switches.arachneSelector = 3; // default goal selection method
// Misc
switches.switchP = 0; // multi-purpose parameter
// Output
switches.output = ATTACK; // default is to show the attacks
switches.report = 0;
switches.reportClaims = 0; // default don't report on claims
switches.xml = 0; // default no xml output
switches.human = false; // not human friendly by default
switches.reportMemory;
switches.reportTime;
switches.reportStates;
// Obsolete
switches.latex = 0; // latex output?
process_switches ();
}
//! Exit
void
switchesDone (void)
{
}
//! Process a single switch or generate help text //! Process a single switch or generate help text
/** /**
* When process is false, we just generate the help text. * When process is false, we just generate the help text.
@ -29,7 +98,7 @@ const char *releasetag = SVNVERSION;
* The index steps through 1..argc-1. * The index steps through 1..argc-1.
*/ */
int int
switcher (const int process, const System sys, int index) switcher (const int process, int index)
{ {
char *this_arg; // just a shortcut char *this_arg; // just a shortcut
int this_arg_length; // same here int this_arg_length; // same here
@ -166,8 +235,8 @@ switcher (const int process, const System sys, int index)
if (process) if (process)
{ {
argc = sys->argc; argc = switches.argc;
argv = sys->argv; argv = switches.argv;
#ifdef DEBUG #ifdef DEBUG
// Check range for debug; we trust the non-debug version :) // Check range for debug; we trust the non-debug version :)
if (index < 1 || index >= argc) if (index < 1 || index >= argc)
@ -203,8 +272,7 @@ switcher (const int process, const System sys, int index)
else else
{ {
// Select arachne engine // Select arachne engine
sys->engine = ARACHNE_ENGINE; switches.engine = ARACHNE_ENGINE;
bindingInit (sys);
return index; return index;
} }
} }
@ -217,7 +285,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->switchXMLoutput = 1; switches.xml = 1;
return index; return index;
} }
} }
@ -230,7 +298,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->match = integer_argument (); switches.match = integer_argument ();
return index; return index;
} }
} }
@ -259,7 +327,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->switchRuns = integer_argument (); switches.runs = integer_argument ();
return index; return index;
} }
} }
@ -273,7 +341,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->switch_maxtracelength = integer_argument (); switches.maxtracelength = integer_argument ();
return index; return index;
} }
} }
@ -288,7 +356,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->prune = integer_argument (); switches.prune = integer_argument ();
return index; return index;
} }
} }
@ -302,7 +370,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->switchHuman = true; switches.human = true;
return index; return index;
} }
} }
@ -323,7 +391,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->latex = 1; switches.latex = 1;
return index; return index;
} }
} }
@ -337,7 +405,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->output = STATESPACE; switches.output = STATESPACE;
return index; return index;
} }
} }
@ -362,7 +430,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->switchGoalSelectMethod = integer_argument (); switches.arachneSelector = integer_argument ();
return index; return index;
} }
} }
@ -376,7 +444,7 @@ switcher (const int process, const System sys, int index)
else else
{ {
// Proof // Proof
sys->output = PROOF; switches.output = PROOF;
return index; return index;
} }
} }
@ -399,7 +467,7 @@ switcher (const int process, const System sys, int index)
{ {
/* print command line */ /* print command line */
fprintf (stdout, "command\t"); fprintf (stdout, "command\t");
commandlinePrint (stdout, sys); commandlinePrint (stdout);
fprintf (stdout, "\n"); fprintf (stdout, "\n");
return index; return index;
} }
@ -413,7 +481,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->output = SUMMARY; switches.output = SUMMARY;
return index; return index;
} }
} }
@ -428,7 +496,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->switchS = 50000; switches.reportStates = 50000;
return index; return index;
} }
} }
@ -443,7 +511,7 @@ switcher (const int process, const System sys, int index)
} }
else else
{ {
sys->output = EMPTY; switches.output = EMPTY;
return index; return index;
} }
} }
@ -480,7 +548,7 @@ switcher (const int process, const System sys, int index)
{ {
printf ("Usage:\n"); printf ("Usage:\n");
printf (" %s [switches] [FILE]\nSwitches:\n", progname); printf (" %s [switches] [FILE]\nSwitches:\n", progname);
switcher (0, NULL, 0); switcher (0, 0);
exit (0); exit (0);
} }
} }
@ -557,11 +625,11 @@ switcher (const int process, const System sys, int index)
//! Process switches //! Process switches
void void
process_switches (const System sys) process_switches ()
{ {
int index; int index;
if (sys->argc == 1) if (switches.argc == 1)
{ {
printf ("Try '%s --help' for more information, or visit:\n", progname); printf ("Try '%s --help' for more information, or visit:\n", progname);
printf (" http://www.win.tue.nl/~ccremers/scyther/index.html\n"); printf (" http://www.win.tue.nl/~ccremers/scyther/index.html\n");
@ -569,8 +637,8 @@ process_switches (const System sys)
} }
index = 1; index = 1;
while (index < sys->argc && index > 0) while (index < switches.argc && index > 0)
{ {
index = switcher (1, sys, index); index = switcher (1, index);
} }
} }

View File

@ -1,6 +1,68 @@
#ifndef SWITCHES #ifndef SWITCHES
#define SWITCHES #define SWITCHES
void process_switches (const System sys); #include "term.h"
#include "system.h"
void switchesInit ();
void switchesDone ();
//! Command-line switches structure
struct switchdata
{
// Command-line
int argc;
char **argv;
// Methods
int engine; //!< Engine type (POR_ENGINE,ARACHNE_ENGINE)
int match; //!< Matching type.
int clp; //!< Do we use clp?
// Pruning and Bounding
int prune; //!< Type of pruning.
int maxproofdepth; //!< Maximum proof depth
int maxtracelength; //!< Maximum trace length allowed
int runs; //!< The number of runs as in the switch
Term filterClaim; //!< Which claim should be checked?
// Modelchecker
int traverse; //!< Traversal method
int forceChoose; //!< Force chooses for each run, even if involved in first read
int chooseFirst; //!< Priority to chooses, implicit and explicit
int readSymmetries; //!< Enable read symmetry reduction
int agentSymmetries; //!< Enable agent symmetry reduction
int orderSymmetries; //!< Enable symmetry order reduction
int pruneNomoreClaims; //!< Enable no more claims cutter
int reduceEndgame; //!< Enable endgame cutter
int reduceClaims; //!< Symmetry reduction on claims (only works when switchAgentSymm is true)
// Parallellism
int scenario; //!< -1 to count, 0 for disable, 1-n to select the choose scenario
int scenarioSize; //!< Scenario size, also called fixed trace prefix length
// Arachne
int arachneSelector; //!< Goal selection method for Arachne engine
// Misc
int switchP; //!< A multi-purpose integer parameter, passed to the partial order reduction method selected.
// Output
int output; //!< From enum outputs: what should be produced. Default ATTACK.
int report;
int reportClaims; //!< Enable claims report
int xml; //!< xml output
int human; //!< human readable
int reportMemory; //!< Memory display switch.
int reportTime; //!< Time display switch.
int reportStates; //!< Progress display switch. (traversed states)
//! Latex output switch.
/**
* Obsolete. Use globalLatex instead.
*\sa globalLatex
*/
int latex;
};
extern struct switchdata switches;
#endif #endif

View File

@ -16,6 +16,8 @@
#include "tracebuf.h" #include "tracebuf.h"
#include "role.h" #include "role.h"
#include "mgu.h" #include "mgu.h"
#include "switches.h"
#include "binding.h"
/* from compiler.o */ /* from compiler.o */
extern Term TERM_Type; extern Term TERM_Type;
@ -57,32 +59,6 @@ systemInit ()
sys->step = 0; sys->step = 0;
sys->shortestattack = INT_MAX; sys->shortestattack = INT_MAX;
sys->attack = tracebufInit (); sys->attack = tracebufInit ();
/* switches */
sys->engine = POR_ENGINE; // default is partial ordering engine
sys->output = ATTACK; // default is to show the attacks
sys->porparam = 0; // multi-purpose parameter
sys->latex = 0; // latex output?
sys->switchRuns = INT_MAX;
sys->switchScenario = 0;
sys->switchScenarioSize = 0;
sys->switchForceChoose = 1; // force explicit chooses by default
sys->switchChooseFirst = 0; // no priority to chooses by default
sys->switchReadSymm = 0; // don't force read symmetries by default
sys->switchAgentSymm = 1; // default enable agent symmetry
sys->switchSymmOrder = 0; // don't force symmetry order reduction by default
sys->switchNomoreClaims = 1; // default cutter when there are no more claims
sys->switchReduceEndgame = 1; // default cutter of last events in a trace
sys->switchReduceClaims = 1; // default remove claims from duplicate instance choosers
sys->switchClaims = 0; // default don't report on claims
sys->switchClaimToCheck = NULL; // default check all claims
sys->switchXMLoutput = 0; // default no xml output
sys->switchHuman = false; // not human friendly by default
sys->switchGoalSelectMethod = 3; // default goal selection method
sys->traverse = 12; // default traversal method
sys->switch_maxproofdepth = INT_MAX;
sys->switch_maxtracelength = INT_MAX;
sys->maxtracelength = INT_MAX; sys->maxtracelength = INT_MAX;
/* init rundefs */ /* init rundefs */
@ -97,19 +73,21 @@ systemInit ()
sys->secrets = NULL; // list of claimed secrets sys->secrets = NULL; // list of claimed secrets
sys->synchronising_labels = NULL; sys->synchronising_labels = NULL;
sys->attack = NULL; sys->attack = NULL;
sys->prune = 2; // default pruning method
/* no protocols => no protocol preprocessed */ /* no protocols => no protocol preprocessed */
sys->rolecount = 0; sys->rolecount = 0;
sys->roleeventmax = 0; sys->roleeventmax = 0;
sys->claimlist = NULL; sys->claimlist = NULL;
sys->labellist = NULL; sys->labellist = NULL;
sys->match = 0; // default matching
sys->attackid = 0; // First attack will have id 1, because the counter is increased before any attacks are displayed. sys->attackid = 0; // First attack will have id 1, because the counter is increased before any attacks are displayed.
/* matching CLP */ /* matching CLP */
sys->constraints = NULL; // no initial constraints sys->constraints = NULL; // no initial constraints
/* Arachne assist */ /* Arachne assist */
if (switches.engine == ARACHNE_ENGINE)
{
bindingInit (sys);
}
sys->bindings = NULL; sys->bindings = NULL;
sys->current_claim = NULL; sys->current_claim = NULL;
@ -151,7 +129,7 @@ systemReset (const System sys)
sys->secrets = NULL; // list of claimed secrets sys->secrets = NULL; // list of claimed secrets
/* transfer switches */ /* transfer switches */
sys->maxtracelength = sys->switch_maxtracelength; sys->maxtracelength = switches.maxtracelength;
/* POR init */ /* POR init */
sys->PORphase = -1; sys->PORphase = -1;
@ -160,11 +138,11 @@ systemReset (const System sys)
/* global latex switch: ugly, but otherwise I must carry it into every /* global latex switch: ugly, but otherwise I must carry it into every
* single subprocedure such as termPrint */ * single subprocedure such as termPrint */
globalLatex = sys->latex; globalLatex = switches.latex;
/* propagate mgu_mode */ /* propagate mgu_mode */
setMguMode (sys->match); setMguMode (switches.match);
} }
//! Initialize runtime system (according to cut traces, limited runs) //! Initialize runtime system (according to cut traces, limited runs)
@ -186,7 +164,7 @@ systemRuns (const System sys)
} }
} }
#ifdef DEBUG #ifdef DEBUG
if (sys->switchScenario < 0) if (switches.scenario < 0)
{ {
warning ("Last run with a choose: %i", sys->lastChooseRun); warning ("Last run with a choose: %i", sys->lastChooseRun);
} }
@ -294,7 +272,7 @@ ensureValidRun (const System sys, int run)
myrun.artefacts = NULL; myrun.artefacts = NULL;
myrun.substitutions = NULL; myrun.substitutions = NULL;
if (sys->engine == POR_ENGINE) if (switches.engine == POR_ENGINE)
{ {
myrun.know = knowledgeDuplicate (sys->know); myrun.know = knowledgeDuplicate (sys->know);
} }
@ -378,7 +356,7 @@ not_read_first (const Roledef rdstart, const Term t)
Term Term
agentOfRunRole (const System sys, const int run, const Term role) agentOfRunRole (const System sys, const int run, const Term role)
{ {
if (sys->engine != ARACHNE_ENGINE) if (switches.engine != ARACHNE_ENGINE)
{ {
// Non-arachne // Non-arachne
Termlist roles; Termlist roles;
@ -762,7 +740,7 @@ roleInstanceArachne (const System sys, const Protocol protocol,
* TODO currently disabled: something weird was goind on causing weird prunes, * TODO currently disabled: something weird was goind on causing weird prunes,
* for match=2. Investigate later. * for match=2. Investigate later.
*/ */
if (0 && not_read_first (rd, oldt) && sys->match == 2) if (0 && not_read_first (rd, oldt) && switches.match == 2)
{ {
/* this term is forced as a choose, or it does not occur in the (first) read event */ /* this term is forced as a choose, or it does not occur in the (first) read event */
if (extterm == NULL) if (extterm == NULL)
@ -898,7 +876,7 @@ roleInstanceModelchecker (const System sys, const Protocol protocol,
/* newvar is apparently new, but it might occur /* newvar is apparently new, but it might occur
* in the first event if it's a read, in which * in the first event if it's a read, in which
* case we forget it */ * case we forget it */
if (sys->switchForceChoose || not_read_first (rd, scanfrom->term)) if (switches.forceChoose || not_read_first (rd, scanfrom->term))
{ {
/* this term is forced as a choose, or it does not occur in the (first) read event */ /* this term is forced as a choose, or it does not occur in the (first) read event */
if (extterm == NULL) if (extterm == NULL)
@ -964,7 +942,7 @@ roleInstanceModelchecker (const System sys, const Protocol protocol,
/* erase any substitutions in the role definition, as they are now copied */ /* erase any substitutions in the role definition, as they are now copied */
termlistSubstReset (role->variables); termlistSubstReset (role->variables);
if (sys->engine == POR_ENGINE) if (switches.engine == POR_ENGINE)
{ {
/* Determine symmetric run */ /* Determine symmetric run */
runs[rid].prevSymmRun = staticRunSymmetry (sys, rid); // symmetry reduction static analysis runs[rid].prevSymmRun = staticRunSymmetry (sys, rid); // symmetry reduction static analysis
@ -986,7 +964,7 @@ void
roleInstance (const System sys, const Protocol protocol, const Role role, roleInstance (const System sys, const Protocol protocol, const Role role,
const Termlist paramlist, Termlist substlist) const Termlist paramlist, Termlist substlist)
{ {
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
roleInstanceArachne (sys, protocol, role, paramlist, substlist); roleInstanceArachne (sys, protocol, role, paramlist, substlist);
} }
@ -1020,7 +998,7 @@ roleInstanceDestroy (const System sys)
* Arachne does real-time reduction of memory, POR does not * Arachne does real-time reduction of memory, POR does not
* Artefact removal can only be done if knowledge sets are empty, as with Arachne * Artefact removal can only be done if knowledge sets are empty, as with Arachne
*/ */
if (sys->engine == ARACHNE_ENGINE) if (switches.engine == ARACHNE_ENGINE)
{ {
Termlist artefacts; Termlist artefacts;
// Remove artefacts // Remove artefacts
@ -1250,7 +1228,7 @@ untrustedAgent (const System sys, Termlist agents)
{ {
if (isTermVariable (agents->term)) if (isTermVariable (agents->term))
{ {
if (sys->clp) if (switches.clp)
{ {
/* clp: variables are difficult */ /* clp: variables are difficult */
/* TODO Add as constraint that they're /* TODO Add as constraint that they're
@ -1360,13 +1338,13 @@ attackLength (struct tracebuf *tb)
} }
void void
commandlinePrint (FILE * stream, const System sys) commandlinePrint (FILE * stream)
{ {
/* print command line */ /* print command line */
int i; int i;
for (i = 0; i < sys->argc; i++) for (i = 0; i < switches.argc; i++)
fprintf (stream, " %s", sys->argv[i]); fprintf (stream, " %s", switches.argv[i]);
} }
//! Get the number of roles in the system. //! Get the number of roles in the system.

View File

@ -103,7 +103,6 @@ struct tracebuf
//! The main state structure. //! The main state structure.
struct system struct system
{ {
int engine; //!< Engine type (POR_ENGINE,ARACHNE_ENGINE)
int step; //!< Step in trace during exploration. Can be managed globally int step; //!< Step in trace during exploration. Can be managed globally
Knowledge know; //!< Knowledge in currect step of system. Knowledge know; //!< Knowledge in currect step of system.
struct parameters *parameters; // misc struct parameters *parameters; // misc
@ -117,41 +116,7 @@ struct system
Termlist secrets; //!< Integrate secrets list into system. Termlist secrets; //!< Integrate secrets list into system.
Termlist synchronising_labels; //!< List of labels that might synchronise. Termlist synchronising_labels; //!< List of labels that might synchronise.
int shortestattack; //!< Length of shortest attack trace. int shortestattack; //!< Length of shortest attack trace.
/* switches */
int output; //!< From enum outputs: what should be produced. Default ATTACK.
int report;
int prune; //!< Type of pruning.
int switch_maxproofdepth; //!< Maximum proof depth
int switch_maxtracelength; //!< Maximum trace length allowed
int maxtracelength; //!< helps to remember the length of the last trace. int maxtracelength; //!< helps to remember the length of the last trace.
int switchM; //!< Memory display switch.
int switchT; //!< Time display switch.
int switchS; //!< Progress display switch. (traversed states)
int porparam; //!< A multi-purpose integer parameter, passed to the partial order reduction method selected.
int switchRuns; //!< The number of runs as in the switch
int switchScenario; //!< -1 to count, 0 for disable, 1-n to select the choose scenario
int switchScenarioSize; //!< Scenario size, also called fixed trace prefix length
int switchForceChoose; //!< Force chooses for each run, even if involved in first read
int switchChooseFirst; //!< Priority to chooses, implicit and explicit
int switchReadSymm; //!< Enable read symmetry reduction
int switchAgentSymm; //!< Enable agent symmetry reduction
int switchSymmOrder; //!< Enable symmetry order reduction
int switchNomoreClaims; //!< Enable no more claims cutter
int switchReduceEndgame; //!< Enable endgame cutter
int switchReduceClaims; //!< Symmetry reduction on claims (only works when switchAgentSymm is true)
int switchClaims; //!< Enable clails report
int switchGoalSelectMethod; //!< Goal selection method for Arachne engine
Term switchClaimToCheck; //!< Which claim should be checked?
int switchXMLoutput; //!< xml output
int switchHuman; //!< human readable
//! Latex output switch.
/**
* Obsolete. Use globalLatex instead.
*\sa globalLatex
*/
int latex;
/* traversal */ /* traversal */
int traverse; //!< Traversal method. int traverse; //!< Traversal method.
@ -166,10 +131,6 @@ struct system
int attackid; //!< Global counter of attacks (used for assigning identifiers) within this Scyther call. int attackid; //!< Global counter of attacks (used for assigning identifiers) within this Scyther call.
int countScenario; //!< Number of scenarios skipped. int countScenario; //!< Number of scenarios skipped.
/* matching */
int match; //!< Matching type.
int clp; //!< Do we use clp?
/* protocol definition */ /* protocol definition */
Protocol protocols; //!< List of protocols in the system Protocol protocols; //!< List of protocols in the system
Termlist locals; //!< List of local terms Termlist locals; //!< List of local terms
@ -201,10 +162,6 @@ struct system
//! Shortest attack storage. //! Shortest attack storage.
struct tracebuf *attack; struct tracebuf *attack;
//! Command line arguments
int argc;
char **argv;
}; };
typedef struct system *System; typedef struct system *System;
@ -239,7 +196,7 @@ int getMaxTraceLength (const System sys);
void agentsOfRunPrint (const System sys, const int run); void agentsOfRunPrint (const System sys, const int run);
void violatedClaimPrint (const System sys, int i); void violatedClaimPrint (const System sys, int i);
int attackLength (struct tracebuf *tb); int attackLength (struct tracebuf *tb);
void commandlinePrint (FILE * stream, const System sys); void commandlinePrint (FILE * stream);
int compute_rolecount (const System sys); int compute_rolecount (const System sys);
int compute_roleeventmax (const System sys); int compute_roleeventmax (const System sys);

View File

@ -10,6 +10,7 @@
#include "termlist.h" #include "termlist.h"
#include "system.h" #include "system.h"
#include "debug.h" #include "debug.h"
#include "switches.h"
/* /*
* Special term definitions from compiler.c * Special term definitions from compiler.c
@ -142,7 +143,7 @@ checkTypeLocals (const System sys)
{ {
if (sys->runs[run].protocol != INTRUDER) if (sys->runs[run].protocol != INTRUDER)
{ {
if (!checkTypeTermlist (sys->match, sys->runs[run].locals)) if (!checkTypeTermlist (switches.match, sys->runs[run].locals))
return false; return false;
} }
run++; run++;

View File

@ -17,6 +17,7 @@
#include "system.h" #include "system.h"
#include "binding.h" #include "binding.h"
#include "arachne.h" // for get_semitrace_length #include "arachne.h" // for get_semitrace_length
#include "switches.h"
#include "xmlout.h" #include "xmlout.h"
@ -411,7 +412,7 @@ isProtocolInvolved (const System sys, const Protocol p)
int int
isEventInteresting (const System sys, const Roledef rd) isEventInteresting (const System sys, const Roledef rd)
{ {
if (sys->switchHuman) if (switches.human)
{ {
if (rd->type != CLAIM) if (rd->type != CLAIM)
{ {
@ -624,7 +625,7 @@ xmlOutSysInfo (const System sys)
xmlPrint ("<system>"); xmlPrint ("<system>");
xmlindent++; xmlindent++;
xmlOutInteger ("match", sys->match); xmlOutInteger ("match", switches.match);
xmlInitialKnowledge (sys); xmlInitialKnowledge (sys);
xmlInvolvedProtocolRoles (sys); xmlInvolvedProtocolRoles (sys);