/usr/include/openscap/cpe_name.h is in libopenscap-dev 1.2.9-1+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | /**
* @addtogroup CPE
* @{
* @addtogroup cpeuri CPE URIs
* @{
*
*
* @file cpe_name.h
* \brief Interface to Common Platform Enumeration (CPE) URI
*
* See more details at http://nvd.nist.gov/cpe.cfm
*
*/
/*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors:
* Lukas Kuklinek <lkuklinek@redhat.com>
*/
#ifndef _CPEURI_H_
#define _CPEURI_H_
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
/// enumeration of possible CPE parts
typedef enum {
CPE_PART_NONE, ///< no part specified
CPE_PART_HW, ///< hardware
CPE_PART_OS, ///< operating system
CPE_PART_APP ///< application
} cpe_part_t;
typedef enum {
CPE_FORMAT_UNKNOWN, ///< can't be serialized, is usually used to signal errors
CPE_FORMAT_URI, ///< available in all CPE versions, default in CPE 2.2 and previous
CPE_FORMAT_STRING, ///< available in CPE 2.3 and newer
CPE_FORMAT_WFN ///< available in CPE 2.3 and newer versions, default in CPE 2.3 and newer
} cpe_format_t;
/**
* @struct cpe_name
* Structure holding Common Platform Enumeration URI data.
*
* Empty components are set to NULL.
*/
struct cpe_name;
/**
* Create a new CPE structure from string @a cpe.
*
* @memberof cpe_name
* @note If @a cpe is NULL, empty cpe will be created.
* @param cpe CPE URI string to be parsed
* @return new structure holding parsed data
* @retval NULL on failure
*/
struct cpe_name *cpe_name_new(const char *cpe);
/**
* Clone CPE Name
* @param old_name CPE name
* @memberof cpe_name
*/
struct cpe_name * cpe_name_clone(struct cpe_name * old_name);
/**
* Destructor. Frees any used resources and safely destroys @a cpe.
* @memberof cpe_name
* @param cpe CPE to be deleted
*/
void cpe_name_free(struct cpe_name *cpe);
/************************************************************/
/**
* @name Getters
* Return value is pointer to structure's member. Do not free unless you null the pointer in the structure.
* Use remove function otherwise.
* @{
* */
/**
* Get how the CPE name was loaded and how it should be saved
* @memberof cpe_name
*/
cpe_format_t cpe_name_get_format(const struct cpe_name *cpe);
/**
* Get CPE name part type field.
* @memberof cpe_name
*/
cpe_part_t cpe_name_get_part(const struct cpe_name *cpe);
/**
* Get CPE name vendor field.
* @memberof cpe_name
*/
const char *cpe_name_get_vendor(const struct cpe_name *cpe);
/**
* Get CPE name product field.
* @memberof cpe_name
*/
const char *cpe_name_get_product(const struct cpe_name *cpe);
/**
* Get CPE name version field.
* @memberof cpe_name
*/
const char *cpe_name_get_version(const struct cpe_name *cpe);
/**
* Get CPE name update field.
* @memberof cpe_name
*/
const char *cpe_name_get_update(const struct cpe_name *cpe);
/**
* Get CPE name edition field.
* @memberof cpe_name
*/
const char *cpe_name_get_edition(const struct cpe_name *cpe);
/**
* Get CPE name language field.
* @memberof cpe_name
*/
const char *cpe_name_get_language(const struct cpe_name *cpe);
/**
* Get CPE name sw_edition field.
* @memberof cpe_name
*/
const char *cpe_name_get_sw_edition(const struct cpe_name *cpe);
/**
* Get CPE name target_sw field.
* @memberof cpe_name
*/
const char *cpe_name_get_target_sw(const struct cpe_name *cpe);
/**
* Get CPE name target_hw field.
* @memberof cpe_name
*/
const char *cpe_name_get_target_hw(const struct cpe_name *cpe);
/**
* Get CPE name other field.
* @memberof cpe_name
*/
const char *cpe_name_get_other(const struct cpe_name *cpe);
/**
* Return CPE URI as a new string in specified format.
* @memberof cpe_name
* @note Returned string is newly allocated and is caller's responsibility to free it.
* @param cpe CPE to be converted
* @param format Which format should the string be in
* @return CPE URI as string
* @retval NULL on failure
*/
char *cpe_name_get_as_format(const struct cpe_name *cpe, cpe_format_t format);
/**
* Return CPE URI as a new string in the format in which it was loaded.
* @memberof cpe_name
* @note Returned string is newly allocated and is caller's responsibility to free it.
* @param cpe CPE to be converted
* @return CPE URI as string
* @retval NULL on failure
*/
char *cpe_name_get_as_str(const struct cpe_name *cpe);
/************************************************************/
/** @} End of Getters group */
/************************************************************/
/**
* @name Setters
* For lists use add functions. Parameters of set functions are duplicated in memory and need to
* be freed by caller.
* @{
*/
/**
* Set how the CPE name was loaded and how it should be saved
* @memberof cpe_name
*/
bool cpe_name_set_format(struct cpe_name *cpe, cpe_format_t newval);
/**
* Set CPE name part type field.
* @memberof cpe_name
*/
bool cpe_name_set_part(struct cpe_name *cpe, cpe_part_t newval);
/**
* Set CPE name vendor field.
* @memberof cpe_name
*/
bool cpe_name_set_vendor(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name product field.
* @memberof cpe_name
*/
bool cpe_name_set_product(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name version field.
* @memberof cpe_name
*/
bool cpe_name_set_version(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name update field.
* @memberof cpe_name
*/
bool cpe_name_set_update(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name edition field.
* @memberof cpe_name
*/
bool cpe_name_set_edition(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name language field.
* @memberof cpe_name
*/
bool cpe_name_set_language(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name sw_edition field.
* @memberof cpe_name
*/
bool cpe_name_set_sw_edition(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name target_sw field.
* @memberof cpe_name
*/
bool cpe_name_set_target_sw(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name target_hw field.
* @memberof cpe_name
*/
bool cpe_name_set_target_hw(struct cpe_name *cpe, const char *newval);
/**
* Set CPE name other field.
* @memberof cpe_name
*/
bool cpe_name_set_other(struct cpe_name *cpe, const char *newval);
/************************************************************/
/** @} End of Setters group */
/************************************************************/
/**
* @name Evaluators
* @{
* */
/**
* Check if candidate CPE @a cpe matches CPE @a against
* according to CPE specification v 2.1.
* @memberof cpe_name
*/
bool cpe_name_match_one(const struct cpe_name *cpe, const struct cpe_name *against);
/**
* Check if CPE @a name matches any CPE in @a namelist.
* @memberof cpe_name
* @param name name to be looked-up
* @param n number of items in namelist
* @param namelist list of names to search in
* @return true if @a name was found within @a namelist
*/
bool cpe_name_match_cpes(const struct cpe_name *name, size_t n, struct cpe_name **namelist);
/**
* Write CPE URI @a cpe to file a descriptor @a f
* @memberof cpe_name
* @param cpe cpe to write
* @param f file descriptor to write CPE URI to
* @return number of written characters
* @retval <0 on failure
*/
int cpe_name_write(const struct cpe_name *cpe, FILE * f);
/**
* Looks at given string and returns format it is in
*
* CPE_FORMAT_UNKNOWN is used in case of errors
*/
cpe_format_t cpe_name_get_format_of_str(const char *str);
/**
* Checks whether @a str is valid CPE string (in any supported format).
* @memberof cpe_name
* @param str string to be validated
*/
bool cpe_name_check(const char *str);
/**
* Match CPE URI @a candidate against list of @a n CPE URIs given by @a targets.
* @memberof cpe_name
* @param candidate candidarte CPE URI as string
* @param n number of items in targets
* @param targets list of CPE URIs to be candidate matched against
* @return index of first URI in targets, that matched
* @retval -1 on mismatch
* @retval -2 invalid CPE URI was given as parameter
*/
int cpe_name_match_strs(const char *candidate, size_t n, char **targets);
/**
* Get supported version of CPE uri XML
* @return version of XML file format
* @memberof cpe_name
*/
const char * cpe_name_supported(void);
/************************************************************/
/** @} End of Evaluators group */
/**@}*/
/**@}*/
/**
* Shared callback definition used to evaluate checks to perform applicability tests
*
* first arg = system
* second arg = href
* third arg = check name / id
* fourth arg = arbitrary pointer / user data
*
* returns true = applicable, false = not applicable
*/
typedef bool *(*cpe_check_fn) (const char*, const char*, const char*, void*);
/**
* Shared callback definition used to match CPE names to perform applicability tests
*
* first argument = cpe name to match
* second argument = arbitrary pointer / user data
* returns true = matched to existing applicable name, false = not matched/not applicable
*/
typedef bool *(*cpe_dict_fn) (const struct cpe_name*, void*);
#endif /* _CPEURI_H_ */
|