| 1 | /** |
| 2 | * @addtogroup OVAL |
| 3 | * @{ |
| 4 | * @addtogroup OVALVAR |
| 5 | * Interface to Variable model |
| 6 | * @{ |
| 7 | * |
| 8 | * @file |
| 9 | * |
| 10 | * @author "David Niemoller" <[email protected]> |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * Copyright 2009-2014 Red Hat Inc., Durham, North Carolina. |
| 16 | * All Rights Reserved. |
| 17 | * |
| 18 | * This library is free software; you can redistribute it and/or |
| 19 | * modify it under the terms of the GNU Lesser General Public |
| 20 | * License as published by the Free Software Foundation; either |
| 21 | * version 2.1 of the License, or (at your option) any later version. |
| 22 | * |
| 23 | * This library is distributed in the hope that it will be useful, |
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 26 | * Lesser General Public License for more details. |
| 27 | * |
| 28 | * You should have received a copy of the GNU Lesser General Public |
| 29 | * License along with this library; if not, write to the Free Software |
| 30 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 31 | * |
| 32 | * Authors: |
| 33 | * "David Niemoller" <[email protected]> |
| 34 | */ |
| 35 | |
| 36 | #ifndef OVAL_VARIABLES_H_ |
| 37 | #define OVAL_VARIABLES_H_ |
| 38 | |
| 39 | #include "oval_types.h" |
| 40 | #include "oscap.h" |
| 41 | #include "oscap_source.h" |
| 42 | #include "oscap_export.h" |
| 43 | |
| 44 | /** |
| 45 | * Create a new empty OVAL variable model |
| 46 | * @memberof oval_variable_model |
| 47 | */ |
| 48 | OSCAP_API struct oval_variable_model *oval_variable_model_new(void); |
| 49 | |
| 50 | /** |
| 51 | * Import the content from the oscap_source into a new oval_variable_model. |
| 52 | * @param source The oscap_source to import from. |
| 53 | * @return new oval_variable_model, or NULL if an error occurred |
| 54 | * @memberof oval_variable_model |
| 55 | */ |
| 56 | OSCAP_API struct oval_variable_model *oval_variable_model_import_source(struct oscap_source *source); |
| 57 | |
| 58 | /** |
| 59 | * Clone an OVAL variable model |
| 60 | * @return A copy of the specified @ref oval_variable_model. |
| 61 | * @memberof oval_variable_model |
| 62 | */ |
| 63 | OSCAP_API struct oval_variable_model *oval_variable_model_clone(struct oval_variable_model *); |
| 64 | /** |
| 65 | * Free memory allocated to a specified oval_variable_model |
| 66 | * @param variable_model the specified oval_variable_model |
| 67 | * @memberof oval_variable_model |
| 68 | */ |
| 69 | OSCAP_API void oval_variable_model_free(struct oval_variable_model *); |
| 70 | /** |
| 71 | * Export the specified oval_variable_model into file |
| 72 | * @memberof oval_variable_model |
| 73 | */ |
| 74 | OSCAP_API int oval_variable_model_export (struct oval_variable_model *, const char *file); |
| 75 | |
| 76 | |
| 77 | /** |
| 78 | * @name Setters |
| 79 | * @{ |
| 80 | */ |
| 81 | OSCAP_API void oval_variable_model_set_generator(struct oval_variable_model *model, struct oval_generator *generator); |
| 82 | /** |
| 83 | * Get the values bound to a specified external variable. |
| 84 | * If the varid does not resolve to a managed external variable, this method returns NULL. |
| 85 | * @param variable_model the specified oval_variable_model. |
| 86 | * @param varid the identifier of the required oval_variable. |
| 87 | * @memberof oval_variable_model |
| 88 | */ |
| 89 | OSCAP_API void oval_variable_model_add(struct oval_variable_model *model, char *varid, const char *comment, oval_datatype_t datatype, char *value); |
| 90 | /** @} */ |
| 91 | |
| 92 | /** |
| 93 | * @name Getters |
| 94 | * @{ |
| 95 | */ |
| 96 | OSCAP_API struct oval_generator *oval_variable_model_get_generator(struct oval_variable_model *model); |
| 97 | /** |
| 98 | * Get all external variables managed by a specified oval_variable_model. |
| 99 | * @param variable_model the specified oval_variable_model. |
| 100 | * @memberof oval_variable_model |
| 101 | */ |
| 102 | OSCAP_API struct oval_string_iterator *oval_variable_model_get_variable_ids (struct oval_variable_model *); |
| 103 | |
| 104 | /** |
| 105 | * Return true if variable with ID is present in variable model, false otherwise |
| 106 | * @param model Variable model |
| 107 | * @param id ID of variable |
| 108 | * @memberof oval_variable_model |
| 109 | */ |
| 110 | OSCAP_API bool oval_variable_model_has_variable(struct oval_variable_model *model, const char * id); |
| 111 | /** |
| 112 | * Get a specified external variable datatype. |
| 113 | * If the varid does not resolve to a managed external variable, this method returns 0. |
| 114 | * @param variable_model the specified oval_variable_model. |
| 115 | * @param varid the identifier of the required oval_variable. |
| 116 | * @memberof oval_variable_model |
| 117 | */ |
| 118 | OSCAP_API oval_datatype_t oval_variable_model_get_datatype (struct oval_variable_model *, char *); |
| 119 | /** |
| 120 | * Get a specified external variable comment. |
| 121 | * If the varid does not resolve to a managed external variable, this method returns NULL. |
| 122 | * @param variable_model the specified oval_variable_model. |
| 123 | * @param varid the identifier of the required oval_variable. |
| 124 | * @memberof oval_variable_model |
| 125 | */ |
| 126 | OSCAP_API const char *oval_variable_model_get_comment (struct oval_variable_model *, char *); |
| 127 | /** |
| 128 | * Get the values bound to a specified external variable. |
| 129 | * If the varid does not resolve to a managed external variable, this method returns NULL. |
| 130 | * @param variable_model the specified oval_variable_model. |
| 131 | * @param varid the identifier of the required oval_variable. |
| 132 | * @memberof oval_variable_model |
| 133 | */ |
| 134 | OSCAP_API struct oval_value_iterator *oval_variable_model_get_values(struct oval_variable_model *, char *); |
| 135 | /** @} */ |
| 136 | |
| 137 | /** |
| 138 | * @name Iterators |
| 139 | * @{ |
| 140 | */ |
| 141 | /** |
| 142 | * @struct oval_variable_model_iterator |
| 143 | * @see oval_definition_model_get_bound_variable_models |
| 144 | */ |
| 145 | struct oval_variable_model_iterator; |
| 146 | /** |
| 147 | * Returns <b>true</b> if iterator not exhausted. |
| 148 | * @memberof oval_variable_model_iterator |
| 149 | */ |
| 150 | OSCAP_API bool oval_variable_model_iterator_has_more(struct oval_variable_model_iterator *); |
| 151 | /** |
| 152 | * Returns next instance of @ref oval_variable_model. |
| 153 | * @memberof oval_variable_model_iterator |
| 154 | */ |
| 155 | OSCAP_API struct oval_variable_model *oval_variable_model_iterator_next(struct oval_variable_model_iterator *); |
| 156 | /** |
| 157 | * Free iterator. |
| 158 | * @memberof oval_variable_model_iterator |
| 159 | */ |
| 160 | OSCAP_API void oval_variable_model_iterator_free(struct oval_variable_model_iterator *); |
| 161 | /** @} */ |
| 162 | |
| 163 | /** |
| 164 | * @name Evaluators |
| 165 | * @{ |
| 166 | */ |
| 167 | /** @} */ |
| 168 | |
| 169 | /** |
| 170 | * @}END OVALVAR |
| 171 | * @}END OVAL |
| 172 | */ |
| 173 | #endif /* OVAL_VARIABLES_H_ */ |
| 174 | |
| 175 |