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