Loading...
Searching...
No Matches
cpe_lang.h
Go to the documentation of this file.
/*
* Copyright 2009--2014 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
* Lukas Kuklinek <lkuklinek@redhat.com>
* Maros Barabas <mbarabas@redhat.com>
*/
#ifndef CPELANG_H_
#define CPELANG_H_
#include <stdlib.h>
#include "cpe_name.h"
#include "oscap.h"
#include "oscap_text.h"
#include "oscap_source.h"
#include "oscap_export.h"
typedef enum {
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_lang_oper_t;
struct cpe_lang_model;
struct cpe_platform;
struct cpe_testexpr;
/************************************************************/
struct cpe_platform_iterator;
OSCAP_API struct cpe_platform *cpe_platform_iterator_next(struct cpe_platform_iterator *it);
OSCAP_API bool cpe_platform_iterator_has_more(struct cpe_platform_iterator *it);
OSCAP_API void cpe_platform_iterator_free(struct cpe_platform_iterator *it);
struct cpe_testexpr_iterator;
OSCAP_API struct cpe_testexpr *cpe_testexpr_iterator_next(struct cpe_testexpr_iterator *it);
OSCAP_API bool cpe_testexpr_iterator_has_more(struct cpe_testexpr_iterator *it);
OSCAP_API void cpe_testexpr_iterator_free(struct cpe_testexpr_iterator *it);
/************************************************************/
/************************************************************/
OSCAP_API cpe_lang_oper_t cpe_testexpr_get_oper(const struct cpe_testexpr *item);
OSCAP_API struct cpe_testexpr_iterator *cpe_testexpr_get_meta_expr(const struct cpe_testexpr *item);
OSCAP_API const struct cpe_name *cpe_testexpr_get_meta_cpe(const struct cpe_testexpr *item);
OSCAP_API const char* cpe_testexpr_get_meta_check_system(const struct cpe_testexpr *item);
OSCAP_API const char* cpe_testexpr_get_meta_check_href(const struct cpe_testexpr *item);
OSCAP_API const char* cpe_testexpr_get_meta_check_id(const struct cpe_testexpr *item);
OSCAP_API const struct cpe_testexpr *cpe_testexpr_get_next(const struct cpe_testexpr *expr);
OSCAP_API struct cpe_platform_iterator *cpe_lang_model_get_platforms(const struct cpe_lang_model *item);
OSCAP_API struct cpe_platform *cpe_lang_model_get_item(const struct cpe_lang_model *item, const char *key);
OSCAP_API 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);
OSCAP_API const char *cpe_platform_get_id(const struct cpe_platform *item);
OSCAP_API const char *cpe_platform_get_remark(const struct cpe_platform *item);
OSCAP_API struct oscap_text_iterator *cpe_platform_get_titles(const struct cpe_platform *item);
OSCAP_API const struct cpe_testexpr *cpe_platform_get_expr(const struct cpe_platform *item);
/************************************************************/
/************************************************************/
OSCAP_API bool cpe_lang_model_add_platform(struct cpe_lang_model *lang, struct cpe_platform *platform);
OSCAP_API bool cpe_platform_add_title(struct cpe_platform *platform, struct oscap_text *title);
/*bool cpe_lang_model_add_xmlns(struct cpe_lang_model * model, struct xml_metadata * xml);*/
OSCAP_API bool cpe_testexpr_add_subexpression(struct cpe_testexpr *expr, struct cpe_testexpr *sub);
OSCAP_API bool cpe_platform_set_id(struct cpe_platform *platform, const char *new_id);
OSCAP_API bool cpe_platform_set_remark(struct cpe_platform *platform, const char *new_remark);
OSCAP_API bool cpe_platform_set_expr(struct cpe_platform *platform, struct cpe_testexpr *expr);
OSCAP_API bool cpe_testexpr_set_oper(struct cpe_testexpr *expr, cpe_lang_oper_t oper);
OSCAP_API bool cpe_testexpr_set_name(struct cpe_testexpr *expr, struct cpe_name *name);
/************************************************************/
OSCAP_API void cpe_platform_iterator_remove(struct cpe_platform_iterator *it, struct cpe_lang_model *parent);
OSCAP_API void cpe_platform_iterator_reset(struct cpe_platform_iterator *it);
OSCAP_API struct cpe_lang_model *cpe_lang_model_new(void);
OSCAP_API struct cpe_testexpr *cpe_testexpr_new(void);
OSCAP_API struct cpe_platform *cpe_platform_new(void);
OSCAP_API struct cpe_testexpr * cpe_testexpr_clone(struct cpe_testexpr * old_expr);
OSCAP_API void cpe_testexpr_free(struct cpe_testexpr *expr);
OSCAP_API void cpe_testexpr_iterator_reset(struct cpe_testexpr_iterator *it);
OSCAP_API void cpe_lang_model_free(struct cpe_lang_model *platformspec);
OSCAP_API void cpe_platform_free(struct cpe_platform *platform);
/************************************************************/
OSCAP_API const char * cpe_lang_model_supported(void);
/************************************************************/
OSCAP_API struct cpe_lang_model *cpe_lang_model_import_source(struct oscap_source *source);
OSCAP_API void cpe_lang_model_export(const struct cpe_lang_model *spec, const char *file);
#endif /* _CPELANG_H_ */
cpe_name.h
Interface to Common Platform Enumeration (CPE) URI.
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:341
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:350
cpe_platform::cpe_platform_get_expr
OSCAP_API const struct cpe_testexpr * cpe_platform_get_expr(const struct cpe_platform *item)
cpe_platform functions to get test expression
cpe_testexpr::cpe_testexpr_add_subexpression
OSCAP_API bool cpe_testexpr_add_subexpression(struct cpe_testexpr *expr, struct cpe_testexpr *sub)
Add XML namespace to CPE lang model.
Definition cpelang_priv.c:710
cpe_lang_model::cpe_lang_model_get_platforms
OSCAP_API struct cpe_platform_iterator * cpe_lang_model_get_platforms(const struct cpe_lang_model *item)
cpe_lang_model function to get CPE platforms
cpe_testexpr::cpe_testexpr_set_name
OSCAP_API bool cpe_testexpr_set_name(struct cpe_testexpr *expr, struct cpe_name *name)
Set CPE name.
Definition cpelang_priv.c:698
cpe_testexpr::cpe_testexpr_get_meta_expr
OSCAP_API struct cpe_testexpr_iterator * cpe_testexpr_get_meta_expr(const struct cpe_testexpr *item)
Get CPE expression subexpression.
Definition cpelang_priv.c:649
cpe_testexpr::cpe_testexpr_new
OSCAP_API struct cpe_testexpr * cpe_testexpr_new(void)
Constructor of CPE test expression.
Definition cpelang_priv.c:137
cpe_testexpr::cpe_testexpr_set_oper
OSCAP_API bool cpe_testexpr_set_oper(struct cpe_testexpr *expr, cpe_lang_oper_t oper)
Set CPE operation.
Definition cpelang_priv.c:689
cpe_testexpr::cpe_testexpr_free
OSCAP_API void cpe_testexpr_free(struct cpe_testexpr *expr)
Free function of CPE test expression.
Definition cpelang_priv.c:631
cpe_platform::cpe_platform_add_title
OSCAP_API bool cpe_platform_add_title(struct cpe_platform *platform, struct oscap_text *title)
Add title to platform.
cpe_platform::cpe_platform_set_remark
OSCAP_API bool cpe_platform_set_remark(struct cpe_platform *platform, const char *new_remark)
Set remark of CPE platform.
cpe_testexpr::cpe_testexpr_iterator_reset
OSCAP_API void cpe_testexpr_iterator_reset(struct cpe_testexpr_iterator *it)
Reset function of CPE test expression.
cpe_platform::cpe_platform_get_remark
OSCAP_API const char * cpe_platform_get_remark(const struct cpe_platform *item)
cpe_platform functions to get remark
cpe_platform::cpe_platform_new
OSCAP_API struct cpe_platform * cpe_platform_new(void)
Constructor of CPE Platform.
Definition cpelang_priv.c:192
cpe_lang_model::cpe_platform_applicable_lang_model
OSCAP_API 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:123
cpe_platform::cpe_platform_set_id
OSCAP_API bool cpe_platform_set_id(struct cpe_platform *platform, const char *new_id)
Set ID of CPE platform.
cpe_lang_model::cpe_lang_model_export
OSCAP_API void cpe_lang_model_export(const struct cpe_lang_model *spec, const char *file)
Write the lang_model to a file.
Definition cpelang.c:46
cpe_testexpr::cpe_testexpr_get_meta_check_href
OSCAP_API 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:673
cpe_testexpr::cpe_testexpr_get_next
OSCAP_API 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_testexpr::cpe_testexpr_clone
OSCAP_API struct cpe_testexpr * cpe_testexpr_clone(struct cpe_testexpr *old_expr)
Clone CPE test expression.
Definition cpelang_priv.c:151
cpe_lang_model::cpe_lang_model_new
OSCAP_API struct cpe_lang_model * cpe_lang_model_new(void)
Constructor of CPE Language model.
Definition cpelang_priv.c:176
cpe_testexpr::cpe_testexpr_get_oper
OSCAP_API cpe_lang_oper_t cpe_testexpr_get_oper(const struct cpe_testexpr *item)
cpe_testexpr functions to get variable members
cpe_platform::cpe_platform_get_id
OSCAP_API const char * cpe_platform_get_id(const struct cpe_platform *item)
cpe_platform functions to get id
cpe_lang_model::cpe_lang_model_get_item
OSCAP_API 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_lang_oper_t
cpe_lang_oper_t
CPE language operators.
Definition cpe_lang.h:50
cpe_testexpr::cpe_testexpr_get_meta_check_system
OSCAP_API 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:665
cpe_testexpr::cpe_testexpr_get_meta_cpe
OSCAP_API const struct cpe_name * cpe_testexpr_get_meta_cpe(const struct cpe_testexpr *item)
Get CPE name to match against.
Definition cpelang_priv.c:657
cpe_testexpr::cpe_testexpr_get_meta_check_id
OSCAP_API 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:681
cpe_platform::cpe_platform_set_expr
OSCAP_API bool cpe_platform_set_expr(struct cpe_platform *platform, struct cpe_testexpr *expr)
Set evaluation expression for this CPE platform.
Definition cpelang_priv.c:740
cpe_platform::cpe_platform_get_titles
OSCAP_API struct oscap_text_iterator * cpe_platform_get_titles(const struct cpe_platform *item)
cpe_platform functions to get titles
cpe_lang_model::cpe_lang_model_import_source
OSCAP_API 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_LANG_OPER_CHECK
@ CPE_LANG_OPER_CHECK
check-ref = evaluate given check
Definition cpe_lang.h:55
CPE_LANG_OPER_MASK
@ CPE_LANG_OPER_MASK
mask to extract the operator w/o possible negation
Definition cpe_lang.h:57
CPE_LANG_OPER_AND
@ CPE_LANG_OPER_AND
logical AND
Definition cpe_lang.h:52
CPE_LANG_OPER_MATCH
@ CPE_LANG_OPER_MATCH
fact-ref = match given CPE name against available dictionaries
Definition cpe_lang.h:54
CPE_LANG_OPER_NOT
@ CPE_LANG_OPER_NOT
negate
Definition cpe_lang.h:58
CPE_LANG_OPER_OR
@ CPE_LANG_OPER_OR
logical OR
Definition cpe_lang.h:53
CPE_LANG_OPER_INVALID
@ CPE_LANG_OPER_INVALID
invalid or unknown operation
Definition cpe_lang.h:51
oscap.h
General OpenScap functions and types.
oscap_text.h
Multilingual text processing interface.
cpe_lang_model
CPE platform specification.
Definition cpelang_priv.c:63
cpe_name
Structure holding Common Platform Enumeration URI data.
Definition cpename.c:70
cpe_platform_iterator
Iterator over CPE dictionary items.
cpe_platform
Single platform representation in CPE language.
Definition cpelang_priv.c:73
cpe_testexpr_iterator
Iterator over CPE language expressions.
cpe_testexpr
CPE language boolean expression.
Definition cpelang_priv.h:51
cpe_testexpr::oper
cpe_lang_oper_t oper
operator
Definition cpelang_priv.h:52
cpe_testexpr::expr
struct oscap_list * expr
array of subexpressions for operators
Definition cpelang_priv.h:54
oscap_source
Definition oscap_source.c:66
oscap_text_iterator
Internationalized string iterator.
oscap_text
Representation of internationalizable character strings.
Definition text_priv.h:46