| 1 | /** |
| 2 | * @addtogroup CPE |
| 3 | * @{ |
| 4 | * @addtogroup cpedict CPE Dictionary |
| 5 | * @{ |
| 6 | * |
| 7 | * @image html cpe_dictionary.png "Class diagram" |
| 8 | * @file cpe_dict.h |
| 9 | * |
| 10 | * \brief Interface to Common Platform Enumeration (CPE) Dictionary. |
| 11 | */ |
| 12 | |
| 13 | /* |
| 14 | * Copyright 2009--2014 Red Hat Inc., Durham, North Carolina. |
| 15 | * All Rights Reserved. |
| 16 | * |
| 17 | * This library is free software; you can redistribute it and/or |
| 18 | * modify it under the terms of the GNU Lesser General Public |
| 19 | * License as published by the Free Software Foundation; either |
| 20 | * version 2.1 of the License, or (at your option) any later version. |
| 21 | * |
| 22 | * This library is distributed in the hope that it will be useful, |
| 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 25 | * Lesser General Public License for more details. |
| 26 | * |
| 27 | * You should have received a copy of the GNU Lesser General Public |
| 28 | * License along with this library; if not, write to the Free Software |
| 29 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 30 | * |
| 31 | * Authors: |
| 32 | * Maros Barabas <[email protected]> |
| 33 | * Lukas Kuklinek <[email protected]> |
| 34 | * Šimon Lukašík |
| 35 | */ |
| 36 | |
| 37 | #ifndef CPEDICT_H_ |
| 38 | #define CPEDICT_H_ |
| 39 | |
| 40 | #include "oscap.h" |
| 41 | #include "cpe_name.h" |
| 42 | #include "oscap_text.h" |
| 43 | #include "oscap_source.h" |
| 44 | #include "oscap_export.h" |
| 45 | |
| 46 | /** |
| 47 | * @struct cpe_dict_model |
| 48 | * Structure representing a CPE dictionary. |
| 49 | */ |
| 50 | struct cpe_dict_model; |
| 51 | |
| 52 | /** |
| 53 | * @struct cpe_item |
| 54 | * Structure representing single CPE dictionary item. |
| 55 | */ |
| 56 | struct cpe_item; |
| 57 | |
| 58 | /** |
| 59 | * @struct cpe_vendor |
| 60 | * Structure with information about vendor |
| 61 | */ |
| 62 | struct cpe_vendor; |
| 63 | |
| 64 | /** |
| 65 | * @struct cpe_generator |
| 66 | * Structure with information about document |
| 67 | */ |
| 68 | struct cpe_generator; |
| 69 | |
| 70 | /** |
| 71 | * @struct cpe_check |
| 72 | * Structure representing single CPE check. |
| 73 | */ |
| 74 | struct cpe_check; |
| 75 | |
| 76 | /** |
| 77 | * @struct cpe_reference |
| 78 | * CPE dictionary item reference. |
| 79 | */ |
| 80 | struct cpe_reference; |
| 81 | |
| 82 | /** |
| 83 | * @struct cpe_item_metadata |
| 84 | * Structure representing metadata of CPE item |
| 85 | */ |
| 86 | struct cpe_item_metadata; |
| 87 | |
| 88 | /** |
| 89 | * @struct cpe_product |
| 90 | * Product of some vendor |
| 91 | */ |
| 92 | struct cpe_product; |
| 93 | /** |
| 94 | * @struct cpe_version |
| 95 | * Version of product |
| 96 | */ |
| 97 | struct cpe_version; |
| 98 | /** |
| 99 | * @struct cpe_update |
| 100 | * Update of product version |
| 101 | */ |
| 102 | struct cpe_update; |
| 103 | /** |
| 104 | * @struct cpe_edition |
| 105 | * Edition of product update |
| 106 | */ |
| 107 | struct cpe_edition; |
| 108 | /** |
| 109 | * @struct cpe_language |
| 110 | * Language of product edition |
| 111 | */ |
| 112 | struct cpe_language; |
| 113 | |
| 114 | /************************************************************/ |
| 115 | /** |
| 116 | * @name Getters |
| 117 | * Return value is pointer to structure's member. Do not free unless you null the pointer in the structure. |
| 118 | * Use remove function otherwise. |
| 119 | * @{ |
| 120 | * */ |
| 121 | |
| 122 | /** cpe_item_metadata function to get date |
| 123 | * @memberof cpe_item_metadata |
| 124 | * @param item metadata of CPE item |
| 125 | */ |
| 126 | OSCAP_API const char *cpe_item_metadata_get_modification_date(const struct cpe_item_metadata *item); |
| 127 | |
| 128 | /** cpe_item_metadata function to get status |
| 129 | * @memberof cpe_item_metadata |
| 130 | * @param item metadata of CPE item |
| 131 | */ |
| 132 | OSCAP_API const char *cpe_item_metadata_get_status(const struct cpe_item_metadata *item); |
| 133 | |
| 134 | /** cpe_item_metadata function to get nvd ID |
| 135 | * @memberof cpe_item_metadata |
| 136 | * @param item metadata of CPE item |
| 137 | */ |
| 138 | OSCAP_API const char *cpe_item_metadata_get_nvd_id(const struct cpe_item_metadata *item); |
| 139 | |
| 140 | /** cpe_item_metadata function to get NVD ID of deprecated item |
| 141 | * @memberof cpe_item_metadata |
| 142 | * @param item metadata of CPE item |
| 143 | */ |
| 144 | OSCAP_API const char *cpe_item_metadata_get_deprecated_by_nvd_id(const struct cpe_item_metadata *item); |
| 145 | |
| 146 | /** cpe_check functions to get system |
| 147 | * @memberof cpe_check |
| 148 | * @param item CPE check item |
| 149 | */ |
| 150 | OSCAP_API const char *cpe_check_get_system(const struct cpe_check *item); |
| 151 | |
| 152 | /** cpe_check functions to get href |
| 153 | * @memberof cpe_check |
| 154 | * @param item CPE check item |
| 155 | */ |
| 156 | OSCAP_API const char *cpe_check_get_href(const struct cpe_check *item); |
| 157 | |
| 158 | /** cpe_check functions to get identifier |
| 159 | * @memberof cpe_check |
| 160 | * @param item CPE check item |
| 161 | */ |
| 162 | OSCAP_API const char *cpe_check_get_identifier(const struct cpe_check *item); |
| 163 | |
| 164 | /** cpe_reference functions to get href of reference |
| 165 | * @memberof cpe_reference |
| 166 | * @param item CPE reference item |
| 167 | */ |
| 168 | OSCAP_API const char *cpe_reference_get_href(const struct cpe_reference *item); |
| 169 | |
| 170 | /** cpe_reference functions to get content of reference |
| 171 | * @memberof cpe_reference |
| 172 | * @param item CPE reference item |
| 173 | */ |
| 174 | OSCAP_API const char *cpe_reference_get_content(const struct cpe_reference *item); |
| 175 | |
| 176 | /** cpe_item functions to get variable member name |
| 177 | * @memberof cpe_item |
| 178 | * @param item CPE item |
| 179 | */ |
| 180 | OSCAP_API struct cpe_name *cpe_item_get_name(const struct cpe_item *item); |
| 181 | |
| 182 | /** cpe_item functions to get variable member deprecated_by |
| 183 | * @memberof cpe_item |
| 184 | * @param item CPE item |
| 185 | */ |
| 186 | OSCAP_API struct cpe_name *cpe_item_get_deprecated_by(const struct cpe_item *item); |
| 187 | |
| 188 | /** cpe_item functions to get variable member date |
| 189 | * @memberof cpe_item |
| 190 | * @param item CPE item |
| 191 | */ |
| 192 | OSCAP_API const char *cpe_item_get_deprecation_date(const struct cpe_item *item); |
| 193 | |
| 194 | /** cpe_item functions to get metadata of cpe_item |
| 195 | * @memberof cpe_item |
| 196 | * @param item CPE item |
| 197 | */ |
| 198 | OSCAP_API struct cpe_item_metadata *cpe_item_get_metadata(const struct cpe_item *item); |
| 199 | |
| 200 | /** cpe_item functions to get CPE references |
| 201 | * @memberof cpe_item |
| 202 | * @param item CPE item |
| 203 | */ |
| 204 | OSCAP_API struct cpe_reference_iterator *cpe_item_get_references(const struct cpe_item *item); |
| 205 | |
| 206 | /** cpe_item functions to get CPE checks |
| 207 | * @memberof cpe_item |
| 208 | * @param item CPE item |
| 209 | */ |
| 210 | OSCAP_API struct cpe_check_iterator *cpe_item_get_checks(const struct cpe_item *item); |
| 211 | |
| 212 | /** cpe_item functions to get CPE titles |
| 213 | * @memberof cpe_item |
| 214 | * @param item CPE item |
| 215 | */ |
| 216 | OSCAP_API struct oscap_text_iterator *cpe_item_get_titles(const struct cpe_item *item); |
| 217 | |
| 218 | /** cpe_generator functions to get product name |
| 219 | * @memberof cpe_generator |
| 220 | * @param item document generator |
| 221 | */ |
| 222 | OSCAP_API const char *cpe_generator_get_product_name(const struct cpe_generator *item); |
| 223 | |
| 224 | /** cpe_generator functions to get product version |
| 225 | * @memberof cpe_generator |
| 226 | * @param item document generator |
| 227 | */ |
| 228 | OSCAP_API const char *cpe_generator_get_product_version(const struct cpe_generator *item); |
| 229 | |
| 230 | /** cpe_generator functions to get document schema version |
| 231 | * @memberof cpe_generator |
| 232 | * @param item document generator |
| 233 | */ |
| 234 | OSCAP_API const char *cpe_generator_get_schema_version(const struct cpe_generator *item); |
| 235 | |
| 236 | /** cpe_generator functions to get timestamp from generator |
| 237 | * @memberof cpe_generator |
| 238 | * @param item document generator |
| 239 | */ |
| 240 | OSCAP_API const char *cpe_generator_get_timestamp(const struct cpe_generator *item); |
| 241 | |
| 242 | /** cpe_dict_model functions to get the base version from CPE dictionary model |
| 243 | * |
| 244 | * The base version is the major CPE version, 1 or 2. These two versions differ |
| 245 | * in namespace when exporting so we have to remember which version we loaded. |
| 246 | * |
| 247 | * CPE 1.0 also doesn't have cpe_generator structure inside so we can't get |
| 248 | * the version info from there. |
| 249 | * |
| 250 | * @memberof cpe_dict_model |
| 251 | * @param item dictionary model |
| 252 | */ |
| 253 | OSCAP_API int cpe_dict_model_get_base_version(const struct cpe_dict_model *item); |
| 254 | |
| 255 | /** cpe_dict_model functions to get the base version from CPE dictionary model |
| 256 | * @memberof cpe_dict_model |
| 257 | * @param item dictionary model |
| 258 | */ |
| 259 | OSCAP_API bool cpe_dict_model_set_base_version(struct cpe_dict_model *item, int base_version); |
| 260 | |
| 261 | /** cpe_dict_model functions to get generator from CPE dictionary model |
| 262 | * @memberof cpe_dict_model |
| 263 | * @memberof cpe_generator |
| 264 | * @param item dictionary model |
| 265 | */ |
| 266 | OSCAP_API struct cpe_generator *cpe_dict_model_get_generator(const struct cpe_dict_model *item); |
| 267 | |
| 268 | /** cpe_dict_model functions to get CPE items |
| 269 | * @memberof cpe_dict_model |
| 270 | * @param item dictionary model |
| 271 | */ |
| 272 | OSCAP_API struct cpe_item_iterator *cpe_dict_model_get_items(const struct cpe_dict_model *item); |
| 273 | |
| 274 | /** cpe_dict_model functions to get vendors |
| 275 | * @memberof cpe_dict_model |
| 276 | * @param item dictionary model |
| 277 | */ |
| 278 | OSCAP_API struct cpe_vendor_iterator *cpe_dict_model_get_vendors(const struct cpe_dict_model *item); |
| 279 | |
| 280 | /** cpe_vendor functions to get vendor value |
| 281 | * @memberof cpe_vendor |
| 282 | * @param item cpe_vendor |
| 283 | */ |
| 284 | OSCAP_API const char *cpe_vendor_get_value(const struct cpe_vendor *item); |
| 285 | |
| 286 | /** cpe_vendor functions to get vendor titles |
| 287 | * @memberof cpe_vendor |
| 288 | * @param item cpe_vendor |
| 289 | */ |
| 290 | OSCAP_API struct oscap_text_iterator *cpe_vendor_get_titles(const struct cpe_vendor *item); |
| 291 | |
| 292 | /** cpe_vendor functions to get vendor products |
| 293 | * @memberof cpe_vendor |
| 294 | * @param item cpe_vendor |
| 295 | */ |
| 296 | OSCAP_API struct cpe_product_iterator *cpe_vendor_get_products(const struct cpe_vendor *item); |
| 297 | |
| 298 | /** cpe_product functions to get product value |
| 299 | * @memberof cpe_product |
| 300 | * @param item cpe_product |
| 301 | */ |
| 302 | OSCAP_API const char *cpe_product_get_value(const struct cpe_product *item); |
| 303 | |
| 304 | /** cpe_product functions to get product part |
| 305 | * @memberof cpe_product |
| 306 | * @param item cpe_product |
| 307 | */ |
| 308 | OSCAP_API cpe_part_t cpe_product_get_part(const struct cpe_product *item); |
| 309 | |
| 310 | /** cpe_product functions to get versions of product |
| 311 | * @memberof cpe_product |
| 312 | * @memberof cpe_version |
| 313 | * @param item cpe_product |
| 314 | */ |
| 315 | OSCAP_API struct cpe_version_iterator *cpe_product_get_versions(const struct cpe_product *item); |
| 316 | |
| 317 | /** cpe_version functions to get vupdates of versions |
| 318 | * @memberof cpe_version |
| 319 | * @param item cpe_version |
| 320 | */ |
| 321 | OSCAP_API const char *cpe_version_get_value(const struct cpe_version *item); |
| 322 | |
| 323 | /** cpe_version functions to get value of version |
| 324 | * @memberof cpe_version |
| 325 | * @memberof cpe_update |
| 326 | * @param item cpe_version |
| 327 | */ |
| 328 | OSCAP_API struct cpe_update_iterator *cpe_version_get_updates(const struct cpe_version *item); |
| 329 | |
| 330 | /** cpe_update functions to get updates of version |
| 331 | * @memberof cpe_update |
| 332 | * @param item |
| 333 | */ |
| 334 | OSCAP_API const char *cpe_update_get_value(const struct cpe_update *item); |
| 335 | |
| 336 | /** cpe_update functions to get editions of update |
| 337 | * @memberof cpe_update |
| 338 | * @memberof cpe_edition |
| 339 | * @param item cpe_update of product element |
| 340 | */ |
| 341 | OSCAP_API struct cpe_edition_iterator *cpe_update_get_editions(const struct cpe_update *item); |
| 342 | |
| 343 | /** cpe_edition functions to get value of edition |
| 344 | * @memberof cpe_edition |
| 345 | * @param item cpe_edition of update |
| 346 | */ |
| 347 | OSCAP_API const char *cpe_edition_get_value(const struct cpe_edition *item); |
| 348 | |
| 349 | /** cpe_edition functions to get languages of edition |
| 350 | * @memberof cpe_edition |
| 351 | * @memberof cpe_language |
| 352 | * @param item cpe_edition of update |
| 353 | */ |
| 354 | OSCAP_API struct cpe_language_iterator *cpe_edition_get_languages(const struct cpe_edition *item); |
| 355 | |
| 356 | /** cpe_language functions to get value of language |
| 357 | * @memberof cpe_language |
| 358 | * @param item language |
| 359 | */ |
| 360 | OSCAP_API const char *cpe_language_get_value(const struct cpe_language *item); |
| 361 | |
| 362 | /************************************************************/ |
| 363 | /** @} End of Getters group */ |
| 364 | |
| 365 | /// @memberof cpe_check |
| 366 | OSCAP_API void cpe_check_free(struct cpe_check *check); |
| 367 | /// @memberof cpe_reference |
| 368 | OSCAP_API void cpe_reference_free(struct cpe_reference *ref); |
| 369 | /// @memberof cpe_vendor |
| 370 | OSCAP_API void cpe_vendor_free(struct cpe_vendor *vendor); |
| 371 | /// @memberof cpe_product |
| 372 | OSCAP_API void cpe_product_free(struct cpe_product *product); |
| 373 | /// @memberof cpe_version |
| 374 | OSCAP_API void cpe_version_free(struct cpe_version *version); |
| 375 | /// @memberof cpe_update |
| 376 | OSCAP_API void cpe_update_free(struct cpe_update *update); |
| 377 | /// @memberof cpe_edition |
| 378 | OSCAP_API void cpe_edition_free(struct cpe_edition *edition); |
| 379 | /// @memberof cpe_language |
| 380 | OSCAP_API void cpe_language_free(struct cpe_language *language); |
| 381 | /// @memberof cpe_itemmetadata |
| 382 | OSCAP_API void cpe_itemmetadata_free(struct cpe_item_metadata *meta); |
| 383 | /// @memberof cpe_dict_model |
| 384 | OSCAP_API void cpe_dict_model_free(struct cpe_dict_model *dict); |
| 385 | /// @memberof cpe_generator |
| 386 | OSCAP_API void cpe_generator_free(struct cpe_generator *generator); |
| 387 | /// @memberof cpe_item |
| 388 | OSCAP_API void cpe_item_free(struct cpe_item *item); |
| 389 | |
| 390 | /// @memberof cpe_dict_model |
| 391 | OSCAP_API struct cpe_dict_model *cpe_dict_model_new(void); |
| 392 | /// @memberof cpe_generator |
| 393 | OSCAP_API struct cpe_generator *cpe_generator_new(void); |
| 394 | /// @memberof cpe_check |
| 395 | OSCAP_API struct cpe_check *cpe_check_new(void); |
| 396 | /// @memberof cpe_reference |
| 397 | OSCAP_API struct cpe_reference *cpe_reference_new(void); |
| 398 | /// @memberof cpe_item |
| 399 | OSCAP_API struct cpe_item *cpe_item_new(void); |
| 400 | /// @memberof cpe_vendor |
| 401 | OSCAP_API struct cpe_vendor *cpe_vendor_new(void); |
| 402 | /// @memberof cpe_product |
| 403 | OSCAP_API struct cpe_product *cpe_product_new(void); |
| 404 | /// @memberof cpe_version |
| 405 | OSCAP_API struct cpe_version *cpe_version_new(void); |
| 406 | /// @memberof cpe_update |
| 407 | OSCAP_API struct cpe_update *cpe_update_new(void); |
| 408 | /// @memberof cpe_edition |
| 409 | OSCAP_API struct cpe_edition *cpe_edition_new(void); |
| 410 | /// @memberof cpe_language |
| 411 | OSCAP_API struct cpe_language *cpe_language_new(void); |
| 412 | /// @memberof cpe_item_metadata |
| 413 | OSCAP_API struct cpe_item_metadata *cpe_item_metadata_new(void); |
| 414 | |
| 415 | /************************************************************/ |
| 416 | /** |
| 417 | * @name Setters |
| 418 | * For lists use add functions. Parameters of set functions are duplicated in memory and need to |
| 419 | * be freed by caller. |
| 420 | * @{ |
| 421 | */ |
| 422 | |
| 423 | /// @memberof cpe_item |
| 424 | OSCAP_API bool cpe_item_set_name(struct cpe_item *item, struct cpe_name *new_name); |
| 425 | |
| 426 | /// @memberof cpe_item |
| 427 | OSCAP_API bool cpe_item_set_deprecated_by(struct cpe_item *item, struct cpe_name *new_deprecated_by); |
| 428 | |
| 429 | /// @memberof cpe_item |
| 430 | OSCAP_API bool cpe_item_set_deprecation_date(struct cpe_item *item, const char *new_deprecation_date); |
| 431 | |
| 432 | /// @memberof cpe_item_metadata |
| 433 | OSCAP_API bool cpe_item_metadata_set_modification_date(struct cpe_item_metadata *item_metadata, |
| 434 | const char *new_modification_date); |
| 435 | |
| 436 | /// @memberof cpe_item_metadata |
| 437 | OSCAP_API bool cpe_item_metadata_set_status(struct cpe_item_metadata *item_metadata, const char *new_status); |
| 438 | |
| 439 | /// @memberof cpe_item_metadata |
| 440 | OSCAP_API bool cpe_item_metadata_set_nvd_id(struct cpe_item_metadata *item_metadata, const char *new_nvd_id); |
| 441 | |
| 442 | /// @memberof cpe_item_metadata |
| 443 | OSCAP_API bool cpe_item_metadata_set_deprecated_by_nvd_id(struct cpe_item_metadata *item_metadata, |
| 444 | const char *new_deprecated_by_nvd_id); |
| 445 | |
| 446 | /// @memberof cpe_check |
| 447 | OSCAP_API bool cpe_check_set_system(struct cpe_check *check, const char *new_system); |
| 448 | |
| 449 | /// @memberof cpe_check |
| 450 | OSCAP_API bool cpe_check_set_href(struct cpe_check *check, const char *new_href); |
| 451 | |
| 452 | /// @memberof cpe_check |
| 453 | OSCAP_API bool cpe_check_set_identifier(struct cpe_check *check, const char *new_identifier); |
| 454 | |
| 455 | /// @memberof cpe_reference |
| 456 | OSCAP_API bool cpe_reference_set_href(struct cpe_reference *reference, const char *new_href); |
| 457 | |
| 458 | /// @memberof cpe_reference |
| 459 | OSCAP_API bool cpe_reference_set_content(struct cpe_reference *reference, const char *new_content); |
| 460 | |
| 461 | /// @memberof cpe_generator |
| 462 | OSCAP_API bool cpe_generator_set_product_name(struct cpe_generator *generator, const char *new_product_name); |
| 463 | |
| 464 | /// @memberof cpe_generator |
| 465 | OSCAP_API bool cpe_generator_set_product_version(struct cpe_generator *generator, const char *new_product_version); |
| 466 | |
| 467 | /// @memberof cpe_generator |
| 468 | OSCAP_API bool cpe_generator_set_schema_version(struct cpe_generator *generator, const char *new_schema_version); |
| 469 | |
| 470 | /// @memberof cpe_generator |
| 471 | OSCAP_API bool cpe_generator_set_timestamp(struct cpe_generator *generator, const char *new_timestamp); |
| 472 | |
| 473 | /// @memberof cpe_vendor |
| 474 | OSCAP_API bool cpe_vendor_set_value(struct cpe_vendor *vendor, const char *new_value); |
| 475 | |
| 476 | /// @memberof cpe_product |
| 477 | OSCAP_API bool cpe_product_set_value(struct cpe_product *product, const char *new_value); |
| 478 | |
| 479 | /// @memberof cpe_product |
| 480 | OSCAP_API bool cpe_product_set_part(struct cpe_product *product, cpe_part_t new_part); |
| 481 | |
| 482 | /// @memberof cpe_version |
| 483 | OSCAP_API bool cpe_version_set_value(struct cpe_version *version, const char *new_value); |
| 484 | |
| 485 | /// @memberof cpe_update |
| 486 | OSCAP_API bool cpe_update_set_value(struct cpe_update *update, const char *new_value); |
| 487 | |
| 488 | /// @memberof cpe_edition |
| 489 | OSCAP_API bool cpe_edition_set_value(struct cpe_edition *edition, const char *new_value); |
| 490 | |
| 491 | /// @memberof cpe_language |
| 492 | OSCAP_API bool cpe_language_set_value(struct cpe_language *language, const char *new_value); |
| 493 | |
| 494 | /* |
| 495 | * Add functions |
| 496 | */ |
| 497 | |
| 498 | /// @memberof cpe_item |
| 499 | OSCAP_API bool cpe_item_add_reference(struct cpe_item *item, struct cpe_reference *new_reference); |
| 500 | |
| 501 | /// @memberof cpe_item |
| 502 | OSCAP_API bool cpe_item_add_check(struct cpe_item *item, struct cpe_check *new_check); |
| 503 | |
| 504 | /// @memberof cpe_item |
| 505 | OSCAP_API bool cpe_item_add_title(struct cpe_item *item, struct oscap_text *new_title); |
| 506 | |
| 507 | /// @memberof cpe_dict_model |
| 508 | OSCAP_API bool cpe_dict_model_add_item(struct cpe_dict_model *dict, struct cpe_item *new_item); |
| 509 | |
| 510 | /// @memberof cpe_dict_model |
| 511 | OSCAP_API bool cpe_dict_model_add_vendor(struct cpe_dict_model *dict, struct cpe_vendor *new_vendor); |
| 512 | |
| 513 | /// @memberof cpe_vendor |
| 514 | OSCAP_API bool cpe_vendor_add_title(struct cpe_vendor *vendor, struct oscap_text *new_title); |
| 515 | |
| 516 | /// @memberof cpe_vendor |
| 517 | OSCAP_API bool cpe_vendor_add_product(struct cpe_vendor *vendor, struct cpe_product *new_product); |
| 518 | |
| 519 | /// @memberof cpe_product |
| 520 | OSCAP_API bool cpe_product_add_version(struct cpe_product *product, struct cpe_version *new_version); |
| 521 | |
| 522 | /// @memberof cpe_version |
| 523 | OSCAP_API bool cpe_version_add_update(struct cpe_version *version, struct cpe_update *new_update); |
| 524 | |
| 525 | /// @memberof cpe_update |
| 526 | OSCAP_API bool cpe_update_add_edition(struct cpe_update *update, struct cpe_edition *new_edition); |
| 527 | |
| 528 | /// @memberof cpe_edition |
| 529 | OSCAP_API bool cpe_edition_add_language(struct cpe_edition *edition, struct cpe_language *new_language); |
| 530 | |
| 531 | |
| 532 | /************************************************************/ |
| 533 | /** @} End of Setters group */ |
| 534 | |
| 535 | /************************************************************/ |
| 536 | /** |
| 537 | * @name Iterators |
| 538 | * @{ |
| 539 | * */ |
| 540 | |
| 541 | /** |
| 542 | * @struct cpe_item_iterator |
| 543 | * Iterator over CPE dictionary items. |
| 544 | * @see oscap_iterator |
| 545 | */ |
| 546 | struct cpe_item_iterator; |
| 547 | |
| 548 | /** |
| 549 | * Iterator over CPE dictionary items. |
| 550 | * @see oscap_iterator |
| 551 | * @memberof cpe_item_iterator |
| 552 | */ |
| 553 | OSCAP_API struct cpe_item *cpe_item_iterator_next(struct cpe_item_iterator *it); |
| 554 | |
| 555 | /** |
| 556 | * Iterator over CPE dictionary items. |
| 557 | * @see oscap_iterator |
| 558 | * @memberof cpe_item_iterator |
| 559 | */ |
| 560 | OSCAP_API bool cpe_item_iterator_has_more(struct cpe_item_iterator *it); |
| 561 | |
| 562 | /** |
| 563 | * Iterator over CPE dictionary items. |
| 564 | * @see oscap_iterator |
| 565 | * @memberof cpe_item_iterator |
| 566 | */ |
| 567 | OSCAP_API void cpe_item_iterator_free(struct cpe_item_iterator *it); |
| 568 | |
| 569 | /// @memberof cpe_item |
| 570 | OSCAP_API void cpe_item_iterator_remove(struct cpe_item_iterator *it); |
| 571 | /// @memberof cpe_item_iterator |
| 572 | OSCAP_API void cpe_item_iterator_reset(struct cpe_item_iterator *it); |
| 573 | |
| 574 | /** |
| 575 | * @struct cpe_reference_iterator |
| 576 | * Iterator over CPE dictionary references. |
| 577 | * @see oscap_iterator |
| 578 | */ |
| 579 | struct cpe_reference_iterator; |
| 580 | |
| 581 | /** |
| 582 | * Iterator over CPE item reference items. |
| 583 | * @see oscap_iterator |
| 584 | * @memberof cpe_reference_iterator |
| 585 | */ |
| 586 | OSCAP_API struct cpe_reference *cpe_reference_iterator_next(struct cpe_reference_iterator *it); |
| 587 | |
| 588 | /** |
| 589 | * Iterator over CPE item reference items. |
| 590 | * @see oscap_iterator |
| 591 | * @memberof cpe_reference_iterator |
| 592 | */ |
| 593 | OSCAP_API bool cpe_reference_iterator_has_more(struct cpe_reference_iterator *it); |
| 594 | |
| 595 | /** |
| 596 | * Iterator over CPE item reference items. |
| 597 | * @see oscap_iterator |
| 598 | * @memberof cpe_reference_iterator |
| 599 | */ |
| 600 | OSCAP_API void cpe_reference_iterator_free(struct cpe_reference_iterator *it); |
| 601 | |
| 602 | /// @memberof cpe_reference_iterator |
| 603 | OSCAP_API void cpe_reference_iterator_remove(struct cpe_reference_iterator *it); |
| 604 | /// @memberof cpe_reference_iterator |
| 605 | OSCAP_API void cpe_reference_iterator_reset(struct cpe_reference_iterator *it); |
| 606 | |
| 607 | /** |
| 608 | * @struct cpe_check_iterator |
| 609 | * Iterator over CPE dictionary checks. |
| 610 | * @see oscap_iterator |
| 611 | */ |
| 612 | struct cpe_check_iterator; |
| 613 | |
| 614 | /** |
| 615 | * Iterator over CPE item check items. |
| 616 | * @see oscap_iterator |
| 617 | * @memberof cpe_check_iterator |
| 618 | */ |
| 619 | OSCAP_API struct cpe_check *cpe_check_iterator_next(struct cpe_check_iterator *it); |
| 620 | |
| 621 | /** |
| 622 | * Iterator over CPE item check items. |
| 623 | * @see oscap_iterator |
| 624 | * @memberof cpe_check_iterator |
| 625 | */ |
| 626 | OSCAP_API bool cpe_check_iterator_has_more(struct cpe_check_iterator *it); |
| 627 | |
| 628 | /** |
| 629 | * Iterator over CPE item check items. |
| 630 | * @see oscap_iterator |
| 631 | * @memberof cpe_check_iterator |
| 632 | */ |
| 633 | OSCAP_API void cpe_check_iterator_free(struct cpe_check_iterator *it); |
| 634 | |
| 635 | /// @memberof cpe_check_iterator |
| 636 | OSCAP_API void cpe_check_iterator_remove(struct cpe_check_iterator *it); |
| 637 | /// @memberof cpe_check_iterator |
| 638 | OSCAP_API void cpe_check_iterator_reset(struct cpe_check_iterator *it); |
| 639 | |
| 640 | /** |
| 641 | * @struct cpe_vendor_iterator |
| 642 | * Iterator over CPE dictionary item vendors. |
| 643 | * @see oscap_iterator |
| 644 | */ |
| 645 | struct cpe_vendor_iterator; |
| 646 | |
| 647 | /** |
| 648 | * Iterator over CPE vendor items. |
| 649 | * @see oscap_iterator |
| 650 | * @memberof cpe_vendor_iterator |
| 651 | */ |
| 652 | OSCAP_API struct cpe_vendor *cpe_vendor_iterator_next(struct cpe_vendor_iterator *it); |
| 653 | |
| 654 | /** |
| 655 | * Iterator over CPE vendor items. |
| 656 | * @see oscap_iterator |
| 657 | * @memberof cpe_vendor_iterator |
| 658 | */ |
| 659 | OSCAP_API bool cpe_vendor_iterator_has_more(struct cpe_vendor_iterator *it); |
| 660 | |
| 661 | /** |
| 662 | * Iterator over CPE vendor items. |
| 663 | * @see oscap_iterator |
| 664 | * @memberof cpe_vendor_iterator |
| 665 | */ |
| 666 | OSCAP_API void cpe_vendor_iterator_free(struct cpe_vendor_iterator *it); |
| 667 | |
| 668 | /// @memberof cpe_vendor_iterator |
| 669 | OSCAP_API void cpe_vendor_iterator_remove(struct cpe_vendor_iterator *it); |
| 670 | /// @memberof cpe_vendor_iterator |
| 671 | OSCAP_API void cpe_vendor_iterator_reset(struct cpe_vendor_iterator *it); |
| 672 | |
| 673 | /** |
| 674 | * @struct cpe_product_iterator |
| 675 | * Iterator over CPE dictionary item products. |
| 676 | * @see oscap_iterator |
| 677 | */ |
| 678 | struct cpe_product_iterator; |
| 679 | |
| 680 | /** |
| 681 | * Iterator over CPE product items. |
| 682 | * @see oscap_iterator |
| 683 | * @memberof cpe_product_iterator |
| 684 | */ |
| 685 | OSCAP_API struct cpe_product *cpe_product_iterator_next(struct cpe_product_iterator *it); |
| 686 | |
| 687 | /** |
| 688 | * Iterator over CPE product items. |
| 689 | * @see oscap_iterator |
| 690 | * @memberof cpe_product_iterator |
| 691 | */ |
| 692 | OSCAP_API bool cpe_product_iterator_has_more(struct cpe_product_iterator *it); |
| 693 | |
| 694 | /** |
| 695 | * Iterator over CPE product items. |
| 696 | * @see oscap_iterator |
| 697 | * @memberof cpe_product_iterator |
| 698 | */ |
| 699 | OSCAP_API void cpe_product_iterator_free(struct cpe_product_iterator *it); |
| 700 | |
| 701 | /// @memberof cpe_product_iterator |
| 702 | OSCAP_API void cpe_product_iterator_remove(struct cpe_product_iterator *it); |
| 703 | /// @memberof cpe_product_iterator |
| 704 | OSCAP_API void cpe_product_iterator_reset(struct cpe_product_iterator *it); |
| 705 | |
| 706 | /** |
| 707 | * @struct cpe_version_iterator |
| 708 | * Iterator over CPE dictionary item versions. |
| 709 | * @see oscap_iterator |
| 710 | */ |
| 711 | struct cpe_version_iterator; |
| 712 | |
| 713 | /** |
| 714 | * Iterator over CPE version items. |
| 715 | * @see oscap_iterator |
| 716 | * @memberof cpe_version_iterator |
| 717 | */ |
| 718 | OSCAP_API struct cpe_version *cpe_version_iterator_next(struct cpe_version_iterator *it); |
| 719 | |
| 720 | /** |
| 721 | * Iterator over CPE version items. |
| 722 | * @see oscap_iterator |
| 723 | * @memberof cpe_version_iterator |
| 724 | */ |
| 725 | OSCAP_API bool cpe_version_iterator_has_more(struct cpe_version_iterator *it); |
| 726 | |
| 727 | /** |
| 728 | * Iterator over CPE version items. |
| 729 | * @see oscap_iterator |
| 730 | * @memberof cpe_version_iterator |
| 731 | */ |
| 732 | OSCAP_API void cpe_version_iterator_free(struct cpe_version_iterator *it); |
| 733 | |
| 734 | /// @memberof cpe_version_iterator |
| 735 | OSCAP_API void cpe_version_iterator_remove(struct cpe_version_iterator *it); |
| 736 | /// @memberof cpe_version_iterator |
| 737 | OSCAP_API void cpe_version_iterator_reset(struct cpe_version_iterator *it); |
| 738 | |
| 739 | /** |
| 740 | * @struct cpe_update_iterator |
| 741 | * Iterator over CPE dictionary item updates. |
| 742 | * @see oscap_iterator |
| 743 | */ |
| 744 | struct cpe_update_iterator; |
| 745 | |
| 746 | /** |
| 747 | * Iterator over CPE update items. |
| 748 | * @see oscap_iterator |
| 749 | * @memberof cpe_update_iterator |
| 750 | */ |
| 751 | OSCAP_API struct cpe_update *cpe_update_iterator_next(struct cpe_update_iterator *it); |
| 752 | |
| 753 | /** |
| 754 | * Iterator over CPE update items. |
| 755 | * @see oscap_iterator |
| 756 | * @memberof cpe_update_iterator |
| 757 | */ |
| 758 | OSCAP_API bool cpe_update_iterator_has_more(struct cpe_update_iterator *it); |
| 759 | |
| 760 | /** |
| 761 | * Iterator over CPE update items. |
| 762 | * @see oscap_iterator |
| 763 | * @memberof cpe_update_iterator |
| 764 | */ |
| 765 | OSCAP_API void cpe_update_iterator_free(struct cpe_update_iterator *it); |
| 766 | |
| 767 | /// @memberof cpe_update_iterator |
| 768 | OSCAP_API void cpe_update_iterator_remove(struct cpe_update_iterator *it); |
| 769 | /// @memberof cpe_update_iterator |
| 770 | OSCAP_API void cpe_update_iterator_reset(struct cpe_update_iterator *it); |
| 771 | |
| 772 | /** |
| 773 | * @struct cpe_edition_iterator |
| 774 | * Iterator over CPE dictionary item editions. |
| 775 | * @see oscap_iterator |
| 776 | */ |
| 777 | struct cpe_edition_iterator; |
| 778 | |
| 779 | /** |
| 780 | * Iterator over CPE edition items. |
| 781 | * @see oscap_iterator |
| 782 | * @memberof cpe_edition_iterator |
| 783 | */ |
| 784 | OSCAP_API struct cpe_edition *cpe_edition_iterator_next(struct cpe_edition_iterator *it); |
| 785 | |
| 786 | /** |
| 787 | * Iterator over CPE edition items. |
| 788 | * @see oscap_iterator |
| 789 | * @memberof cpe_edition_iterator |
| 790 | */ |
| 791 | OSCAP_API bool cpe_edition_iterator_has_more(struct cpe_edition_iterator *it); |
| 792 | |
| 793 | /** |
| 794 | * Iterator over CPE edition items. |
| 795 | * @see oscap_iterator |
| 796 | * @memberof cpe_edition_iterator |
| 797 | */ |
| 798 | OSCAP_API void cpe_edition_iterator_free(struct cpe_edition_iterator *it); |
| 799 | |
| 800 | /// @memberof cpe_edition_iterator |
| 801 | OSCAP_API void cpe_edition_iterator_remove(struct cpe_edition_iterator *it); |
| 802 | /// @memberof cpe_edition_iterator |
| 803 | OSCAP_API void cpe_edition_iterator_reset(struct cpe_edition_iterator *it); |
| 804 | |
| 805 | /** |
| 806 | * @struct cpe_language_iterator |
| 807 | * Iterator over CPE dictionary item languages. |
| 808 | * @see oscap_iterator |
| 809 | */ |
| 810 | struct cpe_language_iterator; |
| 811 | |
| 812 | /** |
| 813 | * Iterator over CPE language items. |
| 814 | * @see oscap_iterator |
| 815 | * @memberof cpe_language_iterator |
| 816 | */ |
| 817 | OSCAP_API struct cpe_language *cpe_language_iterator_next(struct cpe_language_iterator *it); |
| 818 | |
| 819 | /** |
| 820 | * Iterator over CPE language items. |
| 821 | * @see oscap_iterator |
| 822 | * @memberof cpe_language_iterator |
| 823 | */ |
| 824 | OSCAP_API bool cpe_language_iterator_has_more(struct cpe_language_iterator *it); |
| 825 | |
| 826 | /** |
| 827 | * Iterator over CPE language items. |
| 828 | * @see oscap_iterator |
| 829 | * @memberof cpe_language_iterator |
| 830 | */ |
| 831 | OSCAP_API void cpe_language_iterator_free(struct cpe_language_iterator *it); |
| 832 | |
| 833 | /// @memberof cpe_language_iterator |
| 834 | OSCAP_API void cpe_language_iterator_remove(struct cpe_language_iterator *it); |
| 835 | /// @memberof cpe_language_iterator |
| 836 | OSCAP_API void cpe_language_iterator_reset(struct cpe_language_iterator *it); |
| 837 | |
| 838 | /************************************************************/ |
| 839 | /** @} End of Iterators group */ |
| 840 | |
| 841 | /************************************************************/ |
| 842 | /** |
| 843 | * @name Evaluators |
| 844 | * @{ |
| 845 | * */ |
| 846 | |
| 847 | /** |
| 848 | * Get the newest supported version of CPE dictionary XML |
| 849 | * @return version of XML file format |
| 850 | * @memberof cpe_dict_model |
| 851 | */ |
| 852 | OSCAP_API const char * cpe_dict_model_supported(void); |
| 853 | |
| 854 | /** |
| 855 | * Verify wether given CPE is known according to specified dictionary |
| 856 | * @memberof cpe_name |
| 857 | * @memberof cpe_dict_model |
| 858 | * @param cpe CPE to verify |
| 859 | * @param dict used CPE dictionary |
| 860 | * @return true if dictionary contains given CPE |
| 861 | */ |
| 862 | OSCAP_API bool cpe_name_match_dict(struct cpe_name *cpe, struct cpe_dict_model *dict); |
| 863 | |
| 864 | /** |
| 865 | * Verify whether given CPE is applicable to current platform by evaluating checks associated with it |
| 866 | * |
| 867 | * @memberof cpe_name |
| 868 | * @memberof cpe_dict_model |
| 869 | * @param cpe CPE to verify |
| 870 | * @param dict used CPE dictionary |
| 871 | * @return true if dictionary contains given CPE and the CPE is applicable |
| 872 | */ |
| 873 | OSCAP_API bool cpe_name_applicable_dict(struct cpe_name *cpe, struct cpe_dict_model *dict, cpe_check_fn cb, void* usr); |
| 874 | |
| 875 | /// @memberof cpe_item |
| 876 | OSCAP_API bool cpe_item_is_applicable(struct cpe_item* item, cpe_check_fn cb, void* usr); |
| 877 | |
| 878 | /************************************************************/ |
| 879 | /** @} End of Evaluators group */ |
| 880 | |
| 881 | /** |
| 882 | * Write the dict_model to a file. |
| 883 | * @param dict CPE Dict model |
| 884 | * @memberof cpe_dict_model |
| 885 | */ |
| 886 | OSCAP_API void cpe_dict_model_export(const struct cpe_dict_model *dict, const char *file); |
| 887 | |
| 888 | /** |
| 889 | * Load new CPE dictionary from an oscap_source |
| 890 | * @memberof cpe_dict_model |
| 891 | * @param source The oscap_source to parse content from |
| 892 | * @returns new dictionary or NULL |
| 893 | */ |
| 894 | OSCAP_API struct cpe_dict_model *cpe_dict_model_import_source(struct oscap_source *source); |
| 895 | |
| 896 | |
| 897 | /** @} */ |
| 898 | |
| 899 | /** @} */ |
| 900 | |
| 901 | #endif /* _CPEDICT_H_ */ |