diff options
author | Lars Hanisch <dvb@flensrocker.de> | 2011-02-02 21:44:20 +0100 |
---|---|---|
committer | Lars Hanisch <dvb@flensrocker.de> | 2011-02-02 21:44:20 +0100 |
commit | 6fb28a2e29faf239b1b14fcac981d560a7550e65 (patch) | |
tree | 0fe226aad44f26d2d375fa9320bcfa2f2135123f /dynamite.c | |
parent | 8a8770d8b8b8d19e5f7d07628f742957d1ade4f1 (diff) | |
download | vdr-plugin-dynamite-6fb28a2e29faf239b1b14fcac981d560a7550e65.tar.gz vdr-plugin-dynamite-6fb28a2e29faf239b1b14fcac981d560a7550e65.tar.bz2 |
add generic udev-filter
Other plugins can add a filter for different subsystems and devnodes.
example:
AddUdevMonitor video4linux /dev/video
If udev signals an "add"-event whose devnode starts with "/dev/video"
the whole devnode is queued for attaching.
Diffstat (limited to 'dynamite.c')
-rw-r--r-- | dynamite.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -219,6 +219,13 @@ bool cPluginDynamite::Service(const char *Id, void *Data) } return true; } + if (strcmp(Id, "dynamite-AddUdevMonitor-v0.1") == 0) { + if (Data != NULL) { + int replyCode; + SVDRPCommand("AddUdevMonitor", (const char*)Data, replyCode); + } + return true; + } return false; } @@ -265,6 +272,11 @@ const char **cPluginDynamite::SVDRPHelpPages(void) " Sets the \"GetTSPacket\"-watchdog timeout for all attached devices\n" " and all devices that will be attached.\n" " alternate command: SetDefaultGetTSTimeout", + "ADUM subsystem begin-of-devnode\n" + " Adds a filter to the udev-monitor.\n" + " If an event occurs whose devnode starts with the supplied parameter\n" + " this devnode will be queued for attaching.\n" + " alternate command: AddUdevMonitor", NULL }; return HelpPages; @@ -335,6 +347,26 @@ cString cPluginDynamite::SVDRPCommand(const char *Command, const char *Option, i return cString::sprintf("set default GetTS-Timeout on all devices to %d seconds", seconds); } } + + if ((strcasecmp(Command, "AUDM") == 0) || (strcasecmp(Command, "AddUdevMonitor") == 0)) { + int maxlen = strlen(Option); + if (maxlen > 0) { + char *subsystem = new char[maxlen + 1]; + char *devnode = new char[maxlen + 1]; + subsystem[0] = '\0'; + devnode[0] = '\0'; + cString msg; + if ((sscanf(Option, "%s %s", subsystem, devnode) == 2) && cUdevPatternFilter::AddFilter(subsystem, devnode)) + msg = cString::sprintf("add udev-filter for %s %s", subsystem, devnode); + else { + ReplyCode = 550; + msg = cString::sprintf("can't add udev-filter for %s %s", subsystem, devnode); + } + delete [] subsystem; + delete [] devnode; + return msg; + } + } return NULL; } |