Open SCAP Library
cpe_name.h
Go to the documentation of this file.
1 
15 /*
16  * Copyright 2009 Red Hat Inc., Durham, North Carolina.
17  * All Rights Reserved.
18  *
19  * This library is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU Lesser General Public
21  * License as published by the Free Software Foundation; either
22  * version 2.1 of the License, or (at your option) any later version.
23  *
24  * This library is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27  * Lesser General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public
30  * License along with this library; if not, write to the Free Software
31  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
32  *
33  * Authors:
34  * Lukas Kuklinek <lkuklinek@redhat.com>
35  */
36 
37 #ifndef _CPEURI_H_
38 #define _CPEURI_H_
39 
40 #include <stdbool.h>
41 #include <stdlib.h>
42 #include <stdio.h>
43 #include "oscap_export.h"
44 
46 typedef enum {
51 } cpe_part_t;
52 
53 typedef enum {
58 } cpe_format_t;
59 
66 struct cpe_name;
67 
77 OSCAP_API struct cpe_name *cpe_name_new(const char *cpe);
78 
84 OSCAP_API struct cpe_name * cpe_name_clone(struct cpe_name * old_name);
85 
91 OSCAP_API void cpe_name_free(struct cpe_name *cpe);
92 
93 /************************************************************/
105 OSCAP_API cpe_format_t cpe_name_get_format(const struct cpe_name *cpe);
106 
111 OSCAP_API cpe_part_t cpe_name_get_part(const struct cpe_name *cpe);
112 
117 OSCAP_API const char *cpe_name_get_vendor(const struct cpe_name *cpe);
118 
123 OSCAP_API const char *cpe_name_get_product(const struct cpe_name *cpe);
124 
129 OSCAP_API const char *cpe_name_get_version(const struct cpe_name *cpe);
130 
135 OSCAP_API const char *cpe_name_get_update(const struct cpe_name *cpe);
136 
141 OSCAP_API const char *cpe_name_get_edition(const struct cpe_name *cpe);
142 
147 OSCAP_API const char *cpe_name_get_language(const struct cpe_name *cpe);
148 
153 OSCAP_API const char *cpe_name_get_sw_edition(const struct cpe_name *cpe);
154 
159 OSCAP_API const char *cpe_name_get_target_sw(const struct cpe_name *cpe);
160 
165 OSCAP_API const char *cpe_name_get_target_hw(const struct cpe_name *cpe);
166 
171 OSCAP_API const char *cpe_name_get_other(const struct cpe_name *cpe);
172 
182 OSCAP_API char *cpe_name_get_as_format(const struct cpe_name *cpe, cpe_format_t format);
183 
192 OSCAP_API char *cpe_name_get_as_str(const struct cpe_name *cpe);
193 
194 /************************************************************/
197 /************************************************************/
209 OSCAP_API bool cpe_name_set_format(struct cpe_name *cpe, cpe_format_t newval);
210 
215 OSCAP_API bool cpe_name_set_part(struct cpe_name *cpe, cpe_part_t newval);
216 
221 OSCAP_API bool cpe_name_set_vendor(struct cpe_name *cpe, const char *newval);
222 
227 OSCAP_API bool cpe_name_set_product(struct cpe_name *cpe, const char *newval);
228 
233 OSCAP_API bool cpe_name_set_version(struct cpe_name *cpe, const char *newval);
234 
239 OSCAP_API bool cpe_name_set_update(struct cpe_name *cpe, const char *newval);
240 
245 OSCAP_API bool cpe_name_set_edition(struct cpe_name *cpe, const char *newval);
246 
251 OSCAP_API bool cpe_name_set_language(struct cpe_name *cpe, const char *newval);
252 
257 OSCAP_API bool cpe_name_set_sw_edition(struct cpe_name *cpe, const char *newval);
258 
263 OSCAP_API bool cpe_name_set_target_sw(struct cpe_name *cpe, const char *newval);
264 
269 OSCAP_API bool cpe_name_set_target_hw(struct cpe_name *cpe, const char *newval);
270 
275 OSCAP_API bool cpe_name_set_other(struct cpe_name *cpe, const char *newval);
276 
277 /************************************************************/
280 /************************************************************/
291 OSCAP_API bool cpe_name_match_one(const struct cpe_name *cpe, const struct cpe_name *against);
292 
301 OSCAP_API int cpe_name_write(const struct cpe_name *cpe, FILE * f);
302 
308 OSCAP_API cpe_format_t cpe_name_get_format_of_str(const char *str);
309 
315 OSCAP_API bool cpe_name_check(const char *str);
316 
322 OSCAP_API const char * cpe_name_supported(void);
323 
324 /************************************************************/
341 typedef bool (*cpe_check_fn) (const char*, const char*, const char*, void*);
342 
350 typedef bool (*cpe_dict_fn) (const struct cpe_name*, void*);
351 
352 #endif /* _CPEURI_H_ */
OSCAP_API const char * cpe_name_supported(void)
Get supported version of CPE uri XML.
Definition: cpename.c:719
OSCAP_API const char * cpe_name_get_edition(const struct cpe_name *cpe)
Get CPE name edition field.
OSCAP_API bool cpe_name_set_update(struct cpe_name *cpe, const char *newval)
Set CPE name update field.
available in all CPE versions, default in CPE 2.2 and previous
Definition: cpe_name.h:55
OSCAP_API const char * cpe_name_get_vendor(const struct cpe_name *cpe)
Get CPE name vendor field.
no part specified
Definition: cpe_name.h:47
OSCAP_API cpe_part_t cpe_name_get_part(const struct cpe_name *cpe)
Get CPE name part type field.
OSCAP_API const char * cpe_name_get_target_hw(const struct cpe_name *cpe)
Get CPE name target_hw field.
OSCAP_API const char * cpe_name_get_target_sw(const struct cpe_name *cpe)
Get CPE name target_sw field.
OSCAP_API bool cpe_name_check(const char *str)
Checks whether str is valid CPE string (in any supported format).
Definition: cpename.c:589
OSCAP_API bool cpe_name_set_part(struct cpe_name *cpe, cpe_part_t newval)
Set CPE name part type field.
OSCAP_API bool cpe_name_set_sw_edition(struct cpe_name *cpe, const char *newval)
Set CPE name sw_edition field.
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:601
OSCAP_API bool cpe_name_set_edition(struct cpe_name *cpe, const char *newval)
Set CPE name edition field.
OSCAP_API struct cpe_name * cpe_name_new(const char *cpe)
Create a new CPE structure from string cpe.
Definition: cpename.c:225
OSCAP_API bool cpe_name_set_other(struct cpe_name *cpe, const char *newval)
Set CPE name other field.
cpe_format_t
Definition: cpe_name.h:53
OSCAP_API const char * cpe_name_get_product(const struct cpe_name *cpe)
Get CPE name product field.
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:683
OSCAP_API bool cpe_name_set_product(struct cpe_name *cpe, const char *newval)
Set CPE name product field.
OSCAP_API const char * cpe_name_get_update(const struct cpe_name *cpe)
Get CPE name update field.
available in CPE 2.3 and newer versions, default in CPE 2.3 and newer
Definition: cpe_name.h:57
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
OSCAP_API bool cpe_name_set_version(struct cpe_name *cpe, const char *newval)
Set CPE name version field.
OSCAP_API const char * cpe_name_get_version(const struct cpe_name *cpe)
Get CPE name version field.
can&#39;t be serialized, is usually used to signal errors
Definition: cpe_name.h:54
OSCAP_API const char * cpe_name_get_sw_edition(const struct cpe_name *cpe)
Get CPE name sw_edition field.
OSCAP_API bool cpe_name_set_target_hw(struct cpe_name *cpe, const char *newval)
Set CPE name target_hw field.
application
Definition: cpe_name.h:50
OSCAP_API bool cpe_name_set_language(struct cpe_name *cpe, const char *newval)
Set CPE name language field.
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
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
Structure holding Common Platform Enumeration URI data.
Definition: cpename.c:70
hardware
Definition: cpe_name.h:48
OSCAP_API const char * cpe_name_get_language(const struct cpe_name *cpe)
Get CPE name language field.
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:690
available in CPE 2.3 and newer
Definition: cpe_name.h:56
OSCAP_API void cpe_name_free(struct cpe_name *cpe)
Destructor.
Definition: cpename.c:708
operating system
Definition: cpe_name.h:49
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.
OSCAP_API struct cpe_name * cpe_name_clone(struct cpe_name *old_name)
Clone CPE Name.
Definition: cpename.c:313
OSCAP_API bool cpe_name_set_target_sw(struct cpe_name *cpe, const char *newval)
Set CPE name target_sw field.
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.
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.1.
Definition: cpename.c:527
OSCAP_API bool cpe_name_set_vendor(struct cpe_name *cpe, const char *newval)
Set CPE name vendor field.
cpe_part_t
enumeration of possible CPE parts
Definition: cpe_name.h:46
OSCAP_API const char * cpe_name_get_other(const struct cpe_name *cpe)
Get CPE name other field.