AppStream-glib Reference Manual: as-utils

## as-utils as-utils — Helper functions that are used inside libappstream-glib |

## Stability Level

Stable, unless otherwise indicated

## Functions

gchar * | as_markup_convert_simple ()
gboolean | as_utils_is_stock_icon_name ()
gboolean | as_utils_is_spdx_license_id ()
gboolean | as_utils_is_spdx_license ()
gboolean | as_utils_is_environment_id ()
gboolean | as_utils_is_category_id ()
gboolean | as_utils_is_blacklisted_id ()
gchar ** | as_utils_spdx_license_tokenize ()
gchar * | as_utils_spdx_license_detokenize ()
gboolean | as_utils_check_url_exists ()
gchar * | as_utils_find_icon_filename ()

## Includes

    #include <appstream-glib.h>

## Description

These functions are used internally to libappstream-glib, and some may be useful to user-applications.

## Functions

### as_markup_convert_simple ()

    gchar *
    as_markup_convert_simple (const gchar *markup,
                              gssize markup_len,
                              GError **error);

Converts an XML description into a printable form.

#### Parameters

markup | the text to copy. |
markup_len | the length of `markup` , or -1 if `markup` is NULL terminated. |
error | A GError or `NULL` |

#### Returns

a newly allocated `NULL` terminated string.

[transfer full]

Since 0.1.0

### as_utils_is_stock_icon_name ()

    gboolean
    as_utils_is_stock_icon_name (const gchar *name);

Searches the known list of stock icons.

#### Parameters

name | an icon name |

#### Returns

`TRUE` if the icon is a "stock icon name" and does not need to be included in the AppStream icon tarball

Since 0.1.3

### as_utils_is_spdx_license_id ()

    gboolean
    as_utils_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. "CC-BY-3.0" |

#### Returns

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

Since 0.1.5

### as_utils_is_spdx_license ()

    gboolean
    as_utils_is_spdx_license (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.2.5

### as_utils_is_environment_id ()

    gboolean
    as_utils_is_environment_id (const gchar *environment_id);

Searches the known list of registered environment IDs.

#### Parameters

environment_id | a desktop ID, e.g. "GNOME" |

#### Returns

`TRUE` if the environment ID is valid

Since 0.2.4

### as_utils_is_category_id ()

    gboolean
    as_utils_is_category_id (const gchar *category_id);

Searches the known list of registered category IDs.

#### Parameters

category_id | a desktop ID, e.g. "AudioVideoEditing" |

#### Returns

`TRUE` if the category ID is valid

Since 0.2.4

### as_utils_is_blacklisted_id ()

    gboolean
    as_utils_is_blacklisted_id (const gchar *desktop_id);

Searches the known list of blacklisted desktop IDs.

#### Parameters

desktop_id | a desktop ID, e.g. "gimp.desktop" |

#### Returns

`TRUE` if the desktop ID is blacklisted

Since 0.2.2

### as_utils_spdx_license_tokenize ()

    gchar **
    as_utils_spdx_license_tokenize (const gchar *license);

Tokenizes the SPDX license string (or any simarly formatted string) into parts. Any non-licence parts of the string e.g. " and " are prefexed with "#".

#### Parameters

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

#### Returns

array of strings.

[transfer full]

Since 0.1.5

### as_utils_spdx_license_detokenize ()

    gchar *
    as_utils_spdx_license_detokenize (gchar **license_tokens);

De-tokenizes the SPDX licenses into a string.

#### Parameters

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

#### Returns

string.

[transfer full]

Since 0.2.5

### as_utils_check_url_exists ()

    gboolean
    as_utils_check_url_exists (const gchar *url,
                               guint timeout,
                               GError **error);

Checks to see if a URL is reachable.

#### Parameters

url | the URL to check. |
timeout | the timeout in seconds. |
error | A GError or `NULL` |

#### Returns

`TRUE` if the URL was reachable and pointed to a non-zero-length file.

Since 0.1.5

### as_utils_find_icon_filename ()

    gchar *
    as_utils_find_icon_filename (const gchar *destdir,
                                 const gchar *search,
                                 GError **error);

Finds an icon filename from a filesystem root.

#### Parameters

destdir | the destdir. |
search | the icon search name, e.g. "microphone.svg" |
error | A GError or `NULL` |

#### Returns

a newly allocated `NULL` terminated string.

[transfer full]

Since 0.2.5

## Types and Values