]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_journal_enumerate_fields.xml
man: drop unused <authorgroup> tags from man sources
[thirdparty/systemd.git] / man / sd_journal_enumerate_fields.xml
CommitLineData
eb86030e
LP
1<?xml version='1.0'?> <!--*-nxml-*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<!--
572eb058 6 SPDX-License-Identifier: LGPL-2.1+
eb86030e
LP
7-->
8
7d6b2723 9<refentry id="sd_journal_enumerate_fields" xmlns:xi="http://www.w3.org/2001/XInclude">
eb86030e
LP
10
11 <refentryinfo>
12 <title>sd_journal_enumerate_fields</title>
13 <productname>systemd</productname>
eb86030e
LP
14 </refentryinfo>
15
16 <refmeta>
17 <refentrytitle>sd_journal_enumerate_fields</refentrytitle>
18 <manvolnum>3</manvolnum>
19 </refmeta>
20
21 <refnamediv>
22 <refname>sd_journal_enumerate_fields</refname>
23 <refname>sd_journal_restart_fields</refname>
24 <refname>SD_JOURNAL_FOREACH_FIELD</refname>
25 <refpurpose>Read used field names from the journal</refpurpose>
26 </refnamediv>
27
28 <refsynopsisdiv>
29 <funcsynopsis>
30 <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
31
32 <funcprototype>
33 <funcdef>int <function>sd_journal_enumerate_fields</function></funcdef>
34 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
35 <paramdef>const char **<parameter>field</parameter></paramdef>
36 </funcprototype>
37
38 <funcprototype>
39 <funcdef>void <function>sd_journal_restart_fields</function></funcdef>
40 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
41 </funcprototype>
42
43 <funcprototype>
44 <funcdef><function>SD_JOURNAL_FOREACH_FIELD</function></funcdef>
45 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
46 <paramdef>const char *<parameter>field</parameter></paramdef>
47 </funcprototype>
48
49 </funcsynopsis>
50 </refsynopsisdiv>
51
52 <refsect1>
53 <title>Description</title>
54
55 <para><function>sd_journal_enumerate_fields()</function> may be used to iterate through all field names used in the
56 opened journal files. On each invocation the next field name is returned. The order of the returned field names is
57 not defined. It takes two arguments: the journal context object, plus a pointer to a constant string pointer where
58 the field name is stored in. The returned data is in a read-only memory map and is only valid until the next
59 invocation of <function>sd_journal_enumerate_fields()</function>. Note that this call is subject to the data field
60 size threshold as controlled by <function>sd_journal_set_data_threshold()</function>.</para>
61
62 <para><function>sd_journal_restart_fields()</function> resets the field name enumeration index to the beginning of
63 the list. The next invocation of <function>sd_journal_enumerate_fields()</function> will return the first field
64 name again.</para>
65
66 <para>The <function>SD_JOURNAL_FOREACH_FIELD()</function> macro may be used as a handy wrapper around
67 <function>sd_journal_restart_fields()</function> and <function>sd_journal_enumerate_fields()</function>.</para>
68
69 <para>These functions currently are not influenced by matches set with <function>sd_journal_add_match()</function>
70 but this might change in a later version of this software.</para>
71
72 <para>To retrieve the possible values a specific field can take use
73 <citerefentry><refentrytitle>sd_journal_query_unique</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
74 </refsect1>
75
76 <refsect1>
77 <title>Return Value</title>
78
79 <para><function>sd_journal_enumerate_fields()</function> returns a
80 positive integer if the next field name has been read, 0 when no
81 more field names are known, or a negative errno-style error code.
82 <function>sd_journal_restart_fields()</function> returns
83 nothing.</para>
84 </refsect1>
85
86 <refsect1>
87 <title>Notes</title>
88
a8d46a16
ZJS
89 <para>All functions listed here are thread-agnostic and only a single thread may operate
90 on a given <structname>sd_journal</structname> object.</para>
91
7d6b2723 92 <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
eb86030e
LP
93 </refsect1>
94
95 <refsect1>
96 <title>Examples</title>
97
98 <para>Use the <function>SD_JOURNAL_FOREACH_FIELD</function> macro to iterate through all field names in use in the
99 current journal.</para>
100
101 <programlisting>#include &lt;stdio.h&gt;
102#include &lt;string.h&gt;
103#include &lt;systemd/sd-journal.h&gt;
104
105int main(int argc, char *argv[]) {
106 sd_journal *j;
107 const char *field;
108 int r;
109
110 r = sd_journal_open(&amp;j, SD_JOURNAL_LOCAL_ONLY);
111 if (r &lt; 0) {
112 fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
113 return 1;
114 }
115 SD_JOURNAL_FOREACH_FIELD(j, field)
116 printf("%s\n", field);
117 sd_journal_close(j);
118 return 0;
119}</programlisting>
120
121 </refsect1>
122
123 <refsect1>
124 <title>See Also</title>
125
126 <para>
127 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
128 <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
129 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>sd_journal_query_unique</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132 <citerefentry><refentrytitle>sd_journal_get_data</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>sd_journal_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>
134 </para>
135 </refsect1>
136
137</refentry>