Open SCAP Library
cpedict.h
Go to the documentation of this file.
1 
13 /*
14  * Copyright 2009 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  *
31  * Authors:
32  * Maros Barabas <mbarabas@redhat.com>
33  * Lukas Kuklinek <lkuklinek@redhat.com>
34  */
35 
36 #ifndef CPEDICT_H_
37 #define CPEDICT_H_
38 
39 #include "cpeuri.h"
40 #include "oscap.h"
41 
46 struct cpe_dict_model;
47 
52 struct cpe_item;
53 
58 struct cpe_vendor;
59 
64 struct cpe_generator;
65 
70 struct cpe_check;
71 
76 struct cpe_reference;
77 
82 struct cpe_item_metadata;
83 
88 struct cpe_product;
93 struct cpe_version;
98 struct cpe_update;
103 struct cpe_edition;
108 struct cpe_language;
109 
110 /************************************************************/
122 const char *cpe_item_metadata_get_modification_date(const struct cpe_item_metadata *item);
123 
128 const char *cpe_item_metadata_get_status(const struct cpe_item_metadata *item);
129 
134 const char *cpe_item_metadata_get_nvd_id(const struct cpe_item_metadata *item);
135 
140 const char *cpe_item_metadata_get_deprecated_by_nvd_id(const struct cpe_item_metadata *item);
141 
146 const char *cpe_check_get_system(const struct cpe_check *item);
147 
152 const char *cpe_check_get_href(const struct cpe_check *item);
153 
158 const char *cpe_check_get_identifier(const struct cpe_check *item);
159 
164 const char *cpe_reference_get_href(const struct cpe_reference *item);
165 
170 const char *cpe_reference_get_content(const struct cpe_reference *item);
171 
176 struct cpe_name *cpe_item_get_name(const struct cpe_item *item);
177 
182 struct cpe_name *cpe_item_get_deprecated(const struct cpe_item *item);
183 
188 const char *cpe_item_get_deprecation_date(const struct cpe_item *item);
189 
194 struct cpe_item_metadata *cpe_item_get_metadata(const struct cpe_item *item);
195 
200 struct cpe_reference_iterator *cpe_item_get_references(const struct cpe_item *item);
201 
206 struct cpe_check_iterator *cpe_item_get_checks(const struct cpe_item *item);
207 
212 struct oscap_text_iterator *cpe_item_get_titles(const struct cpe_item *item);
213 
218 struct oscap_text_iterator *cpe_item_get_notes(const struct cpe_item *item);
219 
224 const char *cpe_generator_get_product_name(const struct cpe_generator *item);
225 
230 const char *cpe_generator_get_product_version(const struct cpe_generator *item);
231 
236 const char *cpe_generator_get_schema_version(const struct cpe_generator *item);
237 
242 const char *cpe_generator_get_timestamp(const struct cpe_generator *item);
243 
249 struct cpe_generator *cpe_dict_model_get_generator(const struct cpe_dict_model *item);
250 
255 struct cpe_item_iterator *cpe_dict_model_get_items(const struct cpe_dict_model *item);
256 
262 
267 const char *cpe_vendor_get_value(const struct cpe_vendor *item);
268 
273 struct oscap_text_iterator *cpe_vendor_get_titles(const struct cpe_vendor *item);
274 
279 struct cpe_product_iterator *cpe_vendor_get_products(const struct cpe_vendor *item);
280 
285 const char *cpe_product_get_value(const struct cpe_product *item);
286 
291 cpe_part_t cpe_product_get_part(const struct cpe_product *item);
292 
298 struct cpe_version_iterator *cpe_product_get_versions(const struct cpe_product *item);
299 
304 const char *cpe_version_get_value(const struct cpe_version *item);
305 
311 struct cpe_update_iterator *cpe_version_get_updates(const struct cpe_version *items);
312 
317 const char *cpe_update_get_value(const struct cpe_update *item);
318 
324 struct cpe_edition_iterator *cpe_update_get_editions(const struct cpe_update *items);
325 
330 const char *cpe_edition_get_value(const struct cpe_edition *item);
331 
337 struct cpe_language_iterator *cpe_edition_get_languages(const struct cpe_edition *items);
338 
343 const char *cpe_language_get_value(const struct cpe_language *item);
344 
345 /************************************************************/
348 
349 void cpe_check_free(struct cpe_check *check);
351 void cpe_reference_free(struct cpe_reference *ref);
353 void cpe_vendor_free(struct cpe_vendor *vendor);
355 void cpe_product_free(struct cpe_product *product);
357 void cpe_version_free(struct cpe_version *version);
359 void cpe_update_free(struct cpe_update *update);
361 void cpe_edition_free(struct cpe_edition *edition);
363 void cpe_language_free(struct cpe_language *language);
365 void cpe_itemmetadata_free(struct cpe_item_metadata *meta);
367 void cpe_dict_model_free(struct cpe_dict_model *dict);
369 void cpe_generator_free(struct cpe_generator *generator);
371 void cpe_item_free(struct cpe_item *item);
372 
374 struct cpe_dict_model *cpe_dict_model_new(void);
376 struct cpe_generator *cpe_generator_new(void);
378 struct cpe_check *cpe_check_new(void);
380 struct cpe_reference *cpe_reference_new(void);
382 struct cpe_item *cpe_item_new(void);
384 struct cpe_vendor *cpe_vendor_new(void);
386 struct cpe_product *cpe_product_new(void);
388 struct cpe_version *cpe_version_new(void);
390 struct cpe_update *cpe_update_new(void);
392 struct cpe_edition *cpe_edition_new(void);
394 struct cpe_language *cpe_language_new(void);
397 
398 /************************************************************/
406 
407 bool cpe_item_set_deprecation_date(struct cpe_item *item, const char *new_deprecation_date);
408 
411  const char *new_modification_date);
412 
414 bool cpe_item_metadata_set_status(struct cpe_item_metadata *item_metadata, const char *new_status);
415 
417 bool cpe_item_metadata_set_nvd_id(struct cpe_item_metadata *item_metadata, const char *new_nvd_id);
418 
421  const char *new_deprecated_by_nvd_id);
422 
424 bool cpe_check_set_system(struct cpe_check *check, const char *new_system);
425 
427 bool cpe_check_set_href(struct cpe_check *check, const char *new_href);
428 
430 bool cpe_check_set_identifier(struct cpe_check *check, const char *new_identifier);
431 
433 bool cpe_reference_set_href(struct cpe_reference *reference, const char *new_href);
434 
436 bool cpe_reference_set_content(struct cpe_reference *reference, const char *new_content);
437 
439 bool cpe_generator_set_product_name(struct cpe_generator *generator, const char *new_product_name);
440 
442 bool cpe_generator_set_product_version(struct cpe_generator *generator, const char *new_product_version);
443 
445 bool cpe_generator_set_schema_version(struct cpe_generator *generator, const char *new_schema_version);
446 
448 bool cpe_generator_set_timestamp(struct cpe_generator *generator, const char *new_timestamp);
449 
451 bool cpe_vendor_set_value(struct cpe_vendor *vendor, const char *new_value);
452 
454 bool cpe_product_set_value(struct cpe_product *product, const char *new_value);
455 
457 bool cpe_product_set_part(struct cpe_product *product, cpe_part_t new_part);
458 
460 bool cpe_version_set_value(struct cpe_version *version, const char *new_value);
461 
463 bool cpe_update_set_value(struct cpe_update *update, const char *new_value);
464 
466 bool cpe_edition_set_value(struct cpe_edition *edition, const char *new_value);
467 
469 bool cpe_language_set_value(struct cpe_language *language, const char *new_value);
470 
471 /*
472  * Add functions
473  */
474 
476 bool cpe_item_add_reference(struct cpe_item *item, struct cpe_reference *new_reference);
477 
479 bool cpe_item_add_check(struct cpe_item *item, struct cpe_check *new_check);
480 
482 bool cpe_item_add_title(struct cpe_item *item, struct oscap_text *new_title);
483 
485 bool cpe_item_add_note(struct cpe_item *item, struct oscap_text *new_title);
486 
488 bool cpe_dict_model_add_vendor(struct cpe_dict_model *dict, struct cpe_vendor *new_vendor);
489 
491 bool cpe_vendor_add_title(struct cpe_vendor *vendor, struct oscap_text *new_title);
492 
494 bool cpe_vendor_add_product(struct cpe_vendor *vendor, struct cpe_product *new_product);
495 
497 bool cpe_product_add_version(struct cpe_product *product, struct cpe_version *new_version);
498 
500 bool cpe_version_add_update(struct cpe_version *version, struct cpe_update *new_update);
501 
503 bool cpe_update_add_edition(struct cpe_update *update, struct cpe_edition *new_edition);
504 
506 bool cpe_edition_add_language(struct cpe_edition *edition, struct cpe_language *new_language);
507 
508 
509 /************************************************************/
512 /************************************************************/
523 struct cpe_item_iterator;
524 
531 
538 
545 
550 
557 
564 
571 
578 
583 
589 struct cpe_check_iterator;
590 
597 
604 
611 
616 
622 struct cpe_vendor_iterator;
623 
630 
637 
644 
649 
655 struct cpe_product_iterator;
656 
663 
670 
677 
682 
688 struct cpe_version_iterator;
689 
696 
703 
710 
715 
721 struct cpe_update_iterator;
722 
729 
736 
743 
748 
754 struct cpe_edition_iterator;
755 
762 
769 
776 
781 
787 struct cpe_language_iterator;
788 
795 
802 
809 
814 
815 /************************************************************/
818 /************************************************************/
829 const char * cpe_dict_model_supported(void);
830 
836 char * cpe_dict_detect_version(const char* file);
837 
846 bool cpe_name_match_dict(struct cpe_name *cpe, struct cpe_dict_model *dict);
847 
856 bool cpe_name_match_dict_str(const char *cpe, struct cpe_dict_model *dict);
857 
858 /************************************************************/
866 void cpe_dict_model_export(const struct cpe_dict_model *dict, const char *file);
867 
875 struct cpe_dict_model *cpe_dict_model_import(const char *file);
876 
881 #endif /* _CPEDICT_H_ */