X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/record-dvb/blobdiff_plain/fbc24ab023eb1ae6572fccff3fa1140c3e01c8b7..e102f6947ff0fa3284ccb675b774560e8ee2454c:/common.c diff --git a/common.c b/common.c index 80327f5..825b5ae 100644 --- a/common.c +++ b/common.c @@ -10,12 +10,14 @@ 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)); @@ -90,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; +}