[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdesupport/strigi/src/daemon
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2007-10-03 9:58:01
Message-ID: 1191405481.472993.19981.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 720597 by trueg:
Added command line parameters:
* standard --version and --help
* -t <backend> to override the index backend
* -d <dir> to override the index storage dir
M +61 -4 daemon.cpp
--- trunk/kdesupport/strigi/src/daemon/daemon.cpp #720596:720597
@@ -1,6 +1,6 @@
/* This file is part of Strigi Desktop Search
*
- * Copyright (C) 2006 Jos van den Oever <jos@vandenoever.info>
+ * Copyright (C) 2006-2007 Jos van den Oever <jos@vandenoever.info>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -56,6 +56,13 @@
using namespace Strigi;
using namespace std;
+namespace {
+ // can be set via the command line to override settings in the
+ // configuration file.
+ string userForcedIndexType;
+ string userForcedIndexDir;
+}
+
/**
* Initialize a directory for storing the index data and the socket.
* Make sure it is well protected from peeping eyes.
@@ -125,6 +132,53 @@
fcntl(fileno(f), F_SETLK, &lock);
fclose(f);
}
+void
+printVersion(int argc, char** argv) {
+ printf( "%s %s\n Copyright (C) 2006-2007 Jos van den Oever <jos@vandenoever.info>\n",
+ argv[0],
+ STRIGI_VERSION_STRING );
+}
+void
+printUsage(int argc, char** argv) {
+ printf( "%s [--version] [--help] [-t <backend>] [-d <indexdir>]\n",
+ argv[0] );
+ printf( " --version Display the version.\n" );
+ printf( " --help Display this help text.\n" );
+ printf( " -t <backend> Override the index backend.\n" );
+ printf( " -d <indexdir> Override the index dir.\n" );
+}
+void
+checkArgs(int argc, char** argv) {
+ int i = 1;
+ while ( i < argc ) {
+ if ( !strcmp( argv[i], "--version" ) ) {
+ printVersion(argc, argv);
+ exit( 0 );
+ }
+ else if ( !strcmp( argv[i], "--help" ) ) {
+ printUsage(argc, argv);
+ exit( 0 );
+ }
+ else if ( !strcmp( argv[i], "-t" ) ) {
+ ++i;
+ if ( i >= argc ) {
+ printUsage(argc, argv);
+ exit( 1 );
+ }
+ userForcedIndexType = argv[i];
+ }
+ else if ( !strcmp( argv[i], "-d" ) ) {
+ ++i;
+ if ( i >= argc ) {
+ printUsage(argc, argv);
+ exit( 1 );
+ }
+ userForcedIndexDir = argv[i];
+ }
+
+ ++i;
+ }
+}
int
main(int argc, char** argv) {
// set up the directory paths
@@ -142,6 +196,8 @@
string pathfilterfile = daemondir+"/pathfilter.conf";
string patternfilterfile = daemondir+"/patternfilter.conf";
+ checkArgs( argc,argv );
+
// initialize the directory for the daemon data
if (!initializeDir(daemondir)) {
fprintf(stderr, "Could not initialize the daemon directory.\n");
@@ -187,7 +243,8 @@
set<string> dirs = config.getIndexedDirectories();
CombinedIndexManager* index = new CombinedIndexManager(
- config.getWriteableIndexType(), config.getWriteableIndexDir());
+ !userForcedIndexType.empty() ? userForcedIndexType : config.getWriteableIndexType(),
+ !userForcedIndexDir.empty() ? userForcedIndexDir : config.getWriteableIndexDir());
list<Repository> rors = config.getReadOnlyRepositories();
list<Repository>::const_iterator i;
for (i = rors.begin(); i != rors.end(); ++i) {
@@ -273,10 +330,10 @@
//delete listener
delete listener;
-
+
//delete listener event queue
delete listenerEventQueue;
-
+
// release lock
releaseLock(lockfile, lock);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic