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