[vlc-commits] fix error in getting proxy setting on darwin.
Kuang Rufan
git at videolan.org
Sat Apr 20 16:01:40 CEST 2013
vlc | branch: master | Kuang Rufan <master at a1983.com.cn> | Sat Apr 20 16:37:50 2013 +0800| [adb1e78b73477c01481927ce8c1d6202fb890233] | committer: Felix Paul Kühne
fix error in getting proxy setting on darwin.
1. fix build error for ios.
2. fix vlc_getProxyUrl always return NULL on osx.
Signed-off-by: Felix Paul Kühne <fkuehne at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=adb1e78b73477c01481927ce8c1d6202fb890233
---
src/darwin/netconf.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/src/darwin/netconf.c b/src/darwin/netconf.c
index 45abf9b..0d9ca43 100644
--- a/src/darwin/netconf.c
+++ b/src/darwin/netconf.c
@@ -28,8 +28,13 @@
#include <vlc_common.h>
#include <vlc_network.h>
+#import <TargetConditionals.h>
#include <CoreFoundation/CoreFoundation.h>
+#if TARGET_OS_IPHONE
+#include <CFNetwork/CFProxySupport.h>
+#else
#include <SystemConfiguration/SystemConfiguration.h>
+#endif
/**
* Determines the network proxy server to use (if any).
@@ -39,6 +44,37 @@
char *vlc_getProxyUrl(const char *url)
{
VLC_UNUSED(url);
+#if TARGET_OS_IPHONE
+ char *proxy_url = NULL;
+ CFDictionaryRef dicRef = CFNetworkCopySystemProxySettings();
+ if (NULL != dicRef) {
+ const CFStringRef proxyCFstr = (const CFStringRef)CFDictionaryGetValue(
+ dicRef, (const void*)kCFNetworkProxiesHTTPProxy);
+ const CFNumberRef portCFnum = (const CFNumberRef)CFDictionaryGetValue(
+ dicRef, (const void*)kCFNetworkProxiesHTTPPort);
+ if (NULL != proxyCFstr && NULL != portCFnum) {
+ int port = 0;
+ if (!CFNumberGetValue(portCFnum, kCFNumberIntType, &port)) {
+ CFRelease(dicRef);
+ return NULL;
+ }
+
+ char host_buffer[4096];
+ memset(host_buffer, 0, sizeof(host_buffer));
+ if (CFStringGetCString(proxyCFstr, host_buffer, sizeof(host_buffer)
+ - 1, kCFStringEncodingUTF8)) {
+ char buffer[4096];
+ memset(host_buffer, 0, sizeof(host_buffer));
+ sprintf(buffer, "%s:%d", host_buffer, port);
+ proxy_url = strdup(buffer);
+ }
+ }
+
+ CFRelease(dicRef);
+ }
+
+ return proxy_url;
+#else
CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL);
char *proxy_url = NULL;
@@ -77,10 +113,11 @@ char *vlc_getProxyUrl(const char *url)
CFSTR(":%i"),
i_httpProxyPort);
- CFStringGetCString(outputURL,
- proxy_url,
- sizeof(proxy_url),
- kCFStringEncodingASCII);
+ char buffer[4096];
+ if (CFStringGetCString(outputURL, buffer, sizeof(buffer),
+ kCFStringEncodingUTF8))
+ proxy_url = strdup(buffer);
+
CFRelease(outputURL);
}
CFRelease(httpProxy);
@@ -90,4 +127,5 @@ char *vlc_getProxyUrl(const char *url)
}
return proxy_url;
+#endif
}
More information about the vlc-commits
mailing list