Skip to content

Commit ec7ea47

Browse files
committed
man: add description of all the sd-hwdb funtions
1 parent 21dc5e8 commit ec7ea47

File tree

4 files changed

+313
-0
lines changed

4 files changed

+313
-0
lines changed

man/rules/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ manpages = [
107107
'SD_WARNING'],
108108
''],
109109
['sd-event', '3', [], ''],
110+
['sd-hwdb', '3', [], ''],
110111
['sd-id128',
111112
'3',
112113
['SD_ID128_CONST_STR',
@@ -559,6 +560,8 @@ manpages = [
559560
'3',
560561
['sd_get_machine_names', 'sd_get_sessions', 'sd_get_uids'],
561562
'HAVE_PAM'],
563+
['sd_hwdb_get', '3', ['sd_hwdb_enumerate', 'sd_hwdb_seek'], ''],
564+
['sd_hwdb_new', '3', ['sd_hwdb_ref', 'sd_hwdb_unref'], ''],
562565
['sd_id128_get_machine',
563566
'3',
564567
['sd_id128_get_boot',

man/sd-hwdb.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+ -->
5+
6+
<refentry id="sd-hwdb" xmlns:xi="http://www.w3.org/2001/XInclude">
7+
8+
<refentryinfo>
9+
<title>sd-hwdb</title>
10+
<productname>systemd</productname>
11+
</refentryinfo>
12+
13+
<refmeta>
14+
<refentrytitle>sd-hwdb</refentrytitle>
15+
<manvolnum>3</manvolnum>
16+
</refmeta>
17+
18+
<refnamediv>
19+
<refname>sd-hwdb</refname>
20+
<refpurpose>Read-only access to the hardware description database</refpurpose>
21+
</refnamediv>
22+
23+
<refsynopsisdiv>
24+
<funcsynopsis>
25+
<funcsynopsisinfo>#include &lt;systemd/sd-hwdb.h&gt;</funcsynopsisinfo>
26+
</funcsynopsis>
27+
28+
<cmdsynopsis>
29+
<command>pkg-config --cflags --libs libsystemd</command>
30+
</cmdsynopsis>
31+
32+
</refsynopsisdiv>
33+
34+
<refsect1>
35+
<title>Description</title>
36+
37+
<para><filename>sd-hwdb.h</filename> allows read-only access the systemd database of hardware properties.
38+
See <citerefentry><refentrytitle>hwdb</refentrytitle><manvolnum>7</manvolnum></citerefentry> and
39+
<citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum></citerefentry> for more
40+
information about the database.</para>
41+
42+
<para>See <citerefentry><refentrytitle>sd_hwdb_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
43+
and <citerefentry><refentrytitle>sd_hwdb_get</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
44+
information about the functions available.</para>
45+
</refsect1>
46+
47+
<xi:include href="libsystemd-pkgconfig.xml" />
48+
49+
<refsect1>
50+
<title>See Also</title>
51+
<para>
52+
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
53+
<citerefentry><refentrytitle>systemd-udevd.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
54+
</para>
55+
</refsect1>
56+
57+
</refentry>

man/sd_hwdb_get.xml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
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+ -->
5+
6+
<refentry id="sd_hwdb_get" xmlns:xi="http://www.w3.org/2001/XInclude">
7+
<refentryinfo>
8+
<title>sd_hwdb_get</title>
9+
<productname>systemd</productname>
10+
</refentryinfo>
11+
12+
<refmeta>
13+
<refentrytitle>sd_hwdb_get</refentrytitle>
14+
<manvolnum>3</manvolnum>
15+
</refmeta>
16+
17+
<refnamediv>
18+
<refname>sd_hwdb_get</refname>
19+
<refname>sd_hwdb_seek</refname>
20+
<refname>sd_hwdb_enumerate</refname>
21+
22+
<refpurpose>Seek to a location in hwdb or access entries</refpurpose>
23+
</refnamediv>
24+
25+
<refsynopsisdiv>
26+
<funcsynopsis>
27+
<funcsynopsisinfo>#include &lt;systemd/sd-hwdb.h&gt;</funcsynopsisinfo>
28+
29+
<funcprototype>
30+
<funcdef>int <function>sd_hwdb_get</function></funcdef>
31+
<paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
32+
<paramdef>const char *<parameter>modalias</parameter></paramdef>
33+
<paramdef>const char *<parameter>key</parameter></paramdef>
34+
<paramdef>const char **<parameter>value</parameter></paramdef>
35+
</funcprototype>
36+
37+
<funcprototype>
38+
<funcdef>int <function>sd_hwdb_seek</function></funcdef>
39+
<paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
40+
<paramdef>const char *<parameter>modalias</parameter></paramdef>
41+
</funcprototype>
42+
43+
<funcprototype>
44+
<funcdef>int <function>sd_hwdb_enumerate</function></funcdef>
45+
<paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
46+
<paramdef>const char **<parameter>key</parameter></paramdef>
47+
<paramdef>const char **<parameter>value</parameter></paramdef>
48+
</funcprototype>
49+
50+
</funcsynopsis>
51+
</refsynopsisdiv>
52+
53+
<refsect1>
54+
<title>Description</title>
55+
56+
<para><function>sd_hwdb_get()</function> queries the <parameter>hwdb</parameter> object created earlier
57+
with <citerefentry><refentrytitle>sd_hwdb_new</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
58+
entries matching the specified string <parameter>modalias</parameter>, and returns the value
59+
corresponding to the the key <parameter>key</parameter>. The value is returned as a
60+
<constant>NUL</constant>-terminated string in <parameter>value</parameter>. It must not be modified by
61+
the caller and is valid as long as a reference to <parameter>hwdb</parameter> is kept. When multiple
62+
patterns in the database match <parameter>modalias</parameter>, the one with the highest priority is
63+
used. See <citerefentry><refentrytitle>hwdb</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
64+
details.</para>
65+
66+
<para><function>sd_hwdb_seek()</function> selects entries matching the specified string
67+
<parameter>modalias</parameter>. Subsequent queries with <function>sd_hwdb_enumerate()</function> will
68+
access the key-value pairs for that string.</para>
69+
70+
<para><function>sd_hwdb_enumerate()</function> returns (in turn) all the key-value pairs defined for the
71+
string used with <function>sd_hwdb_seek()</function>. Each pair is returned as
72+
<constant>NUL</constant>-terminated strings in <parameter>key</parameter> and
73+
<parameter>value</parameter>. The strings must not be modified by the caller and are valid as long as a
74+
reference to <parameter>hwdb</parameter> is kept. When multiple patterns in the database match
75+
<parameter>modalias</parameter>, the combination of all matching key-value pairs is used. See
76+
<citerefentry><refentrytitle>hwdb</refentrytitle><manvolnum>7</manvolnum></citerefentry> for
77+
details.</para>
78+
</refsect1>
79+
80+
<refsect1>
81+
<title>Return Value</title>
82+
83+
<para>On success, <function>sd_hwdb_get()</function> and <function>sd_hwdb_seek()</function> return a
84+
non-negative integer. On failure, they return a negative errno-style error code.</para>
85+
86+
<para><function>sd_hwdb_enumerate()</function> returns a positive integer if another key-value pair was found or zero if
87+
all entries have already been enumerated. On failure, it returns a negative errno-style error code.
88+
</para>
89+
90+
<refsect2>
91+
<title>Errors</title>
92+
93+
<para>Returned errors may indicate the following problems:</para>
94+
95+
<variablelist>
96+
<varlistentry>
97+
<term><constant>-EINVAL</constant></term>
98+
99+
<listitem><para>A parameter is <constant>NULL</constant>.</para></listitem>
100+
</varlistentry>
101+
102+
<varlistentry>
103+
<term><constant>-ENOENT</constant></term>
104+
105+
<listitem><para>An entry for the specified <parameter>modalias</parameter> was not found.
106+
</para></listitem>
107+
</varlistentry>
108+
109+
<varlistentry>
110+
<term><constant>-EAGAIN</constant></term>
111+
112+
<listitem><para><function>sd_hwdb_seek()</function> was not called before
113+
<function>sd_hwdb_enumerate()</function>.</para></listitem>
114+
</varlistentry>
115+
</variablelist>
116+
</refsect2>
117+
</refsect1>
118+
119+
<xi:include href="libsystemd-pkgconfig.xml" />
120+
121+
<refsect1>
122+
<title>See Also</title>
123+
124+
<para>
125+
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
126+
<citerefentry><refentrytitle>systemd-udev.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
127+
<citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
128+
<citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum></citerefentry>
129+
</para>
130+
</refsect1>
131+
132+
</refentry>

man/sd_hwdb_new.xml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+ -->
5+
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>
11+
12+
<refmeta>
13+
<refentrytitle>sd_hwdb_new</refentrytitle>
14+
<manvolnum>3</manvolnum>
15+
</refmeta>
16+
17+
<refnamediv>
18+
<refname>sd_hwdb_new</refname>
19+
<refname>sd_hwdb_ref</refname>
20+
<refname>sd_hwdb_unref</refname>
21+
22+
<refpurpose>Create a new hwdb object and create or destroy references to it</refpurpose>
23+
</refnamediv>
24+
25+
<refsynopsisdiv>
26+
<funcsynopsis>
27+
<funcsynopsisinfo>#include &lt;systemd/sd-hwdb.h&gt;</funcsynopsisinfo>
28+
29+
<funcprototype>
30+
<funcdef>int <function>sd_hwdb_new</function></funcdef>
31+
<paramdef>sd_hwdb **<parameter>hwdb</parameter></paramdef>
32+
</funcprototype>
33+
34+
<funcprototype>
35+
<funcdef>sd_hwdb* <function>sd_hwdb_ref</function></funcdef>
36+
<paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
37+
</funcprototype>
38+
39+
<funcprototype>
40+
<funcdef>sd_hwdb* <function>sd_hwdb_unref</function></funcdef>
41+
<paramdef>sd_hwdb *<parameter>hwdb</parameter></paramdef>
42+
</funcprototype>
43+
</funcsynopsis>
44+
</refsynopsisdiv>
45+
46+
<refsect1>
47+
<title>Description</title>
48+
49+
<para><function>sd_hwdb_new()</function> creates a new hwdb object to access the binary hwdb
50+
database. Upon initialization, the file containing the binary representation of the hardware database is
51+
located and opened. The new object is returned in <parameter>hwdb</parameter>.</para>
52+
53+
<para>The <parameter>hwdb</parameter> object is reference counted. <function>sd_hwdb_ref()</function> and
54+
<function>sd_hwdb_unref()</function> may be used to get a new reference or destroy an existing reference
55+
to an object. The caller must dispose of the reference acquired with <function>sd_hwdb_new()</function>
56+
by calling <function>sd_hwdb_unref()</function> when done with the object.</para>
57+
58+
<para>Use
59+
<citerefentry><refentrytitle>sd_hwdb_seek</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
60+
<citerefentry><refentrytitle>sd_hwdb_get</refentrytitle><manvolnum>3</manvolnum></citerefentry>, and
61+
<citerefentry><refentrytitle>sd_hwdb_enumerate</refentrytitle><manvolnum>3</manvolnum></citerefentry> to
62+
access entries.</para>
63+
</refsect1>
64+
65+
<refsect1>
66+
<title>Return Value</title>
67+
68+
<para>On success, <function>sd_hwdb_new()</function> returns a non-negative integer. On
69+
failure, it returns a negative errno-style error code.</para>
70+
71+
<para><function>sd_hwdb_ref()</function> always returns the argument.
72+
</para>
73+
74+
<para><function>sd_hwdb_unref()</function> always returns <constant>NULL</constant>.
75+
</para>
76+
77+
<refsect2>
78+
<title>Errors</title>
79+
80+
<para>Returned errors may indicate the following problems:</para>
81+
82+
<variablelist>
83+
<varlistentry>
84+
<term><constant>-ENOENT</constant></term>
85+
86+
<listitem><para>The binary hardware database file could not be located. See
87+
<citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>8</manvolnum></citerefentry>
88+
for more information.</para>
89+
</listitem>
90+
</varlistentry>
91+
92+
<varlistentry>
93+
<term><constant>-EINVAL</constant></term>
94+
95+
<listitem><para>The located binary hardware database file is in an incompatible format.
96+
</para></listitem>
97+
</varlistentry>
98+
99+
<varlistentry>
100+
<term><constant>-ENOMEM</constant></term>
101+
102+
<listitem><para>Memory allocation failed.</para></listitem>
103+
</varlistentry>
104+
</variablelist>
105+
</refsect2>
106+
</refsect1>
107+
108+
<xi:include href="libsystemd-pkgconfig.xml" />
109+
110+
<refsect1>
111+
<title>See Also</title>
112+
113+
<para>
114+
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
115+
<citerefentry><refentrytitle>systemd-udev.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
116+
<citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
117+
<citerefentry><refentrytitle>systemd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>
118+
</para>
119+
</refsect1>
120+
121+
</refentry>

0 commit comments

Comments
 (0)