Debian Codegraph @

man/sd_journal_get_cursor.xml

raw
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>ret_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 cursor string for the current journal
47 entry. A cursor is a serialization of the current journal position formatted as text. The string only
48 contains printable characters and can be passed around in text form. The cursor identifies a journal
49 entry globally and in a stable way and may be used to later seek to it via
50 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
51 The cursor string should be considered opaque and not be parsed by clients. Seeking to a cursor position
52 without the specific entry being available locally will seek to the next closest (in terms of time)
53 available entry. The call takes two arguments: a journal context object and a pointer to a string pointer
54 where the cursor string will be placed. The string is allocated via libc <citerefentry
55 project='man-pages'><refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
56 should be freed after use with <citerefentry
57 project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>. The
58 <parameter>ret_cursor</parameter> parameter may be passed as <constant>NULL</constant> in which case the
59 cursor string is not generated, however the return value will indicate whether the journal context is
60 currently positioned on an entry, and thus has a cursor associated.</para>
61
62 <para><function>sd_journal_test_cursor()</function>
63 may be used to check whether the current position in
64 the journal matches the specified cursor. This is
65 useful since cursor strings do not uniquely identify
66 an entry: the same entry might be referred to by
67 multiple different cursor strings, and hence string
68 comparing cursors is not possible. Use this call to
69 verify after an invocation of
70 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
71 whether the entry being sought to was actually found
72 in the journal or the next closest entry was used
73 instead.</para>
74
75 <para>Note that <function>sd_journal_get_cursor()</function>
76 and <function>sd_journal_test_cursor()</function>
77 will not work before
78 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
79 (or one of the other functions which move to an entry)
80 has been called at least once to position the read pointer at a valid entry.</para>
81 </refsect1>
82
83 <refsect1>
84 <title>Return Value</title>
85
86 <para><function>sd_journal_get_cursor()</function> returns 0 on
87 success or a negative errno-style error code.
88 <function>sd_journal_test_cursor()</function> returns positive if
89 the current entry matches the specified cursor, 0 if it does not
90 match the specified cursor or a negative errno-style error code on
91 failure.</para>
92
93 <refsect2>
94 <title>Errors</title>
95
96 <para>Returned errors may indicate the following problems:</para>
97
98 <variablelist>
99 <varlistentry>
100 <term><constant>-EADDRNOTAVAIL</constant></term>
101
102 <listitem><para>The journal context is currently not positioned on any entry, and hence no cursor
103 string can be generated.</para></listitem>
104 </varlistentry>
105
106 <varlistentry>
107 <term><constant>-EINVAL</constant></term>
108
109 <listitem><para>The journal context parameter is <constant>NULL</constant>.</para></listitem>
110 </varlistentry>
111
112 <varlistentry>
113 <term><constant>-ECHILD</constant></term>
114
115 <listitem><para>The journal context object has been allocated in a different process than it is
116 being used in now.</para></listitem>
117 </varlistentry>
118 </variablelist>
119 </refsect2>
120 </refsect1>
121
122 <refsect1>
123 <title>Notes</title>
124
125 <xi:include href="threads-aware.xml" xpointer="strict" />
126
127 <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
128 </refsect1>
129
130 <refsect1>
131 <title>History</title>
132 <para><function>sd_journal_get_cursor()</function> was added in version 187.</para>
133 <para><function>sd_journal_test_cursor()</function> was added in version 195.</para>
134 </refsect1>
135
136 <refsect1>
137 <title>See Also</title>
138
139 <para><simplelist type="inline">
140 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
141 <member><citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
142 <member><citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
143 <member><citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
144 </simplelist></para>
145 </refsect1>
146
147 </refentry>