summaryrefslogtreecommitdiff
path: root/server/connection.c
diff options
context:
space:
mode:
authorFrank Schmirler <vdr@schmirler.de>2010-12-02 09:48:23 +0100
committerFrank Schmirler <vdr@schmirler.de>2010-12-02 09:48:23 +0100
commit11b22d9f33d50f20cba1eaee2aadb55d3580d879 (patch)
tree5c4e7fe1046bd9cc1ef7a7b21abe118f43689902 /server/connection.c
parent435f01649c2ee8c23c21e0680d0a39e773008549 (diff)
downloadvdr-plugin-streamdev-11b22d9f33d50f20cba1eaee2aadb55d3580d879.tar.gz
vdr-plugin-streamdev-11b22d9f33d50f20cba1eaee2aadb55d3580d879.tar.bz2
Streamdev 0.5.0-rc1
Diffstat (limited to 'server/connection.c')
-rw-r--r--server/connection.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/server/connection.c b/server/connection.c
index 74b2783..6121b7a 100644
--- a/server/connection.c
+++ b/server/connection.c
@@ -1,5 +1,5 @@
/*
- * $Id: connection.c,v 1.12 2009/02/13 10:39:22 schmirl Exp $
+ * $Id: connection.c,v 1.13.2.1 2010/06/11 06:06:02 schmirl Exp $
*/
#include "server/connection.h"
@@ -27,6 +27,66 @@ cServerConnection::~cServerConnection()
{
}
+const cChannel* cServerConnection::ChannelFromString(const char *String, int *Apid, int *Dpid) {
+ const cChannel *channel = NULL;
+ char *string = strdup(String);
+ char *ptr, *end;
+ int apididx = 0;
+
+ if ((ptr = strrchr(string, '+')) != NULL) {
+ *(ptr++) = '\0';
+ apididx = strtoul(ptr, &end, 10);
+ Dprintf("found apididx: %d\n", apididx);
+ }
+
+ if (isnumber(string)) {
+ int temp = strtol(String, NULL, 10);
+ if (temp >= 1 && temp <= Channels.MaxNumber())
+ channel = Channels.GetByNumber(temp);
+ } else {
+ channel = Channels.GetByChannelID(tChannelID::FromString(string));
+
+ if (channel == NULL) {
+ int i = 1;
+ while ((channel = Channels.GetByNumber(i, 1)) != NULL) {
+ if (String == channel->Name())
+ break;
+
+ i = channel->Number() + 1;
+ }
+ }
+ }
+
+ if (channel != NULL && apididx > 0) {
+ int apid = 0, dpid = 0;
+ int index = 1;
+
+ for (int i = 0; channel->Apid(i) != 0; ++i, ++index) {
+ if (index == apididx) {
+ apid = channel->Apid(i);
+ break;
+ }
+ }
+
+ if (apid == 0) {
+ for (int i = 0; channel->Dpid(i) != 0; ++i, ++index) {
+ if (index == apididx) {
+ dpid = channel->Dpid(i);
+ break;
+ }
+ }
+ }
+
+ if (Apid != NULL)
+ *Apid = apid;
+ if (Dpid != NULL)
+ *Dpid = dpid;
+ }
+
+ free(string);
+ return channel;
+}
+
bool cServerConnection::Read(void)
{
int b;