1/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3#ident "$Id$"
4/*======
5This file is part of PerconaFT.
6
7
8Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9
10 PerconaFT is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License, version 2,
12 as published by the Free Software Foundation.
13
14 PerconaFT is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
21
22----------------------------------------
23
24 PerconaFT is free software: you can redistribute it and/or modify
25 it under the terms of the GNU Affero General Public License, version 3,
26 as published by the Free Software Foundation.
27
28 PerconaFT is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU Affero General Public License for more details.
32
33 You should have received a copy of the GNU Affero General Public License
34 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
35======= */
36
37#ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
38
39#pragma once
40
41#include <ft/log_header.h>
42
43struct toku_logcursor;
44typedef struct toku_logcursor *TOKULOGCURSOR;
45
46// All routines return 0 on success
47
48// toku_logcursor_create()
49// - creates a logcursor (lc)
50// - following toku_logcursor_create()
51// if toku_logcursor_next() is called, it returns the first entry in the log
52// if toku_logcursor_prev() is called, it returns the last entry in the log
53int toku_logcursor_create(TOKULOGCURSOR *lc, const char *log_dir);
54// toku_logcursor_create_for_file()
55// - creates a logcusor (lc) that only knows about the file log_file
56int toku_logcursor_create_for_file(TOKULOGCURSOR *lc, const char *log_dir, const char *log_file);
57// toku_logcursor_destroy()
58// - frees all resources associated with the logcursor, including the log_entry
59// associated with the latest cursor action
60int toku_logcursor_destroy(TOKULOGCURSOR *lc);
61
62// toku_logcursor_[next,prev,first,last] take care of malloc'ing and free'ing log_entrys.
63// - routines NULL out the **le pointers on entry, then set the **le pointers to
64// the malloc'ed entries when successful,
65int toku_logcursor_next(TOKULOGCURSOR lc, struct log_entry **le);
66int toku_logcursor_prev(TOKULOGCURSOR lc, struct log_entry **le);
67
68int toku_logcursor_first(const TOKULOGCURSOR lc, struct log_entry **le);
69int toku_logcursor_last(const TOKULOGCURSOR lc, struct log_entry **le);
70
71// return 0 if log exists, ENOENT if no log
72int toku_logcursor_log_exists(const TOKULOGCURSOR lc);
73
74void toku_logcursor_print(TOKULOGCURSOR lc);
75