Debian Codegraph @

upstream/debian-unstable/man3/sd_journal_get_data.3

raw
1 '\" t
2 .TH "SD_JOURNAL_GET_DATA" "3" "" "systemd 261~rc3" "sd_journal_get_data"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_journal_get_data, sd_journal_enumerate_data, sd_journal_enumerate_available_data, sd_journal_restart_data, SD_JOURNAL_FOREACH_DATA, sd_journal_set_data_threshold, sd_journal_get_data_threshold \- Read data fields from the current journal entry
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-journal\&.h>
29 .fi
30 .ft
31 .HP \w'int\ sd_journal_get_data('u
32 .BI "int sd_journal_get_data(sd_journal\ *" "j" ", const\ char\ *" "field" ", const\ void\ **" "data" ", size_t\ *" "length" ");"
33 .HP \w'int\ sd_journal_enumerate_data('u
34 .BI "int sd_journal_enumerate_data(sd_journal\ *" "j" ", const\ void\ **" "data" ", size_t\ *" "length" ");"
35 .HP \w'int\ sd_journal_enumerate_available_data('u
36 .BI "int sd_journal_enumerate_available_data(sd_journal\ *" "j" ", const\ void\ **" "data" ", size_t\ *" "length" ");"
37 .HP \w'void\ sd_journal_restart_data('u
38 .BI "void sd_journal_restart_data(sd_journal\ *" "j" ");"
39 .HP \w'SD_JOURNAL_FOREACH_DATA('u
40 .BI "SD_JOURNAL_FOREACH_DATA(sd_journal\ *" "j" ", const\ void\ *" "data" ", size_t\ " "length" ");"
41 .HP \w'int\ sd_journal_set_data_threshold('u
42 .BI "int sd_journal_set_data_threshold(sd_journal\ *" "j" ", size_t\ " "sz" ");"
43 .HP \w'int\ sd_journal_get_data_threshold('u
44 .BI "int sd_journal_get_data_threshold(sd_journal\ *" "j" ", size_t\ *" "sz" ");"
45 .SH "DESCRIPTION"
46 .PP
47 \fBsd_journal_get_data()\fR
48 gets the data object associated with a specific field from the current journal entry\&. It takes four arguments: the journal context object, a string with the field name to request, plus a pair of optional pointers to pointer/size variables where the data object and its size shall be stored in\&. Either pointer may be
49 \fBNULL\fR, in which case the corresponding value is not returned (this is supported since version 261)\&. The field name should be an entry field name\&. Well\-known field names are listed in
50 \fBsystemd.journal-fields\fR(7), but any field can be specified\&. The returned data is in a read\-only memory map and is only valid until the next invocation of
51 \fBsd_journal_get_data()\fR,
52 \fBsd_journal_enumerate_data()\fR,
53 \fBsd_journal_enumerate_available_data()\fR, or when the read pointer is altered\&. Note that the data returned will be prefixed with the field name and
54 "="\&. Also note that, by default, data fields larger than 64K might get truncated to 64K\&. This threshold may be changed and turned off with
55 \fBsd_journal_set_data_threshold()\fR
56 (see below)\&.
57 .PP
58 \fBsd_journal_enumerate_data()\fR
59 may be used to iterate through all fields of the current entry\&. On each invocation the data for the next field is returned\&. The order of these fields is not defined\&. The data returned is in the same format as with
60 \fBsd_journal_get_data()\fR
61 and also follows the same life\-time semantics\&.
62 .PP
63 \fBsd_journal_enumerate_available_data()\fR
64 is similar to
65 \fBsd_journal_enumerate_data()\fR, but silently skips any fields which may be valid, but are too large or not supported by current implementation\&.
66 .PP
67 \fBsd_journal_restart_data()\fR
68 resets the data enumeration index to the beginning of the entry\&. The next invocation of
69 \fBsd_journal_enumerate_data()\fR
70 will return the first field of the entry again\&.
71 .PP
72 Note that the
73 \fBSD_JOURNAL_FOREACH_DATA()\fR
74 macro may be used as a handy wrapper around
75 \fBsd_journal_restart_data()\fR
76 and
77 \fBsd_journal_enumerate_available_data()\fR\&.
78 .PP
79 Note that these functions will not work before
80 \fBsd_journal_next\fR(3)
81 (or related call) has been called at least once, in order to position the read pointer at a valid entry\&.
82 .PP
83 \fBsd_journal_set_data_threshold()\fR
84 may be used to change the data field size threshold for data returned by
85 \fBsd_journal_get_data()\fR,
86 \fBsd_journal_enumerate_data()\fR
87 and
88 \fBsd_journal_enumerate_unique()\fR\&. This threshold is a hint only: it indicates that the client program is interested only in the initial parts of the data fields, up to the threshold in size \(em but the library might still return larger data objects\&. That means applications should not rely exclusively on this setting to limit the size of the data fields returned, but need to apply an explicit size limit on the returned data as well\&. This threshold defaults to 64K by default\&. To retrieve the complete data fields this threshold should be turned off by setting it to 0, so that the library always returns the complete data objects\&. It is recommended to set this threshold as low as possible since this relieves the library from having to decompress large compressed data objects in full\&.
89 .PP
90 \fBsd_journal_get_data_threshold()\fR
91 returns the currently configured data field size threshold\&.
92 .SH "RETURN VALUE"
93 .PP
94 \fBsd_journal_get_data()\fR
95 returns 0 on success or a negative errno\-style error code\&.
96 \fBsd_journal_enumerate_data()\fR
97 and
98 \fBsd_journal_enumerate_available_data()\fR
99 return a positive integer if the next field has been read, 0 when no more fields remain, or a negative errno\-style error code\&.
100 \fBsd_journal_restart_data()\fR
101 does not return anything\&.
102 \fBsd_journal_set_data_threshold()\fR
103 and
104 \fBsd_journal_get_threshold()\fR
105 return 0 on success or a negative errno\-style error code\&.
106 .SS "Errors"
107 .PP
108 Returned errors may indicate the following problems:
109 .PP
110 \fB\-EINVAL\fR
111 .RS 4
112 One of the required parameters is
113 \fBNULL\fR
114 or invalid\&. For
115 \fBsd_journal_get_data()\fR, only the journal context object and field name are required non\-\fBNULL\fR\&. For
116 \fBsd_journal_enumerate_data()\fR
117 and
118 \fBsd_journal_enumerate_available_data()\fR,
119 \fIret_data\fR
120 and
121 \fIret_size\fR
122 are required as well\&.
123 .sp
124 Added in version 246\&.
125 .RE
126 .PP
127 \fB\-ECHILD\fR
128 .RS 4
129 The journal object was created in a different process, library or module instance\&.
130 .sp
131 Added in version 246\&.
132 .RE
133 .PP
134 \fB\-EADDRNOTAVAIL\fR
135 .RS 4
136 The read pointer is not positioned at a valid entry;
137 \fBsd_journal_next\fR(3)
138 or a related call has not been called at least once\&.
139 .sp
140 Added in version 246\&.
141 .RE
142 .PP
143 \fB\-ENOENT\fR
144 .RS 4
145 The current entry does not include the specified field\&.
146 .sp
147 Added in version 246\&.
148 .RE
149 .PP
150 \fB\-ENOMEM\fR
151 .RS 4
152 Memory allocation failed\&.
153 .sp
154 Added in version 246\&.
155 .RE
156 .PP
157 \fB\-ENOBUFS\fR
158 .RS 4
159 A compressed entry is too large\&.
160 .sp
161 Added in version 246\&.
162 .RE
163 .PP
164 \fB\-E2BIG\fR
165 .RS 4
166 The data field is too large for this computer architecture (e\&.g\&. above 4 GB on a 32\-bit architecture)\&.
167 .sp
168 Added in version 246\&.
169 .RE
170 .PP
171 \fB\-EPROTONOSUPPORT\fR
172 .RS 4
173 The journal is compressed with an unsupported method or the journal uses an unsupported feature\&.
174 .sp
175 Added in version 246\&.
176 .RE
177 .PP
178 \fB\-EBADMSG\fR
179 .RS 4
180 The journal is corrupted (possibly just the entry being iterated over)\&.
181 .sp
182 Added in version 246\&.
183 .RE
184 .PP
185 \fB\-EIO\fR
186 .RS 4
187 An I/O error was reported by the kernel\&.
188 .sp
189 Added in version 246\&.
190 .RE
191 .SH "NOTES"
192 .PP
193 All functions listed here are thread\-agnostic and only a single thread may operate on a given object at any given time\&. Different threads may access the same object at different times\&. Multiple independent objects may be used from different threads in parallel\&.
194 .PP
195 Functions described here are available as a shared library, which can be compiled against and linked to with the
196 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
197 file\&.
198 .SH "EXAMPLES"
199 .PP
200 See
201 \fBsd_journal_next\fR(3)
202 for a complete example how to use
203 \fBsd_journal_get_data()\fR\&.
204 .PP
205 Use the
206 \fBSD_JOURNAL_FOREACH_DATA()\fR
207 macro to iterate through all fields of the current journal entry:
208 .sp
209 .if n \{\
210 .RS 4
211 .\}
212 .nf
213 \&...
214 int print_fields(sd_journal *j) {
215 const void *data;
216 size_t length;
217 SD_JOURNAL_FOREACH_DATA(j, data, length)
218 printf("%\&.*s\en", (int) length, data);
219 }
220 \&...
221 .fi
222 .if n \{\
223 .RE
224 .\}
225 .SH "HISTORY"
226 .PP
227 \fBsd_journal_get_data()\fR,
228 \fBsd_journal_enumerate_data()\fR,
229 \fBsd_journal_restart_data()\fR, and
230 \fBSD_JOURNAL_FOREACH_DATA()\fR
231 were added in version 187\&.
232 .PP
233 \fBsd_journal_set_data_threshold()\fR
234 and
235 \fBsd_journal_get_data_threshold()\fR
236 were added in version 196\&.
237 .PP
238 \fBsd_journal_enumerate_available_data()\fR
239 was added in version 246\&.
240 .SH "SEE ALSO"
241 .PP
242 \fBsystemd\fR(1), \fBsystemd.journal-fields\fR(7), \fBsd-journal\fR(3), \fBsd_journal_open\fR(3), \fBsd_journal_next\fR(3), \fBsd_journal_get_realtime_usec\fR(3), \fBsd_journal_query_unique\fR(3)