| 1 | /** |
| 2 | * @addtogroup CPE |
| 3 | * @{ |
| 4 | * @addtogroup cpeuri CPE URIs |
| 5 | * @{ |
| 6 | * |
| 7 | * |
| 8 | * @file cpe_name.h |
| 9 | * \brief Interface to Common Platform Enumeration (CPE) URI |
| 10 | * |
| 11 | * See more details at http://nvd.nist.gov/cpe.cfm |
| 12 | * |
| 13 | */ |
| 14 | |
| 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 <[email protected]> |
| 35 | */ |
| 36 | |
| 37 | #ifndef _CPEURI_H_ |
| 38 | #define _CPEURI_H_cxx . . $ `src/CPE/public/cpe_name.h:38:9`! |
| 39 | |
| 40 | #include <stdbool.h> |
| 41 | #include <stdlib.h> |
| 42 | #include <stdio.h> |
| 43 | #include "oscap_export.h"cxx . . $ `<file>/src/common/public/oscap_export.h`/ |
| 44 | |
| 45 | /// enumeration of possible CPE parts |
| 46 | typedef enumcxx . . $ $anonymous_type_7d25cc5baa6604fd_0# { |
| 47 | CPE_PART_NONEcxx . . $ CPE_PART_NONE., ///< no part specified |
| 48 | CPE_PART_HWcxx . . $ CPE_PART_HW., ///< hardware |
| 49 | CPE_PART_OScxx . . $ CPE_PART_OS., ///< operating system |
| 50 | CPE_PART_APPcxx . . $ CPE_PART_APP. ///< application |
| 51 | } cpe_part_tcxx . . $ cpe_part_t#; |
| 52 | |
| 53 | typedef enumcxx . . $ $anonymous_type_7d25cc5baa6604fd_1# { |
| 54 | CPE_FORMAT_UNKNOWNcxx . . $ CPE_FORMAT_UNKNOWN., ///< can't be serialized, is usually used to signal errors |
| 55 | CPE_FORMAT_URIcxx . . $ CPE_FORMAT_URI., ///< available in all CPE versions, default in CPE 2.2 and previous |
| 56 | CPE_FORMAT_STRINGcxx . . $ CPE_FORMAT_STRING., ///< available in CPE 2.3 and newer |
| 57 | CPE_FORMAT_WFNcxx . . $ CPE_FORMAT_WFN. ///< available in CPE 2.3 and newer versions, default in CPE 2.3 and newer |
| 58 | } cpe_format_tcxx . . $ cpe_format_t#; |
| 59 | |
| 60 | /** |
| 61 | * @struct cpe_name |
| 62 | * Structure holding Common Platform Enumeration URI data. |
| 63 | * |
| 64 | * Empty components are set to NULL. |
| 65 | */ |
| 66 | struct cpe_namecxx . . $ cpe_name#; |
| 67 | |
| 68 | /** |
| 69 | * Create a new CPE structure from string @a cpe. |
| 70 | * |
| 71 | * @memberof cpe_name |
| 72 | * @note If @a cpe is NULL, empty cpe will be created. |
| 73 | * @param cpe CPE URI string to be parsed |
| 74 | * @return new structure holding parsed data |
| 75 | * @retval NULL on failure |
| 76 | */ |
| 77 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! struct cpe_namecxx . . $ cpe_name# *cpe_name_newcxx . . $ cpe_name_new(dfbdfc9fcef857b).(const char *cpe); |
| 78 | |
| 79 | /** |
| 80 | * Clone CPE Name |
| 81 | * @param old_name CPE name |
| 82 | * @memberof cpe_name |
| 83 | */ |
| 84 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! struct cpe_namecxx . . $ cpe_name# * cpe_name_clonecxx . . $ cpe_name_clone(9f8de1d0fa045834).(struct cpe_namecxx . . $ cpe_name# * old_name); |
| 85 | |
| 86 | /** |
| 87 | * Destructor. Frees any used resources and safely destroys @a cpe. |
| 88 | * @memberof cpe_name |
| 89 | * @param cpe CPE to be deleted |
| 90 | */ |
| 91 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! void cpe_name_freecxx . . $ cpe_name_free(6799d02d05c0f5d7).(struct cpe_namecxx . . $ cpe_name# *cpe); |
| 92 | |
| 93 | /************************************************************/ |
| 94 | /** |
| 95 | * @name Getters |
| 96 | * Return value is pointer to structure's member. Do not free unless you null the pointer in the structure. |
| 97 | * Use remove function otherwise. |
| 98 | * @{ |
| 99 | * */ |
| 100 | |
| 101 | /** |
| 102 | * Get how the CPE name was loaded and how it should be saved |
| 103 | * @memberof cpe_name |
| 104 | */ |
| 105 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! cpe_format_tcxx . . $ cpe_format_t# cpe_name_get_formatcxx . . $ cpe_name_get_format(3d8320da7db56924).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 106 | |
| 107 | /** |
| 108 | * Get CPE name part type field. |
| 109 | * @memberof cpe_name |
| 110 | */ |
| 111 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! cpe_part_tcxx . . $ cpe_part_t# cpe_name_get_partcxx . . $ cpe_name_get_part(29b323fcfe8a3f1b).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 112 | |
| 113 | /** |
| 114 | * Get CPE name vendor field. |
| 115 | * @memberof cpe_name |
| 116 | */ |
| 117 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_vendorcxx . . $ cpe_name_get_vendor(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 118 | |
| 119 | /** |
| 120 | * Get CPE name product field. |
| 121 | * @memberof cpe_name |
| 122 | */ |
| 123 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_productcxx . . $ cpe_name_get_product(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 124 | |
| 125 | /** |
| 126 | * Get CPE name version field. |
| 127 | * @memberof cpe_name |
| 128 | */ |
| 129 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_versioncxx . . $ cpe_name_get_version(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 130 | |
| 131 | /** |
| 132 | * Get CPE name update field. |
| 133 | * @memberof cpe_name |
| 134 | */ |
| 135 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_updatecxx . . $ cpe_name_get_update(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 136 | |
| 137 | /** |
| 138 | * Get CPE name edition field. |
| 139 | * @memberof cpe_name |
| 140 | */ |
| 141 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_editioncxx . . $ cpe_name_get_edition(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 142 | |
| 143 | /** |
| 144 | * Get CPE name language field. |
| 145 | * @memberof cpe_name |
| 146 | */ |
| 147 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_languagecxx . . $ cpe_name_get_language(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 148 | |
| 149 | /** |
| 150 | * Get CPE name sw_edition field. |
| 151 | * @memberof cpe_name |
| 152 | */ |
| 153 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_sw_editioncxx . . $ cpe_name_get_sw_edition(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 154 | |
| 155 | /** |
| 156 | * Get CPE name target_sw field. |
| 157 | * @memberof cpe_name |
| 158 | */ |
| 159 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_target_swcxx . . $ cpe_name_get_target_sw(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 160 | |
| 161 | /** |
| 162 | * Get CPE name target_hw field. |
| 163 | * @memberof cpe_name |
| 164 | */ |
| 165 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_target_hwcxx . . $ cpe_name_get_target_hw(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 166 | |
| 167 | /** |
| 168 | * Get CPE name other field. |
| 169 | * @memberof cpe_name |
| 170 | */ |
| 171 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char *cpe_name_get_othercxx . . $ cpe_name_get_other(ef2083b6d5d2bc20).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 172 | |
| 173 | /** |
| 174 | * Return CPE URI as a new string in specified format. |
| 175 | * @memberof cpe_name |
| 176 | * @note Returned string is newly allocated and is caller's responsibility to free it. |
| 177 | * @param cpe CPE to be converted |
| 178 | * @param format Which format should the string be in |
| 179 | * @return CPE URI as string |
| 180 | * @retval NULL on failure |
| 181 | */ |
| 182 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! char *cpe_name_get_as_formatcxx . . $ cpe_name_get_as_format(d944afa77bbd3357).(const struct cpe_namecxx . . $ cpe_name# *cpe, cpe_format_tcxx . . $ cpe_format_t# format); |
| 183 | |
| 184 | /** |
| 185 | * Return CPE URI as a new string in the format in which it was loaded. |
| 186 | * @memberof cpe_name |
| 187 | * @note Returned string is newly allocated and is caller's responsibility to free it. |
| 188 | * @param cpe CPE to be converted |
| 189 | * @return CPE URI as string |
| 190 | * @retval NULL on failure |
| 191 | */ |
| 192 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! char *cpe_name_get_as_strcxx . . $ cpe_name_get_as_str(ca24c8d7625ff2e2).(const struct cpe_namecxx . . $ cpe_name# *cpe); |
| 193 | |
| 194 | /************************************************************/ |
| 195 | /** @} End of Getters group */ |
| 196 | |
| 197 | /************************************************************/ |
| 198 | /** |
| 199 | * @name Setters |
| 200 | * For lists use add functions. Parameters of set functions are duplicated in memory and need to |
| 201 | * be freed by caller. |
| 202 | * @{ |
| 203 | */ |
| 204 | |
| 205 | /** |
| 206 | * Set how the CPE name was loaded and how it should be saved |
| 207 | * @memberof cpe_name |
| 208 | */ |
| 209 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_formatcxx . . $ cpe_name_set_format(8ea6244cb4fc9cf0).(struct cpe_namecxx . . $ cpe_name# *cpe, cpe_format_tcxx . . $ cpe_format_t# newval); |
| 210 | |
| 211 | /** |
| 212 | * Set CPE name part type field. |
| 213 | * @memberof cpe_name |
| 214 | */ |
| 215 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_partcxx . . $ cpe_name_set_part(93e2ef208903b1fd).(struct cpe_namecxx . . $ cpe_name# *cpe, cpe_part_tcxx . . $ cpe_part_t# newval); |
| 216 | |
| 217 | /** |
| 218 | * Set CPE name vendor field. |
| 219 | * @memberof cpe_name |
| 220 | */ |
| 221 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_vendorcxx . . $ cpe_name_set_vendor(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 222 | |
| 223 | /** |
| 224 | * Set CPE name product field. |
| 225 | * @memberof cpe_name |
| 226 | */ |
| 227 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_productcxx . . $ cpe_name_set_product(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 228 | |
| 229 | /** |
| 230 | * Set CPE name version field. |
| 231 | * @memberof cpe_name |
| 232 | */ |
| 233 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_versioncxx . . $ cpe_name_set_version(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 234 | |
| 235 | /** |
| 236 | * Set CPE name update field. |
| 237 | * @memberof cpe_name |
| 238 | */ |
| 239 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_updatecxx . . $ cpe_name_set_update(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 240 | |
| 241 | /** |
| 242 | * Set CPE name edition field. |
| 243 | * @memberof cpe_name |
| 244 | */ |
| 245 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_editioncxx . . $ cpe_name_set_edition(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 246 | |
| 247 | /** |
| 248 | * Set CPE name language field. |
| 249 | * @memberof cpe_name |
| 250 | */ |
| 251 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_languagecxx . . $ cpe_name_set_language(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 252 | |
| 253 | /** |
| 254 | * Set CPE name sw_edition field. |
| 255 | * @memberof cpe_name |
| 256 | */ |
| 257 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_sw_editioncxx . . $ cpe_name_set_sw_edition(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 258 | |
| 259 | /** |
| 260 | * Set CPE name target_sw field. |
| 261 | * @memberof cpe_name |
| 262 | */ |
| 263 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_target_swcxx . . $ cpe_name_set_target_sw(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 264 | |
| 265 | /** |
| 266 | * Set CPE name target_hw field. |
| 267 | * @memberof cpe_name |
| 268 | */ |
| 269 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_target_hwcxx . . $ cpe_name_set_target_hw(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 270 | |
| 271 | /** |
| 272 | * Set CPE name other field. |
| 273 | * @memberof cpe_name |
| 274 | */ |
| 275 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_set_othercxx . . $ cpe_name_set_other(38f4026cdfc5a13a).(struct cpe_namecxx . . $ cpe_name# *cpe, const char *newval); |
| 276 | |
| 277 | /************************************************************/ |
| 278 | /** @} End of Setters group */ |
| 279 | |
| 280 | /************************************************************/ |
| 281 | /** |
| 282 | * @name Evaluators |
| 283 | * @{ |
| 284 | * */ |
| 285 | |
| 286 | /** |
| 287 | * Check if candidate CPE @a cpe matches CPE @a against |
| 288 | * according to CPE specification v 2.1. |
| 289 | * @memberof cpe_name |
| 290 | */ |
| 291 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_match_onecxx . . $ cpe_name_match_one(4808e5a017f8458a).(const struct cpe_namecxx . . $ cpe_name# *cpe, const struct cpe_namecxx . . $ cpe_name# *against); |
| 292 | |
| 293 | /** |
| 294 | * Write CPE URI @a cpe to file a descriptor @a f |
| 295 | * @memberof cpe_name |
| 296 | * @param cpe cpe to write |
| 297 | * @param f file descriptor to write CPE URI to |
| 298 | * @return number of written characters |
| 299 | * @retval <0 on failure |
| 300 | */ |
| 301 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! int cpe_name_writecxx . . $ cpe_name_write(8b00dff880ab70e4).(const struct cpe_namecxx . . $ cpe_name# *cpe, FILEcxx . . $ FILE# * f); |
| 302 | |
| 303 | /** |
| 304 | * Looks at given string and returns format it is in |
| 305 | * |
| 306 | * CPE_FORMAT_UNKNOWN is used in case of errors |
| 307 | */ |
| 308 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! cpe_format_tcxx . . $ cpe_format_t# cpe_name_get_format_of_strcxx . . $ cpe_name_get_format_of_str(1af0b57d976473a4).(const char *str); |
| 309 | |
| 310 | /** |
| 311 | * Checks whether @a str is valid CPE string (in any supported format). |
| 312 | * @memberof cpe_name |
| 313 | * @param str string to be validated |
| 314 | */ |
| 315 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! cpe_name_checkcxx . . $ cpe_name_check(c5f7da30cbc0f4e9).(const char *str); |
| 316 | |
| 317 | /** |
| 318 | * Get supported version of CPE uri XML |
| 319 | * @return version of XML file format |
| 320 | * @memberof cpe_name |
| 321 | */ |
| 322 | OSCAP_APIcxx . . $ `src/common/public/oscap_export.h:42:15`! const char * cpe_name_supportedcxx . . $ cpe_name_supported(33a1f659e94feb42).(void); |
| 323 | |
| 324 | /************************************************************/ |
| 325 | /** @} End of Evaluators group */ |
| 326 | |
| 327 | /**@}*/ |
| 328 | |
| 329 | /**@}*/ |
| 330 | |
| 331 | /** |
| 332 | * Shared callback definition used to evaluate checks to perform applicability tests |
| 333 | * |
| 334 | * first arg = system |
| 335 | * second arg = href |
| 336 | * third arg = check name / id |
| 337 | * fourth arg = arbitrary pointer / user data |
| 338 | * |
| 339 | * returns true = applicable, false = not applicable |
| 340 | */ |
| 341 | typedef boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! (*cpe_check_fncxx . . $ cpe_check_fn#) (const char*, const char*, const char*, void*); |
| 342 | |
| 343 | /** |
| 344 | * Shared callback definition used to match CPE names to perform applicability tests |
| 345 | * |
| 346 | * first argument = cpe name to match |
| 347 | * second argument = arbitrary pointer / user data |
| 348 | * returns true = matched to existing applicable name, false = not matched/not applicable |
| 349 | */ |
| 350 | typedef boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! (*cpe_dict_fncxx . . $ cpe_dict_fn#) (const struct cpe_namecxx . . $ cpe_name#*, void*); |
| 351 | |
| 352 | #endif /* _CPEURI_H_ */ |