1:255.16-alt1
[systemd_ALT.git] / man / sd_hwdb_new.xml
blob4d02deacc2d481f849cb890267c6eed26b82ef86
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3   "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_hwdb_new" xmlns:xi="http://www.w3.org/2001/XInclude">
7   <refentryinfo>
8     <title>sd_hwdb_new</title>
9     <productname>systemd</productname>
10   </refentryinfo>
12   <refmeta>
13     <refentrytitle>sd_hwdb_new</refentrytitle>
14     <manvolnum>3</manvolnum>
15   </refmeta>
17   <refnamediv>
18     <refname>sd_hwdb_new</refname>
19     <refname>sd_hwdb_new_from_path</refname>
20     <refname>sd_hwdb_ref</refname>
21     <refname>sd_hwdb_unref</refname>
23     <refpurpose>Create a new hwdb object and create or destroy references to it</refpurpose>
24   </refnamediv>
26   <refsynopsisdiv>
27     <funcsynopsis>
28       <funcsynopsisinfo>#include &lt;systemd/sd-hwdb.h&gt;</funcsynopsisinfo>
30       <funcprototype>
31         <funcdef>int <function>sd_hwdb_new</function></funcdef>
32         <paramdef>sd_hwdb **<parameter>hwdb</parameter></paramdef>
33       </funcprototype>
35       <funcprototype>
36         <funcdef>int <function>sd_hwdb_new_from_path</function></funcdef>
37         <paramdef>const char *<parameter>path</parameter></paramdef>
38         <paramdef>sd_hwdb **<parameter>hwdb</parameter></paramdef>
39       </funcprototype>
41       <funcprototype>
42         <funcdef>sd_hwdb* <function>sd_hwdb_ref</function></funcdef>
43         <paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
44       </funcprototype>
46       <funcprototype>
47         <funcdef>sd_hwdb* <function>sd_hwdb_unref</function></funcdef>
48         <paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
49       </funcprototype>
50     </funcsynopsis>
51   </refsynopsisdiv>
53   <refsect1>
54     <title>Description</title>
56     <para><function>sd_hwdb_new()</function> creates a new hwdb object to access the binary hwdb
57     database. Upon initialization, the file containing the binary representation of the hardware database is
58     located and opened. The new object is returned in <parameter>hwdb</parameter>.</para>
60     <para><function>sd_hwdb_new_from_path()</function> may be used to specify the path from which the binary
61     hardware database should be opened.</para>
63     <para>The <parameter>hwdb</parameter> object is reference counted. <function>sd_hwdb_ref()</function> and
64     <function>sd_hwdb_unref()</function> may be used to get a new reference or destroy an existing reference
65     to an object. The caller must dispose of the reference acquired with <function>sd_hwdb_new()</function>
66     by calling <function>sd_hwdb_unref()</function> when done with the object.</para>
68     <para>Use
69     <citerefentry><refentrytitle>sd_hwdb_seek</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
70     <citerefentry><refentrytitle>sd_hwdb_get</refentrytitle><manvolnum>3</manvolnum></citerefentry>, and
71     <citerefentry><refentrytitle>sd_hwdb_enumerate</refentrytitle><manvolnum>3</manvolnum></citerefentry> to
72     access entries.</para>
73   </refsect1>
75   <refsect1>
76     <title>Return Value</title>
78     <para>On success, <function>sd_hwdb_new()</function> and <function>sd_hwdb_new_from_path()</function>
79     return a non-negative integer. On failure, a negative errno-style error code is returned.</para>
81     <para><function>sd_hwdb_ref()</function> always returns the argument.
82     </para>
84     <para><function>sd_hwdb_unref()</function> always returns <constant>NULL</constant>.
85     </para>
87     <refsect2>
88       <title>Errors</title>
90       <para>Returned errors may indicate the following problems:</para>
92       <variablelist>
93         <varlistentry>
94           <term><constant>-ENOENT</constant></term>
96           <listitem><para>The binary hardware database file could not be located. See
97           <citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum></citerefentry>
98           for more information.</para>
100           <xi:include href="version-info.xml" xpointer="v246"/>
101           </listitem>
102         </varlistentry>
104         <varlistentry>
105           <term><constant>-EINVAL</constant></term>
107           <listitem><para>The located binary hardware database file is in an incompatible format.
108           </para>
110           <xi:include href="version-info.xml" xpointer="v246"/></listitem>
111         </varlistentry>
113         <varlistentry>
114           <term><constant>-ENOMEM</constant></term>
116           <listitem><para>Memory allocation failed.</para>
118           <xi:include href="version-info.xml" xpointer="v246"/></listitem>
119         </varlistentry>
120       </variablelist>
121     </refsect2>
122   </refsect1>
124   <xi:include href="libsystemd-pkgconfig.xml" />
126   <refsect1>
127     <title>History</title>
128     <para><function>sd_hwdb_new()</function>,
129     <function>sd_hwdb_ref()</function>, and
130     <function>sd_hwdb_unref()</function> were added in version 246.</para>
131     <para><function>sd_hwdb_new_from_path()</function> was added in version 252.</para>
132   </refsect1>
134   <refsect1>
135     <title>See Also</title>
137     <para>
138       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
139       <citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
140       <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
141       <citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>
142     </para>
143   </refsect1>
145 </refentry>