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