178 lines
5.3 KiB
HTML
178 lines
5.3 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of SD_JOURNAL_ENUMERATE_FIELDS</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>SD_JOURNAL_ENUMERATE_FIELDS</H1>
|
|
Section: sd_journal_enumerate_fields (3)<BR>Updated: <BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
sd_journal_enumerate_fields, sd_journal_restart_fields, SD_JOURNAL_FOREACH_FIELD - Read used field names from the journal
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<P>
|
|
<B>
|
|
</B><PRE>
|
|
#include <<A HREF="file:///usr/include/systemd/sd-journal.h">systemd/sd-journal.h</A>>
|
|
</PRE>
|
|
|
|
|
|
<DL COMPACT>
|
|
<DT id="1">
|
|
<B>int sd_journal_enumerate_fields(sd_journal *</B><I>j</I><B>, const char **</B><I>field</I><B>);</B>
|
|
|
|
<DT id="2">
|
|
<B>void sd_journal_restart_fields(sd_journal *</B><I>j</I><B>);</B>
|
|
|
|
<DT id="3">
|
|
<B>SD_JOURNAL_FOREACH_FIELD(sd_journal *</B><I>j</I><B>, const char *</B><I>field</I><B>);</B>
|
|
|
|
</DL>
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
|
|
<B>sd_journal_enumerate_fields()</B>
|
|
<DD>may be used to iterate through all field names used in the opened journal files. On each invocation the next field name is returned. The order of the returned field names is not defined. It takes two arguments: the journal context object, plus a pointer to a constant string pointer where the field name is stored in. The returned data is in a read-only memory map and is only valid until the next invocation of
|
|
<B>sd_journal_enumerate_fields()</B>. Note that this call is subject to the data field size threshold as controlled by
|
|
<B>sd_journal_set_data_threshold()</B>.
|
|
<P>
|
|
|
|
<B>sd_journal_restart_fields()</B>
|
|
resets the field name enumeration index to the beginning of the list. The next invocation of
|
|
<B>sd_journal_enumerate_fields()</B>
|
|
will return the first field name again.
|
|
<P>
|
|
|
|
The
|
|
<B>SD_JOURNAL_FOREACH_FIELD()</B>
|
|
macro may be used as a handy wrapper around
|
|
<B>sd_journal_restart_fields()</B>
|
|
and
|
|
<B>sd_journal_enumerate_fields()</B>.
|
|
<P>
|
|
|
|
These functions currently are not influenced by matches set with
|
|
<B>sd_journal_add_match()</B>
|
|
but this might change in a later version of this software.
|
|
<P>
|
|
|
|
To retrieve the possible values a specific field can take use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_journal_query_unique">sd_journal_query_unique</A></B>(3).
|
|
<A NAME="lbAE"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
<P>
|
|
|
|
<B>sd_journal_enumerate_fields()</B>
|
|
returns a positive integer if the next field name has been read, 0 when no more field names are known, or a negative errno-style error code.
|
|
<B>sd_journal_restart_fields()</B>
|
|
returns nothing.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
<P>
|
|
|
|
All functions listed here are thread-agnostic and only a single specific thread may operate on a given object during its entire lifetime. It's safe to allocate multiple independent objects and use each from a specific thread in parallel. However, it's not safe to allocate such an object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don't operate on it at the very same time.
|
|
<P>
|
|
|
|
These APIs are implemented as a shared library, which can be compiled and linked to with the
|
|
<B>libsystemd</B> <B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
|
|
file.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>EXAMPLES</H2>
|
|
|
|
<P>
|
|
|
|
Use the
|
|
<B>SD_JOURNAL_FOREACH_FIELD</B>
|
|
macro to iterate through all field names in use in the current journal.
|
|
<P>
|
|
<DL COMPACT><DT id="4"><DD>
|
|
|
|
|
|
|
|
<PRE>
|
|
#include <<A HREF="file:///usr/include/stdio.h">stdio.h</A>>
|
|
#include <<A HREF="file:///usr/include/string.h">string.h</A>>
|
|
#include <<A HREF="file:///usr/include/systemd/sd-journal.h">systemd/sd-journal.h</A>>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
sd_journal *j;
|
|
const char *field;
|
|
int r;
|
|
|
|
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
|
|
if (r < 0) {
|
|
fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
|
|
return 1;
|
|
}
|
|
SD_JOURNAL_FOREACH_FIELD(j, field)
|
|
printf("%s\n", field);
|
|
sd_journal_close(j);
|
|
return 0;
|
|
}
|
|
</PRE>
|
|
|
|
</DL>
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<P>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1),
|
|
<B><A HREF="/cgi-bin/man/man2html?7+systemd.journal-fields">systemd.journal-fields</A></B>(7),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd-journal">sd-journal</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_journal_open">sd_journal_open</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_journal_query_unique">sd_journal_query_unique</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_journal_get_data">sd_journal_get_data</A></B>(3),
|
|
<B><A HREF="/cgi-bin/man/man2html?3+sd_journal_add_match">sd_journal_add_match</A></B>(3)
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="8"><A HREF="#lbAE">RETURN VALUE</A><DD>
|
|
<DT id="9"><A HREF="#lbAF">NOTES</A><DD>
|
|
<DT id="10"><A HREF="#lbAG">EXAMPLES</A><DD>
|
|
<DT id="11"><A HREF="#lbAH">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:55 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|