## as-spdx as-spdx — Helper functions to work with SPDX license descriptions. |

## Functions

gboolean | as_is_spdx_license_id ()
gboolean | as_is_spdx_license_expression ()
gchar ** | as_spdx_license_tokenize ()
gchar * | as_spdx_license_detokenize ()
gchar * | as_license_to_spdx_id ()
gboolean | as_license_is_metadata_license ()

## Includes

    #include <appstream.h>

## Description

## Functions

### as_is_spdx_license_id ()

    gboolean
    as_is_spdx_license_id (const gchar *license_id);

Searches the known list of SPDX license IDs.

#### Parameters

license_id | a single SPDX license ID, e.g. "GPL-3.0" |

#### Returns

`TRUE` if the icon is a valid "SPDX license ID"

Since: 0.9.8

### as_is_spdx_license_expression ()

    gboolean
    as_is_spdx_license_expression (const gchar *license);

Checks the licence string to check it being a valid licence. NOTE: SPDX licences can't typically contain brackets.

#### Parameters

license | a SPDX license string, e.g. "CC-BY-3.0 and GFDL-1.3" |

#### Returns

`TRUE` if the icon is a valid "SPDX license"

Since: 0.9.8

### as_spdx_license_tokenize ()

    gchar **
    as_spdx_license_tokenize (const gchar *license);

Tokenizes the SPDX license string (or any simarly formatted string) into parts. Any licence parts of the string e.g. "LGPL-2.0+" are prefexed with "@", the conjunctive replaced with "&" and the disjunctive replaced with "|". Brackets are added as indervidual tokens and other strings are appended into single tokens where possible.

#### Parameters

license | a license string, e.g. "LGPLv2+ and (QPL or GPLv2) and MIT" |

#### Returns

array of strings, or `NULL` for invalid.

[transfer full][nullable]

Since: 0.9.8

### as_spdx_license_detokenize ()

    gchar *
    as_spdx_license_detokenize (gchar **license_tokens);

De-tokenizes the SPDX licenses into a string.

#### Parameters

license_tokens | license tokens, typically from `as_spdx_license_tokenize()` |

#### Returns

string, or `NULL` for invalid.

[transfer full][nullable]

Since: 0.9.8

### as_license_to_spdx_id ()

    gchar *
    as_license_to_spdx_id (const gchar *license);

Converts a non-SPDX license into an SPDX format string where possible.

#### Parameters

license | a not-quite SPDX license string, e.g. "GPLv3+" |

#### Returns

the best-effort SPDX license string

Since: 0.9.8

### as_license_is_metadata_license ()

    gboolean
    as_license_is_metadata_license (const gchar *license);

Check if the metadata license is suitable for mixing with other metadata and redistributing the bundled result (this means we prefer permissive licenses here, to not require people shipping catalog metadata to perform a full license review).

This method checks against a hardcoded list of permissive licenses commonly used to license metadata under.

Retrurns: `TRUE` if the license contains only permissive licenses suitable as metadata license.

#### Parameters

license | The SPDX license string to test. |

## Types and Values