Open SCAP Library: CPE Language

Open SCAP Library

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Files | Data Structures | Enumerations | Functions
CPE Language
CPE

## Files
file | cpe_lang.h
| Interface to Common Platform Enumeration (CPE) Language.

## Data Structures
struct | cpe_lang_model
| CPE platform specification. More...
struct | cpe_platform
| Single platform representation in CPE language. More...
struct | cpe_testexpr
| CPE language boolean expression. More...
struct | cpe_platform_iterator
| Iterator over CPE dictionary items. More...
struct | cpe_testexpr_iterator
| Iterator over CPE language expressions. More...

## Enumerations
enum | cpe_lang_oper_t { CPE_LANG_OPER_INVALID = 0x00, CPE_LANG_OPER_AND = 0x01, CPE_LANG_OPER_OR = 0x02, CPE_LANG_OPER_MATCH = 0x04, CPE_LANG_OPER_CHECK = 0x08, CPE_LANG_OPER_MASK = 0xFF, CPE_LANG_OPER_NOT = 0x100, CPE_LANG_OPER_NAND = CPE_LANG_OPER_AND | CPE_LANG_OPER_NOT, CPE_LANG_OPER_NOR = CPE_LANG_OPER_OR | CPE_LANG_OPER_NOT }
| CPE language operators. More...

## Functions
bool | cpe_lang_model_set_origin_file (struct cpe_lang_model *lang_model, const char *origin_file)
| Sets the origin file hint. More...
const char * | cpe_lang_model_get_origin_file (const struct cpe_lang_model *lang_model)
| Gets the file the CPE dict model was loaded from.
void | cpe_platform_iterator::cpe_platform_iterator_remove (struct cpe_platform_iterator *it, struct cpe_lang_model *parent)
void | cpe_testexpr_iterator::cpe_platform_iterator_reset (struct cpe_platform_iterator *it)
struct cpe_lang_model * | cpe_lang_model::cpe_lang_model_new (void)
| Constructor of CPE Language model.
struct cpe_testexpr * | cpe_testexpr::cpe_testexpr_new (void)
| Constructor of CPE test expression.
struct cpe_platform * | cpe_platform::cpe_platform_new (void)
| Constructor of CPE Platform.
struct cpe_testexpr * | cpe_testexpr::cpe_testexpr_clone (struct cpe_testexpr *old_expr)
| Clone CPE test expression. More...
void | cpe_testexpr::cpe_testexpr_free (struct cpe_testexpr *expr)
| Free function of CPE test expression.
void | cpe_testexpr::cpe_testexpr_iterator_reset (struct cpe_testexpr_iterator *it)
| Reset function of CPE test expression.
void | cpe_lang_model::cpe_lang_model_free (struct cpe_lang_model *platformspec)
| Free function of CPE test expression.
void | cpe_platform::cpe_platform_free (struct cpe_platform *platform)
| Free function of CPE Platform.
struct cpe_lang_model * | cpe_lang_model::cpe_lang_model_import (const char *file)
| Load CPE language model from a XML document. More...
struct cpe_lang_model * | cpe_lang_model::cpe_lang_model_import_source (struct oscap_source *source)
| Load CPE language model from an oscap_source.
void | cpe_lang_model::cpe_lang_model_export (const struct cpe_lang_model *spec, const char *file)
| Write the lang_model to a file. More...

## Iterators
struct cpe_platform * | cpe_platform_iterator::cpe_platform_iterator_next (struct cpe_platform_iterator *it)
bool | cpe_platform_iterator::cpe_platform_iterator_has_more (struct cpe_platform_iterator *it)
void | cpe_platform_iterator::cpe_platform_iterator_free (struct cpe_platform_iterator *it)
struct cpe_testexpr * | cpe_testexpr_iterator::cpe_testexpr_iterator_next (struct cpe_testexpr_iterator *it)
bool | cpe_testexpr_iterator::cpe_testexpr_iterator_has_more (struct cpe_testexpr_iterator *it)
void | cpe_testexpr_iterator::cpe_testexpr_iterator_free (struct cpe_testexpr_iterator *it)

## Getters
Return value is pointer to structure's member. Do not free unless you null the pointer in the structure. Use remove function otherwise.
cpe_lang_oper_t | cpe_testexpr::cpe_testexpr_get_oper (const struct cpe_testexpr *item)
| cpe_testexpr functions to get variable members
struct cpe_testexpr_iterator * | cpe_testexpr::cpe_testexpr_get_meta_expr (const struct cpe_testexpr *item)
| Get CPE expression subexpression. More...
const struct cpe_name * | cpe_testexpr::cpe_testexpr_get_meta_cpe (const struct cpe_testexpr *item)
| Get CPE name to match against. More...
const char * | cpe_testexpr::cpe_testexpr_get_meta_check_system (const struct cpe_testexpr *item)
| Get check system to evaluate Only valid for CPE_LANG_OPER_CHECK.
const char * | cpe_testexpr::cpe_testexpr_get_meta_check_href (const struct cpe_testexpr *item)
| Get check href to evaluate Only valid for CPE_LANG_OPER_CHECK.
const char * | cpe_testexpr::cpe_testexpr_get_meta_check_id (const struct cpe_testexpr *item)
| Get check idref to evaluate Only valid for CPE_LANG_OPER_CHECK.
const struct cpe_testexpr * | cpe_testexpr::cpe_testexpr_get_next (const struct cpe_testexpr *expr)
| Function to get next expr from array. More...
struct cpe_platform_iterator * | cpe_lang_model::cpe_lang_model_get_platforms (const struct cpe_lang_model *item)
| cpe_lang_model function to get CPE platforms
struct cpe_platform * | cpe_lang_model::cpe_lang_model_get_item (const struct cpe_lang_model *item, const char *key)
| cpe_lang_model function to get CPE platforms
bool | cpe_lang_model::cpe_platform_applicable_lang_model (const char *platform, struct cpe_lang_model *lang_model, cpe_check_fn check_cb, cpe_dict_fn dict_cb, void *usr)
| Verify whether given CPE platform idref is applicable by evaluating test expression associated with it. More...
const char * | cpe_platform::cpe_platform_get_id (const struct cpe_platform *item)
| cpe_platform functions to get id
const char * | cpe_platform::cpe_platform_get_remark (const struct cpe_platform *item)
| cpe_platform functions to get remark
struct oscap_text_iterator * | cpe_platform::cpe_platform_get_titles (const struct cpe_platform *item)
| cpe_platform functions to get titles
const struct cpe_testexpr * | cpe_platform::cpe_platform_get_expr (const struct cpe_platform *item)
| cpe_platform functions to get test expression

## Setters
For lists use add functions. Parameters of set functions are duplicated in memory and need to be freed by caller.
bool | cpe_lang_model::cpe_lang_model_add_platform (struct cpe_lang_model *lang, struct cpe_platform *platform)
| Add platform to CPE lang model.
bool | cpe_platform::cpe_platform_add_title (struct cpe_platform *platform, struct oscap_text *title)
| Add title to platform.
bool | cpe_testexpr::cpe_testexpr_add_subexpression (struct cpe_testexpr *expr, struct cpe_testexpr *sub)
| Add XML namespace to CPE lang model. More...
bool | cpe_platform::cpe_platform_set_id (struct cpe_platform *platform, const char *new_id)
| Set ID of CPE platform.
bool | cpe_platform::cpe_platform_set_remark (struct cpe_platform *platform, const char *new_remark)
| Set remark of CPE platform.
bool | cpe_platform::cpe_platform_set_expr (struct cpe_platform *platform, struct cpe_testexpr *expr)
| Set evaluation expression for this CPE platform. More...
bool | cpe_testexpr::cpe_testexpr_set_oper (struct cpe_testexpr *expr, cpe_lang_oper_t oper)
| Set CPE operation. More...
bool | cpe_testexpr::cpe_testexpr_set_name (struct cpe_testexpr *expr, struct cpe_name *name)
| Set CPE name. More...

## Evaluators
const char * | cpe_lang_model::cpe_lang_model_supported (void)
| Get supported version of CPE language XML. More...
char * | cpe_lang_model::cpe_lang_model_detect_version (const char *file)
| Detect version of given CPE language XML. More...
bool | cpe_platform::cpe_platform_match_cpe (struct cpe_name **cpe, size_t n, const struct cpe_platform *platform)
| Function to match cpe in platform. More...

## Detailed Description

Class diagram

## Enumeration Type Documentation

enum cpe_lang_oper_t

CPE language operators.

Enumerator
CPE_LANG_OPER_INVALID | invalid or unknown operation
CPE_LANG_OPER_AND | logical AND
CPE_LANG_OPER_OR | logical OR
CPE_LANG_OPER_MATCH | fact-ref = match given CPE name against available dictionaries
CPE_LANG_OPER_CHECK | check-ref = evaluate given check
CPE_LANG_OPER_MASK | mask to extract the operator w/o possible negation
CPE_LANG_OPER_NOT | negate

## Function Documentation

char * cpe_lang_model_detect_version | ( | const char * | file | ) |

Detect version of given CPE language XML.

Deprecated:
  This function has been deprecated by oscap_source_get_schema_version. This function may be dropped from later versions of the library.

void cpe_lang_model_export | ( | const struct cpe_lang_model * | spec,
|  | const char * | file
| ) |  |

Write the lang_model to a file.

Parameters

  spec | CPE lang model
  file | filename

struct cpe_lang_model * cpe_lang_model_import | ( | const char * | file | ) |

Load CPE language model from a XML document.

Deprecated:
  This function has been deprecated by cpe_lang_model_import_source This function may be dropped from later versions of the library.

bool cpe_lang_model_set_origin_file | ( | struct cpe_lang_model * | lang_model,
|  | const char * | origin_file
| ) |  |

Sets the origin file hint.

Note
  This is intended for internal use only!

See also
  cpe_lang_model_get_origin_file

const char * cpe_lang_model_supported | ( | void |  | ) |

Get supported version of CPE language XML.

Returns
  version of XML file format

bool cpe_platform_applicable_lang_model | ( | const char * | platform,
|  | struct cpe_lang_model * | lang_model,
|  | cpe_check_fn | check_cb,
|  | cpe_dict_fn | dict_cb,
|  | void * | usr
| ) |  |

Verify whether given CPE platform idref is applicable by evaluating test expression associated with it.

Parameters

  platform | idref to the platform to verify (do not pass with "#" prepended)
  lang_model | used CPE language model

Returns
  true if lang model contains given platform and the platform is applicable

void cpe_platform_iterator_free | ( | struct cpe_platform_iterator * | it | ) |

bool cpe_platform_iterator_has_more | ( | struct cpe_platform_iterator * | it | ) |

struct cpe_platform * cpe_platform_iterator_next | ( | struct cpe_platform_iterator * | it | ) |

void cpe_platform_iterator_remove | ( | struct cpe_platform_iterator * | it,
|  | struct cpe_lang_model * | parent
| ) |  |

void cpe_platform_iterator_reset | ( | struct cpe_platform_iterator * | it | ) |

bool cpe_platform_match_cpe | ( | struct cpe_name ** | cpe,
|  | size_t | n,
|  | const struct cpe_platform * | platform
| ) |  |

Function to match cpe in platform.

Parameters

  cpe | to be matched with
  n | size
  platform | CPE platform

bool cpe_platform_set_expr | ( | struct cpe_platform * | platform,
|  | struct cpe_testexpr * | expr
| ) |  |

Set evaluation expression for this CPE platform.

Expression has to be a logical-test (i.e. its operation shall be AND or OR, possibly with negation)

bool cpe_testexpr_add_subexpression | ( | struct cpe_testexpr * | expr,
|  | struct cpe_testexpr * | sub
| ) |  |

Add XML namespace to CPE lang model.

Add an subexpression to a compound CPE language expression.

Expression has to be of type CPE_LANG_OPER_AND or CPE_LANG_OPER_OR, possibly with negation.

struct cpe_testexpr * cpe_testexpr_clone | ( | struct cpe_testexpr * | old_expr | ) |

Clone CPE test expression.

Parameters

  old_expr | CPE test expression

const struct cpe_name * cpe_testexpr_get_meta_cpe | ( | const struct cpe_testexpr * | item | ) |

Get CPE name to match against.

Only valid for CPE_LANG_OPER_MATCH.

struct cpe_testexpr_iterator * cpe_testexpr_get_meta_expr | ( | const struct cpe_testexpr * | item | ) |

Get CPE expression subexpression.

Not valid for CPE_LANG_OPER_MATCH operation.

const struct cpe_testexpr * cpe_testexpr_get_next | ( | const struct cpe_testexpr * | expr | ) |

Function to get next expr from array.

Parameters

  expr | CPE Test expression structure

void cpe_testexpr_iterator_free | ( | struct cpe_testexpr_iterator * | it | ) |

bool cpe_testexpr_iterator_has_more | ( | struct cpe_testexpr_iterator * | it | ) |

struct cpe_testexpr * cpe_testexpr_iterator_next | ( | struct cpe_testexpr_iterator * | it | ) |

bool cpe_testexpr_set_name | ( | struct cpe_testexpr * | expr,
|  | struct cpe_name * | name
| ) |  |

Set CPE name.

If the expression does not have type CPE_LANG_OPER_MATCH, this function has no effect and returns false.

bool cpe_testexpr_set_oper | ( | struct cpe_testexpr * | expr,
|  | cpe_lang_oper_t | oper
| ) |  |

Set CPE operation.

Any subexpressions and CPE names associated with this expression will be removed.