|
| 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 <systemd/sd-hwdb.h></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> |
0 commit comments