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