cpe_dict.h
Go to the documentation of this file.
/*
* Copyright 2009--2013 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors:
* Maros Barabas <mbarabas@redhat.com>
* Lukas Kuklinek <lkuklinek@redhat.com>
* Šimon Lukašík
*/
#ifndef CPEDICT_H_
#define CPEDICT_H_
#include "oscap.h"
#include "cpe_name.h"
#include "oscap_text.h"
struct cpe_dict_model;
struct cpe_item;
struct cpe_vendor;
struct cpe_generator;
struct cpe_check;
struct cpe_reference;
struct cpe_item_metadata;
struct cpe_product;
struct cpe_version;
struct cpe_update;
struct cpe_edition;
struct cpe_language;
/************************************************************/
const char *cpe_item_metadata_get_modification_date(const struct cpe_item_metadata *item);
const char *cpe_item_metadata_get_status(const struct cpe_item_metadata *item);
const char *cpe_item_metadata_get_nvd_id(const struct cpe_item_metadata *item);
const char *cpe_item_metadata_get_deprecated_by_nvd_id(const struct cpe_item_metadata *item);
const char *cpe_check_get_system(const struct cpe_check *item);
const char *cpe_check_get_href(const struct cpe_check *item);
const char *cpe_check_get_identifier(const struct cpe_check *item);
const char *cpe_reference_get_href(const struct cpe_reference *item);
const char *cpe_reference_get_content(const struct cpe_reference *item);
struct cpe_name *cpe_item_get_name(const struct cpe_item *item);
struct cpe_name *cpe_item_get_deprecated_by(const struct cpe_item *item);
OSCAP_DEPRECATED(struct cpe_name *cpe_item_get_deprecated(const struct cpe_item *item));
const char *cpe_item_get_deprecation_date(const struct cpe_item *item);
struct cpe_item_metadata *cpe_item_get_metadata(const struct cpe_item *item);
struct cpe_reference_iterator *cpe_item_get_references(const struct cpe_item *item);
struct cpe_check_iterator *cpe_item_get_checks(const struct cpe_item *item);
struct oscap_text_iterator *cpe_item_get_titles(const struct cpe_item *item);
OSCAP_DEPRECATED(struct oscap_text_iterator *cpe_item_get_notes(const struct cpe_item *item));
const char *cpe_generator_get_product_name(const struct cpe_generator *item);
const char *cpe_generator_get_product_version(const struct cpe_generator *item);
const char *cpe_generator_get_schema_version(const struct cpe_generator *item);
const char *cpe_generator_get_timestamp(const struct cpe_generator *item);
int cpe_dict_model_get_base_version(const struct cpe_dict_model *item);
bool cpe_dict_model_set_base_version(struct cpe_dict_model *item, int base_version);
struct cpe_generator *cpe_dict_model_get_generator(const struct cpe_dict_model *item);
struct cpe_item_iterator *cpe_dict_model_get_items(const struct cpe_dict_model *item);
struct cpe_vendor_iterator *cpe_dict_model_get_vendors(const struct cpe_dict_model *item);
const char *cpe_vendor_get_value(const struct cpe_vendor *item);
struct oscap_text_iterator *cpe_vendor_get_titles(const struct cpe_vendor *item);
struct cpe_product_iterator *cpe_vendor_get_products(const struct cpe_vendor *item);
const char *cpe_product_get_value(const struct cpe_product *item);
cpe_part_t cpe_product_get_part(const struct cpe_product *item);
struct cpe_version_iterator *cpe_product_get_versions(const struct cpe_product *item);
const char *cpe_version_get_value(const struct cpe_version *item);
struct cpe_update_iterator *cpe_version_get_updates(const struct cpe_version *item);
const char *cpe_update_get_value(const struct cpe_update *item);
struct cpe_edition_iterator *cpe_update_get_editions(const struct cpe_update *item);
const char *cpe_edition_get_value(const struct cpe_edition *item);
struct cpe_language_iterator *cpe_edition_get_languages(const struct cpe_edition *item);
const char *cpe_language_get_value(const struct cpe_language *item);
/************************************************************/
void cpe_check_free(struct cpe_check *check);
void cpe_reference_free(struct cpe_reference *ref);
void cpe_vendor_free(struct cpe_vendor *vendor);
void cpe_product_free(struct cpe_product *product);
void cpe_version_free(struct cpe_version *version);
void cpe_update_free(struct cpe_update *update);
void cpe_edition_free(struct cpe_edition *edition);
void cpe_language_free(struct cpe_language *language);
void cpe_itemmetadata_free(struct cpe_item_metadata *meta);
void cpe_dict_model_free(struct cpe_dict_model *dict);
void cpe_generator_free(struct cpe_generator *generator);
void cpe_item_free(struct cpe_item *item);
struct cpe_dict_model *cpe_dict_model_new(void);
struct cpe_generator *cpe_generator_new(void);
struct cpe_check *cpe_check_new(void);
struct cpe_reference *cpe_reference_new(void);
struct cpe_item *cpe_item_new(void);
struct cpe_vendor *cpe_vendor_new(void);
struct cpe_product *cpe_product_new(void);
struct cpe_version *cpe_version_new(void);
struct cpe_update *cpe_update_new(void);
struct cpe_edition *cpe_edition_new(void);
struct cpe_language *cpe_language_new(void);
struct cpe_item_metadata *cpe_item_metadata_new(void);
/************************************************************/
bool cpe_item_set_deprecation_date(struct cpe_item *item, const char *new_deprecation_date);
bool cpe_item_metadata_set_modification_date(struct cpe_item_metadata *item_metadata,
const char *new_modification_date);
bool cpe_item_metadata_set_status(struct cpe_item_metadata *item_metadata, const char *new_status);
bool cpe_item_metadata_set_nvd_id(struct cpe_item_metadata *item_metadata, const char *new_nvd_id);
bool cpe_item_metadata_set_deprecated_by_nvd_id(struct cpe_item_metadata *item_metadata,
const char *new_deprecated_by_nvd_id);
bool cpe_check_set_system(struct cpe_check *check, const char *new_system);
bool cpe_check_set_href(struct cpe_check *check, const char *new_href);
bool cpe_check_set_identifier(struct cpe_check *check, const char *new_identifier);
bool cpe_reference_set_href(struct cpe_reference *reference, const char *new_href);
bool cpe_reference_set_content(struct cpe_reference *reference, const char *new_content);
bool cpe_generator_set_product_name(struct cpe_generator *generator, const char *new_product_name);
bool cpe_generator_set_product_version(struct cpe_generator *generator, const char *new_product_version);
bool cpe_generator_set_schema_version(struct cpe_generator *generator, const char *new_schema_version);
bool cpe_generator_set_timestamp(struct cpe_generator *generator, const char *new_timestamp);
bool cpe_vendor_set_value(struct cpe_vendor *vendor, const char *new_value);
bool cpe_product_set_value(struct cpe_product *product, const char *new_value);
bool cpe_product_set_part(struct cpe_product *product, cpe_part_t new_part);
bool cpe_version_set_value(struct cpe_version *version, const char *new_value);
bool cpe_update_set_value(struct cpe_update *update, const char *new_value);
bool cpe_edition_set_value(struct cpe_edition *edition, const char *new_value);
bool cpe_language_set_value(struct cpe_language *language, const char *new_value);
/*
* Add functions
*/
bool cpe_item_add_reference(struct cpe_item *item, struct cpe_reference *new_reference);
bool cpe_item_add_check(struct cpe_item *item, struct cpe_check *new_check);
bool cpe_item_add_title(struct cpe_item *item, struct oscap_text *new_title);
OSCAP_DEPRECATED(bool cpe_item_add_note(struct cpe_item *item, struct oscap_text *new_title));
bool cpe_dict_model_add_vendor(struct cpe_dict_model *dict, struct cpe_vendor *new_vendor);
bool cpe_vendor_add_title(struct cpe_vendor *vendor, struct oscap_text *new_title);
bool cpe_vendor_add_product(struct cpe_vendor *vendor, struct cpe_product *new_product);
bool cpe_product_add_version(struct cpe_product *product, struct cpe_version *new_version);
bool cpe_version_add_update(struct cpe_version *version, struct cpe_update *new_update);
bool cpe_update_add_edition(struct cpe_update *update, struct cpe_edition *new_edition);
bool cpe_edition_add_language(struct cpe_edition *edition, struct cpe_language *new_language);
/************************************************************/
/************************************************************/
struct cpe_item_iterator;
struct cpe_item *cpe_item_iterator_next(struct cpe_item_iterator *it);
bool cpe_item_iterator_has_more(struct cpe_item_iterator *it);
void cpe_item_iterator_free(struct cpe_item_iterator *it);
void cpe_item_iterator_remove(struct cpe_item_iterator *it);
void cpe_item_iterator_reset(struct cpe_item_iterator *it);
struct cpe_reference_iterator;
struct cpe_reference *cpe_reference_iterator_next(struct cpe_reference_iterator *it);
bool cpe_reference_iterator_has_more(struct cpe_reference_iterator *it);
void cpe_reference_iterator_free(struct cpe_reference_iterator *it);
void cpe_reference_iterator_remove(struct cpe_reference_iterator *it);
void cpe_reference_iterator_reset(struct cpe_reference_iterator *it);
struct cpe_check_iterator;
struct cpe_check *cpe_check_iterator_next(struct cpe_check_iterator *it);
bool cpe_check_iterator_has_more(struct cpe_check_iterator *it);
void cpe_check_iterator_free(struct cpe_check_iterator *it);
void cpe_check_iterator_remove(struct cpe_check_iterator *it);
void cpe_check_iterator_reset(struct cpe_check_iterator *it);
struct cpe_vendor_iterator;
struct cpe_vendor *cpe_vendor_iterator_next(struct cpe_vendor_iterator *it);
bool cpe_vendor_iterator_has_more(struct cpe_vendor_iterator *it);
void cpe_vendor_iterator_free(struct cpe_vendor_iterator *it);
void cpe_vendor_iterator_remove(struct cpe_vendor_iterator *it);
void cpe_vendor_iterator_reset(struct cpe_vendor_iterator *it);
struct cpe_product_iterator;
struct cpe_product *cpe_product_iterator_next(struct cpe_product_iterator *it);
bool cpe_product_iterator_has_more(struct cpe_product_iterator *it);
void cpe_product_iterator_free(struct cpe_product_iterator *it);
void cpe_product_iterator_remove(struct cpe_product_iterator *it);
void cpe_product_iterator_reset(struct cpe_product_iterator *it);
struct cpe_version_iterator;
struct cpe_version *cpe_version_iterator_next(struct cpe_version_iterator *it);
bool cpe_version_iterator_has_more(struct cpe_version_iterator *it);
void cpe_version_iterator_free(struct cpe_version_iterator *it);
void cpe_version_iterator_remove(struct cpe_version_iterator *it);
void cpe_version_iterator_reset(struct cpe_version_iterator *it);
struct cpe_update_iterator;
struct cpe_update *cpe_update_iterator_next(struct cpe_update_iterator *it);
bool cpe_update_iterator_has_more(struct cpe_update_iterator *it);
void cpe_update_iterator_free(struct cpe_update_iterator *it);
void cpe_update_iterator_remove(struct cpe_update_iterator *it);
void cpe_update_iterator_reset(struct cpe_update_iterator *it);
struct cpe_edition_iterator;
struct cpe_edition *cpe_edition_iterator_next(struct cpe_edition_iterator *it);
bool cpe_edition_iterator_has_more(struct cpe_edition_iterator *it);
void cpe_edition_iterator_free(struct cpe_edition_iterator *it);
void cpe_edition_iterator_remove(struct cpe_edition_iterator *it);
void cpe_edition_iterator_reset(struct cpe_edition_iterator *it);
struct cpe_language_iterator;
struct cpe_language *cpe_language_iterator_next(struct cpe_language_iterator *it);
bool cpe_language_iterator_has_more(struct cpe_language_iterator *it);
void cpe_language_iterator_free(struct cpe_language_iterator *it);
void cpe_language_iterator_remove(struct cpe_language_iterator *it);
void cpe_language_iterator_reset(struct cpe_language_iterator *it);
/************************************************************/
/************************************************************/
const char * cpe_dict_model_supported(void);
char * cpe_dict_detect_version(const char* file);
bool cpe_name_match_dict(struct cpe_name *cpe, struct cpe_dict_model *dict);
bool cpe_name_match_dict_str(const char *cpe, struct cpe_dict_model *dict);
bool cpe_name_applicable_dict(struct cpe_name *cpe, struct cpe_dict_model *dict, cpe_check_fn cb, void* usr);
bool cpe_item_is_applicable(struct cpe_item* item, cpe_check_fn cb, void* usr);
/************************************************************/
void cpe_dict_model_export(const struct cpe_dict_model *dict, const char *file);
struct cpe_dict_model *cpe_dict_model_import(const char *file);
bool cpe_dict_model_set_origin_file(struct cpe_dict_model* dict, const char* origin_file);
const char* cpe_dict_model_get_origin_file(const struct cpe_dict_model* dict);
#endif /* _CPEDICT_H_ */