/[pdpsoft]/trunk/grid-mw-security/ees/src/eval_man/pdl.c
ViewVC logotype

Annotation of /trunk/grid-mw-security/ees/src/eval_man/pdl.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 572 - (hide annotations) (download) (as text)
Mon Jul 20 13:31:12 2009 UTC (12 years, 10 months ago) by aramv
File MIME type: text/x-chdr
File size: 3373 byte(s)
Added check for flex to determine of yylex_destroy() can be used
1 aramv 526 #include <stdio.h>
2 aramv 572 #include <stdlib.h>
3 aramv 526 #include "pdl.h"
4     #include "ng_log.h"
5 aramv 572 #include "ees_config.h"
6 aramv 526
7     NG_RC pdl_init(const char* name){
8     if((file = fopen(name,"r")) != NULL){
9     yyin = file;
10     return NG_SUCCESS;
11     } else {
12     ng_log(LOG_ERR, "Failed to open policy file");
13     return NG_FAILURE;
14     }
15     }
16    
17     record_t* concat_strings(record_t* r1, record_t* r2){
18 aramv 566 record_t* new_record;
19     if((new_record = malloc(sizeof(record_t)))){
20     if((new_record->string =
21     calloc(1, sizeof(char)*(strlen(r1->string) + strlen(r2->string)+1)))){
22     strcat(new_record->string, r1->string);
23     strcat(new_record->string, r2->string);
24     free(r1->string);
25     free(r1);
26     free(r2->string);
27     free(r2);
28     return new_record;
29     }
30     }
31 aramv 526 return NULL;
32     }
33    
34 aramv 566 record_t* concat_strings_with_space(record_t *r1, record_t* r2){
35     ng_log(LOG_NOTICE, "Concating: %s with %s", r1->string, r2->string);
36     record_t *r;
37     if((r = malloc(sizeof(record_t)))){
38     if((r1->string[strlen(r1->string)-1]=='"') &&
39     (r2->string[strlen(r2->string)-1]=='"')){
40     r = concat_strings(r1, r2);
41     } else {
42     r->string = calloc(1,(sizeof(char)*(strlen(r1->string)+strlen(r2->string)+2)));
43     strcat(r->string, r1->string);
44     strcat(r->string, " ");
45     strcat(r->string, r2->string);
46     }
47     free(r1->string);
48     free(r1);
49     free(r2->string);
50     free(r2);
51     return r;
52     }
53     return NULL;
54     }
55    
56 aramv 526 int yyerror(const char* string){
57     return ng_log(LOG_ERR, string);
58     }
59    
60     void set_path(record_t* path){
61 aramv 566 ng_log(LOG_ERR, "Found a new path: %s\n", path->string);
62     free(path->string);
63     free(path);
64 aramv 526 }
65    
66     void add_policy(record_t* policy, rule_t* rule){
67     ng_log(LOG_ERR, "Found a new policy: %s\n", policy->string);
68     /*ng_log(LOG_ERR, "Found a new rule: %s\n", rule->string);*/
69     free(policy->string);
70     free(policy);
71 aramv 566
72 aramv 526 /*free(rule->true_branch);*/
73     /*free(rule->false_branch);*/
74     /*free(rule);*/
75     }
76    
77     const char* pdl_path(){
78     return _pdl_path;
79     }
80    
81     rule_t* add_rule(record_t* state, record_t* true_branch, record_t* false_branch){
82 aramv 566 rule_t* new_rule = malloc(sizeof(rule_t));
83     if(state != NULL){
84     ng_log(LOG_ERR, "Added a new rule: %s\n", state->string);
85     }
86     if(true_branch != NULL){
87     ng_log(LOG_ERR, "True branch: %s\n", true_branch->string);
88     }
89     if(false_branch != NULL){
90     ng_log(LOG_ERR, "False branch: %s\n", false_branch->string);
91     }
92     if(state != NULL){
93     free(state->string);
94     }
95 aramv 526 free(state);
96 aramv 566 if(true_branch != NULL){
97     free(true_branch->string);
98     }
99 aramv 526 free(true_branch);
100 aramv 566 if(false_branch != NULL){
101     free(false_branch->string);
102     }
103 aramv 526 free(false_branch);
104 aramv 566 free(new_rule);
105     return new_rule;
106 aramv 526 }
107    
108     void remove_policy(record_t* policy){
109     ng_log(LOG_ERR, "Deleted policy: %s\n", policy->string);
110     free(policy->string);
111     free(policy);
112     }
113    
114 aramv 572 char** _var_to_argv(char* value){
115     printf("Value: %s", value);
116     }
117    
118 aramv 526 void add_variable(record_t* name, record_t* value){
119     ng_log(LOG_ERR, "Added variable name: %s\n", name->string);
120 aramv 566 ng_log(LOG_ERR, "Added variable value: %s\n", value->string);
121 aramv 526 free(name->string);
122     free(name);
123 aramv 566 free(value->string);
124 aramv 526 free(value);
125     }
126    
127     NG_RC pdl_term(){
128     if((fclose(file)==0) ){
129 aramv 572 #if HAVE_YYLEX_DESTROY
130 aramv 526 yylex_destroy();
131 aramv 572 #endif
132 aramv 526 return NG_SUCCESS;
133     } else {
134     return NG_FAILURE;
135     }
136     }
137    
138     NG_RC allow_rules(int val){
139 aramv 566 return NG_SUCCESS;
140 aramv 526 }
141    
142     NG_RC allowed_policy_rule(const char* label){
143 aramv 566 return NG_SUCCESS;
144 aramv 526 }

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