<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
  <!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
]>
<refentry id="appstream-as-utils">
<refmeta>
<refentrytitle role="top_of_page" id="appstream-as-utils.top_of_page">as-utils</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>APPSTREAM Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>as-utils</refname>
<refpurpose>Helper functions that are used inside libappstream</refpurpose>
</refnamediv>

<refsect1 id="appstream-as-utils.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_return" colwidth="150px"/>
<colspec colname="functions_name"/>
<tbody>
<row><entry role="function_type"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="as-markup-convert-simple">as_markup_convert_simple</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="as-utils-locale-is-compatible">as_utils_locale_is_compatible</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="as-utils-is-category-name">as_utils_is_category_name</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="as-utils-is-tld">as_utils_is_tld</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="as-utils-is-desktop-environment">as_utils_is_desktop_environment</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="as-utils-sort-components-into-categories">as_utils_sort_components_into_categories</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gint"><returnvalue>gint</returnvalue></link>
</entry><entry role="function_name"><link linkend="as-utils-compare-versions">as_utils_compare_versions</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>

<refsect1 id="appstream-as-utils.includes"><title>Includes</title><synopsis>#include &lt;appstream.h&gt;
</synopsis></refsect1>

<refsect1 id="appstream-as-utils.description" role="desc">
<title role="desc.title">Description</title>
<para>Functions which are used in libappstream and might be useful for others
as well.</para>

</refsect1>
<refsect1 id="appstream-as-utils.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="as-markup-convert-simple" role="function">
<title>as_markup_convert_simple&#160;()</title>
<indexterm zone="as-markup-convert-simple"><primary>as_markup_convert_simple</primary></indexterm>
<programlisting language="C"><link linkend="gchar"><returnvalue>gchar</returnvalue></link>&#160;*
as_markup_convert_simple (<parameter>const <link linkend="gchar"><type>gchar</type></link> *markup</parameter>,
                          <parameter><link linkend="GError"><type>GError</type></link> **error</parameter>);</programlisting>
<para>
</para>
</refsect2>
<refsect2 id="as-utils-locale-is-compatible" role="function" condition="since:0.9.5">
<title>as_utils_locale_is_compatible&#160;()</title>
<indexterm zone="as-utils-locale-is-compatible" role="0.9.5"><primary>as_utils_locale_is_compatible</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
as_utils_locale_is_compatible (<parameter>const <link linkend="gchar"><type>gchar</type></link> *locale1</parameter>,
                               <parameter>const <link linkend="gchar"><type>gchar</type></link> *locale2</parameter>);</programlisting>
<para>Calculates if one locale is compatible with another.
When doing the calculation the locale and language code is taken into
account if possible.</para>
<refsect3 id="as-utils-locale-is-compatible.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>locale1</para></entry>
<entry role="parameter_description"><para>a locale string, or <link linkend="NULL:CAPS"><literal>NULL</literal></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>locale2</para></entry>
<entry role="parameter_description"><para>a locale string, or <link linkend="NULL:CAPS"><literal>NULL</literal></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="as-utils-locale-is-compatible.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the locale is compatible.</para>
</refsect3><para role="since">Since: <link linkend="api-index-0.9.5">0.9.5</link></para></refsect2>
<refsect2 id="as-utils-is-category-name" role="function">
<title>as_utils_is_category_name&#160;()</title>
<indexterm zone="as-utils-is-category-name"><primary>as_utils_is_category_name</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
as_utils_is_category_name (<parameter>const <link linkend="gchar"><type>gchar</type></link> *category_name</parameter>);</programlisting>
<para>
</para>
</refsect2>
<refsect2 id="as-utils-is-tld" role="function" condition="since:0.9.8">
<title>as_utils_is_tld&#160;()</title>
<indexterm zone="as-utils-is-tld" role="0.9.8"><primary>as_utils_is_tld</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
as_utils_is_tld (<parameter>const <link linkend="gchar"><type>gchar</type></link> *tld</parameter>);</programlisting>
<para>Searches the known list of TLDs we allow for AppStream IDs.
This excludes internationalized names.</para>
<refsect3 id="as-utils-is-tld.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>tld</para></entry>
<entry role="parameter_description"><para>a top-level domain without dot, e.g. "de", "org", "name"</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="as-utils-is-tld.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the TLD is valid</para>
</refsect3><para role="since">Since: <link linkend="api-index-0.9.8">0.9.8</link></para></refsect2>
<refsect2 id="as-utils-is-desktop-environment" role="function" condition="since:0.10.0">
<title>as_utils_is_desktop_environment&#160;()</title>
<indexterm zone="as-utils-is-desktop-environment" role="0.10.0"><primary>as_utils_is_desktop_environment</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
as_utils_is_desktop_environment (<parameter>const <link linkend="gchar"><type>gchar</type></link> *desktop</parameter>);</programlisting>
<para>Searches the known list of desktop environments AppStream
knows about.</para>
<refsect3 id="as-utils-is-desktop-environment.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>desktop</para></entry>
<entry role="parameter_description"><para>a desktop environment id.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="as-utils-is-desktop-environment.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the desktop-id is valid</para>
</refsect3><para role="since">Since: <link linkend="api-index-0.10.0">0.10.0</link></para></refsect2>
<refsect2 id="as-utils-sort-components-into-categories" role="function">
<title>as_utils_sort_components_into_categories&#160;()</title>
<indexterm zone="as-utils-sort-components-into-categories"><primary>as_utils_sort_components_into_categories</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
as_utils_sort_components_into_categories
                               (<parameter><link linkend="GPtrArray"><type>GPtrArray</type></link> *cpts</parameter>,
                                <parameter><link linkend="GPtrArray"><type>GPtrArray</type></link> *categories</parameter>,
                                <parameter><link linkend="gboolean"><type>gboolean</type></link> check_duplicates</parameter>);</programlisting>
<para>Sorts all components in <parameter>cpts</parameter>
 into the <link linkend="AsCategory"><type>AsCategory</type></link> categories listed in <parameter>categories</parameter>
.</para>
<refsect3 id="as-utils-sort-components-into-categories.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>cpts</para></entry>
<entry role="parameter_description"><para> List of components. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>element-type</acronym> AsComponent]</emphasis></entry></row>
<row><entry role="parameter_name"><para>categories</para></entry>
<entry role="parameter_description"><para> List of categories to sort components into. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>element-type</acronym> AsCategory]</emphasis></entry></row>
<row><entry role="parameter_name"><para>check_duplicates</para></entry>
<entry role="parameter_description"><para>Whether to check for duplicates.</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="as-utils-compare-versions" role="function">
<title>as_utils_compare_versions&#160;()</title>
<indexterm zone="as-utils-compare-versions"><primary>as_utils_compare_versions</primary></indexterm>
<programlisting language="C"><link linkend="gint"><returnvalue>gint</returnvalue></link>
as_utils_compare_versions (<parameter>const <link linkend="gchar"><type>gchar</type></link> *a</parameter>,
                           <parameter>const <link linkend="gchar"><type>gchar</type></link> *b</parameter>);</programlisting>
<para>Compare alpha and numeric segments of two versions.
The version compare algorithm is also used by RPM.</para>
<refsect3 id="as-utils-compare-versions.returns" role="returns">
<title>Returns</title>
<para> 1: a is newer than b
0: a and b are the same version
-1: b is newer than a</para>
</refsect3></refsect2>

</refsect1>
<refsect1 id="appstream-as-utils.other_details" role="details">
<title role="details.title">Types and Values</title>

</refsect1>

</refentry>
