Loading...
Searching...
No Matches
cpe_name.h
Go to the documentation of this file.
/*
* Copyright 2009 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>
*/
#ifndef _CPEURI_H_
#define _CPEURI_H_
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include "oscap_export.h"
typedef enum {
CPE_PART_NONE,
CPE_PART_HW,
CPE_PART_OS,
CPE_PART_APP
} cpe_part_t;
typedef enum {
CPE_FORMAT_UNKNOWN,
CPE_FORMAT_URI,
CPE_FORMAT_STRING,
CPE_FORMAT_WFN
} cpe_format_t;
struct cpe_name;
OSCAP_API struct cpe_name *cpe_name_new(const char *cpe);
OSCAP_API struct cpe_name * cpe_name_clone(struct cpe_name * old_name);
OSCAP_API void cpe_name_free(struct cpe_name *cpe);
/************************************************************/
OSCAP_API cpe_format_t cpe_name_get_format(const struct cpe_name *cpe);
OSCAP_API cpe_part_t cpe_name_get_part(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_vendor(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_product(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_version(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_update(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_edition(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_language(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_sw_edition(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_target_sw(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_target_hw(const struct cpe_name *cpe);
OSCAP_API const char *cpe_name_get_other(const struct cpe_name *cpe);
OSCAP_API char *cpe_name_get_as_format(const struct cpe_name *cpe, cpe_format_t format);
OSCAP_API char *cpe_name_get_as_str(const struct cpe_name *cpe);
/************************************************************/
/************************************************************/
OSCAP_API bool cpe_name_set_format(struct cpe_name *cpe, cpe_format_t newval);
OSCAP_API bool cpe_name_set_part(struct cpe_name *cpe, cpe_part_t newval);
OSCAP_API bool cpe_name_set_vendor(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_product(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_version(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_update(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_edition(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_language(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_sw_edition(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_target_sw(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_target_hw(struct cpe_name *cpe, const char *newval);
OSCAP_API bool cpe_name_set_other(struct cpe_name *cpe, const char *newval);
/************************************************************/
/************************************************************/
OSCAP_API bool cpe_name_match_one(const struct cpe_name *cpe, const struct cpe_name *against);
OSCAP_API int cpe_name_write(const struct cpe_name *cpe, FILE * f);
OSCAP_API cpe_format_t cpe_name_get_format_of_str(const char *str);
OSCAP_API bool cpe_name_check(const char *str);
OSCAP_API const char * cpe_name_supported(void);
/************************************************************/
typedef bool (*cpe_check_fn) (const char*, const char*, const char*, void*);
typedef bool (*cpe_dict_fn) (const struct cpe_name*, void*);
#endif /* _CPEURI_H_ */
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_name::cpe_name_set_product
OSCAP_API bool cpe_name_set_product(struct cpe_name *cpe, const char *newval)
Set CPE name product field.
cpe_name::cpe_name_set_format
OSCAP_API bool cpe_name_set_format(struct cpe_name *cpe, cpe_format_t newval)
Set how the CPE name was loaded and how it should be saved.
cpe_name::cpe_name_get_edition
OSCAP_API const char * cpe_name_get_edition(const struct cpe_name *cpe)
Get CPE name edition field.
cpe_name::cpe_name_check
OSCAP_API bool cpe_name_check(const char *str)
Checks whether str is valid CPE string (in any supported format).
Definition cpename.c:601
cpe_name::cpe_name_get_update
OSCAP_API const char * cpe_name_get_update(const struct cpe_name *cpe)
Get CPE name update field.
cpe_name::cpe_name_get_as_str
OSCAP_API char * cpe_name_get_as_str(const struct cpe_name *cpe)
Return CPE URI as a new string in the format in which it was loaded.
Definition cpename.c:695
cpe_name::cpe_name_get_other
OSCAP_API const char * cpe_name_get_other(const struct cpe_name *cpe)
Get CPE name other field.
cpe_name::cpe_name_get_format
OSCAP_API cpe_format_t cpe_name_get_format(const struct cpe_name *cpe)
Get how the CPE name was loaded and how it should be saved.
cpe_name::cpe_name_set_edition
OSCAP_API bool cpe_name_set_edition(struct cpe_name *cpe, const char *newval)
Set CPE name edition field.
cpe_name::cpe_name_set_other
OSCAP_API bool cpe_name_set_other(struct cpe_name *cpe, const char *newval)
Set CPE name other field.
cpe_name::cpe_name_set_vendor
OSCAP_API bool cpe_name_set_vendor(struct cpe_name *cpe, const char *newval)
Set CPE name vendor field.
cpe_name::cpe_name_get_part
OSCAP_API cpe_part_t cpe_name_get_part(const struct cpe_name *cpe)
Get CPE name part type field.
cpe_name::cpe_name_get_product
OSCAP_API const char * cpe_name_get_product(const struct cpe_name *cpe)
Get CPE name product field.
cpe_part_t
cpe_part_t
enumeration of possible CPE parts
Definition cpe_name.h:46
cpe_name::cpe_name_get_target_sw
OSCAP_API const char * cpe_name_get_target_sw(const struct cpe_name *cpe)
Get CPE name target_sw field.
cpe_name::cpe_name_get_as_format
OSCAP_API char * cpe_name_get_as_format(const struct cpe_name *cpe, cpe_format_t format)
Return CPE URI as a new string in specified format.
Definition cpename.c:613
cpe_name::cpe_name_set_language
OSCAP_API bool cpe_name_set_language(struct cpe_name *cpe, const char *newval)
Set CPE name language field.
cpe_name::cpe_name_get_sw_edition
OSCAP_API const char * cpe_name_get_sw_edition(const struct cpe_name *cpe)
Get CPE name sw_edition field.
cpe_name_get_format_of_str
OSCAP_API cpe_format_t cpe_name_get_format_of_str(const char *str)
Looks at given string and returns format it is in.
Definition cpename.c:547
cpe_name::cpe_name_get_version
OSCAP_API const char * cpe_name_get_version(const struct cpe_name *cpe)
Get CPE name version field.
cpe_name::cpe_name_get_target_hw
OSCAP_API const char * cpe_name_get_target_hw(const struct cpe_name *cpe)
Get CPE name target_hw field.
cpe_name::cpe_name_new
OSCAP_API struct cpe_name * cpe_name_new(const char *cpe)
Create a new CPE structure from string cpe.
Definition cpename.c:225
cpe_name::cpe_name_free
OSCAP_API void cpe_name_free(struct cpe_name *cpe)
Destructor.
Definition cpename.c:720
cpe_name::cpe_name_clone
OSCAP_API struct cpe_name * cpe_name_clone(struct cpe_name *old_name)
Clone CPE Name.
Definition cpename.c:313
cpe_name::cpe_name_get_language
OSCAP_API const char * cpe_name_get_language(const struct cpe_name *cpe)
Get CPE name language field.
cpe_name::cpe_name_write
OSCAP_API int cpe_name_write(const struct cpe_name *cpe, FILE *f)
Write CPE URI cpe to file a descriptor f.
Definition cpename.c:702
cpe_name::cpe_name_set_part
OSCAP_API bool cpe_name_set_part(struct cpe_name *cpe, cpe_part_t newval)
Set CPE name part type field.
cpe_name::cpe_name_get_vendor
OSCAP_API const char * cpe_name_get_vendor(const struct cpe_name *cpe)
Get CPE name vendor field.
cpe_format_t
cpe_format_t
Definition cpe_name.h:53
cpe_name::cpe_name_set_target_sw
OSCAP_API bool cpe_name_set_target_sw(struct cpe_name *cpe, const char *newval)
Set CPE name target_sw field.
cpe_name::cpe_name_set_version
OSCAP_API bool cpe_name_set_version(struct cpe_name *cpe, const char *newval)
Set CPE name version field.
cpe_name::cpe_name_set_update
OSCAP_API bool cpe_name_set_update(struct cpe_name *cpe, const char *newval)
Set CPE name update field.
cpe_name::cpe_name_set_target_hw
OSCAP_API bool cpe_name_set_target_hw(struct cpe_name *cpe, const char *newval)
Set CPE name target_hw field.
cpe_name::cpe_name_set_sw_edition
OSCAP_API bool cpe_name_set_sw_edition(struct cpe_name *cpe, const char *newval)
Set CPE name sw_edition field.
cpe_name::cpe_name_supported
OSCAP_API const char * cpe_name_supported(void)
Get supported version of CPE uri XML.
Definition cpename.c:731
cpe_name::cpe_name_match_one
OSCAP_API bool cpe_name_match_one(const struct cpe_name *cpe, const struct cpe_name *against)
Check if candidate CPE cpe matches CPE against according to CPE specification v 2....
Definition cpename.c:527
CPE_PART_HW
@ CPE_PART_HW
hardware
Definition cpe_name.h:48
CPE_PART_NONE
@ CPE_PART_NONE
no part specified
Definition cpe_name.h:47
CPE_PART_APP
@ CPE_PART_APP
application
Definition cpe_name.h:50
CPE_PART_OS
@ CPE_PART_OS
operating system
Definition cpe_name.h:49
CPE_FORMAT_WFN
@ CPE_FORMAT_WFN
available in CPE 2.3 and newer versions, default in CPE 2.3 and newer
Definition cpe_name.h:57
CPE_FORMAT_URI
@ CPE_FORMAT_URI
available in all CPE versions, default in CPE 2.2 and previous
Definition cpe_name.h:55
CPE_FORMAT_UNKNOWN
@ CPE_FORMAT_UNKNOWN
can't be serialized, is usually used to signal errors
Definition cpe_name.h:54
CPE_FORMAT_STRING
@ CPE_FORMAT_STRING
available in CPE 2.3 and newer
Definition cpe_name.h:56
cpe_name
Structure holding Common Platform Enumeration URI data.
Definition cpename.c:70