Open SCAP Library: cpe_lang.h Source File

Open SCAP Library

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

- File List
- Globals

cpe_lang.h
Go to the documentation of this file.
1
13 /*
14 * Copyright 2009--2014 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 * Lukas Kuklinek <lkuklinek@redhat.com>
33 * Maros Barabas <mbarabas@redhat.com>
34 */
35
36 #ifndef CPELANG_H_
37 #define CPELANG_H_
38
39 #include <stdlib.h>
40
41 #include "cpe_name.h"
42 #include "oscap.h"
43 #include "oscap_text.h"
44 #include "oscap_source.h"
45
49 typedef enum {
50 CPE_LANG_OPER_INVALID = 0x00,
51 CPE_LANG_OPER_AND = 0x01,
52 CPE_LANG_OPER_OR = 0x02,
53 CPE_LANG_OPER_MATCH = 0x04,
54 CPE_LANG_OPER_CHECK = 0x08,
55
56 CPE_LANG_OPER_MASK = 0xFF,
57 CPE_LANG_OPER_NOT = 0x100,
58
59 CPE_LANG_OPER_NAND = CPE_LANG_OPER_AND | CPE_LANG_OPER_NOT,
60 CPE_LANG_OPER_NOR = CPE_LANG_OPER_OR | CPE_LANG_OPER_NOT,
61 } cpe_lang_oper_t;
62
67 struct cpe_lang_model;
68
73 struct cpe_platform;
74
79 struct cpe_testexpr;
80
81
82 /************************************************************/
93 struct cpe_platform_iterator;
94
96 struct cpe_platform *cpe_platform_iterator_next(struct cpe_platform_iterator *it);
98 bool cpe_platform_iterator_has_more(struct cpe_platform_iterator *it);
100 void cpe_platform_iterator_free(struct cpe_platform_iterator *it);
101
107 struct cpe_testexpr_iterator;
109 struct cpe_testexpr *cpe_testexpr_iterator_next(struct cpe_testexpr_iterator *it);
111 bool cpe_testexpr_iterator_has_more(struct cpe_testexpr_iterator *it);
113 void cpe_testexpr_iterator_free(struct cpe_testexpr_iterator *it);
114
115 /************************************************************/
118 /************************************************************/
130 cpe_lang_oper_t cpe_testexpr_get_oper(const struct cpe_testexpr *item);
131
137 struct cpe_testexpr_iterator *cpe_testexpr_get_meta_expr(const struct cpe_testexpr *item);
138
144 const struct cpe_name *cpe_testexpr_get_meta_cpe(const struct cpe_testexpr *item);
145
151 const char* cpe_testexpr_get_meta_check_system(const struct cpe_testexpr *item);
152
158 const char* cpe_testexpr_get_meta_check_href(const struct cpe_testexpr *item);
159
165 const char* cpe_testexpr_get_meta_check_id(const struct cpe_testexpr *item);
166
172 const struct cpe_testexpr *cpe_testexpr_get_next(const struct cpe_testexpr *expr);
173
178 struct cpe_platform_iterator *cpe_lang_model_get_platforms(const struct cpe_lang_model *item);
179
184 struct cpe_platform *cpe_lang_model_get_item(const struct cpe_lang_model *item, const char *key);
185
194 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);
195
200 const char *cpe_platform_get_id(const struct cpe_platform *item);
205 const char *cpe_platform_get_remark(const struct cpe_platform *item);
210 struct oscap_text_iterator *cpe_platform_get_titles(const struct cpe_platform *item);
215 const struct cpe_testexpr *cpe_platform_get_expr(const struct cpe_platform *item);
216
217 /************************************************************/
220 /************************************************************/
232 bool cpe_lang_model_add_platform(struct cpe_lang_model *lang, struct cpe_platform *platform);
237 bool cpe_platform_add_title(struct cpe_platform *platform, struct oscap_text *title);
238
243 /*bool cpe_lang_model_add_xmlns(struct cpe_lang_model * model, struct xml_metadata * xml);*/
244
251 bool cpe_testexpr_add_subexpression(struct cpe_testexpr *expr, struct cpe_testexpr *sub);
252
257 bool cpe_platform_set_id(struct cpe_platform *platform, const char *new_id);
262 bool cpe_platform_set_remark(struct cpe_platform *platform, const char *new_remark);
269 bool cpe_platform_set_expr(struct cpe_platform *platform, struct cpe_testexpr *expr);
276 bool cpe_testexpr_set_oper(struct cpe_testexpr *expr, cpe_lang_oper_t oper);
277
285 bool cpe_testexpr_set_name(struct cpe_testexpr *expr, struct cpe_name *name);
286
287 /************************************************************/
290 void cpe_platform_iterator_remove(struct cpe_platform_iterator *it, struct cpe_lang_model *parent);
293 void cpe_platform_iterator_reset(struct cpe_platform_iterator *it);
294
299 struct cpe_lang_model *cpe_lang_model_new(void);
300
305 struct cpe_testexpr *cpe_testexpr_new(void);
306
311 struct cpe_platform *cpe_platform_new(void);
312
318 struct cpe_testexpr * cpe_testexpr_clone(struct cpe_testexpr * old_expr);
319
324 void cpe_testexpr_free(struct cpe_testexpr *expr);
325
330 void cpe_testexpr_iterator_reset(struct cpe_testexpr_iterator *it);
331
336 void cpe_lang_model_free(struct cpe_lang_model *platformspec);
337
342 void cpe_platform_free(struct cpe_platform *platform);
343
344 /************************************************************/
355 const char * cpe_lang_model_supported(void);
356
363 OSCAP_DEPRECATED(char * cpe_lang_model_detect_version(const char* file));
364
372 bool cpe_platform_match_cpe(struct cpe_name **cpe, size_t n, const struct cpe_platform *platform);
373
374 /************************************************************/
383 OSCAP_DEPRECATED(struct cpe_lang_model *cpe_lang_model_import(const char *file));
384
389 struct cpe_lang_model *cpe_lang_model_import_source(struct oscap_source *source);
390
396 bool cpe_lang_model_set_origin_file(struct cpe_lang_model* lang_model, const char* origin_file);
397
405 const char* cpe_lang_model_get_origin_file(const struct cpe_lang_model* lang_model);
406
413 void cpe_lang_model_export(const struct cpe_lang_model *spec, const char *file);
414
419 #endif /* _CPELANG_H_ */
cpe_lang_model::cpe_platform_applicable_lang_model
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 i...
Definition: cpelang.c:186
cpe_lang_model_get_origin_file
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.
Definition: cpelang_priv.c:764
cpe_lang_model
CPE platform specification.
Definition: cpelang_priv.c:63
cpe_testexpr::cpe_testexpr_free
void cpe_testexpr_free(struct cpe_testexpr *expr)
Free function of CPE test expression.
Definition: cpelang_priv.c:635
cpe_platform::cpe_platform_get_remark
const char * cpe_platform_get_remark(const struct cpe_platform *item)
cpe_platform functions to get remark
oscap.h
General OpenScap functions and types.
cpe_lang_oper_t
cpe_lang_oper_t
CPE language operators.
Definition: cpe_lang.h:49
cpe_platform::cpe_platform_new
struct cpe_platform * cpe_platform_new(void)
Constructor of CPE Platform.
Definition: cpelang_priv.c:192
cpe_platform_iterator::cpe_platform_iterator_has_more
bool cpe_platform_iterator_has_more(struct cpe_platform_iterator *it)
cpe_lang_model::cpe_lang_model_get_platforms
struct cpe_platform_iterator * cpe_lang_model_get_platforms(const struct cpe_lang_model *item)
cpe_lang_model function to get CPE platforms
cpe_lang_model_set_origin_file
bool cpe_lang_model_set_origin_file(struct cpe_lang_model *lang_model, const char *origin_file)
Sets the origin file hint.
Definition: cpelang_priv.c:756
cpe_platform::cpe_platform_set_expr
bool cpe_platform_set_expr(struct cpe_platform *platform, struct cpe_testexpr *expr)
Set evaluation expression for this CPE platform.
Definition: cpelang_priv.c:744
cpe_testexpr::cpe_testexpr_get_meta_check_href
const char * cpe_testexpr_get_meta_check_href(const struct cpe_testexpr *item)
Get check href to evaluate Only valid for CPE_LANG_OPER_CHECK.
Definition: cpelang_priv.c:677
OSCAP_DEPRECATED
#define OSCAP_DEPRECATED(func)
This macro will warn, when a deprecated function is used.
Definition: oscap.h:50
cpe_testexpr::cpe_testexpr_add_subexpression
bool cpe_testexpr_add_subexpression(struct cpe_testexpr *expr, struct cpe_testexpr *sub)
Add XML namespace to CPE lang model.
Definition: cpelang_priv.c:714
cpe_platform::cpe_platform_add_title
bool cpe_platform_add_title(struct cpe_platform *platform, struct oscap_text *title)
Add title to platform.
cpe_lang_model::cpe_lang_model_new
struct cpe_lang_model * cpe_lang_model_new(void)
Constructor of CPE Language model.
Definition: cpelang_priv.c:176
cpe_check_fn
bool *(* cpe_check_fn)(const char *, const char *, const char *, void *)
Shared callback definition used to evaluate checks to perform applicability tests.
Definition: cpe_name.h:362
cpe_platform::cpe_platform_get_expr
const struct cpe_testexpr * cpe_platform_get_expr(const struct cpe_platform *item)
cpe_platform functions to get test expression
cpe_testexpr::oper
cpe_lang_oper_t oper
operator
Definition: cpelang_priv.h:53
cpe_testexpr::cpe
struct cpe_name * cpe
CPE for match operation.
Definition: cpelang_priv.h:56
cpe_platform_iterator::cpe_platform_iterator_remove
void cpe_platform_iterator_remove(struct cpe_platform_iterator *it, struct cpe_lang_model *parent)
Definition: cpelang_priv.c:735
cpe_name.h
Interface to Common Platform Enumeration (CPE) URI.
cpe_platform_iterator::cpe_platform_iterator_next
struct cpe_platform * cpe_platform_iterator_next(struct cpe_platform_iterator *it)
cpe_lang_model::cpe_lang_model_detect_version
char * cpe_lang_model_detect_version(const char *file)
Detect version of given CPE language XML.
Definition: cpelang.c:128
cpe_lang_model::cpe_lang_model_supported
const char * cpe_lang_model_supported(void)
Get supported version of CPE language XML.
Definition: cpelang.c:116
cpe_testexpr::cpe_testexpr_get_meta_expr
struct cpe_testexpr_iterator * cpe_testexpr_get_meta_expr(const struct cpe_testexpr *item)
Get CPE expression subexpression.
Definition: cpelang_priv.c:653
cpe_testexpr::cpe_testexpr_set_oper
bool cpe_testexpr_set_oper(struct cpe_testexpr *expr, cpe_lang_oper_t oper)
Set CPE operation.
Definition: cpelang_priv.c:693
CPE_LANG_OPER_NOT
negate
Definition: cpe_lang.h:57
oscap_text_iterator
Internationalized string iterator.
cpe_platform_iterator
Iterator over CPE dictionary items.
cpe_testexpr_iterator::cpe_testexpr_iterator_has_more
bool cpe_testexpr_iterator_has_more(struct cpe_testexpr_iterator *it)
cpe_testexpr::cpe_testexpr_set_name
bool cpe_testexpr_set_name(struct cpe_testexpr *expr, struct cpe_name *name)
Set CPE name.
Definition: cpelang_priv.c:702
cpe_testexpr::cpe_testexpr_get_meta_check_system
const char * cpe_testexpr_get_meta_check_system(const struct cpe_testexpr *item)
Get check system to evaluate Only valid for CPE_LANG_OPER_CHECK.
Definition: cpelang_priv.c:669
cpe_testexpr::cpe_testexpr_get_meta_cpe
const struct cpe_name * cpe_testexpr_get_meta_cpe(const struct cpe_testexpr *item)
Get CPE name to match against.
Definition: cpelang_priv.c:661
cpe_lang_model::cpe_lang_model_add_platform
bool cpe_lang_model_add_platform(struct cpe_lang_model *lang, struct cpe_platform *platform)
Add platform to CPE lang model.
Definition: cpelang_priv.c:726
cpe_testexpr::expr
struct oscap_list * expr
array of subexpressions for operators
Definition: cpelang_priv.h:55
CPE_LANG_OPER_MATCH
fact-ref = match given CPE name against available dictionaries
Definition: cpe_lang.h:53
cpe_platform::cpe_platform_set_remark
bool cpe_platform_set_remark(struct cpe_platform *platform, const char *new_remark)
Set remark of CPE platform.
cpe_testexpr::cpe_testexpr_clone
struct cpe_testexpr * cpe_testexpr_clone(struct cpe_testexpr *old_expr)
Clone CPE test expression.
Definition: cpelang_priv.c:151
oscap_text.h
Multilingual text processing interface.
cpe_testexpr_iterator::cpe_testexpr_iterator_next
struct cpe_testexpr * cpe_testexpr_iterator_next(struct cpe_testexpr_iterator *it)
oscap_source
Definition: oscap_source.c:57
cpe_platform::cpe_platform_set_id
bool cpe_platform_set_id(struct cpe_platform *platform, const char *new_id)
Set ID of CPE platform.
cpe_testexpr::cpe_testexpr_get_oper
cpe_lang_oper_t cpe_testexpr_get_oper(const struct cpe_testexpr *item)
cpe_testexpr functions to get variable members
cpe_testexpr::cpe_testexpr_get_next
const struct cpe_testexpr * cpe_testexpr_get_next(const struct cpe_testexpr *expr)
Function to get next expr from array.
Definition: cpelang_priv.c:123
CPE_LANG_OPER_OR
logical OR
Definition: cpe_lang.h:52
cpe_testexpr::cpe_testexpr_iterator_reset
void cpe_testexpr_iterator_reset(struct cpe_testexpr_iterator *it)
Reset function of CPE test expression.
cpe_lang_model::cpe_lang_model_export
void cpe_lang_model_export(const struct cpe_lang_model *spec, const char *file)
Write the lang_model to a file.
Definition: cpelang.c:57
cpe_platform::cpe_platform_free
void cpe_platform_free(struct cpe_platform *platform)
Free function of CPE Platform.
Definition: cpelang_priv.c:596
cpe_name
Structure holding Common Platform Enumeration URI data.
Definition: cpename.c:68
cpe_testexpr
CPE language boolean expression.
Definition: cpelang_priv.h:52
oscap_text
Representation of internationalizable character strings.
Definition: text_priv.h:47
cpe_lang_model::cpe_lang_model_import_source
struct cpe_lang_model * cpe_lang_model_import_source(struct oscap_source *source)
Load CPE language model from an oscap_source.
Definition: cpelang_priv.c:219
cpe_testexpr_iterator::cpe_platform_iterator_reset
void cpe_platform_iterator_reset(struct cpe_platform_iterator *it)
cpe_testexpr_iterator::cpe_testexpr_iterator_free
void cpe_testexpr_iterator_free(struct cpe_testexpr_iterator *it)
CPE_LANG_OPER_INVALID
invalid or unknown operation
Definition: cpe_lang.h:50
cpe_lang_model::cpe_lang_model_import
struct cpe_lang_model * cpe_lang_model_import(const char *file)
Load CPE language model from a XML document.
Definition: cpelang.c:46
cpe_platform
Single platform representation in CPE language.
Definition: cpelang_priv.c:73
cpe_platform_iterator::cpe_platform_iterator_free
void cpe_platform_iterator_free(struct cpe_platform_iterator *it)
cpe_dict_fn
bool *(* cpe_dict_fn)(const struct cpe_name *, void *)
Shared callback definition used to match CPE names to perform applicability tests.
Definition: cpe_name.h:371
cpe_lang_model::cpe_lang_model_get_item
struct cpe_platform * cpe_lang_model_get_item(const struct cpe_lang_model *item, const char *key)
cpe_lang_model function to get CPE platforms
cpe_testexpr::cpe_testexpr_get_meta_check_id
const char * cpe_testexpr_get_meta_check_id(const struct cpe_testexpr *item)
Get check idref to evaluate Only valid for CPE_LANG_OPER_CHECK.
Definition: cpelang_priv.c:685
cpe_platform::cpe_platform_match_cpe
bool cpe_platform_match_cpe(struct cpe_name **cpe, size_t n, const struct cpe_platform *platform)
Function to match cpe in platform.
Definition: cpelang.c:111
CPE_LANG_OPER_AND
logical AND
Definition: cpe_lang.h:51
cpe_testexpr_iterator
Iterator over CPE language expressions.
cpe_testexpr::cpe_testexpr_new
struct cpe_testexpr * cpe_testexpr_new(void)
Constructor of CPE test expression.
Definition: cpelang_priv.c:137
cpe_lang_model::cpe_lang_model_free
void cpe_lang_model_free(struct cpe_lang_model *platformspec)
Free function of CPE test expression.
Definition: cpelang_priv.c:584
CPE_LANG_OPER_MASK
mask to extract the operator w/o possible negation
Definition: cpe_lang.h:56
cpe_platform::cpe_platform_get_id
const char * cpe_platform_get_id(const struct cpe_platform *item)
cpe_platform functions to get id
CPE_LANG_OPER_CHECK
check-ref = evaluate given check
Definition: cpe_lang.h:54
cpe_platform::cpe_platform_get_titles
struct oscap_text_iterator * cpe_platform_get_titles(const struct cpe_platform *item)
cpe_platform functions to get titles