summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-06-16 23:45:42 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-06-16 23:45:42 +0200
commit84f77f84234e409271852692e736900ee7b2f0fe (patch)
tree8183ec61854cdc0a5dbc731aeca2ef73309b4ba7 /libavformat
parent4a522eff006532f28c631f13a604c364102b7a6f (diff)
parentec7c51c7868d3ccc66b5cc38bf126258b94f086c (diff)
Merge commit 'ec7c51c7868d3ccc66b5cc38bf126258b94f086c'
* commit 'ec7c51c7868d3ccc66b5cc38bf126258b94f086c': avf: move ff_http_match_no_proxy to network Conflicts: libavformat/internal.h libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/internal.h2
-rw-r--r--libavformat/network.c54
-rw-r--r--libavformat/network.h2
-rw-r--r--libavformat/noproxy-test.c2
-rw-r--r--libavformat/utils.c54
5 files changed, 57 insertions, 57 deletions
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 4d56388312..d1bbf33603 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -390,6 +390,4 @@ AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precissi
*/
void ff_generate_avci_extradata(AVStream *st);
-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 83c1543226..8cffd68aa5 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -304,3 +304,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 3798f97829..d0a1e3174c 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -257,4 +257,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 a156620271..4524764cbf 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 546144a3c9..c2df2c6392 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4331,57 +4331,3 @@ void ff_generate_avci_extradata(AVStream *st)
memcpy(st->codec->extradata, data, size);
st->codec->extradata_size = size;
}
-
-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;
-}