globus_rsl.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00022 #ifndef GLOBUS_RSL_H
00023 #define GLOBUS_RSL_H
00024 
00025 #include "globus_module.h"
00026 #include "globus_list.h"
00027 #include "globus_symboltable.h"
00028 #include "globus_hashtable.h"
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #define GLOBUS_RSL_BOOLEAN  1
00035 #define GLOBUS_RSL_RELATION 2
00036 
00037 #define GLOBUS_RSL_EQ             1 
00038 #define GLOBUS_RSL_NEQ            2 
00039 #define GLOBUS_RSL_GT             3 
00040 #define GLOBUS_RSL_GTEQ           4 
00041 #define GLOBUS_RSL_LT             5 
00042 #define GLOBUS_RSL_LTEQ           6 
00043 #define GLOBUS_RSL_AND            8
00044 #define GLOBUS_RSL_OR             9
00045 #define GLOBUS_RSL_MULTIREQ      10
00046 
00047 #define GLOBUS_RSL_VALUE_LITERAL       1
00048 #define GLOBUS_RSL_VALUE_SEQUENCE      2
00049 #define GLOBUS_RSL_VALUE_VARIABLE      3
00050 #define GLOBUS_RSL_VALUE_CONCATENATION 4
00051 
00052 #define GLOBUS_RSL_PARAM_SINGLE_LITERAL 1
00053 #define GLOBUS_RSL_PARAM_MULTI_LITERAL  2
00054 #define GLOBUS_RSL_PARAM_SEQUENCE       3
00055 
00056 /**********************************************************************
00057  *
00058  *  Module activation structure
00059  *
00060  **********************************************************************
00061 */
00062 extern globus_module_descriptor_t       globus_i_rsl_module;
00063 
00064 #define GLOBUS_RSL_MODULE (&globus_i_rsl_module)
00065 
00066 /***********************************************************************/
00067 
00068 
00069 typedef struct _globus_rsl_value_t globus_rsl_value_t;
00070 
00071 struct _globus_rsl_value_t
00072 {
00073   int type;
00074 
00075   union
00076   {
00077     struct
00078     {
00079       char * string;
00080     } literal;
00081 
00082     struct
00083     {
00084       globus_list_t * value_list;
00085     } sequence;
00086 
00087     struct
00088     {
00089       globus_rsl_value_t * sequence;
00090     } variable;
00091 
00092     struct
00093     {
00094       globus_rsl_value_t * left_value;
00095       globus_rsl_value_t * right_value;
00096     } concatenation;
00097 
00098   } value;
00099 };
00100 
00101 typedef struct _globus_rsl_t globus_rsl_t;
00102 
00103 struct _globus_rsl_t
00104 {
00105   int type; /* GLOBUS_RSL_BOOLEAN || GLOBUS_RSL_RELATION */
00106   union
00107   {
00108     struct
00109     {
00110       /* bison reserves "operator" hence my_operator */
00111       int my_operator;
00112       /* each element of the list has type globus_rsl_t *... 
00113        */
00114       globus_list_t *operand_list;
00115     } boolean;
00116 
00117     struct
00118     {
00119       int my_operator;
00120       char * attribute_name;
00121       globus_rsl_value_t * value_sequence;
00122     } relation;
00123   } req;
00124 };
00125 
00126 /*************************************************************************
00127  *                   is functions
00128  *
00129  ************************************************************************/
00130 
00131 int 
00132 globus_rsl_is_relation (globus_rsl_t *ast);
00133 
00134 int
00135 globus_rsl_is_boolean (globus_rsl_t *ast);
00136 
00137 int 
00138 globus_rsl_is_relation_eq (globus_rsl_t *ast);
00139 
00140 /* return true only for relations w/ the specific operator */
00141 int 
00142 globus_rsl_is_relation_lessthan (globus_rsl_t *ast);
00143 
00144 /* return true if relation attribute is equal to attribute arg */
00145 int
00146 globus_rsl_is_relation_attribute_equal (globus_rsl_t *ast, char * attribute);
00147 
00148 /* return true only for booleans w/ the specific operator */
00149 int
00150 globus_rsl_is_boolean_and (globus_rsl_t *ast);
00151 
00152 /* return true only for booleans w/ the specific operator */
00153 int
00154 globus_rsl_is_boolean_or (globus_rsl_t *ast);
00155 
00156 int
00157 globus_rsl_is_boolean_multi (globus_rsl_t *ast);
00158 
00159 int
00160 globus_rsl_value_is_literal (globus_rsl_value_t *ast);
00161 
00162 int
00163 globus_rsl_value_is_sequence (globus_rsl_value_t *ast);
00164 
00165 int
00166 globus_rsl_value_is_variable (globus_rsl_value_t *ast);
00167 
00168 int
00169 globus_rsl_value_is_concatenation (globus_rsl_value_t *ast);
00170 
00171 
00172 /*************************************************************************
00173  *                   constructor functions
00174  *
00175  ************************************************************************/
00176 
00177 globus_rsl_t *
00178 globus_rsl_make_boolean (int my_operator,
00179                        globus_list_t *children);
00180 
00181 globus_rsl_t *
00182 globus_rsl_make_relation (int my_operator,
00183                         char *attributename,
00184                         globus_rsl_value_t *value_sequence);
00185 
00186 globus_rsl_value_t *
00187 globus_rsl_value_make_literal (char *string);
00188 
00189 globus_rsl_value_t *
00190 globus_rsl_value_make_sequence (globus_list_t * value_list);
00191 
00192 globus_rsl_value_t *
00193 globus_rsl_value_make_variable (globus_rsl_value_t * sequence);
00194 
00195 globus_rsl_value_t *
00196 globus_rsl_value_make_concatenation (globus_rsl_value_t *left_value,
00197                                    globus_rsl_value_t *right_value);
00198 
00199 /* copy the entire rsl tree */
00200 globus_rsl_t *
00201 globus_rsl_copy_recursive(globus_rsl_t * globus_rsl_ptr);
00202 
00203 /* copy the entire rsl value list */
00204 globus_rsl_value_t *
00205 globus_rsl_value_copy_recursive(globus_rsl_value_t * globus_rsl_value_ptr);
00206 
00207 /*************************************************************************
00208  *                   accessor functions
00209  *
00210  ************************************************************************/
00211 
00212 /*                   booleans                   */
00213 
00214 /*     return non-zero on error    */
00215 
00216 int
00217 globus_rsl_boolean_get_operator (globus_rsl_t *ast_node);
00218 
00219 /*
00220  *
00221  */
00222 globus_list_t *
00223 globus_rsl_boolean_get_operand_list (globus_rsl_t *ast_node);
00224 
00225 globus_list_t **
00226 globus_rsl_boolean_get_operand_list_ref (globus_rsl_t *boolean_node);
00227 
00228 
00229 /*                   relations                   */
00230 
00231 char *
00232 globus_rsl_relation_get_attribute (globus_rsl_t *ast_node);
00233 
00234 int
00235 globus_rsl_relation_get_operator (globus_rsl_t *ast_node);
00236 
00237 globus_rsl_value_t *
00238 globus_rsl_relation_get_value_sequence (globus_rsl_t *ast_node);
00239 
00240 /* NULL unless the relation has a simple 1-element value sequence */
00241 globus_rsl_value_t *
00242 globus_rsl_relation_get_single_value (globus_rsl_t *ast_node);
00243 
00244 /*                   value lists                   */
00245 
00246 /* extract the literal node's string
00247  * NULL if not called on a node tagged as a literal
00248  */
00249 char *
00250 globus_rsl_value_literal_get_string (globus_rsl_value_t *literal_node);
00251 
00252 /* extract the list of nodes under the sequence node
00253  * NULL if not called on a node tagges as a sequence
00254  */
00255 globus_list_t *
00256 globus_rsl_value_sequence_get_value_list (globus_rsl_value_t *sequence_node);
00257 
00258 /*
00259  *
00260  */
00261 globus_rsl_value_t *
00262 globus_rsl_value_variable_get_sequence (globus_rsl_value_t * variable_node);
00263 
00264 /* extract the name of the referenced variable
00265  * NULL if not called on a node tagged as a variable
00266  */
00267 char *
00268 globus_rsl_value_variable_get_name (globus_rsl_value_t *variable_node);
00269 
00270 /* extract the optional value for the variable reference
00271  * NULL if no optional value specified
00272  * NULL if not called on a node tagged as a variable
00273  */
00274 char *
00275 globus_rsl_value_variable_get_default (globus_rsl_value_t *variable_node);
00276 
00277 /* extract the left-hand value of a concatenation
00278  * NULL if not called on a node tagged as a variable
00279  */
00280 globus_rsl_value_t *
00281 globus_rsl_value_concatenation_get_left (globus_rsl_value_t *concatenation_node);
00282 
00283 /* extract the right-hand value of a concatenation
00284  * NULL if not called on a node tagged as a variable
00285  */
00286 globus_rsl_value_t *
00287 globus_rsl_value_concatenation_get_right (globus_rsl_value_t *concatenation_node);
00288 
00289 globus_list_t **
00290 globus_rsl_value_sequence_get_list_ref (globus_rsl_value_t *sequence_node);
00291 
00292 
00293 /*************************************************************************
00294  *                   set functions
00295  *
00296  ************************************************************************/
00297 
00298 /* set the left-hand value of a concatenation to a new value
00299  * return non-zero on error */
00300 int
00301 globus_rsl_value_concatenation_set_left (globus_rsl_value_t *concatenate_node,
00302                                          globus_rsl_value_t *new_left_node);
00303 
00304 /* set the right-hand value of a concatenation to a new value
00305  * return non-zero on error */
00306 int
00307 globus_rsl_value_concatenation_set_right (globus_rsl_value_t *concatenate_node,
00308                                           globus_rsl_value_t *new_right_node);
00309 
00310 /*************************************************************************
00311  *                   eval functions
00312  *
00313  ************************************************************************/
00314 
00315 int
00316 globus_rsl_value_eval(globus_rsl_value_t * ast_node,
00317                       globus_symboltable_t * symbol_table,
00318                       char ** string_value,
00319                       int rsl_substitute_flag);
00320 
00321 int
00322 globus_rsl_eval (globus_rsl_t *ast_node,
00323                  globus_symboltable_t * symbol_table);
00324 
00325 /*************************************************************************
00326  *                   free functions
00327  *
00328  ************************************************************************/
00329 
00330 
00331 /*** all freeing is done through globus_free() ***/
00332 
00333 /* free any storage allocated by the globus_rsl*_make_*() routine
00334  * for this type of node
00335  */
00336 int
00337 globus_rsl_value_free (globus_rsl_value_t *val);
00338 
00339 int
00340 globus_rsl_free (globus_rsl_t *ast_node);
00341 
00342 /* like globus_rsl*_free () but recursively free subtrees too.
00343  * Assumes: 1.) no nodes in the tree are shared,
00344  *          2.) everything was allocated with globus_malloc
00345  */
00346 int
00347 globus_rsl_value_free_recursive (globus_rsl_value_t * globus_rsl_value_ptr);
00348 
00349 int
00350 globus_rsl_free_recursive (globus_rsl_t *ast_node);
00351 
00352 int
00353 globus_rsl_value_print_recursive (globus_rsl_value_t * globus_rsl_value_ptr);
00354 
00355 int
00356 globus_rsl_print_recursive (globus_rsl_t *ast_node);
00357 
00358 #define GLOBUS_SPECIFICATION_PARSE_ERROR_MESSAGE_LENGTH 1024
00359 typedef struct globus_parse_error_s
00360 {
00361     int         code;
00362     int         line;
00363     int         position;
00364     char        message[GLOBUS_SPECIFICATION_PARSE_ERROR_MESSAGE_LENGTH];
00365 } globus_rsl_parse_error_t;
00366 
00367 /******************************************************************************
00368                               Function prototypes
00369 ******************************************************************************/
00370 
00371 /* extract the name of the referenced variable
00372  * NULL if not called on a node tagged as a variable
00373  */
00374 int
00375 globus_rsl_value_variable_get_size (globus_rsl_value_t *variable_node);
00376 
00377 globus_list_t *
00378 globus_list_copy_reverse (globus_list_t * orig);
00379 
00380 int
00381 globus_rsl_value_list_literal_replace(globus_list_t * value_list,
00382                                      char * string_value);
00383 
00384 globus_list_t *
00385 globus_rsl_operand_list_copy_recursive(globus_list_t * orig);
00386 
00387 globus_list_t *
00388 globus_rsl_value_sequence_list_copy_recursive(globus_list_t * orig);
00389 
00390 int
00391 globus_rsl_value_list_param_get(globus_list_t * ast_node_list,
00392                      int required_type,
00393                      char *** value,
00394                      int * value_ctr);
00395 
00396 int
00397 globus_rsl_param_get(globus_rsl_t * ast_node,
00398                      int required_type,
00399                      char * param,
00400                      char *** values);
00401 
00402 globus_list_t *
00403 globus_rsl_param_get_values(globus_rsl_t * ast_node,
00404                             char * param);
00405 
00406 globus_rsl_t *
00407 globus_rsl_parse(char * rsl_spec);
00408 
00409 char *
00410 globus_rsl_unparse (globus_rsl_t *rsl_spec);
00411 
00412 char *
00413 globus_rsl_value_unparse (globus_rsl_value_t * rsl_value);
00414 
00415 #ifdef __cplusplus
00416 }
00417 #endif
00418 
00419 #endif /* GLOBUS_RSL_H */

Generated on 5 Sep 2016 for globus_rsl by  doxygen 1.4.7