+ free( psz );
+ }
+#ifdef HAVE_LIBPROXY
+ else
+ {
+ pxProxyFactory *pf = px_proxy_factory_new();
+ if (pf)
+ {
+ char *buf;
+ int i;
+ i=asprintf(&buf, "%s://%s", psz_access, p_access->psz_location);
+ if (i >= 0)
+ {
+ msg_Dbg(p_access, "asking libproxy about url '%s'", buf);
+ char **proxies = px_proxy_factory_get_proxies(pf, buf);
+ if (proxies[0])
+ {
+ msg_Dbg(p_access, "libproxy suggest to use '%s'", proxies[0]);
+ if(strcmp(proxies[0],"direct://") != 0)
+ {
+ p_sys->b_proxy = true;
+ vlc_UrlParse( &p_sys->proxy, proxies[0], 0);
+ }
+ }
+ for(i=0;proxies[i];i++) free(proxies[i]);
+ free(proxies);
+ free(buf);
+ }
+ px_proxy_factory_free(pf);
+ }
+ else
+ {
+ msg_Err(p_access, "Allocating memory for libproxy failed");
+ }
+ }
+#elif defined( WIN32 )
+ else
+ {
+ if( var_InheritBool( p_access, "http-use-IE-proxy" ) )
+ {
+ /* Try to get the proxy server address from Windows internet settings using registry. */
+ HKEY h_key;
+ /* Open the key */
+ if( RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft" \
+ "\\Windows\\CurrentVersion\\Internet Settings",
+ 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
+ {
+ DWORD i_dataReadSize = 4; /* sizeof( DWORD ); */
+ DWORD proxyEnable = 0;
+ /* Get the proxy enable value */
+ if( RegQueryValueEx( h_key, "ProxyEnable", NULL, NULL,
+ (char *)&proxyEnable, &i_dataReadSize )
+ == ERROR_SUCCESS )
+ {
+ if( proxyEnable )
+ {
+ /* Proxy is enable */
+ char psz_key[256];
+ i_dataReadSize = 256;
+ if( RegQueryValueEx( h_key, "ProxyServer",
+ NULL, NULL, psz_key,
+ &i_dataReadSize )
+ == ERROR_SUCCESS )
+ {
+ /* Get the proxy URL :
+ Proxy server value in the registry can be something like "address:port"
+ or "ftp=address1:port1;http=address2:port2 ..." depending of the
+ confirguration. */
+ char *psz_proxy;
+ psz_proxy = strstr( psz_key, "http=" );
+ if( psz_proxy != NULL )
+ {
+ psz_proxy += strlen( "http=" );
+ char *psz_endUrl = strchr( psz_proxy, ';' );
+ if( psz_endUrl != NULL )
+ *psz_endUrl = '\0';
+ }
+ else
+ psz_proxy = psz_key;
+ /* Set proxy enable for this connection. */
+ p_sys->b_proxy = true;
+ vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
+ }
+ msg_Warn( p_access, "Couldn't read in registry " \
+ "the proxy server address." );
+ }
+ }
+ else
+ msg_Warn( p_access, "Couldn't read in registry if the " \
+ "proxy is enable or not." );
+ }
+ else
+ msg_Warn( p_access, "Couldn't open internet settings key " \
+ "in registry." );
+ }