]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_journal_get_cursor.xml
man: xinclude the generic text to talk about libsystemd pkgconfig
[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 This file is part of systemd.
9
10 Copyright 2012 Lennart Poettering
11 -->
12
13 <refentry id="sd_journal_get_cursor" xmlns:xi="http://www.w3.org/2001/XInclude">
14
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
76 <citerefentry project='man-pages'><refentrytitle>malloc</refentrytitle><manvolnum>3</manvolnum></citerefentry>
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
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
117 <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
118 </refsect1>
119
120 <refsect1>
121 <title>See Also</title>
122
123 <para>
124 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
125 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
126 <citerefentry><refentrytitle>sd_journal_open</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
127 <citerefentry><refentrytitle>sd_journal_seek_cursor</refentrytitle><manvolnum>3</manvolnum></citerefentry>
128 </para>
129 </refsect1>
130
131 </refentry>