From 5abd62c097f6c98c5722bdd3da585e5f128aa55a Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Tue, 2 May 2006 22:13:21 +0000 Subject: [PATCH] Add config path option --- mvpclient.c | 8 ++++---- mvpclient.h | 3 ++- mvpserver.c | 9 ++++++--- mvpserver.h | 3 ++- vompserver.c | 34 +++++++++++++++++++++++----------- 5 files changed, 37 insertions(+), 20 deletions(-) diff --git a/mvpclient.c b/mvpclient.c index a8bde75..8fd0b8d 100644 --- a/mvpclient.c +++ b/mvpclient.c @@ -23,7 +23,7 @@ // This is here else it causes compile errors with something in libdvbmpeg #include -MVPClient::MVPClient(int tsocket) +MVPClient::MVPClient(char* tconfigDirExtra, int tsocket) : tcp(tsocket) { lp = NULL; @@ -31,6 +31,7 @@ MVPClient::MVPClient(int tsocket) recordingManager = NULL; log = Log::getInstance(); loggedIn = false; + configDirExtra = tconfigDirExtra; } MVPClient::~MVPClient() @@ -246,7 +247,7 @@ int MVPClient::processLogin(UCHAR* buffer, int length) // Open the config - const char* configDir = cPlugin::ConfigDirectory(); + const char* configDir = cPlugin::ConfigDirectory(configDirExtra); if (!configDir) { log->log("Client", Log::DEBUG, "No config dir!"); @@ -254,8 +255,7 @@ int MVPClient::processLogin(UCHAR* buffer, int length) } char configFileName[PATH_MAX]; - snprintf(configFileName, PATH_MAX - strlen(configDir) - 17 - 20, "%s/vomp-%02X-%02X-%02X-%02X-%02X-%02X.conf", configDir, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); - //( ^^^^^^^^^^^^^eh?^^^^^^^^^^^^^) + snprintf(configFileName, PATH_MAX, "%s/vomp-%02X-%02X-%02X-%02X-%02X-%02X.conf", configDir, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); config.init(configFileName); // Send the login reply diff --git a/mvpclient.h b/mvpclient.h index fd26be7..f0e49bf 100644 --- a/mvpclient.h +++ b/mvpclient.h @@ -43,7 +43,7 @@ class MVPClient { public: - MVPClient(int tsocket); + MVPClient(char* configDirExtra, int tsocket); ~MVPClient(); int run(); @@ -57,6 +57,7 @@ class MVPClient Config config; MVPReceiver* lp; bool loggedIn; + char* configDirExtra; cRecordings* recordingManager; diff --git a/mvpserver.c b/mvpserver.c index 438405c..29cecd8 100644 --- a/mvpserver.c +++ b/mvpserver.c @@ -46,12 +46,14 @@ int MVPServer::stop() return 1; } -int MVPServer::run() +int MVPServer::run(char* tconfigDirExtra) { if (threadIsActive()) return 1; + configDirExtra = tconfigDirExtra; + // Start config - const char* configDir = cPlugin::ConfigDirectory(); + const char* configDir = cPlugin::ConfigDirectory(configDirExtra); if (!configDir) { dsyslog("VOMP: Could not get config dir from VDR"); @@ -60,6 +62,7 @@ int MVPServer::run() { char configFileName[PATH_MAX]; snprintf(configFileName, PATH_MAX, "%s/vomp.conf", configDir); + if (config.init(configFileName)) { dsyslog("VOMP: Config file found"); @@ -231,7 +234,7 @@ void MVPServer::threadMethod() while(1) { clientSocket = accept(listeningSocket,(struct sockaddr *)&address, &length); - MVPClient* m = new MVPClient(clientSocket); + MVPClient* m = new MVPClient(configDirExtra, clientSocket); m->run(); } } diff --git a/mvpserver.h b/mvpserver.h index efb73b5..48598d7 100644 --- a/mvpserver.h +++ b/mvpserver.h @@ -39,7 +39,7 @@ class MVPServer : public Thread MVPServer(); virtual ~MVPServer(); - int run(); + int run(char* configDir); int stop(); private: @@ -51,6 +51,7 @@ class MVPServer : public Thread Bootpd bootpd; Tftpd tftpd; int listeningSocket; + char* configDirExtra; }; #endif diff --git a/vompserver.c b/vompserver.c index 392436e..5904a81 100644 --- a/vompserver.c +++ b/vompserver.c @@ -18,19 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* - * vomp-server.c: A plugin for the Video Disk Recorder - * - * See the README file for copyright information and how to reach the author. - * - * $Id$ - */ - #include +#include #include "mvpserver.h" -static const char *VERSION = "0.2.2"; +static const char *VERSION = "0.2.3"; static const char *DESCRIPTION = "VDR on MVP plugin by Chris Tallon"; class cPluginVompserver : public cPlugin @@ -49,6 +42,7 @@ public: private: MVPServer mvpserver; + char* configDir; }; cPluginVompserver::cPluginVompserver(void) @@ -56,12 +50,14 @@ cPluginVompserver::cPluginVompserver(void) // Initialize any member variables here. // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! + + configDir = NULL; } bool cPluginVompserver::Start(void) { // Start any background activities the plugin shall perform. - int success = mvpserver.run(); + int success = mvpserver.run(configDir); if (success) return true; else return false; } @@ -75,12 +71,27 @@ cPluginVompserver::~cPluginVompserver() const char *cPluginVompserver::CommandLineHelp(void) { // Return a string that describes all known command line options. - return NULL; + + return " -c dir config path relative to VDR plugins config path\n"; } bool cPluginVompserver::ProcessArgs(int argc, char *argv[]) { // Implement command line argument processing here if applicable. + + int c; + while ((c = getopt(argc, argv, "c:")) != -1) + { + if (c == 'c') + { + configDir = optarg; + } + else + { + return false; + } + } + return true; } @@ -97,3 +108,4 @@ bool cPluginVompserver::SetupParse(const char *Name, const char *Value) } VDRPLUGINCREATOR(cPluginVompserver); // Don't touch this! + -- 2.39.2