summaryrefslogtreecommitdiff
path: root/dynamite.c
diff options
context:
space:
mode:
authorLars Hanisch <dvb@flensrocker.de>2011-03-17 18:37:24 +0100
committerLars Hanisch <dvb@flensrocker.de>2011-03-17 18:37:24 +0100
commit346ebc85cd43fbf778a200e912bcb6079b611e64 (patch)
treeaabc62f576036d308a70afb59de7244c6d99cd19 /dynamite.c
parentc2b418c56d5f6e179bd6a62a45a186c70d2b14e2 (diff)
downloadvdr-plugin-dynamite-346ebc85cd43fbf778a200e912bcb6079b611e64.tar.gz
vdr-plugin-dynamite-346ebc85cd43fbf778a200e912bcb6079b611e64.tar.bz2
- use getopt_long on commandline argument processing, look at README for new arguments
- raise event via cPlugin::Service if a device is attached/detached so other plugins can react on it ("dynamite-event-DeviceAttached-v0.1", "dynamite-event-DeviceDetached-v0.1")
Diffstat (limited to 'dynamite.c')
-rw-r--r--dynamite.c69
1 files changed, 49 insertions, 20 deletions
diff --git a/dynamite.c b/dynamite.c
index 9c57d71..60f0180 100644
--- a/dynamite.c
+++ b/dynamite.c
@@ -4,11 +4,12 @@
* See the README file for copyright information and how to reach the author.
*/
+#include <getopt.h>
#include <vdr/plugin.h>
#include "dynamicdevice.h"
#include "monitor.h"
-static const char *VERSION = "0.0.5l";
+static const char *VERSION = "0.0.5m";
static const char *DESCRIPTION = "attach/detach devices on the fly";
static const char *MAINMENUENTRY = NULL;
@@ -120,24 +121,52 @@ const char *cPluginDynamite::CommandLineHelp(void)
bool cPluginDynamite::ProcessArgs(int argc, char *argv[])
{
- for (int i = 0; i < argc; i++) {
- if (strcmp(argv[i], "--log-udev") == 0)
- cUdevMonitor::AddFilter(NULL, new cUdevLogFilter());
-
- if ((strcmp(argv[i], "--dummy-probe") == 0) && (probe == NULL))
- probe = new cDynamiteDeviceProbe;
-
- if ((strcasecmp(argv[i], "--GetTSTimeoutHandler") == 0) && ((i + 1) < argc)) {
- if (getTSTimeoutHandler != NULL)
- delete getTSTimeoutHandler;
- getTSTimeoutHandler = NULL;
- i++;
- if (argv[i] != NULL) {
- getTSTimeoutHandler = new cString(argv[i]);
- isyslog("dynamite: installing GetTSTimeoutHandler %s", **getTSTimeoutHandler);
- }
- }
- }
+ static struct option options[] =
+ {
+ {"log-udev", no_argument, 0, 'u'},
+ {"dummy-probe", no_argument, 0, 'd'},
+ {"GetTSTimeout", required_argument, 0, 't'},
+ {"GetTSTimeoutHandler", required_argument, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+
+ while (true) {
+ int option_index = 0;
+ int c = getopt_long(argc, argv, "udt:h:", options, &option_index);
+ if (c == -1)
+ break;
+ switch (c) {
+ case 'u':
+ {
+ isyslog("dynamite: activate udev-logging");
+ cUdevMonitor::AddFilter(NULL, new cUdevLogFilter());
+ break;
+ }
+ case 'd':
+ {
+ isyslog("dynamite: activate dummy-device-probe");
+ probe = new cDynamiteDeviceProbe;
+ break;
+ }
+ case 't':
+ {
+ if ((optarg != NULL) && isnumber(optarg))
+ cDynamicDevice::SetDefaultGetTSTimeout(strtol(optarg, NULL, 10));
+ break;
+ }
+ case 'h':
+ {
+ if (getTSTimeoutHandler != NULL)
+ delete getTSTimeoutHandler;
+ getTSTimeoutHandler = NULL;
+ if (optarg != NULL) {
+ getTSTimeoutHandler = new cString(optarg);
+ isyslog("dynamite: installing GetTS-Timeout-Handler %s", **getTSTimeoutHandler);
+ }
+ break;
+ }
+ }
+ }
return true;
}
@@ -214,7 +243,7 @@ bool cPluginDynamite::SetupParse(const char *Name, const char *Value)
getTSTimeoutHandler = NULL;
if (Value != NULL) {
getTSTimeoutHandler = new cString(Value);
- isyslog("dynamite: installing GetTSTimeoutHandler %s", **getTSTimeoutHandler);
+ isyslog("dynamite: installing GetTS-Timeout-Handler %s", **getTSTimeoutHandler);
}
}
else