From 8eb9ad35604777e45a59215137dbca11f01bb5ca Mon Sep 17 00:00:00 2001 From: dockes Date: Fri, 8 Sep 2006 09:02:47 +0000 Subject: [PATCH] Add -c option to recoll and recollindex --- src/common/rclconfig.cpp | 20 ++++++++++------- src/common/rclconfig.h | 4 ++-- src/common/rclinit.cpp | 6 ++--- src/common/rclinit.h | 5 +++-- src/doc/man/recoll.1 | 11 ++++++++- src/doc/man/recoll.conf.5 | 5 +++-- src/doc/man/recollindex.1 | 19 +++++++++++++++- src/doc/user/usermanual.sgml | 38 +++++++++++++++++-------------- src/index/recollindex.cpp | 13 ++++++++--- src/qtgui/guiutils.cpp | 4 ++-- src/qtgui/main.cpp | 43 +++++++++++++++++++++++++++++++++--- 11 files changed, 124 insertions(+), 44 deletions(-) diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index 56175fe1..90602227 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -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; diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index 129ef447..c0c0ddef 100644 --- a/src/common/rclconfig.h +++ b/src/common/rclconfig.h @@ -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 @@ -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 */ diff --git a/src/common/rclinit.cpp b/src/common/rclinit.cpp index abf11fb0..2d1d5247 100644 --- a/src/common/rclinit.cpp +++ b/src/common/rclinit.cpp @@ -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) diff --git a/src/common/rclinit.h b/src/common/rclinit.h index 67bfc60e..06fc0b0d 100644 --- a/src/common/rclinit.h +++ b/src/common/rclinit.h @@ -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 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_ */ diff --git a/src/doc/man/recoll.1 b/src/doc/man/recoll.1 index 71e5bed8..a31b7259 100644 --- a/src/doc/man/recoll.1 +++ b/src/doc/man/recoll.1 @@ -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 + +] .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 diff --git a/src/doc/man/recoll.conf.5 b/src/doc/man/recoll.conf.5 index 2d8bc6ee..a99eeb0e 100644 --- a/src/doc/man/recoll.conf.5 +++ b/src/doc/man/recoll.conf.5 @@ -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 diff --git a/src/doc/man/recollindex.1 b/src/doc/man/recollindex.1 index 299dbb2b..50b6691f 100644 --- a/src/doc/man/recollindex.1 +++ b/src/doc/man/recollindex.1 @@ -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 + +] +[ .B -z ] .br .B recollindex +[ +.B -c + +] .B -i .br .B recollindex +[ +.B -c + +] .B -s .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 diff --git a/src/doc/user/usermanual.sgml b/src/doc/user/usermanual.sgml index ba85d865..d8ecc997 100644 --- a/src/doc/user/usermanual.sgml +++ b/src/doc/user/usermanual.sgml @@ -24,7 +24,7 @@ Dockes - $Id: usermanual.sgml,v 1.14 2006-06-24 07:40:04 dockes Exp $ + $Id: usermanual.sgml,v 1.15 2006-09-08 09:02:47 dockes Exp $ This document introduces full text search notions @@ -44,7 +44,8 @@ like to give &RCL; a try, just perform installation and start the recoll user interface, which will index your - home directory and let you search it right after. + home directory by default, allowing you to search immediately after + indexing completes. 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 @@ 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. + those terms are prominent, in a similar way to internet search + engines. - This mode of operation has been made very familiar by internet - search engines. - - 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. + &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. 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. - Stemming, by itself, does not provide for misspellings or - phonetic searches. &RCL; currently does not support these. + Stemming, by itself, does not accomodate for misspellings or + phonetic searches. &RCL; currently does not support these + features. @@ -914,9 +915,11 @@ files are kept in a directory named like /usr/[local/]share/recoll/examples, they define default values for the system. A parallel set of - files exists in the .recoll directory in - your home (this can be changed with the - RECOLL_CONFDIR environment variable. + files exists by default in the .recoll directory + in your home. This directory can be changed with the + RECOLL_CONFDIR environment variable or the -c + option parameter to recoll and + recollindex. If the .recoll directory does not exist when recoll or @@ -1080,7 +1083,8 @@ dbdir The name of the Xapian data directory. It will be created if needed when the index is - initialized. + initialized. If this is not an absolute path, it will be + interpreted relative to the configuration directory. diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index 3e5b6eeb..7763f883 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -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 \n" " Build stem database for additional language \n" +"Common options:\n" +" -c : 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); diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 272b1363..10e42422 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -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 diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 0461f69d..523fcca5 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -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 ]\n" +" -h : Print help and exit\n" +" -c : 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());