aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2009-10-13 08:20:36 -0700
committerCarl Worth <cworth@cworth.org>2009-10-13 08:53:34 -0700
commit26795d64e6150b543d850c1e882a9d1395b58d9e (patch)
tree0a8c5004c97eda602db7a0efd58cbbb1b945934b
parent287ffc828d565ae812bbb6bcae076e17e6c7098f (diff)
xapian-dump: Actually dump document IDs
It's not a complete tool yet, but it at least does something now.
-rw-r--r--xapian-dump.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/xapian-dump.cc b/xapian-dump.cc
index 6d1fc1be..0ab5e32c 100644
--- a/xapian-dump.cc
+++ b/xapian-dump.cc
@@ -1,4 +1,5 @@
-/*
+/* xapian-dump: Dump all document IDs from a Xapian database
+ *
* Copyright © 2009 Carl Worth
*
* This program is free software: you can redistribute it and/or modify
@@ -18,17 +19,41 @@
*/
#include <cstdlib>
+#include <iostream>
#include <xapian.h>
+using namespace std;
+
int
main (int argc, char *argv[])
{
+ const char *database_path;
+
if (argc < 2) {
fprintf (stderr, "Usage: %s <path-to-xapian-database>\n",
argv[0]);
exit (1);
}
+ database_path = argv[1];
+
+ try {
+
+ Xapian::Database db;
+ Xapian::PostingIterator i;
+ Xapian::docid doc_id;
+
+ db = Xapian::Database (database_path);
+ for (i = db.postlist_begin (""); i != db.postlist_end (""); i++) {
+ doc_id = *i;
+ printf ("Found document %u\n", doc_id);
+ }
+
+ } catch (const Xapian::Error &error) {
+ cerr << "A Xapian exception occurred: " << error.get_msg () << endl;
+ exit (1);
+ }
+
return 0;
}