Debian Codegraph @

src/proxy/namespaces_parse.y

raw
1 %{
2 /*********************************************************************
3 *
4 * Authors: Vincenzo Ciaschini - [email protected]
5 *
6 * Copyright (c) Members of the EGEE Collaboration. 2004-2010.
7 * See http://www.eu-egee.org/partners/ for details on the copyright holders.
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 * Parts of this code may be based upon or even include verbatim pieces,
22 * originally written by other people, in which case the original header
23 * follows.
24 *
25 *********************************************************************/
26 #include "config.h"
27 #include <stdio.h>
28 #include <string.h>
29 #include <stdlib.h>
30
31 #include "parsertypes.h"
32 #include "listfunc.h"
33
34 char **parse_subjects(char *string);
35 void namespaceserror(void *policies, void *scanner, char const *msg);
36 extern int namespaceslex(void *, void *scanner);
37 %}
38
39 %error-verbose
40 %pure-parser
41 %name-prefix="namespaces"
42 %parse-param {struct policy ***policies}
43 %parse-param {void *scanner}
44 %lex-param {void *scanner}
45
46 %union{
47 char *string;
48 struct condition *cond;
49 struct policy *policy;
50 int integer;
51 }
52
53 %token <string> SUBJECT
54 %token TO
55 %token SELF
56 %token PERMIT
57 %token DENY
58 %token SUBJECT_WORD
59 %token ISSUER
60
61 %type <policy> rule
62 %type <cond> condition
63 %type <integer> permit_or_deny
64
65 %%
66
67 eacl: rule { *policies = (struct policy**)listadd((char**)*policies, (char*)($1)); }
68 | eacl rule { *policies = (struct policy**)listadd((char**)*policies, (char*)($2)); }
69 ;
70
71 rule: TO ISSUER SUBJECT condition {
72 $$ = (struct policy *)calloc(1, sizeof(struct policy));
73 if ($$) {
74 $$->self = 0;
75 $$->caname = strdup($3);
76 $$->conds = (struct condition**)listadd(NULL, (char*)($4));
77 $$->type = TYPE_NAMESPACE;
78 }
79
80 }
81 | TO ISSUER SELF condition {
82 $$ = (struct policy *)calloc(1, sizeof(struct policy));
83 if ($$) {
84 $$->self = 1;
85 $$->caname = NULL;
86 $$->conds = (struct condition**)listadd(NULL, (char*)($4));
87 $$->type = TYPE_NAMESPACE;
88 }
89 }
90 ;
91
92 condition: permit_or_deny SUBJECT_WORD SUBJECT {
93 $$ = (struct condition *)calloc(1, sizeof(struct condition));
94 if ($$) {
95 $$->positive = $1;
96 $$->original = strdup($3);
97 $$->subjects = listadd(NULL, $$->original);
98 if (!$$->subjects) {
99 free($$->original);
100 free($$);
101 $$ = NULL;
102 }
103 }
104 }
105 ;
106
107 permit_or_deny: PERMIT { $$ = 1; }
108 | DENY { $$ = 0; }
109 ;
110
111 %%
112
113 #if 0
114 int main()
115 {
116 namespacesdebug = 1;
117 struct policy **arg = NULL;
118 void *scanner=NULL;
119 namespaceslex_init(&scanner);
120 namespacesset_debug(1, scanner);
121 return namespacesparse(&arg, scanner);
122 }
123 #endif
124
125 void namespaceserror(UNUSED(void *policies), UNUSED(void *scanner), UNUSED(char const *msg))
126 {
127 }