1*592efe25SPierre Pronchery /* 2*592efe25SPierre Pronchery * SPDX-License-Identifier: BSD-2-Clause 3*592efe25SPierre Pronchery * 4*592efe25SPierre Pronchery * Copyright (c) 2025 The FreeBSD Foundation 5*592efe25SPierre Pronchery * 6*592efe25SPierre Pronchery * Portions of this software were developed by 7*592efe25SPierre Pronchery * Tuukka Pasanen <tuukka.pasanen@ilmi.fi> under sponsorship from 8*592efe25SPierre Pronchery * the FreeBSD Foundation 9*592efe25SPierre Pronchery */ 10*592efe25SPierre Pronchery 11*592efe25SPierre Pronchery #ifndef CLI__SPDXTOOL__UTIL_H 12*592efe25SPierre Pronchery #define CLI__SPDXTOOL__UTIL_H 13*592efe25SPierre Pronchery 14*592efe25SPierre Pronchery #include <libpkgconf/libpkgconf.h> 15*592efe25SPierre Pronchery #include <time.h> 16*592efe25SPierre Pronchery 17*592efe25SPierre Pronchery #ifdef __cplusplus 18*592efe25SPierre Pronchery extern "C" { 19*592efe25SPierre Pronchery #endif 20*592efe25SPierre Pronchery 21*592efe25SPierre Pronchery #define SPDXTOOL_SEPARATOR_COLON 0x80 22*592efe25SPierre Pronchery 23*592efe25SPierre Pronchery typedef struct spdxtool_core_agent_ 24*592efe25SPierre Pronchery { 25*592efe25SPierre Pronchery char *spdx_id; 26*592efe25SPierre Pronchery const char *type; 27*592efe25SPierre Pronchery char *creation_info; 28*592efe25SPierre Pronchery char *name; 29*592efe25SPierre Pronchery } spdxtool_core_agent_t; 30*592efe25SPierre Pronchery 31*592efe25SPierre Pronchery typedef struct spdxtool_core_creation_info_ 32*592efe25SPierre Pronchery { 33*592efe25SPierre Pronchery char *id; 34*592efe25SPierre Pronchery const char *type; 35*592efe25SPierre Pronchery char *created; 36*592efe25SPierre Pronchery char *created_by; 37*592efe25SPierre Pronchery const char *created_using; 38*592efe25SPierre Pronchery char *spec_version; 39*592efe25SPierre Pronchery } spdxtool_core_creation_info_t; 40*592efe25SPierre Pronchery 41*592efe25SPierre Pronchery typedef struct spdxtool_core_spdx_document 42*592efe25SPierre Pronchery { 43*592efe25SPierre Pronchery const char *type; 44*592efe25SPierre Pronchery char *spdx_id; 45*592efe25SPierre Pronchery char *creation_info; 46*592efe25SPierre Pronchery char *agent; 47*592efe25SPierre Pronchery pkgconf_list_t licenses; 48*592efe25SPierre Pronchery pkgconf_list_t element; 49*592efe25SPierre Pronchery pkgconf_list_t rootElement; 50*592efe25SPierre Pronchery pkgconf_list_t relationships; 51*592efe25SPierre Pronchery pkgconf_list_t packages; 52*592efe25SPierre Pronchery pkgconf_list_t maintainers; 53*592efe25SPierre Pronchery } spdxtool_core_spdx_document_t; 54*592efe25SPierre Pronchery 55*592efe25SPierre Pronchery typedef struct spdxtool_software_sbom_ 56*592efe25SPierre Pronchery { 57*592efe25SPierre Pronchery char *spdx_id; 58*592efe25SPierre Pronchery const char *type; 59*592efe25SPierre Pronchery char *creation_info; 60*592efe25SPierre Pronchery char *sbom_type; 61*592efe25SPierre Pronchery spdxtool_core_spdx_document_t *spdx_document; 62*592efe25SPierre Pronchery pkgconf_pkg_t *rootElement; 63*592efe25SPierre Pronchery } spdxtool_software_sbom_t; 64*592efe25SPierre Pronchery 65*592efe25SPierre Pronchery typedef struct spdxtool_simplelicensing_license_expression_ 66*592efe25SPierre Pronchery { 67*592efe25SPierre Pronchery const char *type; 68*592efe25SPierre Pronchery char *spdx_id; 69*592efe25SPierre Pronchery char *license_expression; 70*592efe25SPierre Pronchery } spdxtool_simplelicensing_license_expression_t; 71*592efe25SPierre Pronchery 72*592efe25SPierre Pronchery typedef struct spdxtool_core_relationship_ 73*592efe25SPierre Pronchery { 74*592efe25SPierre Pronchery const char *type; 75*592efe25SPierre Pronchery char *spdx_id; 76*592efe25SPierre Pronchery char *creation_info; 77*592efe25SPierre Pronchery char *from; 78*592efe25SPierre Pronchery pkgconf_list_t *to; 79*592efe25SPierre Pronchery char *relationship_type; 80*592efe25SPierre Pronchery char *scope; 81*592efe25SPierre Pronchery } spdxtool_core_relationship_t; 82*592efe25SPierre Pronchery 83*592efe25SPierre Pronchery void 84*592efe25SPierre Pronchery spdxtool_util_set_key(pkgconf_client_t *client, const char *key, const char *key_value, const char *key_default); 85*592efe25SPierre Pronchery 86*592efe25SPierre Pronchery void 87*592efe25SPierre Pronchery spdxtool_util_set_uri_root(pkgconf_client_t *client, const char *uri_root); 88*592efe25SPierre Pronchery 89*592efe25SPierre Pronchery void 90*592efe25SPierre Pronchery spdxtool_util_set_uri_separator_colon(pkgconf_client_t *client, bool sep); 91*592efe25SPierre Pronchery 92*592efe25SPierre Pronchery char 93*592efe25SPierre Pronchery spdxtool_util_get_uri_separator(pkgconf_client_t *client); 94*592efe25SPierre Pronchery 95*592efe25SPierre Pronchery const char * 96*592efe25SPierre Pronchery spdxtool_util_get_uri_root(pkgconf_client_t *client); 97*592efe25SPierre Pronchery 98*592efe25SPierre Pronchery void 99*592efe25SPierre Pronchery spdxtool_util_set_spdx_version(pkgconf_client_t *client, const char *spdx_version); 100*592efe25SPierre Pronchery 101*592efe25SPierre Pronchery const char * 102*592efe25SPierre Pronchery spdxtool_util_get_spdx_version(pkgconf_client_t *client); 103*592efe25SPierre Pronchery 104*592efe25SPierre Pronchery void 105*592efe25SPierre Pronchery spdxtool_util_set_spdx_license(pkgconf_client_t *client, const char *spdx_license); 106*592efe25SPierre Pronchery 107*592efe25SPierre Pronchery char * 108*592efe25SPierre Pronchery spdxtool_util_get_spdx_id_int(pkgconf_client_t *client, const char *part); 109*592efe25SPierre Pronchery 110*592efe25SPierre Pronchery char * 111*592efe25SPierre Pronchery spdxtool_util_get_spdx_id_string(pkgconf_client_t *client, const char *part, const char *string_id); 112*592efe25SPierre Pronchery 113*592efe25SPierre Pronchery char * 114*592efe25SPierre Pronchery spdxtool_util_get_iso8601_time(time_t *wanted_time); 115*592efe25SPierre Pronchery 116*592efe25SPierre Pronchery char * 117*592efe25SPierre Pronchery spdxtool_util_get_current_iso8601_time(void); 118*592efe25SPierre Pronchery 119*592efe25SPierre Pronchery char * 120*592efe25SPierre Pronchery spdxtool_util_string_correction(char *str); 121*592efe25SPierre Pronchery 122*592efe25SPierre Pronchery char * 123*592efe25SPierre Pronchery spdxtool_util_tuple_lookup(pkgconf_client_t *client, pkgconf_list_t *vars, const char *key); 124*592efe25SPierre Pronchery 125*592efe25SPierre Pronchery #ifdef __cplusplus 126*592efe25SPierre Pronchery } 127*592efe25SPierre Pronchery #endif 128*592efe25SPierre Pronchery 129*592efe25SPierre Pronchery #endif 130