Switch to unified view

a/src/query/xadump.cpp b/src/query/xadump.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.15 2007-05-30 12:31:19 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.16 2007-06-19 15:47:46 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
33
static string thisprog;
33
static string thisprog;
34
34
35
static string usage =
35
static string usage =
36
    " -d <dbdir> -e <output encoding>\n"
36
    " -d <dbdir> -e <output encoding>\n"
37
    " -i docid -D : get document data for docid\n"
37
    " -i docid -D : get document data for docid\n"
38
    " -i docid -X : delete document docid\n"
38
    " -i docid -b : 'rebuild' document from term positions\n"
39
    " -i docid -b : 'rebuild' document from term positions\n"
39
    " -t term -E  : term existence test\n"
40
    " -t term -E  : term existence test\n"
40
    " -t term -F  : retrieve term frequency data for given term\n"
41
    " -t term -F  : retrieve term frequency data for given term\n"
41
    " -t term -P  : retrieve postings for term\n"
42
    " -t term -P  : retrieve postings for term\n"
42
    " -i docid -T : term list for doc docid\n"
43
    " -i docid -T : term list for doc docid\n"
...
...
68
#define OPT_b     0x200
69
#define OPT_b     0x200
69
#define OPT_s     0x400
70
#define OPT_s     0x400
70
#define OPT_f     0x800
71
#define OPT_f     0x800
71
#define OPT_q     0x1000
72
#define OPT_q     0x1000
72
#define OPT_n     0x2000
73
#define OPT_n     0x2000
74
#define OPT_X     0x4000
73
75
74
Xapian::Database *db;
76
Xapian::Database *db;
75
77
76
static void cleanup()
78
static void cleanup()
77
{
79
{
...
...
126
        case 'T':   op_flags |= OPT_T; break;
128
        case 'T':   op_flags |= OPT_T; break;
127
        case 't':   op_flags |= OPT_t; if (argc < 2)  Usage();
129
        case 't':   op_flags |= OPT_t; if (argc < 2)  Usage();
128
        aterm = *(++argv);
130
        aterm = *(++argv);
129
        argc--; 
131
        argc--; 
130
        goto b1;
132
        goto b1;
133
      case 'X':   op_flags |= OPT_X; break;
131
        default: Usage();   break;
134
        default: Usage();   break;
132
        }
135
        }
133
    b1: argc--; argv++;
136
    b1: argc--; argv++;
134
    }
137
    }
135
138
...
...
195
        }
198
        }
196
    } else if (op_flags & OPT_D) {
199
    } else if (op_flags & OPT_D) {
197
        Xapian::Document doc = db->get_document(docid);
200
        Xapian::Document doc = db->get_document(docid);
198
        string data = doc.get_data();
201
        string data = doc.get_data();
199
        cout << data << endl;
202
        cout << data << endl;
203
  } else if (op_flags & OPT_X) {
204
      Xapian::Document doc = db->get_document(docid);
205
      string data = doc.get_data();
206
      cout << data << endl;
207
      cout << "Really delete xapian document ?" << endl;
208
      string rep;
209
      cin >> rep;
210
      if (!rep.empty() && rep[0] == 'y' || rep[0] == 'Y') {
211
      Xapian::WritableDatabase wdb(dbdir,  Xapian::DB_OPEN);
212
      cout << "Deleting" << endl;
213
      wdb.delete_document(docid);
214
      }
200
    } else if (op_flags & OPT_b) {
215
    } else if (op_flags & OPT_b) {
201
        if (!(op_flags & OPT_i))
216
        if (!(op_flags & OPT_i))
202
        Usage();
217
        Usage();
203
        vector<string> buf;
218
        vector<string> buf;
204
        Xapian::TermIterator term;
219
        Xapian::TermIterator term;