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>
31 char *vlc_getProxyUrl(const char *url
)
33 char *proxy_url
= NULL
;
35 /* Try to get the proxy server address from Windows internet settings. */
39 if( RegOpenKeyEx( HKEY_CURRENT_USER
, "Software\\Microsoft"
40 "\\Windows\\CurrentVersion\\Internet Settings",
41 0, KEY_READ
, &h_key
) == ERROR_SUCCESS
)
44 DWORD len
= sizeof( DWORD
);
47 /* Get the proxy enable value */
48 if( RegQueryValueEx( h_key
, "ProxyEnable", NULL
, NULL
,
49 &proxyEnable
, &len
) != ERROR_SUCCESS
53 /* Proxy is enabled */
54 /* Get the proxy URL :
55 Proxy server value in the registry can be something like "address:port"
56 or "ftp=address1:port1;http=address2:port2 ..."
57 depending of the configuration. */
58 unsigned char key
[256];
61 if( RegQueryValueEx( h_key
, "ProxyServer", NULL
, NULL
,
62 key
, &len
) == ERROR_SUCCESS
)
64 /* FIXME: This is lame. The string should be tokenized. */
66 char *psz_proxy
= strstr( (char *)key
, "http=" );
67 if( psz_proxy
!= NULL
)
70 char *end
= strchr( psz_proxy
, ';' );
75 psz_proxy
= (char *)key
;
76 proxy_url
= strdup( psz_proxy
);