]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_journal_get_cursor.xml
man: mention that sd_journal_test_cursor() needs a positioning call
[thirdparty/systemd.git] / man / sd_journal_get_cursor.xml
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.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="sd_journal_get_cursor" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sd_journal_get_cursor</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_journal_get_cursor</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_journal_get_cursor</refname>
20 <refname>sd_journal_test_cursor</refname>
21 <refpurpose>Get cursor string for or test cursor string against the current journal entry</refpurpose>
22 </refnamediv>
23
24 <refsynopsisdiv>
25 <funcsynopsis>
26 <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
27
28 <funcprototype>
29 <funcdef>int <function>sd_journal_get_cursor</function></funcdef>
30 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
31 <paramdef>char **<parameter>cursor</parameter></paramdef>
32 </funcprototype>
33
34 <funcprototype>
35 <funcdef>int <function>sd_journal_test_cursor</function></funcdef>
36 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
37 <paramdef>const char *<parameter>cursor</parameter></paramdef>
38 </funcprototype>
39
40 </funcsynopsis>
41 </refsynopsisdiv>
42
43 <refsect1>
44 <title>Description</title>
45
46 <para><function>sd_journal_get_cursor()</function> returns a
47 cursor string for the current journal entry. A cursor is a
48 serialization of the current journal position formatted as text.
49 The string only contains printable characters and can be passed
50 around in text form. The cursor identifies a journal entry
51 globally and in a stable way and may be used to later seek to it
52 via
53 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
54 The cursor string should be considered opaque and not be parsed by
55 clients. Seeking to a cursor position without the specific entry
56 being available locally will seek to the next closest (in terms of
57 time) available entry. The call takes two arguments: a journal
58 context object and a pointer to a string pointer where the cursor
59 string will be placed. The string is allocated via libc
60 <citerefentry project='man-pages'><refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum></citerefentry>
61 and should be freed after use with
62 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
63
64 <para><function>sd_journal_test_cursor()</function>
65 may be used to check whether the current position in
66 the journal matches the specified cursor. This is
67 useful since cursor strings do not uniquely identify
68 an entry: the same entry might be referred to by
69 multiple different cursor strings, and hence string
70 comparing cursors is not possible. Use this call to
71 verify after an invocation of
72 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
73 whether the entry being sought to was actually found
74 in the journal or the next closest entry was used
75 instead.</para>
76
77 <para>Note that <function>sd_journal_get_cursor()</function>
78 and <function>sd_journal_test_cursor()</function>
79 will not work before
80 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81 (or one of the other functions which move to an entry)
82 has been called at least once to position the read pointer at a valid entry.</para>
83 </refsect1>
84
85 <refsect1>
86 <title>Return Value</title>
87
88 <para><function>sd_journal_get_cursor()</function> returns 0 on
89 success or a negative errno-style error code.
90 <function>sd_journal_test_cursor()</function> returns positive if
91 the current entry matches the specified cursor, 0 if it does not
92 match the specified cursor or a negative errno-style error code on
93 failure.</para>
94 </refsect1>
95
96 <refsect1>
97 <title>Notes</title>
98
99 <xi:include href="threads-aware.xml" xpointer="strict" />
100
101 <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
102 </refsect1>
103
104 <refsect1>
105 <title>History</title>
106 <para><function>sd_journal_get_cursor()</function> was added in version 187.</para>
107 <para><function>sd_journal_test_cursor()</function> was added in version 195.</para>
108 </refsect1>
109
110 <refsect1>
111 <title>See Also</title>
112
113 <para><simplelist type="inline">
114 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
115 <member><citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
116 <member><citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
117 <member><citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
118 </simplelist></para>
119 </refsect1>
120
121 </refentry>