]> cvs.zerfleddert.de Git - record-dvb/commitdiff
better url detection
authormichael <michael>
Sun, 2 Jul 2006 01:07:26 +0000 (01:07 +0000)
committermichael <michael>
Sun, 2 Jul 2006 01:07:26 +0000 (01:07 +0000)
common.c
common.h
dump-stream.c
record-dvb.c

index 8f000fd902a078a9463b3e61e68c90af03632b11..825b5aebebff69b73b0550110ab11fec1184d3d2 100644 (file)
--- a/common.c
+++ b/common.c
@@ -92,3 +92,20 @@ int resolve(struct dvb_host *dvbhost, struct sockaddr_in *server)
        return 0;
 }
 
+int is_url(char *string)
+{
+       char *pos;
+
+       if (!(strlen(string)))
+               return 0;
+
+       pos = string;
+
+       while(*pos != ':' && *pos != 0)
+               pos++;
+
+       if (!strncmp("://", pos, 3))
+               return 1;
+
+       return 0;
+}
index b7015da22da6c98ab8db2840964b1f69112f5ae3..80dba9646152c2f8d23dc88624ac4ea2c9bf3ebe 100644 (file)
--- a/common.h
+++ b/common.h
@@ -7,3 +7,4 @@ struct dvb_host {
 
 struct dvb_host *parse(char *urlpart, char *defport);
 int resolve(struct dvb_host *dvbhost, struct sockaddr_in *server);
+int is_url(char *string);
index 1cbaad260854656b6aedc32699b8d476e28e411a..a6039e0d2a12572b1a067c3d89548308cfd0e6bd 100644 (file)
@@ -9,8 +9,12 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <strings.h>
+#include <netdb.h>
 
 #include "mcast.h"
+#include "http.h"
+#include "sap.h"
+#include "common.h"
 
 #define CHUNKSIZE 1500
 
@@ -28,8 +32,26 @@ int main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
 
-       if ((in = open_mcast(url)) < 0) {
-               fprintf(stderr,"Can't open url %s!\n",url);
+       if (!is_url(url)) {
+               char *service_url;
+               if ((service_url = get_url_from_sap(url))) {
+                       printf("SAP says: '%s' -> %s\n", url, service_url);
+                       url = service_url;
+               }
+       }
+
+       if (is_http(url)) {
+               if ((in = open_http(url)) < 0) {
+                       fprintf(stderr,"Can't open url %s!\n",url);
+                       exit(EXIT_FAILURE);
+               }
+       } else if (is_mcast(url)) {
+               if ((in = open_mcast(url)) < 0) {
+                       fprintf(stderr,"Can't open url %s!\n",url);
+                       exit(EXIT_FAILURE);
+               }
+       } else {
+               printf("URL '%s' not supported!\n", url);
                exit(EXIT_FAILURE);
        }
 
index 9356348343fe4f81d20cc0cf580f8c63b95fd1f2..5a055b8525d9a500c255318bc1f8d2bcc26ce144 100644 (file)
 #include <fcntl.h>
 #include <unistd.h>
 #include <strings.h>
+#include <netdb.h>
 
 #include "http.h"
 #include "mcast.h"
 #include "sap.h"
+#include "common.h"
 
 #define CHUNKSIZE      3000
 #define GTOD_INTERVAL  100
@@ -118,7 +120,7 @@ int main(int argc, char **argv)
                exit(EXIT_FAILURE);
        }
 
-       if (!is_http(url) && !is_mcast(url)) {
+       if (!is_url(url)) {
                char *service_url;
                if ((service_url = get_url_from_sap(url))) {
                        printf("SAP says: '%s' -> %s\n", url, service_url);
Impressum, Datenschutz