1 /*****************************************************************************
2 * netconf.c : Network configuration
3 *****************************************************************************
4 * Copyright (C) 2001-2008 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
28 #include <vlc_common.h>
29 #include <vlc_network.h>
32 char *vlc_getProxyUrl(const char *psz_url
)
36 char *proxy
= config_GetPsz( "http-proxy" );
40 char *proxy_pwd
= config_GetPsz( "http-proxy-pwd" );
41 if (proxy_pwd
== NULL
)
45 if (vlc_UrlParse(&url
, proxy
) < 0) {
52 if (url
.psz_password
== NULL
)
53 url
.psz_password
= proxy_pwd
;
55 char *proxy_url
= vlc_uri_compose (&url
);
62 /* Try to get the proxy server address from Windows internet settings. */
66 if( RegOpenKeyEx( HKEY_CURRENT_USER
, "Software\\Microsoft"
67 "\\Windows\\CurrentVersion\\Internet Settings",
68 0, KEY_READ
, &h_key
) == ERROR_SUCCESS
)
71 DWORD len
= sizeof( DWORD
);
74 /* Get the proxy enable value */
75 if( RegQueryValueEx( h_key
, "ProxyEnable", NULL
, NULL
,
76 &proxyEnable
, &len
) != ERROR_SUCCESS
80 /* Proxy is enabled */
81 /* Get the proxy URL :
82 Proxy server value in the registry can be something like "address:port"
83 or "ftp=address1:port1;http=address2:port2 ..."
84 depending of the configuration. */
85 unsigned char key
[256];
88 if( RegQueryValueEx( h_key
, "ProxyServer", NULL
, NULL
,
89 key
, &len
) == ERROR_SUCCESS
)
91 /* FIXME: This is lame. The string should be tokenized. */
93 char *psz_proxy
= strstr( (char *)key
, "http=" );
94 if( psz_proxy
!= NULL
)
97 char *end
= strchr( psz_proxy
, ';' );
102 psz_proxy
= (char *)key
;
103 proxy_url
= strdup( psz_proxy
);
107 RegCloseKey( h_key
);