#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lcmaps_log.h"
#include "pdl_rule.h"
#include "pdl_policy.h"
#include "pdl_variable.h"
Go to the source code of this file.
Functions | |
rule_t * | _add_rule (const record_t *state, const record_t *true_branch, const record_t *false_branch) |
const rule_t * | find_state (const rule_t *rule, const char *state) |
int | find_insert_position (const int *list, const int rule_number, unsigned int high) |
unsigned int | rule_number (const rule_t *rule) |
BOOL | make_list (int *new_list, const int *list, const int rule_number, const unsigned int depth) |
unsigned int | count_rules (const rule_t *rule) |
void | update_list (unsigned int *rules, unsigned int rule) |
const rule_t * | get_rule_number (unsigned int rule_num) |
void | start_new_rules (void) |
void | allow_new_rules (BOOL allow) |
rule_t * | add_rule (record_t *state, record_t *true_branch, record_t *false_branch) |
BOOL | check_rule_for_recursion (const rule_t *rule) |
recursion_t | has_recursion (const rule_t *rule, int *list, unsigned int depth, unsigned int *seen_rules) |
void | reduce_rule (rule_t *rule) |
void | show_rules (const rule_t *rule) |
void | free_rules (rule_t *rule) |
const rule_t * | get_top_rule (void) |
void | set_top_rule (const rule_t *rule) |
Definition in file pdl_rule.c.
|
Rules come in three different forms:
They share a common structure. First the left hand side gives the starting state and right hand side the states to transit to. This means that each rule has a starting state and depending on the form one or two transit states:
Definition at line 151 of file pdl_rule.c. References rule_s::false_branch, find_policy(), find_state(), record_s::lineno, rule_s::lineno, policy_s::lineno, rule_s::next, PDL_ERROR, policy_t, record_t, rule_t, rule_s::state, record_s::string, rule_s::true_branch, and warning(). Referenced by add_rule(). |
|
Add a new rule to the list of rules. This function acts as a wrapper function for _add_rule().
Definition at line 93 of file pdl_rule.c. References _add_rule(), record_t, rule_t, and record_s::string. |
|
Is it allowed to add new rules?
Definition at line 78 of file pdl_rule.c. Referenced by allow_rules(). |
|
Check the rule for occurances of recursion.
Definition at line 228 of file pdl_rule.c. References count_rules(), get_rule_number(), has_recursion(), lineno, rule_s::lineno, PDL_WARNING, RECURSION, recursion_t, rule_t, TRUE, and warning(). Referenced by check_policies_for_recursion(). |
|
Count the number of rules that follow 'rule' inclusive.
Definition at line 265 of file pdl_rule.c. References rule_s::next, and rule_t. Referenced by check_rule_for_recursion(). |
|
Based on a sorted list, find the position where to insert an new element without disturbing the ordering in the list. The search is a binary search.
Definition at line 496 of file pdl_rule.c. References rule_number(). Referenced by make_list(), and update_list(). |
|
Find a state with name state.
Definition at line 210 of file pdl_rule.c. References find_state(), rule_s::next, rule_t, and rule_s::state. Referenced by _add_rule(), find_state(), has_recursion(), and pdl_next_plugin(). |
|
Free all resources associated with the rules.
Definition at line 645 of file pdl_rule.c. References rule_s::false_branch, rule_s::next, rule_t, rule_s::state, and rule_s::true_branch. Referenced by add_policy(), and free_policies(). |
|
Give the position of the rule in the policy, return that rule.
Definition at line 286 of file pdl_rule.c. References rule_s::next, and rule_t. Referenced by check_rule_for_recursion(). |
|
Get the top rule.
Definition at line 666 of file pdl_rule.c. References rule_t. |
|
Check the a rule for recursion. This is done in a recursive manner. From the top rule, all possible paths are considered. Each path becomes a top of its own and from their all possible paths are traveled. Each time the tree is searched at a greater depth, a list is kept to tell which states have been seen for the current path. In this list of states no duplicates should be present. If a seen state state already appears in the list, the path taken is recursive. This information is propagated back up the traveled tree. At the same time another list is maintained. In this list all visited states are remembered. Duplicates are not added. When all possible paths have been traveled, the list tells all visited rules. When a particular rule is not part of the tree, it is also not listed in the list. This way one can check for disconnected rules.
Definition at line 326 of file pdl_rule.c. References rule_s::false_branch, find_state(), rule_s::lineno, lineno, make_list(), NO_RECURSION, PDL_ERROR, RECURSION, RECURSION_HANDLED, recursion_t, rule_number(), rule_t, rule_s::state, rule_s::true_branch, update_list(), and warning(). Referenced by check_rule_for_recursion(). |
|
Make a new sorted list based on the current list and the element to be inserted. The element will only be added to the list if it is not already present.
Definition at line 534 of file pdl_rule.c. References find_insert_position(), rule_number(), and TRUE. Referenced by has_recursion(). |
|
Reduce a rule to its elementry form, i.e. all variables in the rule are substituted by their respective values.
Definition at line 566 of file pdl_rule.c. References rule_s::false_branch, FALSE_BRANCH, reduce_to_var(), rule_t, rule_s::state, STATE, rule_s::true_branch, and TRUE_BRANCH. Referenced by reduce_policies(). |
|
Given a rule, find the corresponding position in the policy.
Definition at line 433 of file pdl_rule.c. References rule_s::next, and rule_t. Referenced by find_insert_position(), has_recursion(), and make_list(). |
|
Set the top rule to a new value.
Definition at line 678 of file pdl_rule.c. References rule_t. Referenced by free_policies(), and reduce_policies(). |
|
Show a rule and its descendants.
Definition at line 623 of file pdl_rule.c. References rule_s::false_branch, lcmaps_log_debug(), rule_s::next, rule_t, rule_s::state, and rule_s::true_branch. Referenced by show_policies(). |
|
Start a new list of rules. Definition at line 65 of file pdl_rule.c. Referenced by add_policy(). |
|
Update the list that hold the visited rules. This is a sorted list for easy insertion and look-up. Duplicate rules are not inserted. The first element of the list tells the total number of elements that follow.
Definition at line 461 of file pdl_rule.c. References find_insert_position(). Referenced by has_recursion(). |