/home/pvrabec/tmp/openscap/openscap-0.1.4/src/CPE/cpeuri.h File Reference
Interface to Common Product Enumeration (CPE) URI.
More...
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
Go to the source code of this file.
|
Classes |
struct | cpe_t |
Enumerations |
enum | cpe_part_t { CPE_PART_NONE,
CPE_PART_HW,
CPE_PART_OS,
CPE_PART_APP
} |
| enumeration of possible CPE parts More...
|
enum | cpe_field_t {
CPE_FIELD_TYPE,
CPE_FIELD_VENDOR,
CPE_FIELD_PRODUCT,
CPE_FIELD_VERSION,
CPE_FIELD_UPDATE,
CPE_FIELD_EDITION,
CPE_FIELD_LANGUAGE,
CPE_FIELDNUM
} |
| enumeration of CPE URI fields (useful for indexing arrays)
|
Functions |
cpe_t * | cpe_new (const char *cpe) |
char ** | cpe_split (char *str, const char *delim) |
bool | cpe_urldecode (char *str) |
bool | cpe_name_match_one (const cpe_t *cpe, const cpe_t *against) |
bool | cpe_name_match_cpes (const cpe_t *name, size_t n, cpe_t **namelist) |
int | cpe_name_match_strs (const char *candidate, size_t n, char **targets) |
bool | cpe_check (const char *str) |
char * | cpe_get_uri (const cpe_t *cpe) |
int | cpe_write (const cpe_t *cpe, FILE *f) |
bool | cpe_assign_values (cpe_t *cpe, char **fields) |
void | cpe_delete (cpe_t *cpe) |
size_t | ptrarray_length (void **arr) |
Variables |
const char * | CPE_PART_CHAR [4] |
| string representation of CPE parts, order corresponds with values in enum above
|
const char * | CPE_SCHEMA |
| CPE URI schema string.
|
const char | CPE_SEP_CHAR |
| CPE URI component separator character.
|
const char * | CPE_SEP_STR |
| CPE URI component separator character as string.
|
Detailed Description
Interface to Common Product Enumeration (CPE) URI.
See more details at http://nvd.nist.gov/cpe.cfm
Enumeration Type Documentation
enumeration of possible CPE parts
- Enumerator:
-
CPE_PART_NONE |
no part specified -- error condition |
CPE_PART_HW |
hardware |
CPE_PART_OS |
operating system |
CPE_PART_APP |
application |
Function Documentation
bool cpe_assign_values |
( |
cpe_t * |
cpe, |
|
|
char ** |
fields | |
|
) |
| | |
Fill cpe structure with parsed fields.
Fields can be obtained via cpe_split(). Pointers in target sructure will point to same strings as pointers in fields do. No string duplication is performed.
- See also:
- cpe_split
- Parameters:
-
| cpe | structure to be filled |
| fields | NULL-terminated array of strings representing individual fields |
- Returns:
- true on success
bool cpe_check |
( |
const char * |
str |
) |
|
Ensures str is in proper CPE format.
- Parameters:
-
| str | string to be validated |
void cpe_delete |
( |
cpe_t * |
cpe |
) |
|
Destructor. Frees any used resources and safely destroys cpe.
- Parameters:
-
char* cpe_get_uri |
( |
const cpe_t * |
cpe |
) |
|
Return CPE URI as a new string.
- Note:
- Returned string is newly allocated and is caller's responsibility to free it.
- Parameters:
-
- Returns:
- CPE URI as string
- Return values:
-
bool cpe_name_match_cpes |
( |
const cpe_t * |
name, |
|
|
size_t |
n, |
|
|
cpe_t ** |
namelist | |
|
) |
| | |
Check if CPE name matches any CPE in namelist.
- Parameters:
-
| name | name to be looked-up |
| n | number of items in namelist |
| namelist | list of names to search in |
- Returns:
- true if name was found within namelist
bool cpe_name_match_one |
( |
const cpe_t * |
cpe, |
|
|
const cpe_t * |
against | |
|
) |
| | |
Check if candidate CPE cpe matches CPE against according to CPE specification v 2.1.
int cpe_name_match_strs |
( |
const char * |
candidate, |
|
|
size_t |
n, |
|
|
char ** |
targets | |
|
) |
| | |
Match CPE URI candidate against list of n CPE URIs given by targets.
- Parameters:
-
| candidate | candidarte CPE URI as string |
| n | number of items in targets |
| targets | list of CPE URIs to be candidate matched against |
- Todo:
- maybe it should go into libcpe library itself
- Returns:
- index of first URI in targets, that matched
- Return values:
-
| -1 | on mismatch |
| -2 | invalid CPE URI was given as parameter |
cpe_t* cpe_new |
( |
const char * |
cpe |
) |
|
Create new CPE structure from string cpe.
- Note:
- If cpe is NULL, empty cpe will be created.
- Parameters:
-
| cpe | CPE URI string to be parsed |
- Returns:
- new structure holding parsed data
- Return values:
-
char** cpe_split |
( |
char * |
str, |
|
|
const char * |
delim | |
|
) |
| | |
Split CPE string into individual fields separated by delim.
This function returns NULL-terminated array of pointers to strings.
- Note:
- Return value must be freed explicitly by caller.
This function modifies its first argument.
- Parameters:
-
| str | string to be parsed, will be changed as side-effect of this function |
| delim | delimiter |
- Returns:
- newly allocated NULL-terminated array of ponters to strings representing individual parts
- Return values:
-
bool cpe_urldecode |
( |
char * |
str |
) |
|
In-place decodes a -encoded string.
- Parameters:
-
| str | string to be decoded (will be modified) |
- Returns:
- true on success
int cpe_write |
( |
const cpe_t * |
cpe, |
|
|
FILE * |
f | |
|
) |
| | |
Write CPE URI cpe to file a descriptor f
- Parameters:
-
| cpe | cpe to write |
| f | file descriptor to write CPE URI to |
- Returns:
- number of written characters
- Return values:
-
size_t ptrarray_length |
( |
void ** |
arr |
) |
|
Return number of elements in NULL-terminated array of pointers.
- Parameters:
-
- Returns:
- number of members