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