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">
8 <title>sd_hwdb_new</title>
9 <productname>systemd</productname>
13 <refentrytitle>sd_hwdb_new</refentrytitle>
14 <manvolnum>3</manvolnum>
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>
28 <funcsynopsisinfo>#include <systemd/sd-hwdb.h></funcsynopsisinfo>
31 <funcdef>int <function>sd_hwdb_new</function></funcdef>
32 <paramdef>sd_hwdb **<parameter>hwdb</parameter></paramdef>
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>
42 <funcdef>sd_hwdb* <function>sd_hwdb_ref</function></funcdef>
43 <paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
47 <funcdef>sd_hwdb* <function>sd_hwdb_unref</function></funcdef>
48 <paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
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>
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>
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.
84 <para><function>sd_hwdb_unref()</function> always returns <constant>NULL</constant>.
90 <para>Returned errors may indicate the following problems:</para>
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"/>
105 <term><constant>-EINVAL</constant></term>
107 <listitem><para>The located binary hardware database file is in an incompatible format.
110 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
114 <term><constant>-ENOMEM</constant></term>
116 <listitem><para>Memory allocation failed.</para>
118 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
124 <xi:include href="libsystemd-pkgconfig.xml" />
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>
135 <title>See Also</title>
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>