Add -c <confdir> option to recoll and recollindex

This commit is contained in:
dockes 2006-09-08 09:02:47 +00:00
parent 3492765da5
commit 8eb9ad3560
11 changed files with 124 additions and 44 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.29 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.30 2006-09-08 09:02:47 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -41,7 +41,7 @@ static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.29 2006-04-28 07:54:38 dockes E
using namespace std;
#endif /* NO_NAMESPACES */
RclConfig::RclConfig()
RclConfig::RclConfig(const string *argcnf)
{
zeroMe();
// Compute our data dir name, typically /usr/local/share/recoll
@ -53,14 +53,18 @@ RclConfig::RclConfig()
m_datadir = cdatadir;
}
const char *cp = getenv("RECOLL_CONFDIR");
if (cp) {
m_confdir = cp;
// Command line config name overrides environment
if (argcnf && !argcnf->empty()) {
m_confdir = *argcnf;
} else {
m_confdir = path_home();
m_confdir += ".recoll/";
const char *cp = getenv("RECOLL_CONFDIR");
if (cp) {
m_confdir = cp;
} else {
m_confdir = path_home();
m_confdir += ".recoll/";
}
}
if (access(m_confdir.c_str(), 0) < 0) {
if (!initUserConfig())
return;

View File

@ -16,7 +16,7 @@
*/
#ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.20 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclconfig.h,v 1.21 2006-09-08 09:02:47 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list>
@ -26,7 +26,7 @@
class RclConfig {
public:
RclConfig();
RclConfig(const string *argcnf=0);
bool ok() {return m_ok;}
const string &getReason() {return m_reason;}
/** Return the directory where this config is stored */

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclinit.cpp,v 1.5 2006-03-29 11:18:14 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclinit.cpp,v 1.6 2006-09-08 09:02:47 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -27,7 +27,7 @@ static char rcsid[] = "@(#$Id: rclinit.cpp,v 1.5 2006-03-29 11:18:14 dockes Exp
#include "rclinit.h"
RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
string &reason)
string &reason, const string *argcnf)
{
if (cleanup)
atexit(cleanup);
@ -43,7 +43,7 @@ RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
}
DebugLog::getdbl()->setloglevel(DEBDEB1);
DebugLog::setfilename("stderr");
RclConfig *config = new RclConfig;
RclConfig *config = new RclConfig(argcnf);
if (!config || !config->ok()) {
reason = "Configuration could not be built:\n";
if (config)

View File

@ -16,13 +16,14 @@
*/
#ifndef _RCLINIT_H_INCLUDED_
#define _RCLINIT_H_INCLUDED_
/* @(#$Id: rclinit.h,v 1.3 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: rclinit.h,v 1.4 2006-09-08 09:02:47 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string>
class RclConfig;
extern RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
std::string &reason);
std::string &reason,
const std::string *argcnf = 0);
#endif /* _RCLINIT_H_INCLUDED_ */

View File

@ -1,9 +1,13 @@
.\" $Id: recoll.1,v 1.1 2006-01-10 08:14:43 dockes Exp $ (C) 2005 J.F.Dockes\$
.\" $Id: recoll.1,v 1.2 2006-09-08 09:02:47 dockes Exp $ (C) 2005 J.F.Dockes\$
.TH RECOLL 1 "8 January 2006"
.SH NAME
recoll \- user interface for the Recoll full text search system
.SH SYNOPSIS
.B recoll
[
.B -c
<configdir>
]
.SH DESCRIPTION
The
.B recoll
@ -16,6 +20,11 @@ On the first run,
will create the user configuration which can be customized
before starting the first indexation.
.PP
The
.B -c
option specifies the configuration directory name, overriding the
default or $RECOLL_CONFDIR.
.PP
Please refer to online help for a full description.
.SH SEE ALSO
.PP

View File

@ -1,4 +1,4 @@
.\" $Id: recoll.conf.5,v 1.2 2006-03-28 12:49:03 dockes Exp $ (C) 2005 J.F.Dockes\$
.\" $Id: recoll.conf.5,v 1.3 2006-09-08 09:02:47 dockes Exp $ (C) 2005 J.F.Dockes\$
.TH RECOLL.CONF 5 "8 January 2006"
.SH NAME
recoll.conf \- main personal configuration file for Recoll
@ -90,7 +90,8 @@ images.
.TP
.BI "dbdir = " directory
The name of the Xapian database directory. It will be created if needed
when the database is initialized.
when the database is initialized. If this is not an absolute pathname, it
will be taken relative to the configuration directory.
.TP
.BI "defaultcharset = " charset
The name of the character set used for files that do not contain a

View File

@ -1,4 +1,4 @@
.\" $Id: recollindex.1,v 1.1 2006-01-10 08:09:52 dockes Exp $ (C) 2005 J.F.Dockes\$
.\" $Id: recollindex.1,v 1.2 2006-09-08 09:02:47 dockes Exp $ (C) 2005 J.F.Dockes\$
.TH RECOLLINDEX 1 "8 January 2006"
.SH NAME
recollindex \- indexing command for the Recoll full text search system
@ -7,14 +7,26 @@ recollindex \- indexing command for the Recoll full text search system
.br
.B recollindex
[
.B -c
<configdir>
]
[
.B -z
]
.br
.B recollindex
[
.B -c
<configdir>
]
.B -i
<filename [filename ...]>
.br
.B recollindex
[
.B -c
<configdir>
]
.B -s
<lang>
.SH DESCRIPTION
@ -23,6 +35,11 @@ The
utility allows you to perform indexing operations for the Recoll text
search system.
.PP
The
.B -c
option specifies the configuration directory name, overriding the
default or $RECOLL_CONFDIR.
.PP
There are three modes of operation.
.PP
The normal mode will index the set of files described in the configuration

View File

@ -24,7 +24,7 @@
Dockes</holder>
</copyright>
<releaseinfo>$Id: usermanual.sgml,v 1.14 2006-06-24 07:40:04 dockes Exp $</releaseinfo>
<releaseinfo>$Id: usermanual.sgml,v 1.15 2006-09-08 09:02:47 dockes Exp $</releaseinfo>
<abstract>
<para>This document introduces full text search notions
@ -44,7 +44,8 @@
like to give &RCL; a try, just perform <link
linkend="rcl.install">installation</link> and start the
<command>recoll</command> user interface, which will index your
home directory and let you search it right after.</para>
home directory by default, allowing you to search immediately after
indexing completes.</para>
<para>Do not do this if your home has a huge
number of documents and you do not want to wait or are very
@ -73,16 +74,15 @@
<para>You do not need to remember in what file or email message you
stored a given piece of information. You just ask for related
terms, and the tool will return a list of documents where
those terms are prominent.</para>
those terms are prominent, in a similar way to internet search
engines.</para>
<para>This mode of operation has been made very familiar by internet
search engines.</para>
<para>The notion of relevance is a difficult one, as only you, the
user, actually know which documents are relevant to your search,
and the application can only try a guess. The quality of this
guess is probably the most important element for a search
application.</para>
<para>&RCL; tries to determine which documents are most relevant to
the search terms you provide. Computer algorithms for determining
relevance can be very complex, and in general are inferior to the
power of the human mind to rapidly determine relevance. The quality
of relevance guessing by the search tool is probably the most
important element for a search application.</para>
<para>In many cases, you are looking for all the forms of a
word, not for a specific form or spelling. These different
@ -93,8 +93,9 @@
reduce to the same stem). This expansion can be disabled at
search time.</para>
<para>Stemming, by itself, does not provide for misspellings or
phonetic searches. &RCL; currently does not support these.</para>
<para>Stemming, by itself, does not accomodate for misspellings or
phonetic searches. &RCL; currently does not support these
features.</para>
</sect1>
@ -914,9 +915,11 @@
files are kept in a directory named like
<filename>/usr/[local/]share/recoll/examples</filename>,
they define default values for the system. A parallel set of
files exists in the <filename>.recoll</filename> directory in
your home (this can be changed with the
<literal>RECOLL_CONFDIR</literal> environment variable.</para>
files exists by default in the <filename>.recoll</filename> directory
in your home. This directory can be changed with the
<literal>RECOLL_CONFDIR</literal> environment variable or the -c
option parameter to <command>recoll</command> and
<command>recollindex</command>.</para>
<para>If the <filename>.recoll</filename> directory does not
exist when <command>recoll</command> or
@ -1080,7 +1083,8 @@
<varlistentry><term><literal>dbdir</literal></term>
<listitem><para>The name of the Xapian data directory. It
will be created if needed when the index is
initialized. </para>
initialized. If this is not an absolute path, it will be
interpreted relative to the configuration directory.</para>
</listitem>
</varlistentry>

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.19 2006-04-28 07:54:38 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: recollindex.cpp,v 1.20 2006-09-08 09:02:47 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -107,6 +107,7 @@ static int op_flags;
#define OPT_h 0x4
#define OPT_i 0x8
#define OPT_s 0x10
#define OPT_c 0x20
static const char usage [] =
"\n"
@ -119,6 +120,8 @@ static const char usage [] =
" Index individual files. No database purge or stem database updates\n"
"recollindex -s <lang>\n"
" Build stem database for additional language <lang>\n"
"Common options:\n"
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
;
static void
@ -132,6 +135,7 @@ Usage(void)
int main(int argc, const char **argv)
{
string a_config;
thisprog = argv[0];
argc--; argv++;
@ -141,10 +145,13 @@ int main(int argc, const char **argv)
Usage();
while (**argv)
switch (*(*argv)++) {
case 'z': op_flags |= OPT_z; break;
case 'c': op_flags |= OPT_c; if (argc < 2) Usage();
a_config = *(++argv);
argc--; goto b1;
case 'h': op_flags |= OPT_h; break;
case 'i': op_flags |= OPT_i; break;
case 's': op_flags |= OPT_s; break;
case 'z': op_flags |= OPT_z; break;
default: Usage(); break;
}
b1: argc--; argv++;
@ -155,7 +162,7 @@ int main(int argc, const char **argv)
Usage();
string reason;
RclConfig *config = recollinit(cleanup, sigcleanup, reason);
RclConfig *config = recollinit(cleanup, sigcleanup, reason, &a_config);
if (config == 0 || !config->ok()) {
cerr << "Configuration problem: " << reason << endl;
exit(1);

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.12 2006-09-04 15:13:01 dockes Exp $ (C) 2005 Jean-Francois Dockes";
static char rcsid[] = "@(#$Id: guiutils.cpp,v 1.13 2006-09-08 09:02:47 dockes Exp $ (C) 2005 Jean-Francois Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -120,7 +120,7 @@ PrefsPack prefs;
*/
void rwSettings(bool writing)
{
fprintf(stderr, "rwSettings: write %d\n", int(writing));
LOGDEB1(("rwSettings: write %d\n", int(writing)));
#if QT_VERSION >= 0x040000
QSettings settings("Recoll.org", "recoll");
#else

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.45 2006-09-04 15:13:01 dockes Exp $ (C) 2005 J.F.Dockes";
static char rcsid[] = "@(#$Id: main.cpp,v 1.46 2006-09-08 09:02:47 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -130,7 +130,26 @@ static void sigcleanup(int)
extern void qInitImages_recoll();
int main( int argc, char ** argv )
static const char *thisprog;
static int op_flags;
#define OPT_MOINS 0x1
#define OPT_h 0x4
#define OPT_c 0x20
static const char usage [] =
"\n"
"recoll [-h] [-c <configdir>]\n"
" -h : Print help and exit\n"
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
;
static void
Usage(void)
{
FILE *fp = (op_flags & OPT_h) ? stdout : stderr;
fprintf(fp, "%s: Usage: %s", thisprog, usage);
exit((op_flags & OPT_h)==0);
}
int main(int argc, char **argv)
{
#ifdef WITH_KDE
KAboutData about("recoll", I18N_NOOP("Recoll"), rclversion, description,
@ -144,6 +163,24 @@ int main( int argc, char ** argv )
QApplication app(argc, argv);
#endif
string a_config;
thisprog = argv[0];
argc--; argv++;
while (argc > 0 && **argv == '-') {
(*argv)++;
if (!(**argv))
Usage();
while (**argv)
switch (*(*argv)++) {
case 'c': op_flags |= OPT_c; if (argc < 2) Usage();
a_config = *(++argv);
argc--; goto b1;
case 'h': op_flags |= OPT_h; Usage();break;
}
b1: argc--; argv++;
}
// Translation file for Qt
QTranslator qt( 0 );
qt.load( QString( "qt_" ) + QTextCodec::locale(), "." );
@ -160,7 +197,7 @@ int main( int argc, char ** argv )
rwSettings(false);
string reason;
rclconfig = recollinit(recollCleanup, sigcleanup, reason);
rclconfig = recollinit(recollCleanup, sigcleanup, reason, &a_config);
if (!rclconfig || !rclconfig->ok()) {
QString msg = app.translate("Main", "Configuration problem: ");
msg += QString::fromUtf8(reason.c_str());