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