From ec7c51c7868d3ccc66b5cc38bf126258b94f086c Mon Sep 17 00:00:00 2001
From: Luca Barbato <lu_zero@gentoo.org>
Date: Sat, 15 Jun 2013 11:41:36 +0200
Subject: [PATCH] avf: move ff_http_match_no_proxy to network

It is only used by network protocols.
---
 libavformat/internal.h     |  2 --
 libavformat/network.c      | 54 ++++++++++++++++++++++++++++++++++++++
 libavformat/network.h      |  2 ++
 libavformat/noproxy-test.c |  2 +-
 libavformat/utils.c        | 54 --------------------------------------
 5 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 73673696476..3ca2d8fb97c 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -375,6 +375,4 @@ enum AVCodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag);
  */
 enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
 
-int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
-
 #endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/network.c b/libavformat/network.c
index a80e2a2d691..d8e6540b19d 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -277,3 +277,57 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
     }
     return ret;
 }
+
+static int match_host_pattern(const char *pattern, const char *hostname)
+{
+    int len_p, len_h;
+    if (!strcmp(pattern, "*"))
+        return 1;
+    // Skip a possible *. at the start of the pattern
+    if (pattern[0] == '*')
+        pattern++;
+    if (pattern[0] == '.')
+        pattern++;
+    len_p = strlen(pattern);
+    len_h = strlen(hostname);
+    if (len_p > len_h)
+        return 0;
+    // Simply check if the end of hostname is equal to 'pattern'
+    if (!strcmp(pattern, &hostname[len_h - len_p])) {
+        if (len_h == len_p)
+            return 1; // Exact match
+        if (hostname[len_h - len_p - 1] == '.')
+            return 1; // The matched substring is a domain and not just a substring of a domain
+    }
+    return 0;
+}
+
+int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
+{
+    char *buf, *start;
+    int ret = 0;
+    if (!no_proxy)
+        return 0;
+    if (!hostname)
+        return 0;
+    buf = av_strdup(no_proxy);
+    if (!buf)
+        return 0;
+    start = buf;
+    while (start) {
+        char *sep, *next = NULL;
+        start += strspn(start, " ,");
+        sep = start + strcspn(start, " ,");
+        if (*sep) {
+            next = sep + 1;
+            *sep = '\0';
+        }
+        if (match_host_pattern(start, hostname)) {
+            ret = 1;
+            break;
+        }
+        start = next;
+    }
+    av_free(buf);
+    return ret;
+}
diff --git a/libavformat/network.h b/libavformat/network.h
index 673427ab660..fe136c4e47d 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -244,4 +244,6 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
                       socklen_t addrlen, int timeout,
                       URLContext *h);
 
+int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
+
 #endif /* AVFORMAT_NETWORK_H */
diff --git a/libavformat/noproxy-test.c b/libavformat/noproxy-test.c
index 59a435e30a3..e6cc4214137 100644
--- a/libavformat/noproxy-test.c
+++ b/libavformat/noproxy-test.c
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "internal.h"
+#include "network.h"
 
 static void test(const char *pattern, const char *host)
 {
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 951f3f13b4d..106d4e91cd8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3407,57 +3407,3 @@ const struct AVCodecTag *avformat_get_riff_audio_tags(void)
 {
     return ff_codec_wav_tags;
 }
-
-static int match_host_pattern(const char *pattern, const char *hostname)
-{
-    int len_p, len_h;
-    if (!strcmp(pattern, "*"))
-        return 1;
-    // Skip a possible *. at the start of the pattern
-    if (pattern[0] == '*')
-        pattern++;
-    if (pattern[0] == '.')
-        pattern++;
-    len_p = strlen(pattern);
-    len_h = strlen(hostname);
-    if (len_p > len_h)
-        return 0;
-    // Simply check if the end of hostname is equal to 'pattern'
-    if (!strcmp(pattern, &hostname[len_h - len_p])) {
-        if (len_h == len_p)
-            return 1; // Exact match
-        if (hostname[len_h - len_p - 1] == '.')
-            return 1; // The matched substring is a domain and not just a substring of a domain
-    }
-    return 0;
-}
-
-int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
-{
-    char *buf, *start;
-    int ret = 0;
-    if (!no_proxy)
-        return 0;
-    if (!hostname)
-        return 0;
-    buf = av_strdup(no_proxy);
-    if (!buf)
-        return 0;
-    start = buf;
-    while (start) {
-        char *sep, *next = NULL;
-        start += strspn(start, " ,");
-        sep = start + strcspn(start, " ,");
-        if (*sep) {
-            next = sep + 1;
-            *sep = '\0';
-        }
-        if (match_host_pattern(start, hostname)) {
-            ret = 1;
-            break;
-        }
-        start = next;
-    }
-    av_free(buf);
-    return ret;
-}
-- 
GitLab