| AppStream-glib Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <appstream-glib.h> enum AsUtilsError; #define AS_UTILS_ERROR enum AsUtilsFindIconFlag; enum AsUtilsLocation; enum AsMarkupConvertFormat; gchar * as_markup_convert_simple (const gchar *markup,gssize markup_len,GError **error); gchar * as_markup_convert (const gchar *markup,gssize markup_len,AsMarkupConvertFormat format,GError **error); gchar ** as_markup_strsplit_words (const gchar *text,guint line_len); GQuark as_utils_error_quark (void); gboolean as_utils_is_stock_icon_name (const gchar *name); gboolean as_utils_is_spdx_license_id (const gchar *license_id); gboolean as_utils_is_spdx_license (const gchar *license); gboolean as_utils_is_environment_id (const gchar *environment_id); gboolean as_utils_is_category_id (const gchar *category_id); gboolean as_utils_is_blacklisted_id (const gchar *desktop_id); gchar ** as_utils_spdx_license_tokenize (const gchar *license); gchar * as_utils_spdx_license_detokenize (gchar **license_tokens); gboolean as_utils_check_url_exists (const gchar *url,guint timeout,GError **error); gchar * as_utils_find_icon_filename (const gchar *destdir,const gchar *search,GError **error); gchar * as_utils_find_icon_filename_full (const gchar *destdir,const gchar *search,AsUtilsFindIconFlag flags,GError **error); gchar * as_utils_get_string_overlap (const gchar *s1,const gchar *s2); gboolean as_utils_install_filename (AsUtilsLocation location,const gchar *filename,const gchar *origin,const gchar *destdir,GError **error); gboolean as_utils_search_token_valid (const gchar *token); gchar ** as_utils_search_tokenize (const gchar *search); gint as_utils_vercmp (const gchar *version_a,const gchar *version_b);
These functions are used internally to libappstream-glib, and some may be useful to user-applications.
typedef enum {
AS_UTILS_ERROR_FAILED,
AS_UTILS_ERROR_INVALID_TYPE,
} AsUtilsError;
The error type.
typedef enum {
AS_UTILS_FIND_ICON_NONE = 0,
AS_UTILS_FIND_ICON_HI_DPI = 1 << 0,
} AsUtilsFindIconFlag;
The flags used when finding icons.
typedef enum {
AS_UTILS_LOCATION_SHARED,
AS_UTILS_LOCATION_CACHE,
AS_UTILS_LOCATION_USER,
} AsUtilsLocation;
The flags used when installing and removing metadata files.
typedef enum {
AS_MARKUP_CONVERT_FORMAT_SIMPLE,
AS_MARKUP_CONVERT_FORMAT_MARKDOWN,
} AsMarkupConvertFormat;
The output format used when converting AppStream descriptions.
gchar * as_markup_convert_simple (const gchar *markup,gssize markup_len,GError **error);
Converts an XML description into a printable form.
|
the text to copy. |
|
the length of markup, or -1 if markup is NULL terminated. |
|
A GError or NULL
|
Returns : |
a newly allocated NULL terminated string. [transfer full]
|
Since 0.1.0
gchar * as_markup_convert (const gchar *markup,gssize markup_len,AsMarkupConvertFormat format,GError **error);
Converts an XML description into a printable form.
|
the text to copy. |
|
the length of markup, or -1 if markup is NULL terminated. |
|
the AsMarkupConvertFormat, e.g. AS_MARKUP_CONVERT_FORMAT_MARKDOWN
|
|
A GError or NULL
|
Returns : |
a newly allocated NULL terminated string. [transfer full]
|
Since 0.3.5
gchar ** as_markup_strsplit_words (const gchar *text,guint line_len);
Splits up a long line into an array of smaller strings, each being no longer
than line_len. Words are not split.
|
the text to split. |
|
the maximum length of the output line |
Returns : |
lines, or NULL in event of an error. [transfer full]
|
Since 0.3.5
gboolean as_utils_is_stock_icon_name (const gchar *name);
Searches the known list of stock icons.
|
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
gboolean as_utils_is_spdx_license_id (const gchar *license_id);
Searches the known list of SPDX license IDs.
|
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
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.
|
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
gboolean as_utils_is_environment_id (const gchar *environment_id);
Searches the known list of registered environment IDs.
|
a desktop ID, e.g. "GNOME" |
Returns : |
TRUE if the environment ID is valid |
Since 0.2.4
gboolean as_utils_is_category_id (const gchar *category_id);
Searches the known list of registered category IDs.
|
a desktop ID, e.g. "AudioVideoEditing" |
Returns : |
TRUE if the category ID is valid |
Since 0.2.4
gboolean as_utils_is_blacklisted_id (const gchar *desktop_id);
Searches the known list of blacklisted desktop IDs.
|
a desktop ID, e.g. "gimp.desktop" |
Returns : |
TRUE if the desktop ID is blacklisted |
Since 0.2.2
gchar ** as_utils_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.
|
a license string, e.g. "LGPLv2+ and (QPL or GPLv2) and MIT" |
Returns : |
array of strings. [transfer full] |
Since 0.1.5
gchar * as_utils_spdx_license_detokenize (gchar **license_tokens);
De-tokenizes the SPDX licenses into a string.
|
license tokens, typically from as_utils_spdx_license_tokenize()
|
Returns : |
string. [transfer full] |
Since 0.2.5
gboolean as_utils_check_url_exists (const gchar *url,guint timeout,GError **error);
Checks to see if a URL is reachable.
|
the URL to check. |
|
the timeout in seconds. |
|
A GError or NULL
|
Returns : |
TRUE if the URL was reachable and pointed to a non-zero-length file. |
Since 0.1.5
gchar * as_utils_find_icon_filename (const gchar *destdir,const gchar *search,GError **error);
Finds an icon filename from a filesystem root.
|
the destdir. |
|
the icon search name, e.g. "microphone.svg" |
|
A GError or NULL
|
Returns : |
a newly allocated NULL terminated string. [transfer full]
|
Since 0.2.5
gchar * as_utils_find_icon_filename_full (const gchar *destdir,const gchar *search,AsUtilsFindIconFlag flags,GError **error);
Finds an icon filename from a filesystem root.
|
the destdir. |
|
the icon search name, e.g. "microphone.svg" |
|
A AsUtilsFindIconFlag bitfield |
|
A GError or NULL
|
Returns : |
a newly allocated NULL terminated string. [transfer full]
|
Since 0.3.1
gchar * as_utils_get_string_overlap (const gchar *s1,const gchar *s2);
Return a prefix and sufffix that is common to both strings.
|
A string. |
|
Another string |
Returns : |
a newly allocated NULL terminated string, or NULL. [transfer full]
|
Since 0.3.1
gboolean as_utils_install_filename (AsUtilsLocation location,const gchar *filename,const gchar *origin,const gchar *destdir,GError **error);
Installs an AppData, MetaInfo, AppStream XML or AppStream Icon metadata file.
|
the AsUtilsLocation, e.g. AS_UTILS_LOCATION_CACHE
|
|
the full path of the file to install |
|
the origin to use for the installation, or NULL
|
|
the destdir to use, or NULL
|
|
A GError or NULL
|
Returns : |
TRUE for success, FALSE if error is set |
Since 0.3.4
gboolean as_utils_search_token_valid (const gchar *token);
Checks the search token if it is valid. Valid tokens are at least 3 chars in length, not common words like "and", and do not contain markup.
|
the search token |
Returns : |
TRUE is the search token was valid |
Since 0.3.4
gchar ** as_utils_search_tokenize (const gchar *search);
Splits up a string into tokens and returns tokens that are suitable for searching. This includes taking out common words and casefolding the returned search tokens.
|
the search string |
Returns : |
Valid tokens to search for, or NULL for error. [transfer full]
|
Since 0.3.4
gint as_utils_vercmp (const gchar *version_a,const gchar *version_b);
Compares version numbers for sorting. This function cannot deal with version strings that do not contain numbers, for instance "rev2706" or "1.2_alpha".
|
the release version, e.g. 1.2.3 |
|
the release version, e.g. 1.2.3.1 |
Returns : |
-1 if a < b, +1 if a > b, 0 if they are equal, and G_MAXINT on error |
Since 0.3.5