|
a/src/index/recollindex.cpp |
|
b/src/index/recollindex.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.11 2005-11-05 14:40:50 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.12 2005-11-30 09:46:25 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
|
4 |
|
5 |
#include <stdio.h>
|
5 |
#include <stdio.h>
|
6 |
#include <signal.h>
|
6 |
#include <signal.h>
|
7 |
|
7 |
|
|
... |
|
... |
22 |
fprintf(stderr, "sigcleanup\n");
|
22 |
fprintf(stderr, "sigcleanup\n");
|
23 |
cleanup();
|
23 |
cleanup();
|
24 |
exit(1);
|
24 |
exit(1);
|
25 |
}
|
25 |
}
|
26 |
|
26 |
|
|
|
27 |
static const char *thisprog;
|
|
|
28 |
static int op_flags;
|
|
|
29 |
#define OPT_MOINS 0x1
|
|
|
30 |
#define OPT_z 0x2
|
|
|
31 |
#define OPT_h 0x4
|
|
|
32 |
|
|
|
33 |
static const char usage [] =
|
|
|
34 |
" recollindex [-hz]\n"
|
|
|
35 |
"Options:\n"
|
|
|
36 |
" -h : print this message\n"
|
|
|
37 |
" -z : reset database before starting indexation\n\n"
|
|
|
38 |
;
|
|
|
39 |
|
|
|
40 |
static void
|
|
|
41 |
Usage(void)
|
|
|
42 |
{
|
|
|
43 |
FILE *fp = (op_flags & OPT_h) ? stdout : stderr;
|
|
|
44 |
fprintf(fp, "%s: usage: %s", thisprog, usage);
|
|
|
45 |
exit((op_flags & OPT_h)==0);
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
|
27 |
int main(int argc, const char **argv)
|
49 |
int main(int argc, const char **argv)
|
28 |
{
|
50 |
{
|
|
|
51 |
thisprog = argv[0];
|
|
|
52 |
argc--; argv++;
|
|
|
53 |
|
|
|
54 |
while (argc > 0 && **argv == '-') {
|
|
|
55 |
(*argv)++;
|
|
|
56 |
if (!(**argv))
|
|
|
57 |
Usage();
|
|
|
58 |
while (**argv)
|
|
|
59 |
switch (*(*argv)++) {
|
|
|
60 |
case 'z': op_flags |= OPT_z; break;
|
|
|
61 |
case 'h': op_flags |= OPT_h; break;
|
|
|
62 |
default: Usage(); break;
|
|
|
63 |
}
|
|
|
64 |
}
|
|
|
65 |
if (op_flags & OPT_h)
|
|
|
66 |
Usage();
|
29 |
string reason;
|
67 |
string reason;
|
30 |
RclConfig *config = recollinit(cleanup, sigcleanup, reason);
|
68 |
RclConfig *config = recollinit(cleanup, sigcleanup, reason);
|
31 |
|
69 |
|
32 |
if (config == 0 || !config->ok()) {
|
70 |
if (config == 0 || !config->ok()) {
|
33 |
string str = "Configuration problem: ";
|
71 |
string str = "Configuration problem: ";
|
34 |
str += reason;
|
72 |
str += reason;
|
35 |
fprintf(stderr, "%s\n", str.c_str());
|
73 |
fprintf(stderr, "%s\n", str.c_str());
|
36 |
exit(1);
|
74 |
exit(1);
|
37 |
}
|
75 |
}
|
|
|
76 |
|
38 |
indexer = new ConfIndexer(config);
|
77 |
indexer = new ConfIndexer(config);
|
39 |
|
78 |
|
40 |
exit(!indexer->index());
|
79 |
exit(!indexer->index((op_flags & OPT_z) != 0));
|
41 |
}
|
80 |
}
|