mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
xapian-dump: Actually dump document IDs
It's not a complete tool yet, but it at least does something now.
This commit is contained in:
parent
287ffc828d
commit
26795d64e6
1 changed files with 26 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/* xapian-dump: Dump all document IDs from a Xapian database
|
||||||
|
*
|
||||||
* Copyright © 2009 Carl Worth
|
* Copyright © 2009 Carl Worth
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
@ -18,17 +19,41 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <xapian.h>
|
#include <xapian.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
const char *database_path;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf (stderr, "Usage: %s <path-to-xapian-database>\n",
|
fprintf (stderr, "Usage: %s <path-to-xapian-database>\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
exit (1);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue