~ubuntu-branches/ubuntu/raring/lurker/raring

« back to all changes in this revision

Viewing changes to libesort/dump.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2004-09-26 16:27:51 UTC
  • Revision ID: james.westby@ubuntu.com-20040926162751-z1ohcjltv7ojtg6z
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  $Id: dump.cpp,v 1.6 2003/07/01 14:05:52 terpstra Exp $
 
2
 *  
 
3
 *  dump.cpp - Dump the contents of a libesort database to cout
 
4
 *  
 
5
 *  Copyright (C) 2002 - Wesley W. Terpstra
 
6
 *  
 
7
 *  License: GPL
 
8
 *  
 
9
 *  Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca>
 
10
 *  
 
11
 *    This program is free software; you can redistribute it and/or modify
 
12
 *    it under the terms of the GNU General Public License as published by
 
13
 *    the Free Software Foundation; version 2.
 
14
 *    
 
15
 *    This program is distributed in the hope that it will be useful,
 
16
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 *    GNU General Public License for more details.
 
19
 *    
 
20
 *    You should have received a copy of the GNU General Public License
 
21
 *    along with this program; if not, write to the Free Software
 
22
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 */
 
24
 
 
25
#define _XOPEN_SOURCE 500
 
26
#define _FILE_OFFSET_BITS 64
 
27
  
 
28
#include "esort.h"
 
29
 
 
30
#include <iostream>
 
31
#include <memory>
 
32
#include <cstdio>
 
33
#include <cerrno>
 
34
 
 
35
using namespace std;
 
36
using namespace ESort;
 
37
 
 
38
int main(int argc, char** argv)
 
39
{
 
40
        if (argc != 2)
 
41
        {
 
42
                cerr << "Syntax: " << argv[0] << " <database>\n" << endl;
 
43
                return 1;
 
44
        }
 
45
        
 
46
        auto_ptr<Reader> r(Reader::opendb(argv[1]));
 
47
        if (!r.get())
 
48
        {
 
49
                perror("Reader::opendb");
 
50
                return 1;
 
51
        }
 
52
        
 
53
        auto_ptr<Walker> w(r->seek("", Forward));
 
54
        
 
55
        while (w->advance() != -1)
 
56
                cout << w->key << "\n";
 
57
        
 
58
        if (errno != 0)
 
59
        {
 
60
                perror("Walker::advance");
 
61
                return 1;
 
62
        }
 
63
        
 
64
        return 0;
 
65
}