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 #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 #endif
/* /*
* This program is free software; you can redistribute it and/or modify * 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; using namespace std;
#endif /* NO_NAMESPACES */ #endif /* NO_NAMESPACES */
RclConfig::RclConfig() RclConfig::RclConfig(const string *argcnf)
{ {
zeroMe(); zeroMe();
// Compute our data dir name, typically /usr/local/share/recoll // Compute our data dir name, typically /usr/local/share/recoll
@ -53,14 +53,18 @@ RclConfig::RclConfig()
m_datadir = cdatadir; m_datadir = cdatadir;
} }
const char *cp = getenv("RECOLL_CONFDIR"); // Command line config name overrides environment
if (cp) { if (argcnf && !argcnf->empty()) {
m_confdir = cp; m_confdir = *argcnf;
} else { } else {
m_confdir = path_home(); const char *cp = getenv("RECOLL_CONFDIR");
m_confdir += ".recoll/"; if (cp) {
m_confdir = cp;
} else {
m_confdir = path_home();
m_confdir += ".recoll/";
}
} }
if (access(m_confdir.c_str(), 0) < 0) { if (access(m_confdir.c_str(), 0) < 0) {
if (!initUserConfig()) if (!initUserConfig())
return; return;

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _RCLCONFIG_H_INCLUDED_ #ifndef _RCLCONFIG_H_INCLUDED_
#define _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> #include <list>
@ -26,7 +26,7 @@
class RclConfig { class RclConfig {
public: public:
RclConfig(); RclConfig(const string *argcnf=0);
bool ok() {return m_ok;} bool ok() {return m_ok;}
const string &getReason() {return m_reason;} const string &getReason() {return m_reason;}
/** Return the directory where this config is stored */ /** Return the directory where this config is stored */

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
* This program is free software; you can redistribute it and/or modify * 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" #include "rclinit.h"
RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int), RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
string &reason) string &reason, const string *argcnf)
{ {
if (cleanup) if (cleanup)
atexit(cleanup); atexit(cleanup);
@ -43,7 +43,7 @@ RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
} }
DebugLog::getdbl()->setloglevel(DEBDEB1); DebugLog::getdbl()->setloglevel(DEBDEB1);
DebugLog::setfilename("stderr"); DebugLog::setfilename("stderr");
RclConfig *config = new RclConfig; RclConfig *config = new RclConfig(argcnf);
if (!config || !config->ok()) { if (!config || !config->ok()) {
reason = "Configuration could not be built:\n"; reason = "Configuration could not be built:\n";
if (config) if (config)

View File

@ -16,13 +16,14 @@
*/ */
#ifndef _RCLINIT_H_INCLUDED_ #ifndef _RCLINIT_H_INCLUDED_
#define _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> #include <string>
class RclConfig; class RclConfig;
extern RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int), extern RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
std::string &reason); std::string &reason,
const std::string *argcnf = 0);
#endif /* _RCLINIT_H_INCLUDED_ */ #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" .TH RECOLL 1 "8 January 2006"
.SH NAME .SH NAME
recoll \- user interface for the Recoll full text search system recoll \- user interface for the Recoll full text search system
.SH SYNOPSIS .SH SYNOPSIS
.B recoll .B recoll
[
.B -c
<configdir>
]
.SH DESCRIPTION .SH DESCRIPTION
The The
.B recoll .B recoll
@ -16,6 +20,11 @@ On the first run,
will create the user configuration which can be customized will create the user configuration which can be customized
before starting the first indexation. before starting the first indexation.
.PP .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. Please refer to online help for a full description.
.SH SEE ALSO .SH SEE ALSO
.PP .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" .TH RECOLL.CONF 5 "8 January 2006"
.SH NAME .SH NAME
recoll.conf \- main personal configuration file for Recoll recoll.conf \- main personal configuration file for Recoll
@ -90,7 +90,8 @@ images.
.TP .TP
.BI "dbdir = " directory .BI "dbdir = " directory
The name of the Xapian database directory. It will be created if needed 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 .TP
.BI "defaultcharset = " charset .BI "defaultcharset = " charset
The name of the character set used for files that do not contain a 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" .TH RECOLLINDEX 1 "8 January 2006"
.SH NAME .SH NAME
recollindex \- indexing command for the Recoll full text search system 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 .br
.B recollindex .B recollindex
[ [
.B -c
<configdir>
]
[
.B -z .B -z
] ]
.br .br
.B recollindex .B recollindex
[
.B -c
<configdir>
]
.B -i .B -i
<filename [filename ...]> <filename [filename ...]>
.br .br
.B recollindex .B recollindex
[
.B -c
<configdir>
]
.B -s .B -s
<lang> <lang>
.SH DESCRIPTION .SH DESCRIPTION
@ -23,6 +35,11 @@ The
utility allows you to perform indexing operations for the Recoll text utility allows you to perform indexing operations for the Recoll text
search system. search system.
.PP .PP
The
.B -c
option specifies the configuration directory name, overriding the
default or $RECOLL_CONFDIR.
.PP
There are three modes of operation. There are three modes of operation.
.PP .PP
The normal mode will index the set of files described in the configuration The normal mode will index the set of files described in the configuration

View File

@ -24,7 +24,7 @@
Dockes</holder> Dockes</holder>
</copyright> </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> <abstract>
<para>This document introduces full text search notions <para>This document introduces full text search notions
@ -44,7 +44,8 @@
like to give &RCL; a try, just perform <link like to give &RCL; a try, just perform <link
linkend="rcl.install">installation</link> and start the linkend="rcl.install">installation</link> and start the
<command>recoll</command> user interface, which will index your <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 <para>Do not do this if your home has a huge
number of documents and you do not want to wait or are very 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 <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 stored a given piece of information. You just ask for related
terms, and the tool will return a list of documents where 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 <para>&RCL; tries to determine which documents are most relevant to
search engines.</para> the search terms you provide. Computer algorithms for determining
relevance can be very complex, and in general are inferior to the
<para>The notion of relevance is a difficult one, as only you, the power of the human mind to rapidly determine relevance. The quality
user, actually know which documents are relevant to your search, of relevance guessing by the search tool is probably the most
and the application can only try a guess. The quality of this important element for a search application.</para>
guess is probably the most important element for a search
application.</para>
<para>In many cases, you are looking for all the forms of a <para>In many cases, you are looking for all the forms of a
word, not for a specific form or spelling. These different 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 reduce to the same stem). This expansion can be disabled at
search time.</para> search time.</para>
<para>Stemming, by itself, does not provide for misspellings or <para>Stemming, by itself, does not accomodate for misspellings or
phonetic searches. &RCL; currently does not support these.</para> phonetic searches. &RCL; currently does not support these
features.</para>
</sect1> </sect1>
@ -914,9 +915,11 @@
files are kept in a directory named like files are kept in a directory named like
<filename>/usr/[local/]share/recoll/examples</filename>, <filename>/usr/[local/]share/recoll/examples</filename>,
they define default values for the system. A parallel set of they define default values for the system. A parallel set of
files exists in the <filename>.recoll</filename> directory in files exists by default in the <filename>.recoll</filename> directory
your home (this can be changed with the in your home. This directory can be changed with the
<literal>RECOLL_CONFDIR</literal> environment variable.</para> <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 <para>If the <filename>.recoll</filename> directory does not
exist when <command>recoll</command> or exist when <command>recoll</command> or
@ -1080,7 +1083,8 @@
<varlistentry><term><literal>dbdir</literal></term> <varlistentry><term><literal>dbdir</literal></term>
<listitem><para>The name of the Xapian data directory. It <listitem><para>The name of the Xapian data directory. It
will be created if needed when the index is 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> </listitem>
</varlistentry> </varlistentry>

View File

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

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -120,7 +120,7 @@ PrefsPack prefs;
*/ */
void rwSettings(bool writing) void rwSettings(bool writing)
{ {
fprintf(stderr, "rwSettings: write %d\n", int(writing)); LOGDEB1(("rwSettings: write %d\n", int(writing)));
#if QT_VERSION >= 0x040000 #if QT_VERSION >= 0x040000
QSettings settings("Recoll.org", "recoll"); QSettings settings("Recoll.org", "recoll");
#else #else

View File

@ -1,5 +1,5 @@
#ifndef lint #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 #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -130,7 +130,26 @@ static void sigcleanup(int)
extern void qInitImages_recoll(); 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 #ifdef WITH_KDE
KAboutData about("recoll", I18N_NOOP("Recoll"), rclversion, description, KAboutData about("recoll", I18N_NOOP("Recoll"), rclversion, description,
@ -144,6 +163,24 @@ int main( int argc, char ** argv )
QApplication app(argc, argv); QApplication app(argc, argv);
#endif #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 // Translation file for Qt
QTranslator qt( 0 ); QTranslator qt( 0 );
qt.load( QString( "qt_" ) + QTextCodec::locale(), "." ); qt.load( QString( "qt_" ) + QTextCodec::locale(), "." );
@ -160,7 +197,7 @@ int main( int argc, char ** argv )
rwSettings(false); rwSettings(false);
string reason; string reason;
rclconfig = recollinit(recollCleanup, sigcleanup, reason); rclconfig = recollinit(recollCleanup, sigcleanup, reason, &a_config);
if (!rclconfig || !rclconfig->ok()) { if (!rclconfig || !rclconfig->ok()) {
QString msg = app.translate("Main", "Configuration problem: "); QString msg = app.translate("Main", "Configuration problem: ");
msg += QString::fromUtf8(reason.c_str()); msg += QString::fromUtf8(reason.c_str());