|
Open SCAP Library
|
00001 00013 /* 00014 * Copyright 2009--2014 Red Hat Inc., Durham, North Carolina. 00015 * All Rights Reserved. 00016 * 00017 * This library is free software; you can redistribute it and/or 00018 * modify it under the terms of the GNU Lesser General Public 00019 * License as published by the Free Software Foundation; either 00020 * version 2.1 of the License, or (at your option) any later version. 00021 * 00022 * This library is distributed in the hope that it will be useful, 00023 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00025 * Lesser General Public License for more details. 00026 * 00027 * You should have received a copy of the GNU Lesser General Public 00028 * License along with this library; if not, write to the Free Software 00029 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00030 * 00031 * Authors: 00032 * Maros Barabas <mbarabas@redhat.com> 00033 * Lukas Kuklinek <lkuklinek@redhat.com> 00034 * Šimon Lukašík 00035 */ 00036 00037 #ifndef CPEDICT_H_ 00038 #define CPEDICT_H_ 00039 00040 #include "oscap.h" 00041 #include "cpe_name.h" 00042 #include "oscap_text.h" 00043 #include "oscap_source.h" 00044 00049 struct cpe_dict_model; 00050 00055 struct cpe_item; 00056 00061 struct cpe_vendor; 00062 00067 struct cpe_generator; 00068 00073 struct cpe_check; 00074 00079 struct cpe_reference; 00080 00085 struct cpe_item_metadata; 00086 00091 struct cpe_product; 00096 struct cpe_version; 00101 struct cpe_update; 00106 struct cpe_edition; 00111 struct cpe_language; 00112 00113 /************************************************************/ 00125 const char *cpe_item_metadata_get_modification_date(const struct cpe_item_metadata *item); 00126 00131 const char *cpe_item_metadata_get_status(const struct cpe_item_metadata *item); 00132 00137 const char *cpe_item_metadata_get_nvd_id(const struct cpe_item_metadata *item); 00138 00143 const char *cpe_item_metadata_get_deprecated_by_nvd_id(const struct cpe_item_metadata *item); 00144 00149 const char *cpe_check_get_system(const struct cpe_check *item); 00150 00155 const char *cpe_check_get_href(const struct cpe_check *item); 00156 00161 const char *cpe_check_get_identifier(const struct cpe_check *item); 00162 00167 const char *cpe_reference_get_href(const struct cpe_reference *item); 00168 00173 const char *cpe_reference_get_content(const struct cpe_reference *item); 00174 00179 struct cpe_name *cpe_item_get_name(const struct cpe_item *item); 00180 00185 struct cpe_name *cpe_item_get_deprecated_by(const struct cpe_item *item); 00186 00194 OSCAP_DEPRECATED(struct cpe_name *cpe_item_get_deprecated(const struct cpe_item *item)); 00195 00200 const char *cpe_item_get_deprecation_date(const struct cpe_item *item); 00201 00206 struct cpe_item_metadata *cpe_item_get_metadata(const struct cpe_item *item); 00207 00212 struct cpe_reference_iterator *cpe_item_get_references(const struct cpe_item *item); 00213 00218 struct cpe_check_iterator *cpe_item_get_checks(const struct cpe_item *item); 00219 00224 struct oscap_text_iterator *cpe_item_get_titles(const struct cpe_item *item); 00225 00232 OSCAP_DEPRECATED(struct oscap_text_iterator *cpe_item_get_notes(const struct cpe_item *item)); 00233 00238 const char *cpe_generator_get_product_name(const struct cpe_generator *item); 00239 00244 const char *cpe_generator_get_product_version(const struct cpe_generator *item); 00245 00250 const char *cpe_generator_get_schema_version(const struct cpe_generator *item); 00251 00256 const char *cpe_generator_get_timestamp(const struct cpe_generator *item); 00257 00269 int cpe_dict_model_get_base_version(const struct cpe_dict_model *item); 00270 00275 bool cpe_dict_model_set_base_version(struct cpe_dict_model *item, int base_version); 00276 00282 struct cpe_generator *cpe_dict_model_get_generator(const struct cpe_dict_model *item); 00283 00288 struct cpe_item_iterator *cpe_dict_model_get_items(const struct cpe_dict_model *item); 00289 00294 struct cpe_vendor_iterator *cpe_dict_model_get_vendors(const struct cpe_dict_model *item); 00295 00300 const char *cpe_vendor_get_value(const struct cpe_vendor *item); 00301 00306 struct oscap_text_iterator *cpe_vendor_get_titles(const struct cpe_vendor *item); 00307 00312 struct cpe_product_iterator *cpe_vendor_get_products(const struct cpe_vendor *item); 00313 00318 const char *cpe_product_get_value(const struct cpe_product *item); 00319 00324 cpe_part_t cpe_product_get_part(const struct cpe_product *item); 00325 00331 struct cpe_version_iterator *cpe_product_get_versions(const struct cpe_product *item); 00332 00337 const char *cpe_version_get_value(const struct cpe_version *item); 00338 00344 struct cpe_update_iterator *cpe_version_get_updates(const struct cpe_version *item); 00345 00350 const char *cpe_update_get_value(const struct cpe_update *item); 00351 00357 struct cpe_edition_iterator *cpe_update_get_editions(const struct cpe_update *item); 00358 00363 const char *cpe_edition_get_value(const struct cpe_edition *item); 00364 00370 struct cpe_language_iterator *cpe_edition_get_languages(const struct cpe_edition *item); 00371 00376 const char *cpe_language_get_value(const struct cpe_language *item); 00377 00378 /************************************************************/ 00381 00382 void cpe_check_free(struct cpe_check *check); 00384 void cpe_reference_free(struct cpe_reference *ref); 00386 void cpe_vendor_free(struct cpe_vendor *vendor); 00388 void cpe_product_free(struct cpe_product *product); 00390 void cpe_version_free(struct cpe_version *version); 00392 void cpe_update_free(struct cpe_update *update); 00394 void cpe_edition_free(struct cpe_edition *edition); 00396 void cpe_language_free(struct cpe_language *language); 00398 void cpe_itemmetadata_free(struct cpe_item_metadata *meta); 00400 void cpe_dict_model_free(struct cpe_dict_model *dict); 00402 void cpe_generator_free(struct cpe_generator *generator); 00404 void cpe_item_free(struct cpe_item *item); 00405 00407 struct cpe_dict_model *cpe_dict_model_new(void); 00409 struct cpe_generator *cpe_generator_new(void); 00411 struct cpe_check *cpe_check_new(void); 00413 struct cpe_reference *cpe_reference_new(void); 00415 struct cpe_item *cpe_item_new(void); 00417 struct cpe_vendor *cpe_vendor_new(void); 00419 struct cpe_product *cpe_product_new(void); 00421 struct cpe_version *cpe_version_new(void); 00423 struct cpe_update *cpe_update_new(void); 00425 struct cpe_edition *cpe_edition_new(void); 00427 struct cpe_language *cpe_language_new(void); 00429 struct cpe_item_metadata *cpe_item_metadata_new(void); 00430 00431 /************************************************************/ 00439 00440 bool cpe_item_set_name(struct cpe_item *item, const struct cpe_name *new_name); 00441 00443 bool cpe_item_set_deprecated_by(struct cpe_item *item, const struct cpe_name *new_deprecated_by); 00444 00446 bool cpe_item_set_deprecation_date(struct cpe_item *item, const char *new_deprecation_date); 00447 00449 bool cpe_item_metadata_set_modification_date(struct cpe_item_metadata *item_metadata, 00450 const char *new_modification_date); 00451 00453 bool cpe_item_metadata_set_status(struct cpe_item_metadata *item_metadata, const char *new_status); 00454 00456 bool cpe_item_metadata_set_nvd_id(struct cpe_item_metadata *item_metadata, const char *new_nvd_id); 00457 00459 bool cpe_item_metadata_set_deprecated_by_nvd_id(struct cpe_item_metadata *item_metadata, 00460 const char *new_deprecated_by_nvd_id); 00461 00463 bool cpe_check_set_system(struct cpe_check *check, const char *new_system); 00464 00466 bool cpe_check_set_href(struct cpe_check *check, const char *new_href); 00467 00469 bool cpe_check_set_identifier(struct cpe_check *check, const char *new_identifier); 00470 00472 bool cpe_reference_set_href(struct cpe_reference *reference, const char *new_href); 00473 00475 bool cpe_reference_set_content(struct cpe_reference *reference, const char *new_content); 00476 00478 bool cpe_generator_set_product_name(struct cpe_generator *generator, const char *new_product_name); 00479 00481 bool cpe_generator_set_product_version(struct cpe_generator *generator, const char *new_product_version); 00482 00484 bool cpe_generator_set_schema_version(struct cpe_generator *generator, const char *new_schema_version); 00485 00487 bool cpe_generator_set_timestamp(struct cpe_generator *generator, const char *new_timestamp); 00488 00490 bool cpe_vendor_set_value(struct cpe_vendor *vendor, const char *new_value); 00491 00493 bool cpe_product_set_value(struct cpe_product *product, const char *new_value); 00494 00496 bool cpe_product_set_part(struct cpe_product *product, cpe_part_t new_part); 00497 00499 bool cpe_version_set_value(struct cpe_version *version, const char *new_value); 00500 00502 bool cpe_update_set_value(struct cpe_update *update, const char *new_value); 00503 00505 bool cpe_edition_set_value(struct cpe_edition *edition, const char *new_value); 00506 00508 bool cpe_language_set_value(struct cpe_language *language, const char *new_value); 00509 00510 /* 00511 * Add functions 00512 */ 00513 00515 bool cpe_item_add_reference(struct cpe_item *item, struct cpe_reference *new_reference); 00516 00518 bool cpe_item_add_check(struct cpe_item *item, struct cpe_check *new_check); 00519 00521 bool cpe_item_add_title(struct cpe_item *item, struct oscap_text *new_title); 00522 00528 OSCAP_DEPRECATED(bool cpe_item_add_note(struct cpe_item *item, struct oscap_text *new_title)); 00529 00531 bool cpe_dict_model_add_item(struct cpe_dict_model *dict, struct cpe_item *new_item); 00532 00534 bool cpe_dict_model_add_vendor(struct cpe_dict_model *dict, struct cpe_vendor *new_vendor); 00535 00537 bool cpe_vendor_add_title(struct cpe_vendor *vendor, struct oscap_text *new_title); 00538 00540 bool cpe_vendor_add_product(struct cpe_vendor *vendor, struct cpe_product *new_product); 00541 00543 bool cpe_product_add_version(struct cpe_product *product, struct cpe_version *new_version); 00544 00546 bool cpe_version_add_update(struct cpe_version *version, struct cpe_update *new_update); 00547 00549 bool cpe_update_add_edition(struct cpe_update *update, struct cpe_edition *new_edition); 00550 00552 bool cpe_edition_add_language(struct cpe_edition *edition, struct cpe_language *new_language); 00553 00554 00555 /************************************************************/ 00558 /************************************************************/ 00569 struct cpe_item_iterator; 00570 00576 struct cpe_item *cpe_item_iterator_next(struct cpe_item_iterator *it); 00577 00583 bool cpe_item_iterator_has_more(struct cpe_item_iterator *it); 00584 00590 void cpe_item_iterator_free(struct cpe_item_iterator *it); 00591 00593 void cpe_item_iterator_remove(struct cpe_item_iterator *it); 00595 void cpe_item_iterator_reset(struct cpe_item_iterator *it); 00596 00602 struct cpe_reference_iterator; 00603 00609 struct cpe_reference *cpe_reference_iterator_next(struct cpe_reference_iterator *it); 00610 00616 bool cpe_reference_iterator_has_more(struct cpe_reference_iterator *it); 00617 00623 void cpe_reference_iterator_free(struct cpe_reference_iterator *it); 00624 00626 void cpe_reference_iterator_remove(struct cpe_reference_iterator *it); 00628 void cpe_reference_iterator_reset(struct cpe_reference_iterator *it); 00629 00635 struct cpe_check_iterator; 00636 00642 struct cpe_check *cpe_check_iterator_next(struct cpe_check_iterator *it); 00643 00649 bool cpe_check_iterator_has_more(struct cpe_check_iterator *it); 00650 00656 void cpe_check_iterator_free(struct cpe_check_iterator *it); 00657 00659 void cpe_check_iterator_remove(struct cpe_check_iterator *it); 00661 void cpe_check_iterator_reset(struct cpe_check_iterator *it); 00662 00668 struct cpe_vendor_iterator; 00669 00675 struct cpe_vendor *cpe_vendor_iterator_next(struct cpe_vendor_iterator *it); 00676 00682 bool cpe_vendor_iterator_has_more(struct cpe_vendor_iterator *it); 00683 00689 void cpe_vendor_iterator_free(struct cpe_vendor_iterator *it); 00690 00692 void cpe_vendor_iterator_remove(struct cpe_vendor_iterator *it); 00694 void cpe_vendor_iterator_reset(struct cpe_vendor_iterator *it); 00695 00701 struct cpe_product_iterator; 00702 00708 struct cpe_product *cpe_product_iterator_next(struct cpe_product_iterator *it); 00709 00715 bool cpe_product_iterator_has_more(struct cpe_product_iterator *it); 00716 00722 void cpe_product_iterator_free(struct cpe_product_iterator *it); 00723 00725 void cpe_product_iterator_remove(struct cpe_product_iterator *it); 00727 void cpe_product_iterator_reset(struct cpe_product_iterator *it); 00728 00734 struct cpe_version_iterator; 00735 00741 struct cpe_version *cpe_version_iterator_next(struct cpe_version_iterator *it); 00742 00748 bool cpe_version_iterator_has_more(struct cpe_version_iterator *it); 00749 00755 void cpe_version_iterator_free(struct cpe_version_iterator *it); 00756 00758 void cpe_version_iterator_remove(struct cpe_version_iterator *it); 00760 void cpe_version_iterator_reset(struct cpe_version_iterator *it); 00761 00767 struct cpe_update_iterator; 00768 00774 struct cpe_update *cpe_update_iterator_next(struct cpe_update_iterator *it); 00775 00781 bool cpe_update_iterator_has_more(struct cpe_update_iterator *it); 00782 00788 void cpe_update_iterator_free(struct cpe_update_iterator *it); 00789 00791 void cpe_update_iterator_remove(struct cpe_update_iterator *it); 00793 void cpe_update_iterator_reset(struct cpe_update_iterator *it); 00794 00800 struct cpe_edition_iterator; 00801 00807 struct cpe_edition *cpe_edition_iterator_next(struct cpe_edition_iterator *it); 00808 00814 bool cpe_edition_iterator_has_more(struct cpe_edition_iterator *it); 00815 00821 void cpe_edition_iterator_free(struct cpe_edition_iterator *it); 00822 00824 void cpe_edition_iterator_remove(struct cpe_edition_iterator *it); 00826 void cpe_edition_iterator_reset(struct cpe_edition_iterator *it); 00827 00833 struct cpe_language_iterator; 00834 00840 struct cpe_language *cpe_language_iterator_next(struct cpe_language_iterator *it); 00841 00847 bool cpe_language_iterator_has_more(struct cpe_language_iterator *it); 00848 00854 void cpe_language_iterator_free(struct cpe_language_iterator *it); 00855 00857 void cpe_language_iterator_remove(struct cpe_language_iterator *it); 00859 void cpe_language_iterator_reset(struct cpe_language_iterator *it); 00860 00861 /************************************************************/ 00864 /************************************************************/ 00875 const char * cpe_dict_model_supported(void); 00876 00884 OSCAP_DEPRECATED(char *cpe_dict_detect_version(const char* file)); 00885 00894 bool cpe_name_match_dict(struct cpe_name *cpe, struct cpe_dict_model *dict); 00895 00904 bool cpe_name_match_dict_str(const char *cpe, struct cpe_dict_model *dict); 00905 00915 bool cpe_name_applicable_dict(struct cpe_name *cpe, struct cpe_dict_model *dict, cpe_check_fn cb, void* usr); 00916 00918 bool cpe_item_is_applicable(struct cpe_item* item, cpe_check_fn cb, void* usr); 00919 00920 /************************************************************/ 00928 void cpe_dict_model_export(const struct cpe_dict_model *dict, const char *file); 00929 00939 OSCAP_DEPRECATED(struct cpe_dict_model *cpe_dict_model_import(const char *file)); 00940 00947 struct cpe_dict_model *cpe_dict_model_import_source(struct oscap_source *source); 00948 00949 00955 bool cpe_dict_model_set_origin_file(struct cpe_dict_model* dict, const char* origin_file); 00956 00964 const char* cpe_dict_model_get_origin_file(const struct cpe_dict_model* dict); 00965 00970 #endif /* _CPEDICT_H_ */
1.7.3