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