]> git.vomp.tv Git - vompserver.git/commitdiff
Add config path option
authorChris Tallon <chris@vomp.tv>
Tue, 2 May 2006 22:13:21 +0000 (22:13 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 2 May 2006 22:13:21 +0000 (22:13 +0000)
mvpclient.c
mvpclient.h
mvpserver.c
mvpserver.h
vompserver.c

index a8bde75cba31b2bdbe5951263dd51b3f18911d2e..8fd0b8daf3a5c150a8d2bf9d942ab27322e0aa6e 100644 (file)
@@ -23,7 +23,7 @@
 // This is here else it causes compile errors with something in libdvbmpeg
 #include <vdr/menu.h>
 
-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
index fd26be7a590a1babba1a32c1009a6371712c00fa..f0e49bf5111f7cc56b568f1d6714fd55deb11666 100644 (file)
@@ -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;
index 438405c67aaca06fd22d0eb5e6b2cfb795003e3a..29cecd8d87aa9a3ace7227607c5e63f76b23e2a7 100644 (file)
@@ -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();
   }
 }
index efb73b5ef34fda94ef688f1f1093762a4b740fff..48598d78f053f76e8389dc23adfd5b4bd31de3d4 100644 (file)
@@ -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
index 392436e747c7725b2553219778c51711a2c79a96..5904a815330984de0696ec749a6237bda33cde51 100644 (file)
     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 <vdr/plugin.h>
+#include <getopt.h>
 
 #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!
+