result_t (*checkfunc)(net_t,tree_t)
This function acts as the "driver" for an algorithm. It takes as arguments
a net and a formula. It should examine whether the formula holds for the
given net, and return the result. The function may return NULL
to indicate that an error has occurred. Note: For deadlock checkers, the
formula argument can be ignored (it is NULL
).
The data structures used for storing nets and formulae are defined
in netconv.h
and tree.h
, respectively.
The sets of places and transitions of the net are stored in simple
lists of type list_t
. This data type is defined in
list.h
. The for_list
macro allows you to
iterate over all the elements in a list.
tree_t
is a binary tree structure used for storing a formula.
Internal nodes are inscribed with operators, while leaf nodes are inscribed
with places (of the net). The meaning of such a leaf is "the place associated
with this leaf is marked".
The functions task is to evaluate the formula's validity. How this task is
accomplished is entirely in your own responsibility. All the current algorithms
work by writing both the net and the formula into files and running some
external program. External programs should be called with nc_run
(implemented in netconv.c
); direct use of system()
is deprecated.
The function output_formula
in tree.c
goes through
a formula tree and prints its contents to a stream. The exact output can be
customized, so this function may save you a bit of work.
While the algorithm is running you may want to print messages to the screen,
e.g. to inform the user about what is currently going on. Please do not use
printf
directly; use the functions nc_info
,
nc_print
and nc_error
instead. These are implemented
in netconv.c
and emit messages to the standard output or standard
error stream. All of these functions can take multiple arguments just like
printf
does. Using these functions is encouraged because later
versions of the tool may want to redirect or filter the output.
The function should return a data structure of type result_t
(which is defined and explained in greater detail in netconv.h
).
A new, empty structure can be generated by nc_create_result
.
Most importantly, a result_t
struct contains the field
holds
(designed to take the yes/no answer) and the field
example
which is a list that can hold a sequence of transitions
in the intermediary net. This can be used for giving a firing sequence
that witnesses or falsifies the formula.
example
is of type list_t
(see above). You can
add elements to the list with list_add
(defined in
list.c
). Since this list is supposed to hold a sequence
of transitions, it is assumed that the elements in it are of type
node_t
.