]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_journal_get_cursor.xml
verify: use manager_load_startable_unit_or_warn() to load units for verification
[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
ZJS
6 SPDX-License-Identifier: LGPL-2.1+
7
4a010f4e
LP
8 This file is part of systemd.
9
10 Copyright 2012 Lennart Poettering
11
12 systemd is free software; you can redistribute it and/or modify it
13 under the terms of the GNU Lesser General Public License as published by
14 the Free Software Foundation; either version 2.1 of the License, or
15 (at your option) any later version.
16
17 systemd is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public License
23 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24-->
25
26<refentry id="sd_journal_get_cursor">
27
798d3a52
ZJS
28 <refentryinfo>
29 <title>sd_journal_get_cursor</title>
30 <productname>systemd</productname>
31
32 <authorgroup>
33 <author>
34 <contrib>Developer</contrib>
35 <firstname>Lennart</firstname>
36 <surname>Poettering</surname>
37 <email>lennart@poettering.net</email>
38 </author>
39 </authorgroup>
40 </refentryinfo>
41
42 <refmeta>
43 <refentrytitle>sd_journal_get_cursor</refentrytitle>
44 <manvolnum>3</manvolnum>
45 </refmeta>
46
47 <refnamediv>
48 <refname>sd_journal_get_cursor</refname>
49 <refname>sd_journal_test_cursor</refname>
50 <refpurpose>Get cursor string for or test cursor string against the current journal entry</refpurpose>
51 </refnamediv>
52
53 <refsynopsisdiv>
54 <funcsynopsis>
55 <funcsynopsisinfo>#include &lt;systemd/sd-journal.h&gt;</funcsynopsisinfo>
56
57 <funcprototype>
58 <funcdef>int <function>sd_journal_get_cursor</function></funcdef>
59 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
60 <paramdef>char **<parameter>cursor</parameter></paramdef>
61 </funcprototype>
62
63 <funcprototype>
64 <funcdef>int <function>sd_journal_test_cursor</function></funcdef>
65 <paramdef>sd_journal *<parameter>j</parameter></paramdef>
66 <paramdef>const char *<parameter>cursor</parameter></paramdef>
67 </funcprototype>
68
69 </funcsynopsis>
70 </refsynopsisdiv>
71
72 <refsect1>
73 <title>Description</title>
74
75 <para><function>sd_journal_get_cursor()</function> returns a
76 cursor string for the current journal entry. A cursor is a
77 serialization of the current journal position formatted as text.
78 The string only contains printable characters and can be passed
79 around in text form. The cursor identifies a journal entry
80 globally and in a stable way and may be used to later seek to it
81 via
82 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
83 The cursor string should be considered opaque and not be parsed by
84 clients. Seeking to a cursor position without the specific entry
85 being available locally will seek to the next closest (in terms of
86 time) available entry. The call takes two arguments: a journal
87 context object and a pointer to a string pointer where the cursor
88 string will be placed. The string is allocated via libc
3ba3a79d 89 <citerefentry project='man-pages'><refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52
ZJS
90 and should be freed after use with
91 <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
92
93 <para>Note that <function>sd_journal_get_cursor()</function> will
94 not work before
95 <citerefentry><refentrytitle>sd_journal_next</refentrytitle><manvolnum>3</manvolnum></citerefentry>
96 (or related call) has been called at least once, in order to
97 position the read pointer at a valid entry.</para>
98
99 <para><function>sd_journal_test_cursor()</function>
100 may be used to check whether the current position in
101 the journal matches the specified cursor. This is
102 useful since cursor strings do not uniquely identify
103 an entry: the same entry might be referred to by
104 multiple different cursor strings, and hence string
105 comparing cursors is not possible. Use this call to
106 verify after an invocation of
107 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>
108 whether the entry being sought to was actually found
109 in the journal or the next closest entry was used
110 instead.</para>
111 </refsect1>
112
113 <refsect1>
114 <title>Return Value</title>
115
116 <para><function>sd_journal_get_cursor()</function> returns 0 on
117 success or a negative errno-style error code.
118 <function>sd_journal_test_cursor()</function> returns positive if
119 the current entry matches the specified cursor, 0 if it does not
120 match the specified cursor or a negative errno-style error code on
121 failure.</para>
122 </refsect1>
123
124 <refsect1>
125 <title>Notes</title>
126
a8d46a16
ZJS
127 <para>All functions listed here are thread-agnostic and only a single thread may operate
128 on a given <structname>sd_journal</structname> object.</para>
129
798d3a52
ZJS
130 <para>The <function>sd_journal_get_cursor()</function> and
131 <function>sd_journal_test_cursor()</function> interfaces are
132 available as a shared library, which can be compiled and linked to
133 with the
134 <constant>libsystemd</constant> <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
135 file.</para>
136 </refsect1>
137
138 <refsect1>
139 <title>See Also</title>
140
141 <para>
142 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
143 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
144 <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
145 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>
146 </para>
147 </refsect1>
4a010f4e
LP
148
149</refentry>