1 /*****************************************************************************
2 * netconf.c : Network configuration
3 *****************************************************************************
4 * Copyright (C) 2013 VLC authors and VideoLAN
7 * Authors: Felix Paul Kühne <fkuehne # videolan org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
28 #include <vlc_common.h>
29 #include <vlc_network.h>
31 #include <CoreFoundation/CoreFoundation.h>
32 #include <SystemConfiguration/SystemConfiguration.h>
35 * Determines the network proxy server to use (if any).
36 * @param url absolute URL for which to get the proxy server (not used)
37 * @return proxy URL, NULL if no proxy or error
39 char *vlc_getProxyUrl(const char *url
)
42 CFDictionaryRef proxies
= SCDynamicStoreCopyProxies(NULL
);
43 char *proxy_url
= NULL
;
46 CFNumberRef cfn_httpProxyOn
=
47 (CFNumberRef
)CFDictionaryGetValue(proxies
,
48 kSCPropNetProxiesHTTPEnable
);
49 if (cfn_httpProxyOn
) {
51 CFNumberGetValue(cfn_httpProxyOn
, kCFNumberIntType
, &i_httpProxyOn
);
52 CFRelease(cfn_httpProxyOn
);
54 if (i_httpProxyOn
== 1) // http proxy is on
56 CFStringRef httpProxy
=
57 (CFStringRef
)CFDictionaryGetValue(proxies
,
58 kSCPropNetProxiesHTTPProxy
);
61 CFNumberRef cfn_httpProxyPort
=
62 (CFNumberRef
)CFDictionaryGetValue(proxies
,
63 kSCPropNetProxiesHTTPPort
);
65 CFNumberGetValue(cfn_httpProxyPort
,
68 CFRelease(cfn_httpProxyPort
);
70 CFMutableStringRef outputURL
=
71 CFStringCreateMutableCopy(kCFAllocatorDefault
,
74 if (i_httpProxyPort
> 0)
75 CFStringAppendFormat(outputURL
,
80 CFStringGetCString(outputURL
,
83 kCFStringEncodingASCII
);