cpedict_priv.c File Reference

Interface to Common Platform Enumeration (CPE) Language. More...

`#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"`

## 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_name * | cpe_item_get_deprecated (const struct cpe_item *item)
| OSCAP_ITERATOR_REMOVE_F (cpe_reference)
| OSCAP_IGETINS_GEN (cpe_vendor, cpe_dict_model, vendors, vendor)
struct cpe_notes * | cpe_notes_new (void)
void | cpe_notes_free (struct cpe_notes *notes)
struct cpe_dict_model * | cpe_dict_model_new ()
struct cpe_item_metadata * | cpe_item_metadata_new ()
struct cpe_item * | cpe_item_new ()
struct cpe_check * | cpe_check_new ()
struct cpe_reference * | cpe_reference_new ()
struct cpe_generator * | cpe_generator_new ()
struct cpe_vendor * | cpe_vendor_new ()
struct cpe_product * | cpe_product_new ()
struct cpe_version * | cpe_version_new ()
struct cpe_update * | cpe_update_new ()
struct cpe_edition * | cpe_edition_new ()
struct cpe_language * | cpe_language_new ()
struct cpe_dict_model * | cpe_dict_model_parse_xml (const char *file)
| Function to parse XML to CPE dictionary model. More...
struct cpe_dict_model * | cpe_dict_model_parse (struct cpe_parser_ctx *ctx)
| Load new CPE dictionary from XML node. More...
struct cpe_generator * | cpe_generator_parse (struct cpe_parser_ctx *ctx)
| Parse generator part of CPE dictionary XML file. More...
struct cpe_item * | cpe_item_parse (struct cpe_parser_ctx *ctx)
| New dictionary item from XML. More...
struct cpe_vendor * | cpe_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" }

## Detailed Description

Interface to Common Platform Enumeration (CPE) Language.

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

## Function Documentation

void cpe_dict_export | ( | const struct cpe_dict_model * | dict,
|  | xmlTextWriterPtr | writer
| ) |  |

Internal export function for CPE dictionary model.

Parameters

  dict | CPE dictionary
  writer | xmlTextWriterPtr 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

  dict | CPE dictionary structure
  file | filename to export

struct cpe_dict_model* cpe_dict_model_parse | ( | struct cpe_parser_ctx * | ctx | ) |

read

Load new CPE dictionary from XML node.

Parameters

  ctx | CPE parser context

Returns
  new dictionary

Return values

  NULL | on failure

struct cpe_dict_model* cpe_dict_model_parse_xml | ( | const char * | file | ) |

read

Function to parse XML to CPE dictionary model.

Parameters

  file | filename

void cpe_generator_export | ( | const struct cpe_generator * | generator,
|  | xmlTextWriterPtr | writer
| ) |  |

Exporting function for CPE generator - information of XML document.

Parameters

  generator | CPE generator structure
  writer | xmlTextWriterPtr representing XML model

struct cpe_generator* cpe_generator_parse | ( | struct cpe_parser_ctx * | ctx | ) |

read

Parse generator part of CPE dictionary XML file.

Parameters

  ctx | CPE 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

  item | CPE item structure
  writer | xmlTextWriterPtr representing XML model
  base_version | what 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 | ) |

read

New dictionary item from XML.

Parameters

  ctx | CPE parser's context

Returns
  new dictionary item

Return values

  NULL | on failure

void cpe_vendor_export | ( | const struct cpe_vendor * | vendor,
|  | xmlTextWriterPtr | writer
| ) |  |

Exporting function for CPE vendor.

Parameters

  vendor | CPE vendor structure
  writer | xmlTextWriterPtr representing XML model

struct cpe_vendor* cpe_vendor_parse | ( | xmlTextReaderPtr | reader | ) |

read

Parsing function to parse vendors of CPE dictionary.

Parameters

  reader | xmlTextReaderPtr 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