]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
url: small cleanup - add urlinit() fcn
authorJaroslav Kysela <perex@perex.cz>
Wed, 14 Oct 2015 13:37:17 +0000 (15:37 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 14 Oct 2015 13:37:17 +0000 (15:37 +0200)
src/config.c
src/httpc.c
src/imagecache.c
src/input/mpegts/iptv/iptv.c
src/input/mpegts/iptv/iptv_auto.c
src/input/mpegts/iptv/iptv_http.c
src/input/mpegts/iptv/iptv_mux.c
src/input/mpegts/satip/satip.c
src/url.h

index ffdd9a799c0f4af7dfc749aa810d717a1e81c577..5b7f558da15f34d0acdd8df7eac2a7b74fb9daf8 100644 (file)
@@ -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)
index ad4bead4d6cfd296abab9a496b7245d6df4ec7c5..d92971aaf7a1526f8a8766daa5a26ee85f340415 100644 (file)
@@ -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);
@@ -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) {
index 3bb4e43e4aedfdc3c6c13aff56ac884c577e37fd..c46e7d50cf9220013e060a00d647042403411fd5 100644 (file)
@@ -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",
index d152c8f17be33f784a99ac15ad64ba3ea0dbd9da..0c17ce8cf82b6881245119accc14c6af1f7898a6 100644 (file)
@@ -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)) {
 
index 825de463e5defbfa1d5e896722bd96a0da6e0c31..dcf573544405bf9f1db8fed8913f3e370b0820a6 100644 (file)
@@ -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')
@@ -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)
@@ -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;
index db228ee3490a82b5aec88c4b315546a6bba89d00..2e9ef308b4aea8497b27c5dff3f2879613d02f07 100644 (file)
@@ -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);
index 691b251e22690247b0e509e12789b055f66e9958..0004e22efd5bf43efb8f3aa3170f3709033767f2 100644 (file)
@@ -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) +
index 9bd32f431e4e850389160b4b5edf19c0fbcfacf0..3eb63d36957936d398f750eb1a17cc1b441a8b23 100644 (file)
@@ -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;
index 5c9b632a2b5bab5b52e7de548aee7d90d283966d..d0b7d80445a0b0c2abafc1c7a9ad188c3ceaa172 100644 (file)
--- a/src/url.h
+++ b/src/url.h
@@ -21,6 +21,7 @@
 #define __TVH_URL_H__
 
 #include <stdint.h>
+#include <string.h>
 
 /* URL structure */
 typedef struct url
@@ -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 );