1:255.16-alt1
[systemd_ALT.git] / man / sd_journal_enumerate_fields.xml
blobb2185b3a7c3da411f231d28637433656e94414c3
1 <?xml version='1.0'?> <!--*-nxml-*-->
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_journal_enumerate_fields" xmlns:xi="http://www.w3.org/2001/XInclude">
8   <refentryinfo>
9     <title>sd_journal_enumerate_fields</title>
10     <productname>systemd</productname>
11   </refentryinfo>
13   <refmeta>
14     <refentrytitle>sd_journal_enumerate_fields</refentrytitle>
15     <manvolnum>3</manvolnum>
16   </refmeta>
18   <refnamediv>
19     <refname>sd_journal_enumerate_fields</refname>
20     <refname>sd_journal_restart_fields</refname>
21     <refname>SD_JOURNAL_FOREACH_FIELD</refname>
22     <refpurpose>Read used field names from the journal</refpurpose>
23   </refnamediv>
25   <refsynopsisdiv>
26     <funcsynopsis>
27       <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
29       <funcprototype>
30         <funcdef>int <function>sd_journal_enumerate_fields</function></funcdef>
31         <paramdef>sd_journal *<parameter>j</parameter></paramdef>
32         <paramdef>const char **<parameter>field</parameter></paramdef>
33       </funcprototype>
35       <funcprototype>
36         <funcdef>void <function>sd_journal_restart_fields</function></funcdef>
37         <paramdef>sd_journal *<parameter>j</parameter></paramdef>
38       </funcprototype>
40       <funcprototype>
41         <funcdef><function>SD_JOURNAL_FOREACH_FIELD</function></funcdef>
42         <paramdef>sd_journal *<parameter>j</parameter></paramdef>
43         <paramdef>const char *<parameter>field</parameter></paramdef>
44       </funcprototype>
46     </funcsynopsis>
47   </refsynopsisdiv>
49   <refsect1>
50     <title>Description</title>
52     <para><function>sd_journal_enumerate_fields()</function> may be used to iterate through all field names used in the
53     opened journal files. On each invocation the next field name is returned. The order of the returned field names is
54     not defined. It takes two arguments: the journal context object, plus a pointer to a constant string pointer where
55     the field name is stored in. The returned data is in a read-only memory map and is only valid until the next
56     invocation of <function>sd_journal_enumerate_fields()</function>. Note that this call is subject to the data field
57     size threshold as controlled by <function>sd_journal_set_data_threshold()</function>.</para>
59     <para><function>sd_journal_restart_fields()</function> resets the field name enumeration index to the beginning of
60     the list. The next invocation of <function>sd_journal_enumerate_fields()</function> will return the first field
61     name again.</para>
63     <para>The <function>SD_JOURNAL_FOREACH_FIELD()</function> macro may be used as a handy wrapper around
64     <function>sd_journal_restart_fields()</function> and <function>sd_journal_enumerate_fields()</function>.</para>
66     <para>These functions currently are not influenced by matches set with <function>sd_journal_add_match()</function>
67     but this might change in a later version of this software.</para>
69     <para>To retrieve the possible values a specific field can take use
70     <citerefentry><refentrytitle>sd_journal_query_unique</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
71   </refsect1>
73   <refsect1>
74     <title>Return Value</title>
76     <para><function>sd_journal_enumerate_fields()</function> returns a
77     positive integer if the next field name has been read, 0 when no
78     more field names are known, or a negative errno-style error code.
79     <function>sd_journal_restart_fields()</function> returns
80     nothing.</para>
81   </refsect1>
83   <refsect1>
84     <title>Notes</title>
86     <xi:include href="threads-aware.xml" xpointer="strict" />
88     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
89   </refsect1>
91   <refsect1>
92     <title>Examples</title>
94     <para>Use the <function>SD_JOURNAL_FOREACH_FIELD()</function> macro to iterate through all field names in use in the
95     current journal.</para>
97     <programlisting><xi:include href="journal-enumerate-fields.c" parse="text" /></programlisting>
98   </refsect1>
100   <refsect1>
101     <title>History</title>
102     <para><function>sd_journal_enumerate_fields()</function>,
103     <function>sd_journal_restart_fields()</function>, and
104     <function>SD_JOURNAL_FOREACH_FIELD()</function> were added in version 229.</para>
105   </refsect1>
107   <refsect1>
108     <title>See Also</title>
110     <para>
111       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
112       <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
113       <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
114       <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
115       <citerefentry><refentrytitle>sd_journal_query_unique</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
116       <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
117       <citerefentry><refentrytitle>sd_journal_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>
118     </para>
119   </refsect1>
121 </refentry>