]> git.sesse.net Git - vlc/blob - src/win32/netconf.c
udp: fix locking (fixes #14234) and cancellation
[vlc] / src / win32 / netconf.c
1 /*****************************************************************************
2  * netconf.c : Network configuration
3  *****************************************************************************
4  * Copyright (C) 2001-2008 VLC authors and VideoLAN
5  *
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.
10  *
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.
15  *
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  *****************************************************************************/
20
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
24
25 #include <string.h>
26 #include <windows.h>
27
28 #include <vlc_common.h>
29 #include <vlc_network.h>
30
31 char *vlc_getProxyUrl(const char *url)
32 {
33     char *proxy_url = NULL;
34 #if 0
35     /* Try to get the proxy server address from Windows internet settings. */
36     HKEY h_key;
37
38     /* Open the key */
39     if( RegOpenKeyEx( HKEY_CURRENT_USER, "Software\\Microsoft"
40                       "\\Windows\\CurrentVersion\\Internet Settings",
41                       0, KEY_READ, &h_key ) == ERROR_SUCCESS )
42         return NULL;
43
44     DWORD len = sizeof( DWORD );
45     BYTE proxyEnable;
46
47     /* Get the proxy enable value */
48     if( RegQueryValueEx( h_key, "ProxyEnable", NULL, NULL,
49                          &proxyEnable, &len ) != ERROR_SUCCESS
50      || !proxyEnable )
51         goto out;
52
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];
59
60     len = sizeof( key );
61     if( RegQueryValueEx( h_key, "ProxyServer", NULL, NULL,
62                          key, &len ) == ERROR_SUCCESS )
63     {
64         /* FIXME: This is lame. The string should be tokenized. */
65 #warning FIXME.
66         char *psz_proxy = strstr( (char *)key, "http=" );
67         if( psz_proxy != NULL )
68         {
69             psz_proxy += 5;
70             char *end = strchr( psz_proxy, ';' );
71             if( end != NULL )
72                 *end = '\0';
73         }
74         else
75             psz_proxy = (char *)key;
76         proxy_url = strdup( psz_proxy );
77     }
78
79 out:
80     RegCloseKey( h_key );
81 #endif
82     return proxy_url;
83 }