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