Loading...
Searching...
No Matches
globus_rsl.h
Go to the documentation of this file.
/*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GLOBUS_RSL_H
#define GLOBUS_RSL_H
#include "globus_module.h"
#include "globus_list.h"
#include "globus_symboltable.h"
#include "globus_hashtable.h"
#ifdef __cplusplus
extern "C" {
#endif
#define GLOBUS_RSL_BOOLEAN 1
#define GLOBUS_RSL_RELATION 2
#define GLOBUS_RSL_EQ 1
#define GLOBUS_RSL_NEQ 2
#define GLOBUS_RSL_GT 3
#define GLOBUS_RSL_GTEQ 4
#define GLOBUS_RSL_LT 5
#define GLOBUS_RSL_LTEQ 6
#define GLOBUS_RSL_AND 8
#define GLOBUS_RSL_OR 9
#define GLOBUS_RSL_MULTIREQ 10
#define GLOBUS_RSL_VALUE_LITERAL 1
#define GLOBUS_RSL_VALUE_SEQUENCE 2
#define GLOBUS_RSL_VALUE_VARIABLE 3
#define GLOBUS_RSL_VALUE_CONCATENATION 4
#define GLOBUS_RSL_PARAM_SINGLE_LITERAL 1
#define GLOBUS_RSL_PARAM_MULTI_LITERAL 2
#define GLOBUS_RSL_PARAM_SEQUENCE 3
/**********************************************************************
*
* Module activation structure
*
**********************************************************************
*/
extern globus_module_descriptor_t globus_i_rsl_module;
#define GLOBUS_RSL_MODULE (&globus_i_rsl_module)
/***********************************************************************/
typedef struct _globus_rsl_value_t globus_rsl_value_t;
struct _globus_rsl_value_t
{
int type;
union
{
struct
{
char * string;
} literal;
struct
{
globus_list_t * value_list;
} sequence;
struct
{
globus_rsl_value_t * sequence;
} variable;
struct
{
globus_rsl_value_t * left_value;
globus_rsl_value_t * right_value;
} concatenation;
} value;
};
typedef struct _globus_rsl_t globus_rsl_t;
struct _globus_rsl_t
{
int type; /* GLOBUS_RSL_BOOLEAN || GLOBUS_RSL_RELATION */
union
{
struct
{
/* bison reserves "operator" hence my_operator */
int my_operator;
/* each element of the list has type globus_rsl_t *...
*/
globus_list_t *operand_list;
} boolean;
struct
{
int my_operator;
char * attribute_name;
globus_rsl_value_t * value_sequence;
} relation;
} req;
};
/*************************************************************************
* is functions
*
************************************************************************/
int
globus_rsl_is_relation (globus_rsl_t *ast);
int
globus_rsl_is_boolean (globus_rsl_t *ast);
int
globus_rsl_is_relation_eq (globus_rsl_t *ast);
/* return true only for relations w/ the specific operator */
int
globus_rsl_is_relation_lessthan (globus_rsl_t *ast);
/* return true if relation attribute is equal to attribute arg */
int
globus_rsl_is_relation_attribute_equal (globus_rsl_t *ast, char * attribute);
/* return true only for booleans w/ the specific operator */
int
globus_rsl_is_boolean_and (globus_rsl_t *ast);
/* return true only for booleans w/ the specific operator */
int
globus_rsl_is_boolean_or (globus_rsl_t *ast);
int
globus_rsl_is_boolean_multi (globus_rsl_t *ast);
int
globus_rsl_value_is_literal (globus_rsl_value_t *ast);
int
globus_rsl_value_is_sequence (globus_rsl_value_t *ast);
int
globus_rsl_value_is_variable (globus_rsl_value_t *ast);
int
globus_rsl_value_is_concatenation (globus_rsl_value_t *ast);
/*************************************************************************
* constructor functions
*
************************************************************************/
globus_rsl_t *
globus_rsl_make_boolean (int my_operator,
globus_list_t *children);
globus_rsl_t *
globus_rsl_make_relation (int my_operator,
char *attributename,
globus_rsl_value_t *value_sequence);
globus_rsl_value_t *
globus_rsl_value_make_literal (char *string);
globus_rsl_value_t *
globus_rsl_value_make_sequence (globus_list_t * value_list);
globus_rsl_value_t *
globus_rsl_value_make_variable (globus_rsl_value_t * sequence);
globus_rsl_value_t *
globus_rsl_value_make_concatenation (globus_rsl_value_t *left_value,
globus_rsl_value_t *right_value);
/* copy the entire rsl tree */
globus_rsl_t *
globus_rsl_copy_recursive(globus_rsl_t * globus_rsl_ptr);
/* copy the entire rsl value list */
globus_rsl_value_t *
globus_rsl_value_copy_recursive(globus_rsl_value_t * globus_rsl_value_ptr);
/*************************************************************************
* accessor functions
*
************************************************************************/
/* booleans */
/* return non-zero on error */
int
globus_rsl_boolean_get_operator (globus_rsl_t *ast_node);
/*
*
*/
globus_list_t *
globus_rsl_boolean_get_operand_list (globus_rsl_t *ast_node);
globus_list_t **
globus_rsl_boolean_get_operand_list_ref (globus_rsl_t *boolean_node);
/* relations */
char *
globus_rsl_relation_get_attribute (globus_rsl_t *ast_node);
int
globus_rsl_relation_get_operator (globus_rsl_t *ast_node);
globus_rsl_value_t *
globus_rsl_relation_get_value_sequence (globus_rsl_t *ast_node);
/* NULL unless the relation has a simple 1-element value sequence */
globus_rsl_value_t *
globus_rsl_relation_get_single_value (globus_rsl_t *ast_node);
/* value lists */
/* extract the literal node's string
* NULL if not called on a node tagged as a literal
*/
char *
globus_rsl_value_literal_get_string (globus_rsl_value_t *literal_node);
/* extract the list of nodes under the sequence node
* NULL if not called on a node tagges as a sequence
*/
globus_list_t *
globus_rsl_value_sequence_get_value_list (globus_rsl_value_t *sequence_node);
/*
*
*/
globus_rsl_value_t *
globus_rsl_value_variable_get_sequence (globus_rsl_value_t * variable_node);
/* extract the name of the referenced variable
* NULL if not called on a node tagged as a variable
*/
char *
globus_rsl_value_variable_get_name (globus_rsl_value_t *variable_node);
/* extract the optional value for the variable reference
* NULL if no optional value specified
* NULL if not called on a node tagged as a variable
*/
char *
globus_rsl_value_variable_get_default (globus_rsl_value_t *variable_node);
/* extract the left-hand value of a concatenation
* NULL if not called on a node tagged as a variable
*/
globus_rsl_value_t *
globus_rsl_value_concatenation_get_left (globus_rsl_value_t *concatenation_node);
/* extract the right-hand value of a concatenation
* NULL if not called on a node tagged as a variable
*/
globus_rsl_value_t *
globus_rsl_value_concatenation_get_right (globus_rsl_value_t *concatenation_node);
globus_list_t **
globus_rsl_value_sequence_get_list_ref (globus_rsl_value_t *sequence_node);
/*************************************************************************
* set functions
*
************************************************************************/
/* set the left-hand value of a concatenation to a new value
* return non-zero on error */
int
globus_rsl_value_concatenation_set_left (globus_rsl_value_t *concatenate_node,
globus_rsl_value_t *new_left_node);
/* set the right-hand value of a concatenation to a new value
* return non-zero on error */
int
globus_rsl_value_concatenation_set_right (globus_rsl_value_t *concatenate_node,
globus_rsl_value_t *new_right_node);
/*************************************************************************
* eval functions
*
************************************************************************/
int
globus_rsl_value_eval(globus_rsl_value_t * ast_node,
globus_symboltable_t * symbol_table,
char ** string_value,
int rsl_substitute_flag);
int
globus_rsl_eval (globus_rsl_t *ast_node,
globus_symboltable_t * symbol_table);
/*************************************************************************
* free functions
*
************************************************************************/
/*** all freeing is done through globus_free() ***/
/* free any storage allocated by the globus_rsl*_make_*() routine
* for this type of node
*/
int
globus_rsl_value_free (globus_rsl_value_t *val);
int
globus_rsl_free (globus_rsl_t *ast_node);
/* like globus_rsl*_free () but recursively free subtrees too.
* Assumes: 1.) no nodes in the tree are shared,
* 2.) everything was allocated with globus_malloc
*/
int
globus_rsl_value_free_recursive (globus_rsl_value_t * globus_rsl_value_ptr);
int
globus_rsl_free_recursive (globus_rsl_t *ast_node);
int
globus_rsl_value_print_recursive (globus_rsl_value_t * globus_rsl_value_ptr);
int
globus_rsl_print_recursive (globus_rsl_t *ast_node);
#define GLOBUS_SPECIFICATION_PARSE_ERROR_MESSAGE_LENGTH 1024
typedef struct globus_parse_error_s
{
int code;
int line;
int position;
char message[GLOBUS_SPECIFICATION_PARSE_ERROR_MESSAGE_LENGTH];
} globus_rsl_parse_error_t;
/******************************************************************************
Function prototypes
******************************************************************************/
/* extract the name of the referenced variable
* NULL if not called on a node tagged as a variable
*/
int
globus_rsl_value_variable_get_size (globus_rsl_value_t *variable_node);
globus_list_t *
globus_list_copy_reverse (globus_list_t * orig);
int
globus_rsl_value_list_literal_replace(globus_list_t * value_list,
char * string_value);
globus_list_t *
globus_rsl_operand_list_copy_recursive(globus_list_t * orig);
globus_list_t *
globus_rsl_value_sequence_list_copy_recursive(globus_list_t * orig);
int
globus_rsl_value_list_param_get(globus_list_t * ast_node_list,
int required_type,
char *** value,
int * value_ctr);
int
globus_rsl_param_get(globus_rsl_t * ast_node,
int required_type,
char * param,
char *** values);
globus_list_t *
globus_rsl_param_get_values(globus_rsl_t * ast_node,
char * param);
globus_rsl_t *
globus_rsl_parse(char * rsl_spec);
char *
globus_rsl_unparse (globus_rsl_t *rsl_spec);
char *
globus_rsl_value_unparse (globus_rsl_value_t * rsl_value);
#ifdef __cplusplus
}
#endif
#endif /* GLOBUS_RSL_H */
globus_rsl_parse
globus_rsl_t * globus_rsl_parse(char *rsl_spec)
Parse an RSL string.
Definition globus_rsl_parser.c:1885
globus_rsl_relation_get_attribute
char * globus_rsl_relation_get_attribute(globus_rsl_t *ast_node)
Get an RSL relation attribute name.
Definition globus_rsl.c:1107
globus_rsl_value_literal_get_string
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:1234
globus_rsl_value_variable_get_default
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:1358
globus_rsl_relation_get_single_value
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:1193
globus_rsl_value_variable_get_size
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:1397
globus_rsl_value_concatenation_get_right
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:1453
globus_rsl_value_sequence_get_list_ref
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:1481
globus_rsl_boolean_get_operand_list_ref
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:1077
globus_rsl_boolean_get_operand_list
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:1048
globus_rsl_value_sequence_get_value_list
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:1262
globus_rsl_relation_get_operator
int globus_rsl_relation_get_operator(globus_rsl_t *ast_node)
Get an RSL relation operator.
Definition globus_rsl.c:1135
globus_rsl_value_variable_get_name
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:1318
globus_rsl_value_variable_get_sequence
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:1290
globus_rsl_relation_get_value_sequence
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:1163
globus_rsl_boolean_get_operator
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:1022
globus_rsl_value_concatenation_get_left
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:1426
globus_rsl_value_make_concatenation
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:763
globus_rsl_value_make_sequence
globus_rsl_value_t * globus_rsl_value_make_sequence(globus_list_t *value_list)
RSL value sequence constructor.
Definition globus_rsl.c:688
globus_rsl_make_boolean
globus_rsl_t * globus_rsl_make_boolean(int my_operator, globus_list_t *children)
RSL boolean constructor.
Definition globus_rsl.c:569
globus_rsl_value_make_literal
globus_rsl_value_t * globus_rsl_value_make_literal(char *string)
RSL literal constructor.
Definition globus_rsl.c:653
globus_rsl_value_make_variable
globus_rsl_value_t * globus_rsl_value_make_variable(globus_rsl_value_t *sequence)
RSL variable reference constructor.
Definition globus_rsl.c:723
globus_rsl_make_relation
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:614
globus_list_copy_reverse
globus_list_t * globus_list_copy_reverse(globus_list_t *orig)
Create a reverse-order copy of a list.
Definition globus_rsl.c:1587
globus_rsl_value_copy_recursive
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:908
globus_rsl_value_free_recursive
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:1666
globus_rsl_free_recursive
int globus_rsl_free_recursive(globus_rsl_t *ast_node)
Free an RSL syntax tree and all its child nodes.
Definition globus_rsl.c:1737
globus_rsl_value_eval
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:1856
globus_rsl_value_list_literal_replace
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:1805
globus_rsl_value_free
int globus_rsl_value_free(globus_rsl_value_t *val)
Free an RSL value node.
Definition globus_rsl.c:1618
globus_rsl_free
int globus_rsl_free(globus_rsl_t *ast_node)
Free an RSL syntax tree node.
Definition globus_rsl.c:1641
globus_rsl_copy_recursive
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:807
globus_rsl_eval
int globus_rsl_eval(globus_rsl_t *ast_node, globus_symboltable_t *symbol_table)
Evaluate an RSL syntax tree.
Definition globus_rsl.c:2107
globus_rsl_value_list_param_get
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:2235
globus_rsl_value_concatenation_set_right
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:1550
globus_rsl_param_get
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:2392
globus_rsl_value_concatenation_set_left
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:1514
globus_rsl_param_get_values
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:2312
globus_rsl_value_is_literal
int globus_rsl_value_is_literal(globus_rsl_value_t *ast)
RSL literal string test.
Definition globus_rsl.c:437
globus_rsl_value_is_sequence
int globus_rsl_value_is_sequence(globus_rsl_value_t *ast)
RSL value sequence test.
Definition globus_rsl.c:467
globus_rsl_value_is_variable
int globus_rsl_value_is_variable(globus_rsl_value_t *ast)
RSL value variable test.
Definition globus_rsl.c:497
globus_rsl_is_boolean_and
int globus_rsl_is_boolean_and(globus_rsl_t *ast)
RSL boolean and test.
Definition globus_rsl.c:340
globus_rsl_is_relation_attribute_equal
int globus_rsl_is_relation_attribute_equal(globus_rsl_t *ast, char *attribute)
RSL attribute name test.
Definition globus_rsl.c:307
globus_rsl_value_is_concatenation
int globus_rsl_value_is_concatenation(globus_rsl_value_t *ast)
RSL value concatenation test.
Definition globus_rsl.c:527
globus_rsl_is_relation_lessthan
int globus_rsl_is_relation_lessthan(globus_rsl_t *ast)
RSL less than operation test.
Definition globus_rsl.c:275
globus_rsl_is_boolean_multi
int globus_rsl_is_boolean_multi(globus_rsl_t *ast)
RSL boolean multi test.
Definition globus_rsl.c:405
globus_rsl_is_relation_eq
int globus_rsl_is_relation_eq(globus_rsl_t *ast)
RSL equality operation test.
Definition globus_rsl.c:245
globus_rsl_is_boolean
int globus_rsl_is_boolean(globus_rsl_t *ast)
RSL boolean test.
Definition globus_rsl.c:214
globus_rsl_is_relation
int globus_rsl_is_relation(globus_rsl_t *ast)
RSL relation test.
Definition globus_rsl.c:178
globus_rsl_is_boolean_or
int globus_rsl_is_boolean_or(globus_rsl_t *ast)
RSL boolean or test.
Definition globus_rsl.c:372
globus_rsl_value_unparse
char * globus_rsl_value_unparse(globus_rsl_value_t *rsl_value)
Convert an RSL value pointer to a string.
Definition globus_rsl.c:2755
globus_rsl_print_recursive
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:2647
globus_rsl_value_print_recursive
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:2525
globus_rsl_unparse
char * globus_rsl_unparse(globus_rsl_t *rsl_spec)
Convert an RSL parse tree to a string.
Definition globus_rsl.c:2703