struct dvb_host *parse(char *urlpart, char *defport)
{
- struct dvb_host *dvbhost;
+ static struct dvb_host *dvbhost = NULL;
char *pos;
- if (!(dvbhost = malloc(sizeof(struct dvb_host)))) {
- perror("malloc");
- exit(EXIT_FAILURE);
+ if (!dvbhost) {
+ if (!(dvbhost = malloc(sizeof(struct dvb_host)))) {
+ perror("malloc");
+ exit(EXIT_FAILURE);
+ }
}
bzero(dvbhost, sizeof(struct dvb_host));
{
int fd;
struct sockaddr_in server;
- static struct dvb_host *dvbhost = NULL;
+ struct dvb_host *dvbhost = NULL;
char c, buffer[BUFFSIZE], *pos;
int lines = 0;
if(!is_http(url))
return -1;
- if (!dvbhost) {
- dvbhost = parse(&(url[7]), "80");
- dvbhost->socktype = SOCK_STREAM;
- }
+ dvbhost = parse(&(url[7]), "80");
+ dvbhost->socktype = SOCK_STREAM;
if (resolve(dvbhost, &server) < 0) {
return -1;
int open_mcast(char *url)
{
- static struct dvb_host *dvbhost = NULL;
+ struct dvb_host *dvbhost = NULL;
struct sockaddr_in server;
struct ip_mreq mreq;
int val;
if(!is_mcast(url))
return -1;
- if (!dvbhost) {
- dvbhost = parse(&(url[6]), "2000");
- dvbhost->socktype = SOCK_DGRAM;
- }
+ dvbhost = parse(&(url[6]), "2000");
+ dvbhost->socktype = SOCK_DGRAM;
if (resolve(dvbhost, &server) < 0) {
return -1;
mreq.imr_interface.s_addr = INADDR_ANY;
setsockopt (fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
+ close(fd);
+
return url;
}