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.11 2006-09-19 14:18:57 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: xadump.cpp,v 1.12 2006-12-01 10:05:15 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
...
...
37
static string usage =
37
static string usage =
38
    " -d <dbdir> -e <output encoding>\n"
38
    " -d <dbdir> -e <output encoding>\n"
39
    " -i docid -D : get document data for docid\n"
39
    " -i docid -D : get document data for docid\n"
40
    " -i docid -b : 'rebuild' document from term positions\n"
40
    " -i docid -b : 'rebuild' document from term positions\n"
41
    " -t term -E  : term existence test\n"
41
    " -t term -E  : term existence test\n"
42
    " -t term -F  : retrieve term frequency data\n"
42
    " -t term -F  : retrieve term frequency data for given term\n"
43
    " -t term -P  : retrieve postings for term\n"
43
    " -t term -P  : retrieve postings for term\n"
44
    " -i docid -T : term list for doc docid\n"
44
    " -i docid -T : term list for doc docid\n"
45
    " -T          : list all terms\n"
45
    " -T          : list all terms\n"
46
    "    -f       : precede each term in the list with its occurrence count\n"
46
    " -s          : special mode to dump recoll stem db\n"
47
    " -s          : special mode to dump recoll stem db\n"
47
    "  \n\n"
48
    "  \n\n"
48
    ;
49
    ;
49
50
50
static void
51
static void
...
...
64
#define OPT_P     0x40
65
#define OPT_P     0x40
65
#define OPT_F     0x80
66
#define OPT_F     0x80
66
#define OPT_E     0x100
67
#define OPT_E     0x100
67
#define OPT_b     0x200
68
#define OPT_b     0x200
68
#define OPT_s     0x400
69
#define OPT_s     0x400
70
#define OPT_f     0x800
69
71
70
Xapian::Database *db;
72
Xapian::Database *db;
71
73
72
static void cleanup()
74
static void cleanup()
73
{
75
{
...
...
96
    if (!(**argv))
98
    if (!(**argv))
97
        /* Cas du "adb - core" */
99
        /* Cas du "adb - core" */
98
        Usage();
100
        Usage();
99
    while (**argv)
101
    while (**argv)
100
        switch (*(*argv)++) {
102
        switch (*(*argv)++) {
103
      case 'b':   op_flags |= OPT_b; break;
101
        case 'D':   op_flags |= OPT_D; break;
104
        case 'D':   op_flags |= OPT_D; break;
105
      case 'd':   op_flags |= OPT_d; if (argc < 2)  Usage();
106
      dbdir = *(++argv);
107
      argc--; 
108
      goto b1;
102
        case 'E':   op_flags |= OPT_E; break;
109
        case 'E':   op_flags |= OPT_E; break;
110
      case 'e':   op_flags |= OPT_d; if (argc < 2)  Usage();
111
      outencoding = *(++argv);
112
      argc--; 
113
      goto b1;
103
        case 'F':   op_flags |= OPT_F; break;
114
        case 'F':   op_flags |= OPT_F; break;
115
      case 'f':   op_flags |= OPT_f; break;
116
      case 'i':   op_flags |= OPT_i; if (argc < 2)  Usage();
117
      if (sscanf(*(++argv), "%d", &docid) != 1) Usage();
118
      argc--; 
119
      goto b1;
104
        case 'P':   op_flags |= OPT_P; break;
120
        case 'P':   op_flags |= OPT_P; break;
105
        case 's':   op_flags |= OPT_s; break;
121
        case 's':   op_flags |= OPT_s; break;
106
        case 'T':   op_flags |= OPT_T; break;
122
        case 'T':   op_flags |= OPT_T; break;
107
      case 'b':   op_flags |= OPT_b; break;
108
      case 'd':   op_flags |= OPT_d; if (argc < 2)  Usage();
109
      dbdir = *(++argv);
110
      argc--; 
111
      goto b1;
112
      case 'e':   op_flags |= OPT_d; if (argc < 2)  Usage();
113
      outencoding = *(++argv);
114
      argc--; 
115
      goto b1;
116
      case 'i':   op_flags |= OPT_i; if (argc < 2)  Usage();
117
      if (sscanf(*(++argv), "%d", &docid) != 1) Usage();
118
      argc--; 
119
      goto b1;
120
        case 't':   op_flags |= OPT_t; if (argc < 2)  Usage();
123
        case 't':   op_flags |= OPT_t; if (argc < 2)  Usage();
121
        aterm = *(++argv);
124
        aterm = *(++argv);
122
        argc--; 
125
        argc--; 
123
        goto b1;
126
        goto b1;
124
        default: Usage();   break;
127
        default: Usage();   break;
...
...
153
            cout << "[" << *term << "]" << endl;
156
            cout << "[" << *term << "]" << endl;
154
        }
157
        }
155
        } else {
158
        } else {
156
        for (term = db->allterms_begin(); 
159
        for (term = db->allterms_begin(); 
157
             term != db->allterms_end();term++) {
160
             term != db->allterms_end();term++) {
161
          if (op_flags & OPT_f)
162
          cout << term.get_termfreq() << " ";
158
            cout << "[" << *term << "]" << endl;
163
            cout << "[" << *term << "]" << endl;
159
        }
164
        }
160
        }
165
        }
161
    } else if (op_flags & OPT_s) {
166
    } else if (op_flags & OPT_s) {
162
        for (unsigned int docid = 1;
167
        for (unsigned int docid = 1;