Grid Community Toolkit  6.2.1541705016
globus_rsl.h
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
22 #ifndef GLOBUS_RSL_H
23 #define GLOBUS_RSL_H
24 
25 #include "globus_module.h"
26 #include "globus_list.h"
27 #include "globus_symboltable.h"
28 #include "globus_hashtable.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define GLOBUS_RSL_BOOLEAN 1
35 #define GLOBUS_RSL_RELATION 2
36 
37 #define GLOBUS_RSL_EQ 1
38 #define GLOBUS_RSL_NEQ 2
39 #define GLOBUS_RSL_GT 3
40 #define GLOBUS_RSL_GTEQ 4
41 #define GLOBUS_RSL_LT 5
42 #define GLOBUS_RSL_LTEQ 6
43 #define GLOBUS_RSL_AND 8
44 #define GLOBUS_RSL_OR 9
45 #define GLOBUS_RSL_MULTIREQ 10
46 
47 #define GLOBUS_RSL_VALUE_LITERAL 1
48 #define GLOBUS_RSL_VALUE_SEQUENCE 2
49 #define GLOBUS_RSL_VALUE_VARIABLE 3
50 #define GLOBUS_RSL_VALUE_CONCATENATION 4
51 
52 #define GLOBUS_RSL_PARAM_SINGLE_LITERAL 1
53 #define GLOBUS_RSL_PARAM_MULTI_LITERAL 2
54 #define GLOBUS_RSL_PARAM_SEQUENCE 3
55 
56 /**********************************************************************
57  *
58  * Module activation structure
59  *
60  **********************************************************************
61 */
62 extern globus_module_descriptor_t globus_i_rsl_module;
63 
64 #define GLOBUS_RSL_MODULE (&globus_i_rsl_module)
65 
66 /***********************************************************************/
67 
68 
69 typedef struct _globus_rsl_value_t globus_rsl_value_t;
70 
71 struct _globus_rsl_value_t
72 {
73  int type;
74 
75  union
76  {
77  struct
78  {
79  char * string;
80  } literal;
81 
82  struct
83  {
84  globus_list_t * value_list;
85  } sequence;
86 
87  struct
88  {
89  globus_rsl_value_t * sequence;
90  } variable;
91 
92  struct
93  {
94  globus_rsl_value_t * left_value;
95  globus_rsl_value_t * right_value;
96  } concatenation;
97 
98  } value;
99 };
100 
101 typedef struct _globus_rsl_t globus_rsl_t;
102 
103 struct _globus_rsl_t
104 {
105  int type; /* GLOBUS_RSL_BOOLEAN || GLOBUS_RSL_RELATION */
106  union
107  {
108  struct
109  {
110  /* bison reserves "operator" hence my_operator */
111  int my_operator;
112  /* each element of the list has type globus_rsl_t *...
113  */
114  globus_list_t *operand_list;
115  } boolean;
116 
117  struct
118  {
119  int my_operator;
120  char * attribute_name;
121  globus_rsl_value_t * value_sequence;
122  } relation;
123  } req;
124 };
125 
126 /*************************************************************************
127  * is functions
128  *
129  ************************************************************************/
130 
131 int
132 globus_rsl_is_relation (globus_rsl_t *ast);
133 
134 int
135 globus_rsl_is_boolean (globus_rsl_t *ast);
136 
137 int
138 globus_rsl_is_relation_eq (globus_rsl_t *ast);
139 
140 /* return true only for relations w/ the specific operator */
141 int
142 globus_rsl_is_relation_lessthan (globus_rsl_t *ast);
143 
144 /* return true if relation attribute is equal to attribute arg */
145 int
146 globus_rsl_is_relation_attribute_equal (globus_rsl_t *ast, char * attribute);
147 
148 /* return true only for booleans w/ the specific operator */
149 int
150 globus_rsl_is_boolean_and (globus_rsl_t *ast);
151 
152 /* return true only for booleans w/ the specific operator */
153 int
154 globus_rsl_is_boolean_or (globus_rsl_t *ast);
155 
156 int
157 globus_rsl_is_boolean_multi (globus_rsl_t *ast);
158 
159 int
160 globus_rsl_value_is_literal (globus_rsl_value_t *ast);
161 
162 int
163 globus_rsl_value_is_sequence (globus_rsl_value_t *ast);
164 
165 int
166 globus_rsl_value_is_variable (globus_rsl_value_t *ast);
167 
168 int
169 globus_rsl_value_is_concatenation (globus_rsl_value_t *ast);
170 
171 
172 /*************************************************************************
173  * constructor functions
174  *
175  ************************************************************************/
176 
177 globus_rsl_t *
178 globus_rsl_make_boolean (int my_operator,
179  globus_list_t *children);
180 
181 globus_rsl_t *
182 globus_rsl_make_relation (int my_operator,
183  char *attributename,
184  globus_rsl_value_t *value_sequence);
185 
186 globus_rsl_value_t *
187 globus_rsl_value_make_literal (char *string);
188 
189 globus_rsl_value_t *
191 
192 globus_rsl_value_t *
193 globus_rsl_value_make_variable (globus_rsl_value_t * sequence);
194 
195 globus_rsl_value_t *
196 globus_rsl_value_make_concatenation (globus_rsl_value_t *left_value,
197  globus_rsl_value_t *right_value);
198 
199 /* copy the entire rsl tree */
200 globus_rsl_t *
201 globus_rsl_copy_recursive(globus_rsl_t * globus_rsl_ptr);
202 
203 /* copy the entire rsl value list */
204 globus_rsl_value_t *
205 globus_rsl_value_copy_recursive(globus_rsl_value_t * globus_rsl_value_ptr);
206 
207 /*************************************************************************
208  * accessor functions
209  *
210  ************************************************************************/
211 
212 /* booleans */
213 
214 /* return non-zero on error */
215 
216 int
217 globus_rsl_boolean_get_operator (globus_rsl_t *ast_node);
218 
219 /*
220  *
221  */
223 globus_rsl_boolean_get_operand_list (globus_rsl_t *ast_node);
224 
225 globus_list_t **
226 globus_rsl_boolean_get_operand_list_ref (globus_rsl_t *boolean_node);
227 
228 
229 /* relations */
230 
231 char *
232 globus_rsl_relation_get_attribute (globus_rsl_t *ast_node);
233 
234 int
235 globus_rsl_relation_get_operator (globus_rsl_t *ast_node);
236 
237 globus_rsl_value_t *
238 globus_rsl_relation_get_value_sequence (globus_rsl_t *ast_node);
239 
240 /* NULL unless the relation has a simple 1-element value sequence */
241 globus_rsl_value_t *
242 globus_rsl_relation_get_single_value (globus_rsl_t *ast_node);
243 
244 /* value lists */
245 
246 /* extract the literal node's string
247  * NULL if not called on a node tagged as a literal
248  */
249 char *
250 globus_rsl_value_literal_get_string (globus_rsl_value_t *literal_node);
251 
252 /* extract the list of nodes under the sequence node
253  * NULL if not called on a node tagges as a sequence
254  */
256 globus_rsl_value_sequence_get_value_list (globus_rsl_value_t *sequence_node);
257 
258 /*
259  *
260  */
261 globus_rsl_value_t *
262 globus_rsl_value_variable_get_sequence (globus_rsl_value_t * variable_node);
263 
264 /* extract the name of the referenced variable
265  * NULL if not called on a node tagged as a variable
266  */
267 char *
268 globus_rsl_value_variable_get_name (globus_rsl_value_t *variable_node);
269 
270 /* extract the optional value for the variable reference
271  * NULL if no optional value specified
272  * NULL if not called on a node tagged as a variable
273  */
274 char *
275 globus_rsl_value_variable_get_default (globus_rsl_value_t *variable_node);
276 
277 /* extract the left-hand value of a concatenation
278  * NULL if not called on a node tagged as a variable
279  */
280 globus_rsl_value_t *
281 globus_rsl_value_concatenation_get_left (globus_rsl_value_t *concatenation_node);
282 
283 /* extract the right-hand value of a concatenation
284  * NULL if not called on a node tagged as a variable
285  */
286 globus_rsl_value_t *
287 globus_rsl_value_concatenation_get_right (globus_rsl_value_t *concatenation_node);
288 
289 globus_list_t **
290 globus_rsl_value_sequence_get_list_ref (globus_rsl_value_t *sequence_node);
291 
292 
293 /*************************************************************************
294  * set functions
295  *
296  ************************************************************************/
297 
298 /* set the left-hand value of a concatenation to a new value
299  * return non-zero on error */
300 int
301 globus_rsl_value_concatenation_set_left (globus_rsl_value_t *concatenate_node,
302  globus_rsl_value_t *new_left_node);
303 
304 /* set the right-hand value of a concatenation to a new value
305  * return non-zero on error */
306 int
307 globus_rsl_value_concatenation_set_right (globus_rsl_value_t *concatenate_node,
308  globus_rsl_value_t *new_right_node);
309 
310 /*************************************************************************
311  * eval functions
312  *
313  ************************************************************************/
314 
315 int
316 globus_rsl_value_eval(globus_rsl_value_t * ast_node,
317  globus_symboltable_t * symbol_table,
318  char ** string_value,
319  int rsl_substitute_flag);
320 
321 int
322 globus_rsl_eval (globus_rsl_t *ast_node,
323  globus_symboltable_t * symbol_table);
324 
325 /*************************************************************************
326  * free functions
327  *
328  ************************************************************************/
329 
330 
331 /*** all freeing is done through globus_free() ***/
332 
333 /* free any storage allocated by the globus_rsl*_make_*() routine
334  * for this type of node
335  */
336 int
337 globus_rsl_value_free (globus_rsl_value_t *val);
338 
339 int
340 globus_rsl_free (globus_rsl_t *ast_node);
341 
342 /* like globus_rsl*_free () but recursively free subtrees too.
343  * Assumes: 1.) no nodes in the tree are shared,
344  * 2.) everything was allocated with globus_malloc
345  */
346 int
347 globus_rsl_value_free_recursive (globus_rsl_value_t * globus_rsl_value_ptr);
348 
349 int
350 globus_rsl_free_recursive (globus_rsl_t *ast_node);
351 
352 int
353 globus_rsl_value_print_recursive (globus_rsl_value_t * globus_rsl_value_ptr);
354 
355 int
356 globus_rsl_print_recursive (globus_rsl_t *ast_node);
357 
358 #define GLOBUS_SPECIFICATION_PARSE_ERROR_MESSAGE_LENGTH 1024
359 typedef struct globus_parse_error_s
360 {
361  int code;
362  int line;
363  int position;
364  char message[GLOBUS_SPECIFICATION_PARSE_ERROR_MESSAGE_LENGTH];
365 } globus_rsl_parse_error_t;
366 
367 /******************************************************************************
368  Function prototypes
369 ******************************************************************************/
370 
371 /* extract the name of the referenced variable
372  * NULL if not called on a node tagged as a variable
373  */
374 int
375 globus_rsl_value_variable_get_size (globus_rsl_value_t *variable_node);
376 
379 
380 int
382  char * string_value);
383 
385 globus_rsl_operand_list_copy_recursive(globus_list_t * orig);
386 
388 globus_rsl_value_sequence_list_copy_recursive(globus_list_t * orig);
389 
390 int
392  int required_type,
393  char *** value,
394  int * value_ctr);
395 
396 int
397 globus_rsl_param_get(globus_rsl_t * ast_node,
398  int required_type,
399  char * param,
400  char *** values);
401 
403 globus_rsl_param_get_values(globus_rsl_t * ast_node,
404  char * param);
405 
406 globus_rsl_t *
407 globus_rsl_parse(char * rsl_spec);
408 
409 char *
410 globus_rsl_unparse (globus_rsl_t *rsl_spec);
411 
412 char *
413 globus_rsl_value_unparse (globus_rsl_value_t * rsl_value);
414 
415 #ifdef __cplusplus
416 }
417 #endif
418 
419 #endif /* GLOBUS_RSL_H */
int globus_rsl_is_boolean_or(globus_rsl_t *ast)
RSL boolean or test.
Definition: globus_rsl.c:371
int globus_rsl_is_boolean_and(globus_rsl_t *ast)
RSL boolean and test.
Definition: globus_rsl.c:339
int globus_rsl_value_concatenation_set_right(globus_rsl_value_t *concatenate_node, globus_rsl_value_t *new_right_node)
Set the right-hand value of a concatenation.
Definition: globus_rsl.c:1546
int globus_rsl_eval(globus_rsl_t *ast_node, globus_symboltable_t *symbol_table)
Evaluate an RSL syntax tree.
Definition: globus_rsl.c:2102
char * globus_rsl_value_unparse(globus_rsl_value_t *rsl_value)
Convert an RSL value pointer to a string.
Definition: globus_rsl.c:2748
int globus_rsl_value_is_concatenation(globus_rsl_value_t *ast)
RSL value concatenation test.
Definition: globus_rsl.c:526
globus_rsl_t * globus_rsl_parse(char *rsl_spec)
Parse an RSL string.
Definition: globus_rsl_parser.c:1885
int globus_rsl_is_boolean_multi(globus_rsl_t *ast)
RSL boolean multi test.
Definition: globus_rsl.c:404
globus_rsl_t * globus_rsl_copy_recursive(globus_rsl_t *globus_rsl_ptr)
Create a deep copy of an RSL syntax tree.
Definition: globus_rsl.c:804
globus_list_t * globus_rsl_value_sequence_get_value_list(globus_rsl_value_t *sequence_node)
Get the value list from an RSL value sequence.
Definition: globus_rsl.c:1258
globus_rsl_value_t * globus_rsl_value_make_concatenation(globus_rsl_value_t *left_value, globus_rsl_value_t *right_value)
RSL concatenation constructor.
Definition: globus_rsl.c:761
char * globus_rsl_value_variable_get_name(globus_rsl_value_t *variable_node)
Get the name of an RSL variable reference.
Definition: globus_rsl.c:1314
int globus_rsl_value_eval(globus_rsl_value_t *ast_node, globus_symboltable_t *symbol_table, char **string_value, int rsl_substitute_flag)
Evaluate RSL substitions in an RSL value node.
Definition: globus_rsl.c:1851
int globus_rsl_value_variable_get_size(globus_rsl_value_t *variable_node)
Get the size of the value list within an RSL variable reference node.
Definition: globus_rsl.c:1393
Linked List.
int globus_rsl_value_free(globus_rsl_value_t *val)
Free an RSL value node.
Definition: globus_rsl.c:1613
int globus_rsl_param_get(globus_rsl_t *ast_node, int required_type, char *param, char ***values)
Get the value strings for an RSL attribute.
Definition: globus_rsl.c:2386
int globus_rsl_is_relation(globus_rsl_t *ast)
RSL relation test.
Definition: globus_rsl.c:177
Reference Counting Module Activation and Deactivation.
int globus_rsl_value_is_sequence(globus_rsl_value_t *ast)
RSL value sequence test.
Definition: globus_rsl.c:466
char * globus_rsl_unparse(globus_rsl_t *rsl_spec)
Convert an RSL parse tree to a string.
Definition: globus_rsl.c:2696
globus_rsl_value_t * globus_rsl_relation_get_single_value(globus_rsl_t *ast_node)
Get the single value of an RSL relation.
Definition: globus_rsl.c:1189
globus_rsl_value_t * globus_rsl_value_make_literal(char *string)
RSL literal constructor.
Definition: globus_rsl.c:651
globus_rsl_value_t * globus_rsl_value_variable_get_sequence(globus_rsl_value_t *variable_node)
Get the value sequence from an RSL variable reference.
Definition: globus_rsl.c:1286
globus_rsl_value_t * globus_rsl_value_make_variable(globus_rsl_value_t *sequence)
RSL variable reference constructor.
Definition: globus_rsl.c:721
List data type.
Definition: globus_list.h:43
int globus_rsl_value_is_variable(globus_rsl_value_t *ast)
RSL value variable test.
Definition: globus_rsl.c:496
globus_rsl_value_t * globus_rsl_value_copy_recursive(globus_rsl_value_t *globus_rsl_value_ptr)
Create a deep copy of an RSL value.
Definition: globus_rsl.c:905
int globus_rsl_value_list_literal_replace(globus_list_t *value_list, char *string_value)
Replace the first value in a value list with a literal.
Definition: globus_rsl.c:1800
globus_rsl_value_t * globus_rsl_value_concatenation_get_right(globus_rsl_value_t *concatenation_node)
Get the right side of a concatenation value.
Definition: globus_rsl.c:1449
int globus_rsl_is_relation_eq(globus_rsl_t *ast)
RSL equality operation test.
Definition: globus_rsl.c:244
Lightweight Chaining Symboltable.
globus_list_t ** globus_rsl_value_sequence_get_list_ref(globus_rsl_value_t *sequence_node)
Get a reference to the list of values in a sequence.
Definition: globus_rsl.c:1477
globus_list_t * globus_rsl_param_get_values(globus_rsl_t *ast_node, char *param)
Get the list of values for an RSL attribute.
Definition: globus_rsl.c:2306
globus_rsl_value_t * globus_rsl_value_make_sequence(globus_list_t *value_list)
RSL value sequence constructor.
Definition: globus_rsl.c:686
int globus_rsl_boolean_get_operator(globus_rsl_t *ast_node)
Get the RSL operator used in a boolean RSL composition.
Definition: globus_rsl.c:1018
int globus_rsl_is_boolean(globus_rsl_t *ast)
RSL boolean test.
Definition: globus_rsl.c:213
int globus_rsl_is_relation_attribute_equal(globus_rsl_t *ast, char *attribute)
RSL attribute name test.
Definition: globus_rsl.c:306
int globus_rsl_print_recursive(globus_rsl_t *ast_node)
Print the value of an RSL syntax tree to standard output.
Definition: globus_rsl.c:2640
int globus_rsl_value_free_recursive(globus_rsl_value_t *globus_rsl_value_ptr)
Free an RSL value and all its child nodes.
Definition: globus_rsl.c:1661
int globus_rsl_value_print_recursive(globus_rsl_value_t *globus_rsl_value_ptr)
Print the value of a globus_rsl_value_t to standard output.
Definition: globus_rsl.c:2518
globus_rsl_value_t * globus_rsl_value_concatenation_get_left(globus_rsl_value_t *concatenation_node)
Get the left side of a concatenation value.
Definition: globus_rsl.c:1422
int globus_rsl_value_list_param_get(globus_list_t *ast_node_list, int required_type, char ***value, int *value_ctr)
Get the values of an RSL value list.
Definition: globus_rsl.c:2229
int globus_rsl_value_is_literal(globus_rsl_value_t *ast)
RSL literal string test.
Definition: globus_rsl.c:436
Hash Table.
int globus_rsl_relation_get_operator(globus_rsl_t *ast_node)
Get an RSL relation operator.
Definition: globus_rsl.c:1131
globus_rsl_t * globus_rsl_make_boolean(int my_operator, globus_list_t *children)
RSL boolean constructor.
Definition: globus_rsl.c:567
globus_list_t * globus_list_copy_reverse(globus_list_t *orig)
Create a reverse-order copy of a list.
Definition: globus_rsl.c:1582
int globus_rsl_is_relation_lessthan(globus_rsl_t *ast)
RSL less than operation test.
Definition: globus_rsl.c:274
char * globus_rsl_value_variable_get_default(globus_rsl_value_t *variable_node)
Get the default value of an RSL variable reference.
Definition: globus_rsl.c:1354
int globus_rsl_free_recursive(globus_rsl_t *ast_node)
Free an RSL syntax tree and all its child nodes.
Definition: globus_rsl.c:1732
globus_list_t ** globus_rsl_boolean_get_operand_list_ref(globus_rsl_t *boolean_node)
Get a reference to the RSL operand list from a boolean RSL composition.
Definition: globus_rsl.c:1073
globus_list_t * globus_rsl_boolean_get_operand_list(globus_rsl_t *ast_node)
Get the RSL operand list from a boolean RSL composition.
Definition: globus_rsl.c:1044
globus_rsl_value_t * globus_rsl_relation_get_value_sequence(globus_rsl_t *ast_node)
Get the value of an RSL relation.
Definition: globus_rsl.c:1159
char * globus_rsl_relation_get_attribute(globus_rsl_t *ast_node)
Get an RSL relation attribute name.
Definition: globus_rsl.c:1103
globus_rsl_t * globus_rsl_make_relation(int my_operator, char *attributename, globus_rsl_value_t *value_sequence)
RSL relation constructor.
Definition: globus_rsl.c:612
char * globus_rsl_value_literal_get_string(globus_rsl_value_t *literal_node)
Get the string value of an RSL literal.
Definition: globus_rsl.c:1230
int globus_rsl_free(globus_rsl_t *ast_node)
Free an RSL syntax tree node.
Definition: globus_rsl.c:1636
Module Descriptor.
Definition: globus_module.h:69
int globus_rsl_value_concatenation_set_left(globus_rsl_value_t *concatenate_node, globus_rsl_value_t *new_left_node)
Set the left-hand value of a concatenation.
Definition: globus_rsl.c:1510