## as-spdx

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

## Functions

gboolean | as_is_spdx_license_id ()
gboolean | as_is_spdx_license_exception_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_id ()
gboolean | as_license_is_metadata_license ()
gboolean | as_license_is_free_license ()
gchar * | as_get_license_url ()

## 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 string is a valid SPDX license ID

Since: 0.9.8

### as_is_spdx_license_exception_id ()

    gboolean
    as_is_spdx_license_exception_id (const gchar *exception_id);

Searches the known list of SPDX license exception IDs.

#### Parameters

exception_id | a single SPDX license exception ID, e.g. "GCC-exception-3.1" |

#### Returns

`TRUE` if the string is a valid SPDX license exception ID

Since: 0.12.10

### 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 licenses 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 license parts of the string e.g. "LGPL-2.0+" are prefexed with "@", the conjunctive replaced with "&", the disjunctive replaced with "|" and the WITH operator for license exceptions 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_id ()

    gboolean
    as_license_is_metadata_license_id (const gchar *license_id);

Tests license ID against the vetted list of licenses that can be used for metainfo metadata. This function will not work for license expressions, if you need to test an SPDX license expression for compliance, please use `as_license_is_metadata_license` insread.

#### Parameters

license_id | a single SPDX license ID, e.g. "FSFAP" |

#### Returns

`TRUE` if the string is a valid metadata license ID.

### 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.

#### Parameters

license | The SPDX license string to test. |

#### Returns

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

### as_license_is_free_license ()

    gboolean
    as_license_is_free_license (const gchar *license);

Check if the given license is for free-as-in-freedom software. A free software license is either approved by the Free Software Foundation or the Open Source Initiative.

This function does *not* yet handle complex license expressions with AND and OR. If the expression contains any of these, it will still simply check if all mentioned licenses are Free licenses. Currently, any license exception recognized by SPDX is assumed to not impact the free-ness status of a software component.

Please note that this function does not give any legal advice. Please read the license texts to learn more about the individual licenses and their conditions.

#### Parameters

license | The SPDX license string to test. |

#### Returns

`TRUE` if the license string contains only free-as-in-freedom licenses.

Since: 0.12.10

### as_get_license_url ()

    gchar *
    as_get_license_url (const gchar *license);

Get a web URL to the license text and more license information for an SPDX license identifier.

#### Parameters

license | The SPDX license ID. |

#### Returns

The license URL.

[transfer full]

Since: 0.12.7