Switch to unified view

a/src/query/recollq.cpp b/src/query/recollq.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.8 2007-10-25 07:27:30 dockes Exp $ (C) 2006 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.9 2007-11-08 07:54:45 dockes Exp $ (C) 2006 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
...
...
53
"  -a Emulate the gui simple search in ALL TERMS mode\n"
53
"  -a Emulate the gui simple search in ALL TERMS mode\n"
54
"Common options:\n"
54
"Common options:\n"
55
"    -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
55
"    -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
56
"    -d also dump file contents\n"
56
"    -d also dump file contents\n"
57
"    -n <cnt> limit the maximum number of results (0->no limit, default 2000)\n"
57
"    -n <cnt> limit the maximum number of results (0->no limit, default 2000)\n"
58
"    -b : basic. Just output urls, no mime types or titles\n"
58
;
59
;
59
static void
60
static void
60
Usage(void)
61
Usage(void)
61
{
62
{
62
    fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
63
    fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
...
...
68
#define OPT_o     0x2 
69
#define OPT_o     0x2 
69
#define OPT_a     0x4 
70
#define OPT_a     0x4 
70
#define OPT_c     0x8
71
#define OPT_c     0x8
71
#define OPT_d     0x10
72
#define OPT_d     0x10
72
#define OPT_n     0x20
73
#define OPT_n     0x20
74
#define OPT_b     0x40
73
75
74
static RclConfig *rclconfig;
76
static RclConfig *rclconfig;
75
RclConfig *RclConfig::getMainConfig() 
77
RclConfig *RclConfig::getMainConfig() 
76
{
78
{
77
    return rclconfig;
79
    return rclconfig;
...
...
90
            /* Cas du "adb - core" */
92
            /* Cas du "adb - core" */
91
            Usage();
93
            Usage();
92
        while (**argv)
94
        while (**argv)
93
            switch (*(*argv)++) {
95
            switch (*(*argv)++) {
94
            case 'a':   op_flags |= OPT_a; break;
96
            case 'a':   op_flags |= OPT_a; break;
97
            case 'b':   op_flags |= OPT_b; break;
95
        case 'c':   op_flags |= OPT_c; if (argc < 2)  Usage();
98
        case 'c':   op_flags |= OPT_c; if (argc < 2)  Usage();
96
        a_config = *(++argv);
99
        a_config = *(++argv);
97
        argc--; goto b1;
100
        argc--; goto b1;
98
            case 'd':   op_flags |= OPT_d; break;
101
            case 'd':   op_flags |= OPT_d; break;
99
        case 'n':   op_flags |= OPT_n; if (argc < 2)  Usage();
102
        case 'n':   op_flags |= OPT_n; if (argc < 2)  Usage();
...
...
164
    int pc;
167
    int pc;
165
    Rcl::Doc doc;
168
    Rcl::Doc doc;
166
    if (!rcldb.getDoc(i, doc, &pc))
169
    if (!rcldb.getDoc(i, doc, &pc))
167
        break;
170
        break;
168
171
172
  if (op_flags & OPT_b) {
173
      cout << doc.url.c_str() << endl;
174
  } else {
169
    char cpc[20];
175
        char cpc[20];
170
    sprintf(cpc, "%d", pc);
176
        sprintf(cpc, "%d", pc);
171
    cout 
177
        cout 
172
        << doc.mimetype.c_str() << "\t"
178
      << doc.mimetype.c_str() << "\t"
173
        << "[" << doc.url.c_str() << "]" << "\t" 
179
      << "[" << doc.url.c_str() << "]" << "\t" 
174
        << "[" << doc.meta["title"].c_str() << "]" << "\t"
180
      << "[" << doc.meta["title"].c_str() << "]" << "\t"
175
        << doc.fbytes.c_str()   << "\tbytes" << "\t"
181
      << doc.fbytes.c_str()   << "\tbytes" << "\t"
176
        <<  endl;
182
      <<  endl;
177
183
  }
178
    if (op_flags & OPT_d) {
184
    if (op_flags & OPT_d) {
179
        string fn = doc.url.substr(7);
185
        string fn = doc.url.substr(7);
180
        struct stat st;
186
        struct stat st;
181
        if (stat(fn.c_str(), &st) != 0) {
187
        if (stat(fn.c_str(), &st) != 0) {
182
        cout << "No such file: " << fn << endl;
188
        cout << "No such file: " << fn << endl;