Open SCAP Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
cpedict_priv.c File Reference

Detailed Description

Interface to Common Platform Enumeration (CPE) Language.

See more details at http://nvd.nist.gov/cpe.cfm

#include <libxml/xmlreader.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include "public/cpe_dict.h"
#include "public/cpe_name.h"
#include "cpedict_ext_priv.h"
#include "cpedict_priv.h"
#include "cpe_ctx_priv.h"
#include "common/list.h"
#include "common/elements.h"
#include "common/text_priv.h"
#include "common/util.h"
#include "common/_error.h"
#include "common/xmlns_priv.h"
#include "common/xmltext_priv.h"
#include "source/oscap_source_priv.h"
#include "source/public/oscap_source.h"

Data Structures

struct  cpe_item
 Structure representing single CPE dictionary item. More...
 
struct  cpe_item_metadata
 Structure representing metadata of CPE item. More...
 
struct  cpe_check
 Structure representing single CPE check. More...
 
struct  cpe_reference
 CPE dictionary item reference. More...
 
struct  cpe_generator
 Structure with information about document. More...
 
struct  cpe_product
 Product of some vendor. More...
 
struct  cpe_version
 Version of product. More...
 
struct  cpe_update
 Update of product version. More...
 
struct  cpe_edition
 Edition of product update. More...
 
struct  cpe_language
 Language of product edition. More...
 

Macros

#define TAG_CHECK_STR   BAD_CAST "check"
 
#define TAG_NOTES_STR   BAD_CAST "notes"
 
#define TAG_REFERENCES_STR   BAD_CAST "references"
 
#define ATTR_DEP_BY_NVDID_STR   BAD_CAST "deprecated-by-nvd-id"
 
#define ATTR_NVD_ID_STR   BAD_CAST "nvd-id"
 
#define ATTR_STATUS_STR   BAD_CAST "status"
 
#define ATTR_MODIFICATION_DATE_STR   BAD_CAST "modification-date"
 
#define TAG_ITEM_METADATA_STR   BAD_CAST "item-metadata"
 
#define TAG_REFERENCE_STR   BAD_CAST "reference"
 
#define TAG_NOTE_STR   BAD_CAST "note"
 
#define TAG_TITLE_STR   BAD_CAST "title"
 
#define TAG_CPE_ITEM_STR   BAD_CAST "cpe-item"
 
#define ATTR_DEPRECATION_DATE_STR   BAD_CAST "deprecation_date"
 
#define ATTR_DEPRECATED_BY_STR   BAD_CAST "deprecated_by"
 
#define ATTR_DEPRECATED_STR   BAD_CAST "deprecated"
 
#define ATTR_NAME_STR   BAD_CAST "name"
 
#define TAG_GENERATOR_STR   BAD_CAST "generator"
 
#define TAG_PRODUCT_STR   BAD_CAST "product"
 
#define TAG_PRODUCT_NAME_STR   BAD_CAST "product_name"
 
#define TAG_PRODUCT_VERSION_STR   BAD_CAST "product_version"
 
#define TAG_SCHEMA_VERSION_STR   BAD_CAST "schema_version"
 
#define TAG_TIMESTAMP_STR   BAD_CAST "timestamp"
 
#define TAG_COMPONENT_TREE_STR   BAD_CAST "component-tree"
 
#define TAG_VENDOR_STR   BAD_CAST "vendor"
 
#define TAG_CPE_LIST_STR   BAD_CAST "cpe-list"
 
#define TAG_VERSION_STR   BAD_CAST "version"
 
#define TAG_UPDATE_STR   BAD_CAST "update"
 
#define TAG_EDITION_STR   BAD_CAST "edition"
 
#define TAG_LANGUAGE_STR   BAD_CAST "language"
 
#define ATTR_VALUE_STR   BAD_CAST "value"
 
#define ATTR_PART_STR   BAD_CAST "part"
 
#define ATTR_SYSTEM_STR   BAD_CAST "system"
 
#define ATTR_HREF_STR   BAD_CAST "href"
 
#define NS_META_STR   BAD_CAST "meta"
 
#define ATTR_XML_LANG_STR   BAD_CAST "xml:lang"
 
#define VAL_TRUE_STR   BAD_CAST "true"
 

Functions

struct cpe_namecpe_item_get_deprecated (const struct cpe_item *item)
 
 OSCAP_ITERATOR_REMOVE_F (cpe_reference)
 
 OSCAP_IGETINS_GEN (cpe_item, OSCAP_ITERATOR_REMOVE_Fc cpe_dict_model, items, item)
 
struct cpe_notes * cpe_notes_new (void)
 
void cpe_notes_free (struct cpe_notes *notes)
 
struct cpe_dict_modelcpe_dict_model_new ()
 
struct cpe_item_metadatacpe_item_metadata_new ()
 
struct cpe_itemcpe_item_new ()
 
struct cpe_checkcpe_check_new ()
 
struct cpe_referencecpe_reference_new ()
 
struct cpe_generatorcpe_generator_new ()
 
struct cpe_vendorcpe_vendor_new ()
 
struct cpe_productcpe_product_new ()
 
struct cpe_versioncpe_version_new ()
 
struct cpe_updatecpe_update_new ()
 
struct cpe_editioncpe_edition_new ()
 
struct cpe_languagecpe_language_new ()
 
struct cpe_dict_modelcpe_dict_model_parse (struct cpe_parser_ctx *ctx)
 Load new CPE dictionary from XML node. More...
 
struct cpe_generatorcpe_generator_parse (struct cpe_parser_ctx *ctx)
 Parse generator part of CPE dictionary XML file. More...
 
struct cpe_itemcpe_item_parse (struct cpe_parser_ctx *ctx)
 New dictionary item from XML. More...
 
struct cpe_vendorcpe_vendor_parse (xmlTextReaderPtr reader)
 Parsing function to parse vendors of CPE dictionary. More...
 
void cpe_dict_model_export_xml (const struct cpe_dict_model *dict, const char *file)
 Export function for CPE dictionary model. More...
 
void cpe_dict_export (const struct cpe_dict_model *dict, xmlTextWriterPtr writer)
 Internal export function for CPE dictionary model. More...
 
void cpe_generator_export (const struct cpe_generator *generator, xmlTextWriterPtr writer)
 Exporting function for CPE generator - information of XML document. More...
 
void cpe_item_export (const struct cpe_item *item, xmlTextWriterPtr writer, int base_version)
 Exporting function for CPE item. More...
 
void cpe_vendor_export (const struct cpe_vendor *vendor, xmlTextWriterPtr writer)
 Exporting function for CPE vendor. More...
 
void cpe_dict_model_free (struct cpe_dict_model *dict)
 
void cpe_item_free (struct cpe_item *item)
 
void cpe_generator_free (struct cpe_generator *generator)
 
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)
 

Variables

const char * PART_TO_CHAR [] = { NULL, "h", "o", "a" }
 

Function Documentation

void cpe_dict_export ( const struct cpe_dict_model dict,
xmlTextWriterPtr  writer 
)

Internal export function for CPE dictionary model.

Parameters
dictCPE dictionary
writerxmlTextWriterPtr representing XML model
void cpe_dict_model_export_xml ( const struct cpe_dict_model dict,
const char *  file 
)

Export function for CPE dictionary model.

Parameters
dictCPE dictionary structure
filefilename to export
struct cpe_dict_model* cpe_dict_model_parse ( struct cpe_parser_ctx ctx)

Load new CPE dictionary from XML node.

Parameters
ctxCPE parser context
Returns
new dictionary
Return values
NULLon failure
void cpe_generator_export ( const struct cpe_generator generator,
xmlTextWriterPtr  writer 
)

Exporting function for CPE generator - information of XML document.

Parameters
generatorCPE generator structure
writerxmlTextWriterPtr representing XML model
struct cpe_generator* cpe_generator_parse ( struct cpe_parser_ctx ctx)

Parse generator part of CPE dictionary XML file.

Parameters
ctxCPE Parser's context
Returns
new structure cpe_generator
void cpe_item_export ( const struct cpe_item item,
xmlTextWriterPtr  writer,
int  base_version 
)

Exporting function for CPE item.

Parameters
itemCPE item structure
writerxmlTextWriterPtr representing XML model
base_versionwhat is the base version of target CPE dict (1 for CPE 1.x, 2 for CPE 2.x, ...)
struct cpe_item* cpe_item_parse ( struct cpe_parser_ctx ctx)

New dictionary item from XML.

Parameters
ctxCPE parser's context
Returns
new dictionary item
Return values
NULLon failure
void cpe_vendor_export ( const struct cpe_vendor vendor,
xmlTextWriterPtr  writer 
)

Exporting function for CPE vendor.

Parameters
vendorCPE vendor structure
writerxmlTextWriterPtr representing XML model
struct cpe_vendor* cpe_vendor_parse ( xmlTextReaderPtr  reader)

Parsing function to parse vendors of CPE dictionary.

Parameters
readerxmlTextReaderPtr representing XML model
Returns
new structure cpe_vendor
OSCAP_ITERATOR_REMOVE_F ( cpe_reference  )

< representation of <notes> element

< xml:lang attribute

< list of inner <note> elements