Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
url: small cleanup - add urlinit() fcn
  • Loading branch information
perexg committed Oct 14, 2015
1 parent c8edc9d commit 85bfb78
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/config.c
Expand Up @@ -1715,7 +1715,7 @@ config_class_cors_origin_set ( void *o, const void *v )
prop_sbuf[0] = '*';
prop_sbuf[1] = '\0';
} else {
memset(&u, 0, sizeof(u));
urlinit(&u);
urlparse(s, &u);
if (u.scheme && (!strcmp(u.scheme, "http") || !strcmp(u.scheme, "https")) && u.host) {
if (u.port)
Expand Down
6 changes: 3 additions & 3 deletions src/httpc.c
Expand Up @@ -1199,7 +1199,7 @@ http_client_redirected ( http_client_t *hc )
hc->hc_scheme, hc->hc_host, hc->hc_port, location);
}

memset(&u, 0, sizeof(u));
urlinit(&u);
if (urlparse(location2 ? location2 : location, &u)) {
tvherror("httpc", "%04X: redirection - cannot parse url '%s'",
shortid(hc), location2 ? location2 : location);
Expand Down Expand Up @@ -1740,8 +1740,8 @@ http_client_testsuite_run( void )
tvhlog(LOG_NOTICE, "httpc", "Test: unable to open '%s': %s", path, strerror(errno));
return;
}
memset(&u1, 0, sizeof(u1));
memset(&u2, 0, sizeof(u2));
urlinit(&u1);
urlinit(&u2);
http_arg_init(&args);
efd = tvhpoll_create(1);
while (fgets(line, sizeof(line), fp) != NULL && tvheadend_running) {
Expand Down
2 changes: 1 addition & 1 deletion src/imagecache.c
Expand Up @@ -248,7 +248,7 @@ imagecache_image_fetch ( imagecache_image_t *img )
if (img->url == NULL || img->url[0] == '\0')
return res;

memset(&url, 0, sizeof(url));
urlinit(&url);

/* Open file */
if (hts_settings_buildpath(path, sizeof(path), "imagecache/data/%d",
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/iptv/iptv.c
Expand Up @@ -266,7 +266,7 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )

/* Parse URL */
mpegts_mux_nice_name((mpegts_mux_t*)im, buf, sizeof(buf));
memset(&url, 0, sizeof(url));
urlinit(&url);

if (raw && !strncmp(raw, "pipe://", 7)) {

Expand Down
6 changes: 3 additions & 3 deletions src/input/mpegts/iptv/iptv_auto.c
Expand Up @@ -85,7 +85,7 @@ iptv_auto_network_process_m3u_item(iptv_network_t *in,
chnum += (int64_t)*total * CHANNEL_SPLIT;
}

memset(&u, 0, sizeof(u));
urlinit(&u);
if (urlparse(url, &u))
return;
if (u.host == NULL || u.host[0] == '\0')
Expand Down Expand Up @@ -373,7 +373,7 @@ iptv_auto_network_fetch_complete(http_client_t *hc)
return 0;
}

memset(&u, 0, sizeof(u));
urlinit(&u);
if (!urlparse(in->in_url, &u)) {
last_url = strrchr(u.path, '/');
if (last_url)
Expand Down Expand Up @@ -411,7 +411,7 @@ iptv_auto_network_fetch(void *aux)
http_client_t *hc;
url_t u;

memset(&u, 0, sizeof(u));
urlinit(&u);

if (in->in_url == NULL)
goto done;
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/iptv/iptv_http.c
Expand Up @@ -139,7 +139,7 @@ iptv_http_complete
tvherror("iptv", "m3u contents parsing failed");
return 0;
}
memset(&u, 0, sizeof(u));
urlinit(&u);
if (!urlparse(url, &u)) {
hc->hc_keepalive = 0;
r = http_client_simple_reconnect(hc, &u);
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/iptv/iptv_mux.c
Expand Up @@ -64,7 +64,7 @@ iptv_url_set ( char **url, char **sane_url, const char *str, int allow_file, int
iptv_url_set0(url, sane_url, str, str);
return 1;
}
memset(&u, 0, sizeof(u));
urlinit(&u);
if (!urlparse(str, &u)) {
len = (u.scheme ? strlen(u.scheme) + 3 : 0) +
(u.host ? strlen(u.host) + 1 : 0) +
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts/satip/satip.c
Expand Up @@ -1119,6 +1119,7 @@ satip_discovery_static(const char *descurl)
if (satip_device_find_by_descurl(descurl))
return;
d = calloc(1, sizeof(satip_discovery_t));
urlinit(&d->url);
if (urlparse(descurl, &d->url)) {
satip_discovery_destroy(d, 0);
return;
Expand Down
2 changes: 2 additions & 0 deletions src/url.h
Expand Up @@ -21,6 +21,7 @@
#define __TVH_URL_H__

#include <stdint.h>
#include <string.h>

/* URL structure */
typedef struct url
Expand All @@ -36,6 +37,7 @@ typedef struct url
char *raw;
} url_t;

static inline void urlinit ( url_t *url ) { memset(url, 0, sizeof(*url)); }
void urlreset ( url_t *url );
int urlparse ( const char *str, url_t *url );
void urlparse_done ( void );
Expand Down

0 comments on commit 85bfb78

Please sign in to comment.