/[pdpsoft]/trunk/grid-mw-security/ees/src/eef/eef_common.c
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/eef/eef_common.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1258 - (show annotations) (download) (as text)
Wed Dec 9 11:13:47 2009 UTC (12 years, 1 month ago) by aramv
File MIME type: text/x-chdr
File size: 2313 byte(s)
Parser now cleaned up properly
1 #include "eef.h"
2 #include "pdl.h"
3 #include "plugin_manager.h"
4
5 static const char* _modules_path; /*! Holds the global path to plug-in modules */
6
7 /*! Try to initialize the AOS, enable logging, initialize the plug-in manager and try to parse the config file and ascertain the module path
8 */
9 EES_RC EEF_Init(char *config_file, FILE* log_file, int number_of_policies, char* names_of_policies[]){
10 start_log(log_file);
11 eef_log(LOG_NOTICE, "EEF initializing");
12
13 if (AOS_Init() == EES_SUCCESS){
14 if(start_plugin_manager() == EES_SUCCESS){
15 return start_pdl_parser(config_file, number_of_policies, names_of_policies);
16 }
17 }
18 return EES_FAILURE;
19 }
20
21 /*!
22 * Terminates the parser, stops the plug-in manager, terminates the AOS and closes the log.
23 */
24 EES_RC EEF_Term(){
25 eef_log(LOG_INFO, "Cleaning up...");
26 if((pdl_term() == EES_SUCCESS) &&
27 (stop_plugin_manager() == EES_SUCCESS) &&
28 (AOS_Term() == EES_SUCCESS)){
29 stop_log();
30 return EES_SUCCESS;
31 }
32 eef_log(LOG_ERR, "Errors detected\n");
33 eef_log(LOG_NOTICE, "EEF terminating...");
34 stop_log();
35 return EES_FAILURE;
36 }
37
38 /* Opens the log file or logs to syslog if none was provided.
39 * log mask is set depending on whether ENABLE_DEBUG macro is set to true */
40 EES_RC start_log(FILE* log_file){
41 /* Log file */
42 log_file_fp = log_file;
43
44 if(!log_file_fp){
45 /* logmask for debug */
46 #if ENABLE_DEBUG
47 setlogmask (LOG_UPTO(LOG_DEBUG));
48 eef_log(LOG_DEBUG, "DEBUG MODE ENABLED\n");
49 #else
50 setlogmask (LOG_UPTO(LOG_INFO));
51 #endif
52 } else {
53 /* Open syslog, regardless of use*/
54 openlog ("ees", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON);
55 }
56 return EES_SUCCESS;
57
58 }
59
60 /* Closes the log file */
61 EES_RC stop_log(){
62 if(!log_file_fp){
63 closelog();
64 }
65 return EES_SUCCESS;
66 }
67
68 /*!
69 * Sets the global modules path to load plug-ins from
70 */
71 void set_modules_path(const char* path){
72 _modules_path = path;
73 }
74
75 /*!
76 * Returns the global modules path to load plug-ins from
77 * This can be either the _modules_path as set by the set_modules_path() function or the MODULE_DIR path macro generated by the configure script.
78 */
79 const char* get_modules_path(void){
80 if(_modules_path != NULL){
81 if(strlen(_modules_path)!=0){
82 return _modules_path;
83 }
84 }
85 return MODULE_DIR;
86 }

Properties

Name Value
svn:mergeinfo

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28