Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

pdl_main.c File Reference

All functions that do not fit elsewhere can be found here. More...

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "_lcmaps_pluginmanager.h"
#include "lcmaps_log.h"
#include "pdl.h"
#include "pdl_variable.h"
#include "pdl_policy.h"
#include "pdl_rule.h"

Go to the source code of this file.

Functions

void _set_path (const record_t *_path)
record_t_concat_strings (const record_t *s1, const record_t *s2, const char *extra)
void reduce_policies (void)
BOOL plugin_exists (const char *string)
int find_first_space (const char *string)
const policy_tget_current_policy (void)
int pdl_init (const char *name)
int yyparse_errors (void)
const plugin_tget_plugins (void)
int free_plugins (plugin_t **list)
const char * pdl_path (void)
int yyerror (const char *s)
void set_path (record_t *path)
void free_path (void)
record_tconcat_strings (record_t *s1, record_t *s2)
record_tconcat_strings_with_space (record_t *s1, record_t *s2)
const char * pdl_next_plugin (plugin_status_t status)
void free_resources (void)
void warning (pdl_error_t error, const char *s,...)

Variables

const char * script_name = NULL
 If non NULL, the name of the configuration script.

const char * d_path = "/usr/lib"
 Default path where plugins can be found.

const char * path = 0
 Path where plugins can be found.

int path_lineno = 0
 Path line number.

plugin_ttop_plugin = NULL
 First node of the list.

BOOL default_path = TRUE
 Has the default value of the path been changed.

BOOL parse_error = FALSE
 Tell if there have been any error during parsing.

char * level_str [PDL_SAME]
 When a message is printed, how do we spell warning in a given language.

unsigned int lineno = 1
 The first line of a configuration sctipt is labeled 1.


Detailed Description

All functions that do not fit elsewhere can be found here.

In here one can find the more general functions. Most of them are accessible to outside sources. For a complete list of usable function to out side sources,

See also:
pdl.h.
Author:
G.M. Venekamp (venekamp@nikhef.nl)
Version:
Revision
1.42
Date:
Date
2005/03/01 17:05:10

Definition in file pdl_main.c.


Function Documentation

record_t * _concat_strings const record_t s1,
const record_t s2,
const char *  extra
 

Concatenate two string.

Parameters:
s1 first half of the string.
s2 second half of the string.
extra extra string to be inserted between s1 and s2
Returns:
new string which is the concatenation of s1 and s2.

Definition at line 473 of file pdl_main.c.

References PDL_ERROR, record_t, record_s::string, and warning().

Referenced by concat_strings(), and concat_strings_with_space().

void _set_path const record_t _path  ) 
 

Overwrite the default path with the new value. If this function is called more than once, a warning message is displayed for each occurent.

Parameters:
_path The new path.

Definition at line 411 of file pdl_main.c.

References default_path, record_s::lineno, path, path_lineno, PDL_ERROR, record_t, record_s::string, and warning().

Referenced by set_path().

record_t* concat_strings record_t s1,
record_t s2
 

Concatenate two strings. The orginal two strings are freed. When the concatenation fails, the origial strings are still freed. The actual concatenation is done by _concat_strings().

Parameters:
s1 first half of the string.
s2 second half of the string.
Returns:
new string which is the concatenation of s1 and s2.

Definition at line 451 of file pdl_main.c.

References _concat_strings(), record_t, and record_s::string.

record_t* concat_strings_with_space record_t s1,
record_t s2
 

Concatenate two strings. The orginal two strings are freed. When the concatenation fails, the origial strings are still freed. The actual concatenation is done by _concat_strings().

Parameters:
s1 First string.
s2 Second string
Returns:
Concatenated strings of s1 + s2.

Definition at line 507 of file pdl_main.c.

References _concat_strings(), record_t, and record_s::string.

int find_first_space const char *  string  ) 
 

Find the first occurrence of a space in a string.

Parameters:
string String where the first space needs to be found.
Returns:
Position of the first occurrence of the space. If no space could be found, the position is set to the length of the string.

Definition at line 347 of file pdl_main.c.

Referenced by plugin_exists().

void free_path void   ) 
 

Free the string allocated to hold the path

Definition at line 430 of file pdl_main.c.

References default_path, path, and TRUE.

Referenced by free_resources().

int free_plugins plugin_t **  list  ) 
 

Free the list of plugins to which "list" points. Also the pointer to the first plugin is set to NULL.

Parameters:
list Pointer to the plugin list.
Return values:
0 success
1 failure

Definition at line 209 of file pdl_main.c.

References plugin_s::args, lcmaps_log_debug(), plugin_s::name, plugin_s::next, and plugin_t.

Referenced by free_resources(), and pdl_init().

void free_resources void   ) 
 

Free the resources.

Definition at line 671 of file pdl_main.c.

References free_path(), free_plugins(), free_policies(), free_variables(), script_name, and top_plugin.

Referenced by stopEvaluationManager().

const policy_t* get_current_policy void   ) 
 

Return the current policy.

Definition at line 79 of file pdl_main.c.

References policy_t.

Referenced by runEvaluationManager().

const plugin_t* get_plugins void   ) 
 

Get a list of plugins as known by the configuration file.

Returns:
Plugin list (linked list).

Definition at line 154 of file pdl_main.c.

References FALSE_BRANCH, rule_s::false_branch, get_policies(), lcmaps_log(), lcmaps_log_debug(), policy_s::name, policy_s::next, rule_s::next, plugin_t, policies_have_been_reduced(), policy_t, policy_s::rule, rule_t, STATE, rule_s::state, top_plugin, TRUE_BRANCH, and rule_s::true_branch.

Referenced by getPluginNameAndArgs().

int pdl_init const char *  name  ) 
 

Init the pdl engine. The function takes one argument, the name of a configuration file to use.

Parameters:
name Name of the configuration file to use.
Returns:
0 in case the initialization is successful; -1 in case of not being successful.

Definition at line 93 of file pdl_main.c.

References d_path, default_path, free_plugins(), level_str, parse_error, path, PDL_ERROR, PDL_INFO, PDL_UNKNOWN, PDL_WARNING, script_name, top_plugin, TRUE, and warning().

Referenced by startEvaluationManager().

const char* pdl_next_plugin plugin_status_t  status  ) 
 

Find the next plugin to evaluate based on the return status of the previous plugin evaluation. There are three statuses, two of which are rather obvious: either the previous evaluation has succeeded (EVALUATION_SUCCESS), or it has failed (EVALUATION_FAILURE). Based on these results, the next plugin should be the true_branch or false_branch respectively. There is one situation where there is no previous evaluation and that is at the very beginning. The very first call to this function should have (EVALUATION_START) as arguments. In this case the current state of the rule is returned as the next plugin to evaluate.

Parameters:
status Status of previous evaluation.
Returns:
plugin name to be evaluation according to the configuration file.

Definition at line 557 of file pdl_main.c.

References EVALUATION_FAILURE, EVALUATION_START, EVALUATION_SUCCESS, rule_s::false_branch, find_state(), get_policies(), lcmaps_log_debug(), policy_s::name, policy_s::next, PDL_ERROR, pdl_path(), resetCredentialData(), policy_s::rule, rule_s::state, rule_s::true_branch, and warning().

Referenced by runEvaluationManager().

const char* pdl_path void   ) 
 

Get the path.

Returns:
Path.

Definition at line 364 of file pdl_main.c.

References path.

Referenced by getPluginNameAndArgs(), and pdl_next_plugin().

BOOL plugin_exists const char *  string  ) 
 

Check if a plugin as specified by the string argument exists.

Parameters:
string Name of the plugin.
Returns:
TRUE if the plugin exists, FALSE otherwise.

Definition at line 245 of file pdl_main.c.

References plugin_s::args, find_first_space(), plugin_s::name, plugin_s::next, plugin_t, top_plugin, and TRUE.

void reduce_policies void   ) 
 

Reduce_policies to its elemantry form, i.e. each policy has a list of rules which need to be reduced.

Definition at line 217 of file pdl_policy.c.

Referenced by startEvaluationManager().

void set_path record_t path  ) 
 

Function is called when the parser has found the value of the reserved path word. This function acts as a wrapper for the _set_path() function.

Parameters:
path 

Definition at line 394 of file pdl_main.c.

References _set_path(), path, and record_t.

void warning pdl_error_t  error,
const char *  s,
... 
 

Display a warning message.

Parameters:
error Severity of the error.
s The text string.
... Additional values; much like printf(char *, ...);

Definition at line 710 of file pdl_main.c.

References lcmaps_log(), level_str, lineno, parse_error, PDL_ERROR, PDL_SAME, PDL_UNKNOWN, script_name, and TRUE.

Referenced by _add_policy(), _add_rule(), _add_variable(), _concat_strings(), _set_path(), check_rule_for_recursion(), has_recursion(), pdl_init(), pdl_next_plugin(), reduce_to_var(), and yyerror().

int yyerror const char *  s  ) 
 

When yacc encounters an error during the parsing process of the configuration file, it calls yyerror(). The actual message formatting is done in waring();

Parameters:
s error string.

Definition at line 377 of file pdl_main.c.

References PDL_ERROR, and warning().

int yyparse_errors void   ) 
 

Tell if there were errors/warning during parsing.

Returns:
0, if the are no errors/warnings, -1 otherwise.

Definition at line 142 of file pdl_main.c.

References parse_error.

Referenced by startEvaluationManager().


Generated on Sun May 29 21:22:13 2005 for lcmaps by doxygen 1.3.5