#define MAXHOSTNAME 100 /* from http.c */
+#if defined(__MINGW32__) || defined (_MSC_VER)
+#include <ws2tcpip.h>
+#endif
+
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+#ifdef HAVE_SYS_POLL_H
+# include <sys/poll.h>
+#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
CHAR response[MAX_REPLY_LEN];
} WITHREADERROR, *LPWITHREADERROR;
-HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
- LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext);
-
static DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
-static HMODULE WININET_hModule;
-
-#define HANDLE_CHUNK_SIZE 0x10
+HMODULE WININET_hModule;
static CRITICAL_SECTION WININET_cs;
static CRITICAL_SECTION_DEBUG WININET_cs_debug =
};
static CRITICAL_SECTION WININET_cs = { &WININET_cs_debug, -1, 0, 0, 0, 0 };
-static LPWININETHANDLEHEADER *WININET_Handles;
-static UINT WININET_dwNextHandle;
-static UINT WININET_dwMaxHandles;
+static object_header_t **handle_table;
+static UINT_PTR next_handle;
+static UINT_PTR handle_table_size;
-HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info )
+typedef struct
{
- LPWININETHANDLEHEADER *p;
- UINT handle = 0, num;
+ DWORD dwProxyEnabled;
+ LPWSTR lpszProxyServer;
+ LPWSTR lpszProxyBypass;
+} proxyinfo_t;
+
+static const WCHAR szInternetSettings[] =
+ { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
+ 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
+ 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0 };
+static const WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
+static const WCHAR szProxyEnable[] = { 'P','r','o','x','y','E','n','a','b','l','e', 0 };
+
+void *alloc_object(object_header_t *parent, const object_vtbl_t *vtbl, size_t size)
+{
+ UINT_PTR handle = 0, num;
+ object_header_t *ret;
+ object_header_t **p;
+ BOOL res = TRUE;
+
+ ret = heap_alloc_zero(size);
+ if(!ret)
+ return NULL;
- list_init( &info->children );
+ list_init(&ret->children);
EnterCriticalSection( &WININET_cs );
- if( !WININET_dwMaxHandles )
- {
- num = HANDLE_CHUNK_SIZE;
- p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
- sizeof (UINT)* num);
- if( !p )
- goto end;
- WININET_Handles = p;
- WININET_dwMaxHandles = num;
- }
- if( WININET_dwMaxHandles == WININET_dwNextHandle )
- {
- num = WININET_dwMaxHandles + HANDLE_CHUNK_SIZE;
- p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
- WININET_Handles, sizeof (UINT)* num);
- if( !p )
- goto end;
- WININET_Handles = p;
- WININET_dwMaxHandles = num;
- }
-
- handle = WININET_dwNextHandle;
- if( WININET_Handles[handle] )
- ERR("handle isn't free but should be\n");
- WININET_Handles[handle] = WININET_AddRef( info );
-
- while( WININET_Handles[WININET_dwNextHandle] &&
- (WININET_dwNextHandle < WININET_dwMaxHandles ) )
- WININET_dwNextHandle++;
-
-end:
+
+ if(!handle_table_size) {
+ num = 16;
+ p = heap_alloc_zero(sizeof(handle_table[0]) * num);
+ if(p) {
+ handle_table = p;
+ handle_table_size = num;
+ next_handle = 1;
+ }else {
+ res = FALSE;
+ }
+ }else if(next_handle == handle_table_size) {
+ num = handle_table_size * 2;
+ p = heap_realloc_zero(handle_table, sizeof(handle_table[0]) * num);
+ if(p) {
+ handle_table = p;
+ handle_table_size = num;
+ }else {
+ res = FALSE;
+ }
+ }
+
+ if(res) {
+ handle = next_handle;
+ if(handle_table[handle])
+ ERR("handle isn't free but should be\n");
+ handle_table[handle] = ret;
+ ret->valid_handle = TRUE;
+
+ while(handle_table[next_handle] && next_handle < handle_table_size)
+ next_handle++;
+ }
+
LeaveCriticalSection( &WININET_cs );
- return info->hInternet = (HINTERNET) (handle+1);
+ if(!res) {
+ heap_free(ret);
+ return NULL;
+ }
+
+ ret->vtbl = vtbl;
+ ret->refs = 1;
+ ret->hInternet = (HINTERNET)handle;
+
+ if(parent) {
+ ret->lpfnStatusCB = parent->lpfnStatusCB;
+ ret->dwInternalFlags = parent->dwInternalFlags & INET_CALLBACKW;
+ }
+
+ return ret;
}
-LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
+object_header_t *WININET_AddRef( object_header_t *info )
{
ULONG refs = InterlockedIncrement(&info->refs);
TRACE("%p -> refcount = %d\n", info, refs );
return info;
}
-LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
+object_header_t *get_handle_object( HINTERNET hinternet )
{
- LPWININETHANDLEHEADER info = NULL;
- UINT handle = (UINT) hinternet;
+ object_header_t *info = NULL;
+ UINT_PTR handle = (UINT_PTR) hinternet;
EnterCriticalSection( &WININET_cs );
- if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) &&
- WININET_Handles[handle-1] )
- info = WININET_AddRef( WININET_Handles[handle-1] );
+ if(handle > 0 && handle < handle_table_size && handle_table[handle] && handle_table[handle]->valid_handle)
+ info = WININET_AddRef(handle_table[handle]);
LeaveCriticalSection( &WININET_cs );
- TRACE("handle %d -> %p\n", handle, info);
+ TRACE("handle %ld -> %p\n", handle, info);
return info;
}
-BOOL WININET_Release( LPWININETHANDLEHEADER info )
+static void invalidate_handle(object_header_t *info)
+{
+ object_header_t *child, *next;
+
+ if(!info->valid_handle)
+ return;
+ info->valid_handle = FALSE;
+
+ /* Free all children as native does */
+ LIST_FOR_EACH_ENTRY_SAFE( child, next, &info->children, object_header_t, entry )
+ {
+ TRACE("invalidating child handle %p for parent %p\n", child->hInternet, info);
+ invalidate_handle( child );
+ }
+
+ WININET_Release(info);
+}
+
+BOOL WININET_Release( object_header_t *info )
{
ULONG refs = InterlockedDecrement(&info->refs);
TRACE( "object %p refcount = %d\n", info, refs );
if( !refs )
{
+ invalidate_handle(info);
if ( info->vtbl->CloseConnection )
{
TRACE( "closing connection %p\n", info);
info->vtbl->CloseConnection( info );
}
- INTERNET_SendCallback(info, info->dwContext,
- INTERNET_STATUS_HANDLE_CLOSING, &info->hInternet,
- sizeof(HINTERNET));
+ /* Don't send a callback if this is a session handle created with InternetOpenUrl */
+ if ((info->htype != WH_HHTTPSESSION && info->htype != WH_HFTPSESSION)
+ || !(info->dwInternalFlags & INET_OPENURL))
+ {
+ INTERNET_SendCallback(info, info->dwContext,
+ INTERNET_STATUS_HANDLE_CLOSING, &info->hInternet,
+ sizeof(HINTERNET));
+ }
TRACE( "destroying object %p\n", info);
if ( info->htype != WH_HINIT )
list_remove( &info->entry );
info->vtbl->Destroy( info );
- }
- return TRUE;
-}
-
-BOOL WININET_FreeHandle( HINTERNET hinternet )
-{
- BOOL ret = FALSE;
- UINT handle = (UINT) hinternet;
- LPWININETHANDLEHEADER info = NULL, child, next;
- EnterCriticalSection( &WININET_cs );
+ if(info->hInternet) {
+ UINT_PTR handle = (UINT_PTR)info->hInternet;
- if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
- {
- handle--;
- if( WININET_Handles[handle] )
- {
- info = WININET_Handles[handle];
- TRACE( "destroying handle %d for object %p\n", handle+1, info);
- WININET_Handles[handle] = NULL;
- ret = TRUE;
- }
- }
+ EnterCriticalSection( &WININET_cs );
- LeaveCriticalSection( &WININET_cs );
+ handle_table[handle] = NULL;
+ if(next_handle > handle)
+ next_handle = handle;
- /* As on native when the equivalent of WININET_Release is called, the handle
- * is already invalid, but if a new handle is created at this time it does
- * not yet get assigned the freed handle number */
- if( info )
- {
- /* Free all children as native does */
- LIST_FOR_EACH_ENTRY_SAFE( child, next, &info->children, WININETHANDLEHEADER, entry )
- {
- TRACE( "freeing child handle %d for parent handle %d\n",
- (UINT)child->hInternet, handle+1);
- WININET_FreeHandle( child->hInternet );
+ LeaveCriticalSection( &WININET_cs );
}
- WININET_Release( info );
- }
-
- EnterCriticalSection( &WININET_cs );
-
- if( WININET_dwNextHandle > handle && !WININET_Handles[handle] )
- WININET_dwNextHandle = handle;
-
- LeaveCriticalSection( &WININET_cs );
- return ret;
+ heap_free(info);
+ }
+ return TRUE;
}
/***********************************************************************
break;
case DLL_THREAD_DETACH:
- if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
- {
- LPVOID lpwite = TlsGetValue(g_dwTlsErrIndex);
- HeapFree(GetProcessHeap(), 0, lpwite);
- }
- break;
+ if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
+ {
+ heap_free(TlsGetValue(g_dwTlsErrIndex));
+ }
+ break;
case DLL_PROCESS_DETACH:
+ collect_connections(TRUE);
+ NETCON_unload();
+ URLCacheContainers_DeleteAll();
- URLCacheContainers_DeleteAll();
-
- if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
- {
- HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex));
- TlsFree(g_dwTlsErrIndex);
- }
+ if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
+ {
+ heap_free(TlsGetValue(g_dwTlsErrIndex));
+ TlsFree(g_dwTlsErrIndex);
+ }
break;
}
-
return TRUE;
}
+/***********************************************************************
+ * INTERNET_SaveProxySettings
+ *
+ * Stores the proxy settings given by lpwai into the registry
+ *
+ * RETURNS
+ * ERROR_SUCCESS if no error, or error code on fail
+ */
+static LONG INTERNET_SaveProxySettings( proxyinfo_t *lpwpi )
+{
+ HKEY key;
+ LONG ret;
+
+ if ((ret = RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key )))
+ return ret;
+
+ if ((ret = RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE*)&lpwpi->dwProxyEnabled, sizeof(DWORD))))
+ {
+ RegCloseKey( key );
+ return ret;
+ }
+
+ if (lpwpi->lpszProxyServer)
+ {
+ if ((ret = RegSetValueExW( key, szProxyServer, 0, REG_SZ, (BYTE*)lpwpi->lpszProxyServer, sizeof(WCHAR) * (lstrlenW(lpwpi->lpszProxyServer) + 1))))
+ {
+ RegCloseKey( key );
+ return ret;
+ }
+ }
+ else
+ {
+ if ((ret = RegDeleteValueW( key, szProxyServer )))
+ {
+ RegCloseKey( key );
+ return ret;
+ }
+ }
+
+ RegCloseKey(key);
+ return ERROR_SUCCESS;
+}
+
+/***********************************************************************
+ * INTERNET_FindProxyForProtocol
+ *
+ * Searches the proxy string for a proxy of the given protocol.
+ * Returns the found proxy, or the default proxy if none of the given
+ * protocol is found.
+ *
+ * PARAMETERS
+ * szProxy [In] proxy string to search
+ * proto [In] protocol to search for, e.g. "http"
+ * foundProxy [Out] found proxy
+ * foundProxyLen [In/Out] length of foundProxy buffer, in WCHARs
+ *
+ * RETURNS
+ * TRUE if a proxy is found, FALSE if not. If foundProxy is too short,
+ * *foundProxyLen is set to the required size in WCHARs, including the
+ * NULL terminator, and the last error is set to ERROR_INSUFFICIENT_BUFFER.
+ */
+BOOL INTERNET_FindProxyForProtocol(LPCWSTR szProxy, LPCWSTR proto, WCHAR *foundProxy, DWORD *foundProxyLen)
+{
+ LPCWSTR ptr;
+ BOOL ret = FALSE;
+
+ TRACE("(%s, %s)\n", debugstr_w(szProxy), debugstr_w(proto));
+
+ /* First, look for the specified protocol (proto=scheme://host:port) */
+ for (ptr = szProxy; !ret && ptr && *ptr; )
+ {
+ LPCWSTR end, equal;
+
+ if (!(end = strchrW(ptr, ' ')))
+ end = ptr + strlenW(ptr);
+ if ((equal = strchrW(ptr, '=')) && equal < end &&
+ equal - ptr == strlenW(proto) &&
+ !strncmpiW(proto, ptr, strlenW(proto)))
+ {
+ if (end - equal > *foundProxyLen)
+ {
+ WARN("buffer too short for %s\n",
+ debugstr_wn(equal + 1, end - equal - 1));
+ *foundProxyLen = end - equal;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ }
+ else
+ {
+ memcpy(foundProxy, equal + 1, (end - equal) * sizeof(WCHAR));
+ foundProxy[end - equal] = 0;
+ ret = TRUE;
+ }
+ }
+ if (*end == ' ')
+ ptr = end + 1;
+ else
+ ptr = end;
+ }
+ if (!ret)
+ {
+ /* It wasn't found: look for no protocol */
+ for (ptr = szProxy; !ret && ptr && *ptr; )
+ {
+ LPCWSTR end, equal;
+
+ if (!(end = strchrW(ptr, ' ')))
+ end = ptr + strlenW(ptr);
+ if (!(equal = strchrW(ptr, '=')))
+ {
+ if (end - ptr + 1 > *foundProxyLen)
+ {
+ WARN("buffer too short for %s\n",
+ debugstr_wn(ptr, end - ptr));
+ *foundProxyLen = end - ptr + 1;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ }
+ else
+ {
+ memcpy(foundProxy, ptr, (end - ptr) * sizeof(WCHAR));
+ foundProxy[end - ptr] = 0;
+ ret = TRUE;
+ }
+ }
+ if (*end == ' ')
+ ptr = end + 1;
+ else
+ ptr = end;
+ }
+ }
+ if (ret)
+ TRACE("found proxy for %s: %s\n", debugstr_w(proto),
+ debugstr_w(foundProxy));
+ return ret;
+}
/***********************************************************************
* InternetInitializeAutoProxyDll (WININET.@)
BOOL WINAPI InternetInitializeAutoProxyDll(DWORD dwReserved)
{
FIXME("STUB\n");
- INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
DWORD dwAutoProxyUrlLength, DWORD dwDetectFlags)
{
FIXME("STUB\n");
- INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
+static void FreeProxyInfo( proxyinfo_t *lpwpi )
+{
+ heap_free(lpwpi->lpszProxyServer);
+ heap_free(lpwpi->lpszProxyBypass);
+}
/***********************************************************************
- * INTERNET_ConfigureProxyFromReg
+ * INTERNET_LoadProxySettings
+ *
+ * Loads proxy information from the registry or environment into lpwpi.
+ *
+ * The caller should call FreeProxyInfo when done with lpwpi.
*
* FIXME:
* The proxy may be specified in the form 'http=proxy.my.org'
* Presumably that means there can be ftp=ftpproxy.my.org too.
*/
-static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOW lpwai )
+static LONG INTERNET_LoadProxySettings( proxyinfo_t *lpwpi )
{
HKEY key;
- DWORD r, keytype, len, enabled;
- LPCSTR lpszInternetSettings =
- "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
- static const WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
+ DWORD type, len;
+ LPCSTR envproxy;
+ LONG ret;
- r = RegOpenKeyA(HKEY_CURRENT_USER, lpszInternetSettings, &key);
- if ( r != ERROR_SUCCESS )
- return FALSE;
+ if ((ret = RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key )))
+ return ret;
+
+ len = sizeof(DWORD);
+ if (RegQueryValueExW( key, szProxyEnable, NULL, &type, (BYTE *)&lpwpi->dwProxyEnabled, &len ) || type != REG_DWORD)
+ {
+ lpwpi->dwProxyEnabled = 0;
+ if((ret = RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE *)&lpwpi->dwProxyEnabled, sizeof(DWORD) )))
+ {
+ RegCloseKey( key );
+ return ret;
+ }
+ }
- len = sizeof enabled;
- r = RegQueryValueExA( key, "ProxyEnable", NULL, &keytype,
- (BYTE*)&enabled, &len);
- if( (r == ERROR_SUCCESS) && enabled )
+ if (!(envproxy = getenv( "http_proxy" )) || lpwpi->dwProxyEnabled)
{
TRACE("Proxy is enabled.\n");
/* figure out how much memory the proxy setting takes */
- r = RegQueryValueExW( key, szProxyServer, NULL, &keytype,
- NULL, &len);
- if( (r == ERROR_SUCCESS) && len && (keytype == REG_SZ) )
+ if (!RegQueryValueExW( key, szProxyServer, NULL, &type, NULL, &len ) && len && (type == REG_SZ))
{
LPWSTR szProxy, p;
static const WCHAR szHttp[] = {'h','t','t','p','=',0};
- szProxy=HeapAlloc( GetProcessHeap(), 0, len );
- RegQueryValueExW( key, szProxyServer, NULL, &keytype,
- (BYTE*)szProxy, &len);
+ if (!(szProxy = heap_alloc(len)))
+ {
+ RegCloseKey( key );
+ return ERROR_OUTOFMEMORY;
+ }
+ RegQueryValueExW( key, szProxyServer, NULL, &type, (BYTE*)szProxy, &len );
/* find the http proxy, and strip away everything else */
p = strstrW( szProxy, szHttp );
- if( p )
+ if (p)
{
- p += lstrlenW(szHttp);
- lstrcpyW( szProxy, p );
+ p += lstrlenW( szHttp );
+ lstrcpyW( szProxy, p );
}
p = strchrW( szProxy, ' ' );
- if( p )
- *p = 0;
+ if (p) *p = 0;
- lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
- lpwai->lpszProxy = szProxy;
+ lpwpi->lpszProxyServer = szProxy;
- TRACE("http proxy = %s\n", debugstr_w(lpwai->lpszProxy));
+ TRACE("http proxy = %s\n", debugstr_w(lpwpi->lpszProxyServer));
}
else
- ERR("Couldn't read proxy server settings.\n");
+ {
+ TRACE("No proxy server settings in registry.\n");
+ lpwpi->lpszProxyServer = NULL;
+ }
}
- else
- TRACE("Proxy is not enabled.\n");
- RegCloseKey(key);
+ else if (envproxy)
+ {
+ WCHAR *envproxyW;
+
+ len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 );
+ if (!(envproxyW = heap_alloc(len * sizeof(WCHAR))))
+ return ERROR_OUTOFMEMORY;
+ MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len );
+
+ lpwpi->dwProxyEnabled = 1;
+ lpwpi->lpszProxyServer = envproxyW;
+
+ TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi->lpszProxyServer));
+ }
+ RegCloseKey( key );
- return enabled;
+ lpwpi->lpszProxyBypass = NULL;
+
+ return ERROR_SUCCESS;
+}
+
+/***********************************************************************
+ * INTERNET_ConfigureProxy
+ */
+static BOOL INTERNET_ConfigureProxy( appinfo_t *lpwai )
+{
+ proxyinfo_t wpi;
+
+ if (INTERNET_LoadProxySettings( &wpi ))
+ return FALSE;
+
+ if (wpi.dwProxyEnabled)
+ {
+ lpwai->accessType = INTERNET_OPEN_TYPE_PROXY;
+ lpwai->proxy = wpi.lpszProxyServer;
+ return TRUE;
+ }
+
+ lpwai->accessType = INTERNET_OPEN_TYPE_DIRECT;
+ return FALSE;
}
/***********************************************************************
FE(INTERNET_FLAG_TRANSFER_BINARY)
};
#undef FE
- int i;
-
+ unsigned int i;
+
for (i = 0; i < (sizeof(flag) / sizeof(flag[0])); i++) {
if (flag[i].val & dwFlags) {
TRACE(" %s", flag[i].name);
* Close internet handle
*
*/
-static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr)
+static VOID APPINFO_Destroy(object_header_t *hdr)
{
- LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW) hdr;
+ appinfo_t *lpwai = (appinfo_t*)hdr;
TRACE("%p\n",lpwai);
- HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
- HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
- HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
- HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
- HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
- HeapFree(GetProcessHeap(), 0, lpwai);
+ heap_free(lpwai->agent);
+ heap_free(lpwai->proxy);
+ heap_free(lpwai->proxyBypass);
+ heap_free(lpwai->proxyUsername);
+ heap_free(lpwai->proxyPassword);
}
-static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
+static DWORD APPINFO_QueryOption(object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
{
+ appinfo_t *ai = (appinfo_t*)hdr;
+
switch(option) {
case INTERNET_OPTION_HANDLE_TYPE:
TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
*size = sizeof(DWORD);
*(DWORD*)buffer = INTERNET_HANDLE_TYPE_INTERNET;
return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_USER_AGENT: {
+ DWORD bufsize;
+
+ TRACE("INTERNET_OPTION_USER_AGENT\n");
+
+ bufsize = *size;
+
+ if (unicode) {
+ DWORD len = ai->agent ? strlenW(ai->agent) : 0;
+
+ *size = (len + 1) * sizeof(WCHAR);
+ if(!buffer || bufsize < *size)
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ if (ai->agent)
+ strcpyW(buffer, ai->agent);
+ else
+ *(WCHAR *)buffer = 0;
+ /* If the buffer is copied, the returned length doesn't include
+ * the NULL terminator.
+ */
+ *size = len * sizeof(WCHAR);
+ }else {
+ if (ai->agent)
+ *size = WideCharToMultiByte(CP_ACP, 0, ai->agent, -1, NULL, 0, NULL, NULL);
+ else
+ *size = 1;
+ if(!buffer || bufsize < *size)
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ if (ai->agent)
+ WideCharToMultiByte(CP_ACP, 0, ai->agent, -1, buffer, *size, NULL, NULL);
+ else
+ *(char *)buffer = 0;
+ /* If the buffer is copied, the returned length doesn't include
+ * the NULL terminator.
+ */
+ *size -= 1;
+ }
+
+ return ERROR_SUCCESS;
}
- FIXME("Not implemented option %d\n", option);
- return ERROR_INTERNET_INVALID_OPTION;
+ case INTERNET_OPTION_PROXY:
+ if (unicode) {
+ INTERNET_PROXY_INFOW *pi = (INTERNET_PROXY_INFOW *)buffer;
+ DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
+ LPWSTR proxy, proxy_bypass;
+
+ if (ai->proxy)
+ proxyBytesRequired = (lstrlenW(ai->proxy) + 1) * sizeof(WCHAR);
+ if (ai->proxyBypass)
+ proxyBypassBytesRequired = (lstrlenW(ai->proxyBypass) + 1) * sizeof(WCHAR);
+ if (*size < sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired + proxyBypassBytesRequired)
+ {
+ *size = sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired + proxyBypassBytesRequired;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ proxy = (LPWSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOW));
+ proxy_bypass = (LPWSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired);
+
+ pi->dwAccessType = ai->accessType;
+ pi->lpszProxy = NULL;
+ pi->lpszProxyBypass = NULL;
+ if (ai->proxy) {
+ lstrcpyW(proxy, ai->proxy);
+ pi->lpszProxy = proxy;
+ }
+
+ if (ai->proxyBypass) {
+ lstrcpyW(proxy_bypass, ai->proxyBypass);
+ pi->lpszProxyBypass = proxy_bypass;
+ }
+
+ *size = sizeof(INTERNET_PROXY_INFOW) + proxyBytesRequired + proxyBypassBytesRequired;
+ return ERROR_SUCCESS;
+ }else {
+ INTERNET_PROXY_INFOA *pi = (INTERNET_PROXY_INFOA *)buffer;
+ DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
+ LPSTR proxy, proxy_bypass;
+
+ if (ai->proxy)
+ proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0, ai->proxy, -1, NULL, 0, NULL, NULL);
+ if (ai->proxyBypass)
+ proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0, ai->proxyBypass, -1,
+ NULL, 0, NULL, NULL);
+ if (*size < sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired + proxyBypassBytesRequired)
+ {
+ *size = sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired + proxyBypassBytesRequired;
+ return ERROR_INSUFFICIENT_BUFFER;
+ }
+ proxy = (LPSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOA));
+ proxy_bypass = (LPSTR)((LPBYTE)buffer + sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired);
+
+ pi->dwAccessType = ai->accessType;
+ pi->lpszProxy = NULL;
+ pi->lpszProxyBypass = NULL;
+ if (ai->proxy) {
+ WideCharToMultiByte(CP_ACP, 0, ai->proxy, -1, proxy, proxyBytesRequired, NULL, NULL);
+ pi->lpszProxy = proxy;
+ }
+
+ if (ai->proxyBypass) {
+ WideCharToMultiByte(CP_ACP, 0, ai->proxyBypass, -1, proxy_bypass,
+ proxyBypassBytesRequired, NULL, NULL);
+ pi->lpszProxyBypass = proxy_bypass;
+ }
+
+ *size = sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired + proxyBypassBytesRequired;
+ return ERROR_SUCCESS;
+ }
+ }
+
+ return INET_QueryOption(hdr, option, buffer, size, unicode);
}
-static const HANDLEHEADERVtbl APPINFOVtbl = {
+static const object_vtbl_t APPINFOVtbl = {
APPINFO_Destroy,
NULL,
APPINFO_QueryOption,
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
{
- LPWININETAPPINFOW lpwai = NULL;
- HINTERNET handle = NULL;
+ appinfo_t *lpwai = NULL;
if (TRACE_ON(wininet)) {
#define FE(x) { x, #x }
/* Clear any error information */
INTERNET_SetLastError(0);
- lpwai = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETAPPINFOW));
- if (NULL == lpwai)
- {
- INTERNET_SetLastError(ERROR_OUTOFMEMORY);
- goto lend;
+ lpwai = alloc_object(NULL, &APPINFOVtbl, sizeof(appinfo_t));
+ if (!lpwai) {
+ SetLastError(ERROR_OUTOFMEMORY);
+ return NULL;
}
lpwai->hdr.htype = WH_HINIT;
- lpwai->hdr.vtbl = &APPINFOVtbl;
lpwai->hdr.dwFlags = dwFlags;
- lpwai->hdr.refs = 1;
- lpwai->dwAccessType = dwAccessType;
- lpwai->lpszProxyUsername = NULL;
- lpwai->lpszProxyPassword = NULL;
+ lpwai->accessType = dwAccessType;
+ lpwai->proxyUsername = NULL;
+ lpwai->proxyPassword = NULL;
- handle = WININET_AllocHandle( &lpwai->hdr );
- if( !handle )
- {
- HeapFree( GetProcessHeap(), 0, lpwai );
- INTERNET_SetLastError(ERROR_OUTOFMEMORY);
- goto lend;
- }
-
- if (NULL != lpszAgent)
- {
- lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
- (strlenW(lpszAgent)+1)*sizeof(WCHAR));
- if (lpwai->lpszAgent)
- lstrcpyW( lpwai->lpszAgent, lpszAgent );
- }
+ lpwai->agent = heap_strdupW(lpszAgent);
if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
- INTERNET_ConfigureProxyFromReg( lpwai );
- else if (NULL != lpszProxy)
- {
- lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0,
- (strlenW(lpszProxy)+1)*sizeof(WCHAR));
- if (lpwai->lpszProxy)
- lstrcpyW( lpwai->lpszProxy, lpszProxy );
- }
-
- if (NULL != lpszProxyBypass)
- {
- lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0,
- (strlenW(lpszProxyBypass)+1)*sizeof(WCHAR));
- if (lpwai->lpszProxyBypass)
- lstrcpyW( lpwai->lpszProxyBypass, lpszProxyBypass );
- }
-
-lend:
- if( lpwai )
- WININET_Release( &lpwai->hdr );
+ INTERNET_ConfigureProxy( lpwai );
+ else
+ lpwai->proxy = heap_strdupW(lpszProxy);
+ lpwai->proxyBypass = heap_strdupW(lpszProxyBypass);
TRACE("returning %p\n", lpwai);
- return handle;
+ return lpwai->hdr.hInternet;
}
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
{
- HINTERNET rc = NULL;
- INT len;
- WCHAR *szAgent = NULL, *szProxy = NULL, *szBypass = NULL;
+ WCHAR *szAgent, *szProxy, *szBypass;
+ HINTERNET rc;
TRACE("(%s, 0x%08x, %s, %s, 0x%08x)\n", debugstr_a(lpszAgent),
dwAccessType, debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
- if( lpszAgent )
- {
- len = MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, NULL, 0);
- szAgent = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, szAgent, len);
- }
-
- if( lpszProxy )
- {
- len = MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, NULL, 0);
- szProxy = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, szProxy, len);
- }
-
- if( lpszProxyBypass )
- {
- len = MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0);
- szBypass = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, szBypass, len);
- }
+ szAgent = heap_strdupAtoW(lpszAgent);
+ szProxy = heap_strdupAtoW(lpszProxy);
+ szBypass = heap_strdupAtoW(lpszProxyBypass);
rc = InternetOpenW(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
- HeapFree(GetProcessHeap(), 0, szAgent);
- HeapFree(GetProcessHeap(), 0, szProxy);
- HeapFree(GetProcessHeap(), 0, szBypass);
-
+ heap_free(szAgent);
+ heap_free(szProxy);
+ heap_free(szBypass);
return rc;
}
BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
LPSTR lpszBuffer, LPDWORD lpdwBufferLength)
{
- LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
+ LPWITHREADERROR lpwite = TlsGetValue(g_dwTlsErrIndex);
TRACE("\n");
BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError,
LPWSTR lpszBuffer, LPDWORD lpdwBufferLength)
{
- LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
+ LPWITHREADERROR lpwite = TlsGetValue(g_dwTlsErrIndex);
TRACE("\n");
TRACE("(%p, 0x%08x)\n", lpdwStatus, dwReserved);
if (lpdwStatus) {
- FIXME("always returning LAN connection.\n");
+ WARN("always returning LAN connection.\n");
*lpdwStatus = INTERNET_CONNECTION_LAN;
}
return TRUE;
return FALSE;
if (lpdwStatus) {
- FIXME("always returning LAN connection.\n");
+ WARN("always returning LAN connection.\n");
*lpdwStatus = INTERNET_CONNECTION_LAN;
}
return LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen);
TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
if (lpszConnectionName && dwNameLen > 0)
- lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR));
+ lpwszConnectionName = heap_alloc(dwNameLen * sizeof(WCHAR));
rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen,
dwReserved);
{
WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName,
dwNameLen, NULL, NULL);
-
- HeapFree(GetProcessHeap(),0,lpwszConnectionName);
+ heap_free(lpwszConnectionName);
}
-
return rc;
}
LPCWSTR lpszUserName, LPCWSTR lpszPassword,
DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
{
- LPWININETAPPINFOW hIC;
+ appinfo_t *hIC;
HINTERNET rc = NULL;
+ DWORD res = ERROR_SUCCESS;
TRACE("(%p, %s, %i, %s, %s, %i, %i, %lx)\n", hInternet, debugstr_w(lpszServerName),
nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
if (!lpszServerName)
{
- INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
}
- /* Clear any error information */
- INTERNET_SetLastError(0);
- hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
+ hIC = (appinfo_t*)get_handle_object( hInternet );
if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
{
- INTERNET_SetLastError(ERROR_INVALID_HANDLE);
+ res = ERROR_INVALID_HANDLE;
goto lend;
}
case INTERNET_SERVICE_FTP:
rc = FTP_Connect(hIC, lpszServerName, nServerPort,
lpszUserName, lpszPassword, dwFlags, dwContext, 0);
+ if(!rc)
+ res = INTERNET_GetLastError();
break;
case INTERNET_SERVICE_HTTP:
- rc = HTTP_Connect(hIC, lpszServerName, nServerPort,
- lpszUserName, lpszPassword, dwFlags, dwContext, 0);
+ res = HTTP_Connect(hIC, lpszServerName, nServerPort,
+ lpszUserName, lpszPassword, dwFlags, dwContext, 0, &rc);
break;
case INTERNET_SERVICE_GOPHER:
WININET_Release( &hIC->hdr );
TRACE("returning %p\n", rc);
+ SetLastError(res);
return rc;
}
DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
{
HINTERNET rc = NULL;
- INT len = 0;
- LPWSTR szServerName = NULL;
- LPWSTR szUserName = NULL;
- LPWSTR szPassword = NULL;
-
- if (lpszServerName)
- {
- len = MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, NULL, 0);
- szServerName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, szServerName, len);
- }
- if (lpszUserName)
- {
- len = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
- szUserName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, szUserName, len);
- }
- if (lpszPassword)
- {
- len = MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, NULL, 0);
- szPassword = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
- MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, szPassword, len);
- }
+ LPWSTR szServerName;
+ LPWSTR szUserName;
+ LPWSTR szPassword;
+ szServerName = heap_strdupAtoW(lpszServerName);
+ szUserName = heap_strdupAtoW(lpszUserName);
+ szPassword = heap_strdupAtoW(lpszPassword);
rc = InternetConnectW(hInternet, szServerName, nServerPort,
szUserName, szPassword, dwService, dwFlags, dwContext);
- HeapFree(GetProcessHeap(), 0, szServerName);
- HeapFree(GetProcessHeap(), 0, szUserName);
- HeapFree(GetProcessHeap(), 0, szPassword);
+ heap_free(szServerName);
+ heap_free(szUserName);
+ heap_free(szPassword);
return rc;
}
*/
BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
{
- WININETHANDLEHEADER *hdr;
+ object_header_t *hdr;
DWORD res;
TRACE("\n");
- hdr = WININET_GetObject(hFind);
+ hdr = get_handle_object(hFind);
if(!hdr) {
WARN("Invalid handle\n");
SetLastError(ERROR_INVALID_HANDLE);
*/
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
{
- LPWININETHANDLEHEADER lpwh;
+ object_header_t *obj;
- TRACE("%p\n",hInternet);
+ TRACE("%p\n", hInternet);
- lpwh = WININET_GetObject( hInternet );
- if (NULL == lpwh)
- {
- INTERNET_SetLastError(ERROR_INVALID_HANDLE);
+ obj = get_handle_object( hInternet );
+ if (!obj) {
+ SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
- WININET_Release( lpwh );
- WININET_FreeHandle( hInternet );
+ invalidate_handle(obj);
+ WININET_Release(obj);
return TRUE;
}
/***********************************************************************
* ConvertUrlComponentValue (Internal)
*
- * Helper function for InternetCrackUrlW
+ * Helper function for InternetCrackUrlA
*
*/
static void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
LPWSTR lpwszComponent, DWORD dwwComponentLen,
LPCSTR lpszStart, LPCWSTR lpwszStart)
{
- TRACE("%p %d %p %d %p %p\n", lppszComponent, *dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
+ TRACE("%p %d %p %d %p %p\n", *lppszComponent, *dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
if (*dwComponentLen != 0)
{
DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
if (*lppszComponent == NULL)
{
- int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
if (lpwszComponent)
- *lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
+ {
+ int offset = WideCharToMultiByte(CP_ACP, 0, lpwszStart, lpwszComponent-lpwszStart, NULL, 0, NULL, NULL);
+ *lppszComponent = (LPSTR)lpszStart + offset;
+ }
else
*lppszComponent = NULL;
+
*dwComponentLen = nASCIILength;
}
else
{
DWORD nLength;
URL_COMPONENTSW UCW;
- WCHAR* lpwszUrl;
+ BOOL ret = FALSE;
+ WCHAR *lpwszUrl, *hostname = NULL, *username = NULL, *password = NULL, *path = NULL,
+ *scheme = NULL, *extra = NULL;
- TRACE("(%s %u %x %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents);
+ TRACE("(%s %u %x %p)\n",
+ lpszUrl ? debugstr_an(lpszUrl, dwUrlLength ? dwUrlLength : strlen(lpszUrl)) : "(null)",
+ dwUrlLength, dwFlags, lpUrlComponents);
if (!lpszUrl || !*lpszUrl || !lpUrlComponents ||
lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSA))
InternetCrackUrlW should not include it */
if (dwUrlLength == -1) nLength--;
- lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
- MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
+ lpwszUrl = heap_alloc((nLength + 1) * sizeof(WCHAR));
+ MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength + 1);
+ lpwszUrl[nLength] = '\0';
memset(&UCW,0,sizeof(UCW));
UCW.dwStructSize = sizeof(URL_COMPONENTSW);
- if(lpUrlComponents->dwHostNameLength!=0)
- UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
- if(lpUrlComponents->dwUserNameLength!=0)
- UCW.dwUserNameLength=lpUrlComponents->dwUserNameLength;
- if(lpUrlComponents->dwPasswordLength!=0)
- UCW.dwPasswordLength=lpUrlComponents->dwPasswordLength;
- if(lpUrlComponents->dwUrlPathLength!=0)
- UCW.dwUrlPathLength=lpUrlComponents->dwUrlPathLength;
- if(lpUrlComponents->dwSchemeLength!=0)
- UCW.dwSchemeLength=lpUrlComponents->dwSchemeLength;
- if(lpUrlComponents->dwExtraInfoLength!=0)
- UCW.dwExtraInfoLength=lpUrlComponents->dwExtraInfoLength;
- if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
+ if (lpUrlComponents->dwHostNameLength)
{
- HeapFree(GetProcessHeap(), 0, lpwszUrl);
- return FALSE;
+ UCW.dwHostNameLength = lpUrlComponents->dwHostNameLength;
+ if (lpUrlComponents->lpszHostName)
+ {
+ hostname = heap_alloc(UCW.dwHostNameLength * sizeof(WCHAR));
+ UCW.lpszHostName = hostname;
+ }
}
-
- ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
- UCW.lpszHostName, UCW.dwHostNameLength,
- lpszUrl, lpwszUrl);
- ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
- UCW.lpszUserName, UCW.dwUserNameLength,
- lpszUrl, lpwszUrl);
- ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
- UCW.lpszPassword, UCW.dwPasswordLength,
- lpszUrl, lpwszUrl);
- ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
- UCW.lpszUrlPath, UCW.dwUrlPathLength,
- lpszUrl, lpwszUrl);
- ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
- UCW.lpszScheme, UCW.dwSchemeLength,
- lpszUrl, lpwszUrl);
- ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
- UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
- lpszUrl, lpwszUrl);
- lpUrlComponents->nScheme=UCW.nScheme;
- lpUrlComponents->nPort=UCW.nPort;
- HeapFree(GetProcessHeap(), 0, lpwszUrl);
-
- TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
- debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
- debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
- debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
- debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
-
- return TRUE;
+ if (lpUrlComponents->dwUserNameLength)
+ {
+ UCW.dwUserNameLength = lpUrlComponents->dwUserNameLength;
+ if (lpUrlComponents->lpszUserName)
+ {
+ username = heap_alloc(UCW.dwUserNameLength * sizeof(WCHAR));
+ UCW.lpszUserName = username;
+ }
+ }
+ if (lpUrlComponents->dwPasswordLength)
+ {
+ UCW.dwPasswordLength = lpUrlComponents->dwPasswordLength;
+ if (lpUrlComponents->lpszPassword)
+ {
+ password = heap_alloc(UCW.dwPasswordLength * sizeof(WCHAR));
+ UCW.lpszPassword = password;
+ }
+ }
+ if (lpUrlComponents->dwUrlPathLength)
+ {
+ UCW.dwUrlPathLength = lpUrlComponents->dwUrlPathLength;
+ if (lpUrlComponents->lpszUrlPath)
+ {
+ path = heap_alloc(UCW.dwUrlPathLength * sizeof(WCHAR));
+ UCW.lpszUrlPath = path;
+ }
+ }
+ if (lpUrlComponents->dwSchemeLength)
+ {
+ UCW.dwSchemeLength = lpUrlComponents->dwSchemeLength;
+ if (lpUrlComponents->lpszScheme)
+ {
+ scheme = heap_alloc(UCW.dwSchemeLength * sizeof(WCHAR));
+ UCW.lpszScheme = scheme;
+ }
+ }
+ if (lpUrlComponents->dwExtraInfoLength)
+ {
+ UCW.dwExtraInfoLength = lpUrlComponents->dwExtraInfoLength;
+ if (lpUrlComponents->lpszExtraInfo)
+ {
+ extra = heap_alloc(UCW.dwExtraInfoLength * sizeof(WCHAR));
+ UCW.lpszExtraInfo = extra;
+ }
+ }
+ if ((ret = InternetCrackUrlW(lpwszUrl, nLength, dwFlags, &UCW)))
+ {
+ ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
+ UCW.lpszHostName, UCW.dwHostNameLength, lpszUrl, lpwszUrl);
+ ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
+ UCW.lpszUserName, UCW.dwUserNameLength, lpszUrl, lpwszUrl);
+ ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
+ UCW.lpszPassword, UCW.dwPasswordLength, lpszUrl, lpwszUrl);
+ ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
+ UCW.lpszUrlPath, UCW.dwUrlPathLength, lpszUrl, lpwszUrl);
+ ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
+ UCW.lpszScheme, UCW.dwSchemeLength, lpszUrl, lpwszUrl);
+ ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
+ UCW.lpszExtraInfo, UCW.dwExtraInfoLength, lpszUrl, lpwszUrl);
+
+ lpUrlComponents->nScheme = UCW.nScheme;
+ lpUrlComponents->nPort = UCW.nPort;
+
+ TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_a(lpszUrl),
+ debugstr_an(lpUrlComponents->lpszScheme, lpUrlComponents->dwSchemeLength),
+ debugstr_an(lpUrlComponents->lpszHostName, lpUrlComponents->dwHostNameLength),
+ debugstr_an(lpUrlComponents->lpszUrlPath, lpUrlComponents->dwUrlPathLength),
+ debugstr_an(lpUrlComponents->lpszExtraInfo, lpUrlComponents->dwExtraInfoLength));
+ }
+ heap_free(lpwszUrl);
+ heap_free(hostname);
+ heap_free(username);
+ heap_free(password);
+ heap_free(path);
+ heap_free(scheme);
+ heap_free(extra);
+ return ret;
}
static const WCHAR url_schemes[][7] =
LPCWSTR lpszcp = NULL;
LPWSTR lpszUrl_decode = NULL;
DWORD dwUrlLength = dwUrlLength_orig;
- const WCHAR lpszSeparators[3]={';','?',0};
- const WCHAR lpszSlash[2]={'/',0};
- TRACE("(%s %u %x %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC);
+ TRACE("(%s %u %x %p)\n",
+ lpszUrl ? debugstr_wn(lpszUrl, dwUrlLength ? dwUrlLength : strlenW(lpszUrl)) : "(null)",
+ dwUrlLength, dwFlags, lpUC);
if (!lpszUrl_orig || !*lpszUrl_orig || !lpUC)
{
if (dwFlags & ICU_DECODE)
{
- lpszUrl_decode=HeapAlloc( GetProcessHeap(), 0, dwUrlLength * sizeof (WCHAR) );
- if( InternetCanonicalizeUrlW(lpszUrl_orig, lpszUrl_decode, &dwUrlLength, dwFlags))
- {
- lpszUrl = lpszUrl_decode;
- }
+ WCHAR *url_tmp;
+ DWORD len = dwUrlLength + 1;
+
+ if (!(url_tmp = heap_alloc(len * sizeof(WCHAR))))
+ {
+ INTERNET_SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+ memcpy(url_tmp, lpszUrl_orig, dwUrlLength * sizeof(WCHAR));
+ url_tmp[dwUrlLength] = 0;
+ if (!(lpszUrl_decode = heap_alloc(len * sizeof(WCHAR))))
+ {
+ heap_free(url_tmp);
+ INTERNET_SetLastError(ERROR_OUTOFMEMORY);
+ return FALSE;
+ }
+ if (InternetCanonicalizeUrlW(url_tmp, lpszUrl_decode, &len, ICU_DECODE | ICU_NO_ENCODE))
+ {
+ dwUrlLength = len;
+ lpszUrl = lpszUrl_decode;
+ }
+ heap_free(url_tmp);
}
lpszap = lpszUrl;
/* Determine if the URI is absolute. */
- while (*lpszap != '\0')
+ while (lpszap - lpszUrl < dwUrlLength)
{
- if (isalnumW(*lpszap))
+ if (isalnumW(*lpszap) || *lpszap == '+' || *lpszap == '.' || *lpszap == '-')
{
lpszap++;
continue;
lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
/* Parse <params> */
- lpszParam = strpbrkW(lpszap, lpszSeparators);
+ lpszParam = memchrW(lpszap, ';', dwUrlLength - (lpszap - lpszUrl));
+ if(!lpszParam)
+ lpszParam = memchrW(lpszap, '?', dwUrlLength - (lpszap - lpszUrl));
+ if(!lpszParam)
+ lpszParam = memchrW(lpszap, '#', dwUrlLength - (lpszap - lpszUrl));
+
SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
lpszParam, lpszParam ? dwUrlLength-(lpszParam-lpszUrl) : 0);
{
lpszcp += 2;
- lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
+ lpszNetLoc = memchrW(lpszcp, '/', dwUrlLength - (lpszcp - lpszUrl));
if (lpszParam)
{
if (lpszNetLoc)
/* [<user>[<:password>]@]<host>[:<port>] */
/* First find the user and password if they exist */
- lpszHost = strchrW(lpszcp, '@');
+ lpszHost = memchrW(lpszcp, '@', dwUrlLength - (lpszcp - lpszUrl));
if (lpszHost == NULL || lpszHost > lpszNetLoc)
{
/* username and password not specified. */
}
/* If the scheme is "file" and the host is just one letter, it's not a host */
- if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
+ if(lpUC->nScheme==INTERNET_SCHEME_FILE && lpszPort <= lpszHost+1)
{
lpszcp=lpszHost;
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
* <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
- if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
+ if (lpszcp != 0 && lpszcp - lpszUrl < dwUrlLength && (!lpszParam || lpszcp <= lpszParam))
{
- INT len;
+ DWORD len;
/* Only truncate the parameter list if it's already been saved
* in lpUC->lpszExtraInfo.
/* Leave the parameter list in lpszUrlPath. Strip off any trailing
* newlines if necessary.
*/
- LPWSTR lpsznewline = strchrW(lpszcp, '\n');
+ LPWSTR lpsznewline = memchrW(lpszcp, '\n', dwUrlLength - (lpszcp - lpszUrl));
if (lpsznewline != NULL)
len = lpsznewline - lpszcp;
else
len = dwUrlLength-(lpszcp-lpszUrl);
}
- SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
- lpszcp, len);
+ if (lpUC->dwUrlPathLength && lpUC->lpszUrlPath &&
+ lpUC->nScheme == INTERNET_SCHEME_FILE)
+ {
+ WCHAR tmppath[MAX_PATH];
+ if (*lpszcp == '/')
+ {
+ len = MAX_PATH;
+ PathCreateFromUrlW(lpszUrl_orig, tmppath, &len, 0);
+ }
+ else
+ {
+ WCHAR *iter;
+ memcpy(tmppath, lpszcp, len * sizeof(WCHAR));
+ tmppath[len] = '\0';
+
+ iter = tmppath;
+ while (*iter) {
+ if (*iter == '/')
+ *iter = '\\';
+ ++iter;
+ }
+ }
+ /* if ends in \. or \.. append a backslash */
+ if (tmppath[len - 1] == '.' &&
+ (tmppath[len - 2] == '\\' ||
+ (tmppath[len - 2] == '.' && tmppath[len - 3] == '\\')))
+ {
+ if (len < MAX_PATH - 1)
+ {
+ tmppath[len] = '\\';
+ tmppath[len+1] = '\0';
+ ++len;
+ }
+ }
+ SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
+ tmppath, len);
+ }
+ else
+ SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
+ lpszcp, len);
}
else
{
+ if (lpUC->lpszUrlPath && (lpUC->dwUrlPathLength > 0))
+ lpUC->lpszUrlPath[0] = 0;
lpUC->dwUrlPathLength = 0;
}
debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
- HeapFree(GetProcessHeap(), 0, lpszUrl_decode );
+ heap_free( lpszUrl_decode );
return TRUE;
}
DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE;
TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl), lpszBuffer,
- lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags);
+ lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1);
if(dwFlags & ICU_DECODE)
{
DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE;
TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer,
- lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags);
+ lpdwBufferLength, dwFlags, lpdwBufferLength ? *lpdwBufferLength : -1);
if(dwFlags & ICU_DECODE)
{
/* #################################################### */
static INTERNET_STATUS_CALLBACK set_status_callback(
- LPWININETHANDLEHEADER lpwh, INTERNET_STATUS_CALLBACK callback, BOOL unicode)
+ object_header_t *lpwh, INTERNET_STATUS_CALLBACK callback, BOOL unicode)
{
INTERNET_STATUS_CALLBACK ret;
HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
{
INTERNET_STATUS_CALLBACK retVal;
- LPWININETHANDLEHEADER lpwh;
+ object_header_t *lpwh;
- TRACE("0x%08x\n", (ULONG)hInternet);
-
- if (!(lpwh = WININET_GetObject(hInternet)))
+ TRACE("%p\n", hInternet);
+
+ if (!(lpwh = get_handle_object(hInternet)))
return INTERNET_INVALID_STATUS_CALLBACK;
retVal = set_status_callback(lpwh, lpfnIntCB, FALSE);
HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
{
INTERNET_STATUS_CALLBACK retVal;
- LPWININETHANDLEHEADER lpwh;
+ object_header_t *lpwh;
- TRACE("0x%08x\n", (ULONG)hInternet);
+ TRACE("%p\n", hInternet);
- if (!(lpwh = WININET_GetObject(hInternet)))
+ if (!(lpwh = get_handle_object(hInternet)))
return INTERNET_INVALID_STATUS_CALLBACK;
retVal = set_status_callback(lpwh, lpfnIntCB, TRUE);
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer,
DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
{
- LPWININETHANDLEHEADER lpwh;
- BOOL retval = FALSE;
+ object_header_t *lpwh;
+ BOOL res;
TRACE("(%p %p %d %p)\n", hFile, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
- lpwh = WININET_GetObject( hFile );
+ lpwh = get_handle_object( hFile );
if (!lpwh) {
WARN("Invalid handle\n");
SetLastError(ERROR_INVALID_HANDLE);
}
if(lpwh->vtbl->WriteFile) {
- retval = lpwh->vtbl->WriteFile(lpwh, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
+ res = lpwh->vtbl->WriteFile(lpwh, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
}else {
WARN("No Writefile method.\n");
- SetLastError(ERROR_INVALID_HANDLE);
- retval = FALSE;
+ res = ERROR_INVALID_HANDLE;
}
WININET_Release( lpwh );
- return retval;
+ if(res != ERROR_SUCCESS)
+ SetLastError(res);
+ return res == ERROR_SUCCESS;
}
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
{
- LPWININETHANDLEHEADER hdr;
+ object_header_t *hdr;
DWORD res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
TRACE("%p %p %d %p\n", hFile, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead);
- hdr = WININET_GetObject(hFile);
+ hdr = get_handle_object(hFile);
if (!hdr) {
INTERNET_SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut,
DWORD dwFlags, DWORD_PTR dwContext)
{
- LPWININETHANDLEHEADER hdr;
+ object_header_t *hdr;
DWORD res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffersOut, dwFlags, dwContext);
- hdr = WININET_GetObject(hFile);
+ hdr = get_handle_object(hFile);
if (!hdr) {
INTERNET_SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
/***********************************************************************
* InternetReadFileExW (WININET.@)
- *
- * Read data from an open internet file.
- *
- * PARAMS
- * hFile [I] Handle returned by InternetOpenUrl() or HttpOpenRequest().
- * lpBuffersOut [I/O] Buffer.
- * dwFlags [I] Flags.
- * dwContext [I] Context for callbacks.
- *
- * RETURNS
- * FALSE, last error is set to ERROR_CALL_NOT_IMPLEMENTED
- *
- * NOTES
- * Not implemented in Wine or native either (as of IE6 SP2).
- *
+ * SEE
+ * InternetReadFileExA()
*/
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
DWORD dwFlags, DWORD_PTR dwContext)
{
- ERR("(%p, %p, 0x%x, 0x%lx): not implemented in native\n", hFile, lpBuffer, dwFlags, dwContext);
+ object_header_t *hdr;
+ DWORD res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
+
+ TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffer, dwFlags, dwContext);
+
+ hdr = get_handle_object(hFile);
+ if (!hdr) {
+ INTERNET_SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
+
+ if(hdr->vtbl->ReadFileExW)
+ res = hdr->vtbl->ReadFileExW(hdr, lpBuffer, dwFlags, dwContext);
+
+ WININET_Release(hdr);
- INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ TRACE("-- %s (%u, bytes read: %d)\n", res == ERROR_SUCCESS ? "TRUE": "FALSE",
+ res, lpBuffer->dwBufferLength);
+
+ if(res != ERROR_SUCCESS)
+ SetLastError(res);
+ return res == ERROR_SUCCESS;
}
-/***********************************************************************
- * INET_QueryOptionHelper (internal)
- */
-static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
- LPVOID lpBuffer, LPDWORD lpdwBufferLength)
-{
- LPWININETHANDLEHEADER lpwhh;
- BOOL bSuccess = FALSE;
+DWORD INET_QueryOption(object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
+{
+ static BOOL warn = TRUE;
+
+ switch(option) {
+ case INTERNET_OPTION_REQUEST_FLAGS:
+ TRACE("INTERNET_OPTION_REQUEST_FLAGS\n");
+
+ if (*size < sizeof(ULONG))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ *(ULONG*)buffer = 4;
+ *size = sizeof(ULONG);
+
+ return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_HTTP_VERSION:
+ if (*size < sizeof(HTTP_VERSION_INFO))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ /*
+ * Presently hardcoded to 1.1
+ */
+ ((HTTP_VERSION_INFO*)buffer)->dwMajorVersion = 1;
+ ((HTTP_VERSION_INFO*)buffer)->dwMinorVersion = 1;
+ *size = sizeof(HTTP_VERSION_INFO);
+
+ return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_CONNECTED_STATE:
+ if (warn) {
+ FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
+ warn = FALSE;
+ }
+ if (*size < sizeof(ULONG))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ *(ULONG*)buffer = INTERNET_STATE_CONNECTED;
+ *size = sizeof(ULONG);
+
+ return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_PROXY: {
+ appinfo_t ai;
+ BOOL ret;
+
+ TRACE("Getting global proxy info\n");
+ memset(&ai, 0, sizeof(appinfo_t));
+ INTERNET_ConfigureProxy(&ai);
+
+ ret = APPINFO_QueryOption(&ai.hdr, INTERNET_OPTION_PROXY, buffer, size, unicode); /* FIXME */
+ APPINFO_Destroy(&ai.hdr);
+ return ret;
+ }
+
+ case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
+ TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER\n");
+
+ if (*size < sizeof(ULONG))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ *(ULONG*)buffer = 2;
+ *size = sizeof(ULONG);
+
+ return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
+ TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER\n");
+
+ if (*size < sizeof(ULONG))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ *(ULONG*)buffer = 4;
+ *size = sizeof(ULONG);
+
+ return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_SECURITY_FLAGS:
+ FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
+ return ERROR_SUCCESS;
+
+ case INTERNET_OPTION_VERSION: {
+ static const INTERNET_VERSION_INFO info = { 1, 2 };
+
+ TRACE("INTERNET_OPTION_VERSION\n");
+
+ if (*size < sizeof(INTERNET_VERSION_INFO))
+ return ERROR_INSUFFICIENT_BUFFER;
+
+ memcpy(buffer, &info, sizeof(info));
+ *size = sizeof(info);
- TRACE("(%p, 0x%08x, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
+ return ERROR_SUCCESS;
+ }
- lpwhh = WININET_GetObject( hInternet );
+ case INTERNET_OPTION_PER_CONNECTION_OPTION: {
+ INTERNET_PER_CONN_OPTION_LISTW *con = buffer;
+ INTERNET_PER_CONN_OPTION_LISTA *conA = buffer;
+ DWORD res = ERROR_SUCCESS, i;
+ proxyinfo_t pi;
+ LONG ret;
- switch (dwOption)
- {
- case INTERNET_OPTION_REQUEST_FLAGS:
- {
- ULONG flags = 4;
- TRACE("INTERNET_OPTION_REQUEST_FLAGS: %d\n", flags);
- if (*lpdwBufferLength < sizeof(ULONG))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- memcpy(lpBuffer, &flags, sizeof(ULONG));
- bSuccess = TRUE;
- }
- *lpdwBufferLength = sizeof(ULONG);
- break;
- }
+ TRACE("Getting global proxy info\n");
+ if((ret = INTERNET_LoadProxySettings(&pi)))
+ return ret;
- case INTERNET_OPTION_USER_AGENT:
- FIXME("INTERNET_OPTION_USER_AGENT\n");
- break;
+ FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
- case INTERNET_OPTION_HTTP_VERSION:
- {
- if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- /*
- * Presently hardcoded to 1.1
- */
- ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
- ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
- bSuccess = TRUE;
- }
- *lpdwBufferLength = sizeof(HTTP_VERSION_INFO);
- break;
+ if (*size < sizeof(INTERNET_PER_CONN_OPTION_LISTW)) {
+ FreeProxyInfo(&pi);
+ return ERROR_INSUFFICIENT_BUFFER;
}
- case INTERNET_OPTION_CONNECTED_STATE:
- {
- DWORD *pdwConnectedState = (DWORD *)lpBuffer;
- FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
- if (*lpdwBufferLength < sizeof(*pdwConnectedState))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- *pdwConnectedState = INTERNET_STATE_CONNECTED;
- bSuccess = TRUE;
- }
- *lpdwBufferLength = sizeof(*pdwConnectedState);
- break;
- }
- case INTERNET_OPTION_PROXY:
- {
- LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW)lpwhh;
- WININETAPPINFOW wai;
+ for (i = 0; i < con->dwOptionCount; i++) {
+ INTERNET_PER_CONN_OPTIONW *optionW = con->pOptions + i;
+ INTERNET_PER_CONN_OPTIONA *optionA = conA->pOptions + i;
- if (lpwai == NULL)
- {
- TRACE("Getting global proxy info\n");
- memset(&wai, 0, sizeof(WININETAPPINFOW));
- INTERNET_ConfigureProxyFromReg( &wai );
- lpwai = &wai;
- }
+ switch (optionW->dwOption) {
+ case INTERNET_PER_CONN_FLAGS:
+ if(pi.dwProxyEnabled)
+ optionW->Value.dwValue = PROXY_TYPE_PROXY;
+ else
+ optionW->Value.dwValue = PROXY_TYPE_DIRECT;
+ break;
- if (bIsUnicode)
- {
- INTERNET_PROXY_INFOW *pPI = (INTERNET_PROXY_INFOW *)lpBuffer;
- DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
-
- if (lpwai->lpszProxy)
- proxyBytesRequired = (lstrlenW(lpwai->lpszProxy) + 1) *
- sizeof(WCHAR);
- if (lpwai->lpszProxyBypass)
- proxyBypassBytesRequired =
- (lstrlenW(lpwai->lpszProxyBypass) + 1) * sizeof(WCHAR);
- if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOW) +
- proxyBytesRequired + proxyBypassBytesRequired)
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ case INTERNET_PER_CONN_PROXY_SERVER:
+ if (unicode)
+ optionW->Value.pszValue = heap_strdupW(pi.lpszProxyServer);
else
- {
- LPWSTR proxy = (LPWSTR)((LPBYTE)lpBuffer +
- sizeof(INTERNET_PROXY_INFOW));
- LPWSTR proxy_bypass = (LPWSTR)((LPBYTE)lpBuffer +
- sizeof(INTERNET_PROXY_INFOW) +
- proxyBytesRequired);
-
- pPI->dwAccessType = lpwai->dwAccessType;
- pPI->lpszProxy = NULL;
- pPI->lpszProxyBypass = NULL;
- if (lpwai->lpszProxy)
- {
- lstrcpyW(proxy, lpwai->lpszProxy);
- pPI->lpszProxy = proxy;
- }
+ optionA->Value.pszValue = heap_strdupWtoA(pi.lpszProxyServer);
+ break;
- if (lpwai->lpszProxyBypass)
- {
- lstrcpyW(proxy_bypass, lpwai->lpszProxyBypass);
- pPI->lpszProxyBypass = proxy_bypass;
- }
- bSuccess = TRUE;
- }
- *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOW) +
- proxyBytesRequired + proxyBypassBytesRequired;
- }
- else
- {
- INTERNET_PROXY_INFOA *pPI = (INTERNET_PROXY_INFOA *)lpBuffer;
- DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
-
- if (lpwai->lpszProxy)
- proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0,
- lpwai->lpszProxy, -1, NULL, 0, NULL, NULL);
- if (lpwai->lpszProxyBypass)
- proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0,
- lpwai->lpszProxyBypass, -1, NULL, 0, NULL, NULL);
- if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOA) +
- proxyBytesRequired + proxyBypassBytesRequired)
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ case INTERNET_PER_CONN_PROXY_BYPASS:
+ if (unicode)
+ optionW->Value.pszValue = heap_strdupW(pi.lpszProxyBypass);
else
- {
- LPSTR proxy = (LPSTR)((LPBYTE)lpBuffer +
- sizeof(INTERNET_PROXY_INFOA));
- LPSTR proxy_bypass = (LPSTR)((LPBYTE)lpBuffer +
- sizeof(INTERNET_PROXY_INFOA) +
- proxyBytesRequired);
-
- pPI->dwAccessType = lpwai->dwAccessType;
- pPI->lpszProxy = NULL;
- pPI->lpszProxyBypass = NULL;
- if (lpwai->lpszProxy)
- {
- WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxy, -1,
- proxy, proxyBytesRequired, NULL, NULL);
- pPI->lpszProxy = proxy;
- }
+ optionA->Value.pszValue = heap_strdupWtoA(pi.lpszProxyBypass);
+ break;
- if (lpwai->lpszProxyBypass)
- {
- WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxyBypass,
- -1, proxy_bypass, proxyBypassBytesRequired,
- NULL, NULL);
- pPI->lpszProxyBypass = proxy_bypass;
- }
- bSuccess = TRUE;
- }
- *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOA) +
- proxyBytesRequired + proxyBypassBytesRequired;
- }
- break;
- }
- case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
- {
- ULONG conn = 2;
- TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", conn);
- if (*lpdwBufferLength < sizeof(ULONG))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- memcpy(lpBuffer, &conn, sizeof(ULONG));
- bSuccess = TRUE;
- }
- *lpdwBufferLength = sizeof(ULONG);
- break;
- }
- case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
- {
- ULONG conn = 4;
- TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER: %d\n", conn);
- if (*lpdwBufferLength < sizeof(ULONG))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- memcpy(lpBuffer, &conn, sizeof(ULONG));
- bSuccess = TRUE;
+ case INTERNET_PER_CONN_AUTOCONFIG_URL:
+ case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
+ case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
+ case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
+ FIXME("Unhandled dwOption %d\n", optionW->dwOption);
+ memset(&optionW->Value, 0, sizeof(optionW->Value));
+ break;
+
+ default:
+ FIXME("Unknown dwOption %d\n", optionW->dwOption);
+ res = ERROR_INVALID_PARAMETER;
+ break;
}
- *lpdwBufferLength = sizeof(ULONG);
- break;
}
- case INTERNET_OPTION_SECURITY_FLAGS:
- FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
- bSuccess = TRUE;
- break;
+ FreeProxyInfo(&pi);
+
+ return res;
+ }
+ case INTERNET_OPTION_USER_AGENT:
+ return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
+ case INTERNET_OPTION_POLICY:
+ return ERROR_INVALID_PARAMETER;
+ case INTERNET_OPTION_CONTEXT_VALUE:
+ {
+ if (!hdr)
+ return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
+ if (!size)
+ return ERROR_INVALID_PARAMETER;
- case INTERNET_OPTION_VERSION:
+ if (*size < sizeof(DWORD_PTR))
{
- TRACE("INTERNET_OPTION_VERSION\n");
- if (*lpdwBufferLength < sizeof(INTERNET_VERSION_INFO))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- static const INTERNET_VERSION_INFO info = { 1, 2 };
- memcpy(lpBuffer, &info, sizeof(info));
- *lpdwBufferLength = sizeof(info);
- bSuccess = TRUE;
- }
- break;
+ *size = sizeof(DWORD_PTR);
+ return ERROR_INSUFFICIENT_BUFFER;
}
- case INTERNET_OPTION_PER_CONNECTION_OPTION:
- FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
- if (*lpdwBufferLength < sizeof(INTERNET_PER_CONN_OPTION_LISTW))
- INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
- else
- {
- INTERNET_PER_CONN_OPTION_LISTW *con = lpBuffer;
- int x;
- bSuccess = TRUE;
- for (x = 0; x < con->dwOptionCount; ++x)
- {
- INTERNET_PER_CONN_OPTIONW *option = con->pOptions + x;
- switch (option->dwOption)
- {
- case INTERNET_PER_CONN_FLAGS:
- option->Value.dwValue = PROXY_TYPE_DIRECT;
- break;
-
- case INTERNET_PER_CONN_PROXY_SERVER:
- case INTERNET_PER_CONN_PROXY_BYPASS:
- case INTERNET_PER_CONN_AUTOCONFIG_URL:
- case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
- case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
- case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
- case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
- case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
- FIXME("Unhandled dwOption %d\n", option->dwOption);
- option->Value.dwValue = 0;
- bSuccess = FALSE;
- break;
-
- default:
- FIXME("Unknown dwOption %d\n", option->dwOption);
- bSuccess = FALSE;
- break;
- }
- }
- if (!bSuccess)
- INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
- }
- break;
- case 66:
- FIXME("66\n");
- bSuccess = TRUE;
- break;
- default: {
- if(lpwhh) {
- DWORD res;
+ if (!buffer)
+ return ERROR_INVALID_PARAMETER;
- res = lpwhh->vtbl->QueryOption(lpwhh, dwOption, lpBuffer, lpdwBufferLength, bIsUnicode);
- if(res == ERROR_SUCCESS)
- bSuccess = TRUE;
- else
- SetLastError(res);
- }else {
- FIXME("Stub! %d\n", dwOption);
- break;
- }
- }
+ *(DWORD_PTR *)buffer = hdr->dwContext;
+ *size = sizeof(DWORD_PTR);
+ return ERROR_SUCCESS;
+ }
}
- if (lpwhh)
- WININET_Release( lpwhh );
- return bSuccess;
+ FIXME("Stub for %d\n", option);
+ return ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
}
/***********************************************************************
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, LPDWORD lpdwBufferLength)
{
- return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
+ object_header_t *hdr;
+ DWORD res = ERROR_INVALID_HANDLE;
+
+ TRACE("%p %d %p %p\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
+
+ if(hInternet) {
+ hdr = get_handle_object(hInternet);
+ if (hdr) {
+ res = hdr->vtbl->QueryOption(hdr, dwOption, lpBuffer, lpdwBufferLength, TRUE);
+ WININET_Release(hdr);
+ }
+ }else {
+ res = INET_QueryOption(NULL, dwOption, lpBuffer, lpdwBufferLength, TRUE);
+ }
+
+ if(res != ERROR_SUCCESS)
+ SetLastError(res);
+ return res == ERROR_SUCCESS;
}
/***********************************************************************
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, LPDWORD lpdwBufferLength)
{
- return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
+ object_header_t *hdr;
+ DWORD res = ERROR_INVALID_HANDLE;
+
+ TRACE("%p %d %p %p\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
+
+ if(hInternet) {
+ hdr = get_handle_object(hInternet);
+ if (hdr) {
+ res = hdr->vtbl->QueryOption(hdr, dwOption, lpBuffer, lpdwBufferLength, FALSE);
+ WININET_Release(hdr);
+ }
+ }else {
+ res = INET_QueryOption(NULL, dwOption, lpBuffer, lpdwBufferLength, FALSE);
+ }
+
+ if(res != ERROR_SUCCESS)
+ SetLastError(res);
+ return res == ERROR_SUCCESS;
}
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
LPVOID lpBuffer, DWORD dwBufferLength)
{
- LPWININETHANDLEHEADER lpwhh;
+ object_header_t *lpwhh;
BOOL ret = TRUE;
TRACE("(%p %d %p %d)\n", hInternet, dwOption, lpBuffer, dwBufferLength);
- lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
+ lpwhh = (object_header_t*) get_handle_object( hInternet );
if(lpwhh && lpwhh->vtbl->SetOption) {
DWORD res;
{
case INTERNET_OPTION_CALLBACK:
{
- INTERNET_STATUS_CALLBACK callback = *(INTERNET_STATUS_CALLBACK *)lpBuffer;
- ret = (set_status_callback(lpwhh, callback, TRUE) != INTERNET_INVALID_STATUS_CALLBACK);
- break;
+ if (!lpwhh)
+ {
+ SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+ return FALSE;
+ }
+ WININET_Release(lpwhh);
+ SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE);
+ return FALSE;
}
case INTERNET_OPTION_HTTP_VERSION:
{
break;
case INTERNET_OPTION_ERROR_MASK:
{
- unsigned long flags=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
+ if(!lpwhh) {
+ SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+ return FALSE;
+ } else if(*(ULONG*)lpBuffer & (~(INTERNET_ERROR_MASK_INSERT_CDROM|
+ INTERNET_ERROR_MASK_COMBINED_SEC_CERT|
+ INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY))) {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ ret = FALSE;
+ } else if(dwBufferLength != sizeof(ULONG)) {
+ SetLastError(ERROR_INTERNET_BAD_OPTION_LENGTH);
+ ret = FALSE;
+ } else
+ lpwhh->ErrorMask = *(ULONG*)lpBuffer;
}
break;
case INTERNET_OPTION_CODEPAGE:
{
- unsigned long codepage=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
+ ULONG codepage = *(ULONG *)lpBuffer;
+ FIXME("Option INTERNET_OPTION_CODEPAGE (%d): STUB\n", codepage);
}
break;
case INTERNET_OPTION_REQUEST_PRIORITY:
{
- unsigned long priority=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
+ ULONG priority = *(ULONG *)lpBuffer;
+ FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%d): STUB\n", priority);
}
break;
case INTERNET_OPTION_CONNECT_TIMEOUT:
{
- unsigned long connecttimeout=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout);
+ ULONG connecttimeout = *(ULONG *)lpBuffer;
+ FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%d): STUB\n", connecttimeout);
}
break;
case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT:
{
- unsigned long receivetimeout=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout);
+ ULONG receivetimeout = *(ULONG *)lpBuffer;
+ FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%d): STUB\n", receivetimeout);
}
break;
case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
{
- unsigned long conns=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%ld): STUB\n",conns);
+ ULONG conns = *(ULONG *)lpBuffer;
+ FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%d): STUB\n", conns);
}
break;
case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
{
- unsigned long conns=*(unsigned long*)lpBuffer;
- FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%ld): STUB\n",conns);
+ ULONG conns = *(ULONG *)lpBuffer;
+ FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%d): STUB\n", conns);
}
break;
case INTERNET_OPTION_RESET_URLCACHE_SESSION:
break;
case INTERNET_OPTION_SEND_TIMEOUT:
case INTERNET_OPTION_RECEIVE_TIMEOUT:
- FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT\n");
+ case INTERNET_OPTION_DATA_SEND_TIMEOUT:
+ {
+ ULONG timeout = *(ULONG *)lpBuffer;
+ FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT/DATA_SEND_TIMEOUT %d\n", timeout);
break;
+ }
case INTERNET_OPTION_CONNECT_RETRIES:
- FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n");
+ {
+ ULONG retries = *(ULONG *)lpBuffer;
+ FIXME("INTERNET_OPTION_CONNECT_RETRIES %d\n", retries);
break;
+ }
case INTERNET_OPTION_CONTEXT_VALUE:
- FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n");
- break;
+ {
+ if (!lpwhh)
+ {
+ SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+ return FALSE;
+ }
+ if (!lpBuffer || dwBufferLength != sizeof(DWORD_PTR))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ ret = FALSE;
+ }
+ else
+ lpwhh->dwContext = *(DWORD_PTR *)lpBuffer;
+ break;
+ }
case INTERNET_OPTION_SECURITY_FLAGS:
FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
break;
- case 86:
- FIXME("86\n");
+ case INTERNET_OPTION_DISABLE_AUTODIAL:
+ FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
+ break;
+ case INTERNET_OPTION_HTTP_DECODING:
+ FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n");
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_COOKIES_3RD_PARTY:
+ FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n");
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY:
+ FIXME("INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY; STUB\n");
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_CODEPAGE_PATH:
+ FIXME("INTERNET_OPTION_CODEPAGE_PATH; STUB\n");
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_CODEPAGE_EXTRA:
+ FIXME("INTERNET_OPTION_CODEPAGE_EXTRA; STUB\n");
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_IDN:
+ FIXME("INTERNET_OPTION_IDN; STUB\n");
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_POLICY:
+ SetLastError(ERROR_INVALID_PARAMETER);
+ ret = FALSE;
+ break;
+ case INTERNET_OPTION_PER_CONNECTION_OPTION: {
+ INTERNET_PER_CONN_OPTION_LISTW *con = lpBuffer;
+ LONG res;
+ int i;
+ proxyinfo_t pi;
+
+ INTERNET_LoadProxySettings(&pi);
+
+ for (i = 0; i < con->dwOptionCount; i++) {
+ INTERNET_PER_CONN_OPTIONW *option = con->pOptions + i;
+
+ switch (option->dwOption) {
+ case INTERNET_PER_CONN_PROXY_SERVER:
+ heap_free(pi.lpszProxyServer);
+ pi.lpszProxyServer = heap_strdupW(option->Value.pszValue);
+ break;
+
+ case INTERNET_PER_CONN_FLAGS:
+ if(option->Value.dwValue & PROXY_TYPE_PROXY)
+ pi.dwProxyEnabled = 1;
+ else
+ {
+ if(option->Value.dwValue != PROXY_TYPE_DIRECT)
+ FIXME("Unhandled flags: 0x%x\n", option->Value.dwValue);
+ pi.dwProxyEnabled = 0;
+ }
+ break;
+
+ case INTERNET_PER_CONN_AUTOCONFIG_URL:
+ case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
+ case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
+ case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
+ case INTERNET_PER_CONN_PROXY_BYPASS:
+ FIXME("Unhandled dwOption %d\n", option->dwOption);
+ break;
+
+ default:
+ FIXME("Unknown dwOption %d\n", option->dwOption);
+ SetLastError(ERROR_INVALID_PARAMETER);
+ break;
+ }
+ }
+
+ if ((res = INTERNET_SaveProxySettings(&pi)))
+ SetLastError(res);
+
+ FreeProxyInfo(&pi);
+
+ ret = (res == ERROR_SUCCESS);
break;
+ }
default:
FIXME("Option %d STUB\n",dwOption);
- INTERNET_SetLastError(ERROR_INTERNET_INVALID_OPTION);
+ SetLastError(ERROR_INTERNET_INVALID_OPTION);
ret = FALSE;
break;
}
{
case INTERNET_OPTION_CALLBACK:
{
- LPWININETHANDLEHEADER lpwh;
- INTERNET_STATUS_CALLBACK callback = *(INTERNET_STATUS_CALLBACK *)lpBuffer;
+ object_header_t *lpwh;
- if (!(lpwh = WININET_GetObject(hInternet))) return FALSE;
- r = (set_status_callback(lpwh, callback, FALSE) != INTERNET_INVALID_STATUS_CALLBACK);
+ if (!(lpwh = get_handle_object(hInternet)))
+ {
+ INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+ return FALSE;
+ }
WININET_Release(lpwh);
- return r;
+ INTERNET_SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE);
+ return FALSE;
}
case INTERNET_OPTION_PROXY:
{
proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
wlen = sizeof(*piw) + proxlen + prbylen;
- wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
+ wbuffer = heap_alloc(wlen*sizeof(WCHAR) );
piw = (LPINTERNET_PROXY_INFOW) wbuffer;
piw->dwAccessType = pi->dwAccessType;
prox = (LPWSTR) &piw[1];
case INTERNET_OPTION_PASSWORD:
wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
NULL, 0 );
- wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
+ wbuffer = heap_alloc(wlen*sizeof(WCHAR) );
MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
wbuffer, wlen );
break;
+ case INTERNET_OPTION_PER_CONNECTION_OPTION: {
+ int i;
+ INTERNET_PER_CONN_OPTION_LISTW *listW;
+ INTERNET_PER_CONN_OPTION_LISTA *listA = lpBuffer;
+ wlen = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
+ wbuffer = heap_alloc(wlen);
+ listW = wbuffer;
+
+ listW->dwSize = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
+ if (listA->pszConnection)
+ {
+ wlen = MultiByteToWideChar( CP_ACP, 0, listA->pszConnection, -1, NULL, 0 );
+ listW->pszConnection = heap_alloc(wlen*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, listA->pszConnection, -1, listW->pszConnection, wlen );
+ }
+ else
+ listW->pszConnection = NULL;
+ listW->dwOptionCount = listA->dwOptionCount;
+ listW->dwOptionError = listA->dwOptionError;
+ listW->pOptions = heap_alloc(sizeof(INTERNET_PER_CONN_OPTIONW) * listA->dwOptionCount);
+
+ for (i = 0; i < listA->dwOptionCount; ++i) {
+ INTERNET_PER_CONN_OPTIONA *optA = listA->pOptions + i;
+ INTERNET_PER_CONN_OPTIONW *optW = listW->pOptions + i;
+
+ optW->dwOption = optA->dwOption;
+
+ switch (optA->dwOption) {
+ case INTERNET_PER_CONN_AUTOCONFIG_URL:
+ case INTERNET_PER_CONN_PROXY_BYPASS:
+ case INTERNET_PER_CONN_PROXY_SERVER:
+ case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
+ if (optA->Value.pszValue)
+ {
+ wlen = MultiByteToWideChar( CP_ACP, 0, optA->Value.pszValue, -1, NULL, 0 );
+ optW->Value.pszValue = heap_alloc(wlen*sizeof(WCHAR));
+ MultiByteToWideChar( CP_ACP, 0, optA->Value.pszValue, -1, optW->Value.pszValue, wlen );
+ }
+ else
+ optW->Value.pszValue = NULL;
+ break;
+ case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
+ case INTERNET_PER_CONN_FLAGS:
+ case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
+ optW->Value.dwValue = optA->Value.dwValue;
+ break;
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
+ optW->Value.ftValue = optA->Value.ftValue;
+ break;
+ default:
+ WARN("Unknown PER_CONN dwOption: %d, guessing at conversion to Wide\n", optA->dwOption);
+ optW->Value.dwValue = optA->Value.dwValue;
+ break;
+ }
+ }
+ }
+ break;
default:
wbuffer = lpBuffer;
wlen = dwBufferLength;
r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
if( lpBuffer != wbuffer )
- HeapFree( GetProcessHeap(), 0, wbuffer );
+ {
+ if (dwOption == INTERNET_OPTION_PER_CONNECTION_OPTION)
+ {
+ INTERNET_PER_CONN_OPTION_LISTW *list = wbuffer;
+ int i;
+ for (i = 0; i < list->dwOptionCount; ++i) {
+ INTERNET_PER_CONN_OPTIONW *opt = list->pOptions + i;
+ switch (opt->dwOption) {
+ case INTERNET_PER_CONN_AUTOCONFIG_URL:
+ case INTERNET_PER_CONN_PROXY_BYPASS:
+ case INTERNET_PER_CONN_PROXY_SERVER:
+ case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
+ case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
+ heap_free( opt->Value.pszValue );
+ break;
+ default:
+ break;
+ }
+ }
+ heap_free( list->pOptions );
+ }
+ heap_free( wbuffer );
+ }
return r;
}
FIXME("Flags %08x ignored\n", dwFlags);
if( dwFlags & ~ISO_VALID_FLAGS )
{
- INTERNET_SetLastError( ERROR_INVALID_PARAMETER );
+ SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
+ if (!time || !string || format != INTERNET_RFC1123_FORMAT)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (size < INTERNET_RFC1123_BUFSIZE * sizeof(*string))
+ {
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ return FALSE;
+ }
+
ret = InternetTimeFromSystemTimeW( time, format, stringW, sizeof(stringW) );
if (ret) WideCharToMultiByte( CP_ACP, 0, stringW, -1, string, size, NULL, NULL );
TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
- if (!time || !string) return FALSE;
+ if (!time || !string || format != INTERNET_RFC1123_FORMAT)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
- if (format != INTERNET_RFC1123_FORMAT || size < INTERNET_RFC1123_BUFSIZE * sizeof(WCHAR))
+ if (size < INTERNET_RFC1123_BUFSIZE * sizeof(*string))
+ {
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
+ }
sprintfW( string, date,
WININET_wkday[time->wDayOfWeek],
{
BOOL ret = FALSE;
WCHAR *stringW;
- int len;
TRACE( "%s %p 0x%08x\n", debugstr_a(string), time, reserved );
- len = MultiByteToWideChar( CP_ACP, 0, string, -1, NULL, 0 );
- stringW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
-
+ stringW = heap_strdupAtoW(string);
if (stringW)
{
- MultiByteToWideChar( CP_ACP, 0, string, -1, stringW, len );
ret = InternetTimeToSystemTimeW( stringW, time, reserved );
- HeapFree( GetProcessHeap(), 0, stringW );
+ heap_free( stringW );
}
return ret;
}
URL_COMPONENTSW components;
ZeroMemory(&components,sizeof(URL_COMPONENTSW));
- components.lpszHostName = (LPWSTR)&hostW;
+ components.lpszHostName = (LPWSTR)hostW;
components.dwHostNameLength = 1024;
if (!InternetCrackUrlW(lpszUrl,0,0,&components))
if (dwFlags & FLAG_ICC_FORCE_CONNECTION)
{
- struct sockaddr_in sin;
+ struct sockaddr_storage saddr;
+ socklen_t sa_len = sizeof(saddr);
int fd;
- if (!GetAddress(hostW, port, &sin))
+ if (!GetAddress(hostW, port, (struct sockaddr *)&saddr, &sa_len))
goto End;
- fd = socket(sin.sin_family, SOCK_STREAM, 0);
+ fd = socket(saddr.ss_family, SOCK_STREAM, 0);
if (fd != -1)
{
- if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == 0)
+ if (connect(fd, (struct sockaddr *)&saddr, sa_len) == 0)
rc = TRUE;
close(fd);
}
* Build our ping command
*/
len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
- command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
+ command = heap_alloc(strlen(ping)+len+strlen(redirect));
strcpy(command,ping);
WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
strcat(command,redirect);
}
End:
-
- HeapFree( GetProcessHeap(), 0, command );
+ heap_free( command );
if (rc == FALSE)
INTERNET_SetLastError(ERROR_NOT_CONNECTED);
*/
BOOL WINAPI InternetCheckConnectionA(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
{
- WCHAR *szUrl;
- INT len;
+ WCHAR *url = NULL;
BOOL rc;
- len = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0);
- if (!(szUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
- return FALSE;
- MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, len);
- rc = InternetCheckConnectionW(szUrl, dwFlags, dwReserved);
- HeapFree(GetProcessHeap(), 0, szUrl);
-
+ if(lpszUrl) {
+ url = heap_strdupAtoW(lpszUrl);
+ if(!url)
+ return FALSE;
+ }
+
+ rc = InternetCheckConnectionW(url, dwFlags, dwReserved);
+
+ heap_free(url);
return rc;
}
* RETURNS
* handle of connection or NULL on failure
*/
-HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
+static HINTERNET INTERNET_InternetOpenUrlW(appinfo_t *hIC, LPCWSTR lpszUrl,
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
{
URL_COMPONENTSW urlComponents;
WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
WCHAR password[1024], path[2048], extra[1024];
HINTERNET client = NULL, client1 = NULL;
+ DWORD res;
TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hIC, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
dwHeadersLength, dwFlags, dwContext);
else
urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
}
+ if (urlComponents.nScheme == INTERNET_SCHEME_HTTPS) dwFlags |= INTERNET_FLAG_SECURE;
+
/* FIXME: should use pointers, not handles, as handles are not thread-safe */
- client = HTTP_Connect(hIC, hostName, urlComponents.nPort,
- userName, password, dwFlags, dwContext, INET_OPENURL);
- if(client == NULL)
+ res = HTTP_Connect(hIC, hostName, urlComponents.nPort,
+ userName, password, dwFlags, dwContext, INET_OPENURL, &client);
+ if(res != ERROR_SUCCESS) {
+ INTERNET_SetLastError(res);
break;
+ }
if (urlComponents.dwExtraInfoLength) {
WCHAR *path_extra;
DWORD len = urlComponents.dwUrlPathLength + urlComponents.dwExtraInfoLength + 1;
- if (!(path_extra = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
+ if (!(path_extra = heap_alloc(len * sizeof(WCHAR))))
{
InternetCloseHandle(client);
break;
strcpyW(path_extra, urlComponents.lpszUrlPath);
strcatW(path_extra, urlComponents.lpszExtraInfo);
client1 = HttpOpenRequestW(client, NULL, path_extra, NULL, NULL, accept, dwFlags, dwContext);
- HeapFree(GetProcessHeap(), 0, path_extra);
+ heap_free(path_extra);
}
else
client1 = HttpOpenRequestW(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
/* gopher doesn't seem to be implemented in wine, but it's supposed
* to be supported by InternetOpenUrlA. */
default:
- INTERNET_SetLastError(ERROR_INTERNET_UNRECOGNIZED_SCHEME);
+ SetLastError(ERROR_INTERNET_UNRECOGNIZED_SCHEME);
break;
}
static void AsyncInternetOpenUrlProc(WORKREQUEST *workRequest)
{
struct WORKREQ_INTERNETOPENURLW const *req = &workRequest->u.InternetOpenUrlW;
- LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest->hdr;
+ appinfo_t *hIC = (appinfo_t*) workRequest->hdr;
TRACE("%p\n", hIC);
INTERNET_InternetOpenUrlW(hIC, req->lpszUrl,
req->lpszHeaders, req->dwHeadersLength, req->dwFlags, req->dwContext);
- HeapFree(GetProcessHeap(), 0, req->lpszUrl);
- HeapFree(GetProcessHeap(), 0, req->lpszHeaders);
+ heap_free(req->lpszUrl);
+ heap_free(req->lpszHeaders);
}
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
{
HINTERNET ret = NULL;
- LPWININETAPPINFOW hIC = NULL;
+ appinfo_t *hIC = NULL;
if (TRACE_ON(wininet)) {
TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
if (!lpszUrl)
{
- INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_PARAMETER);
goto lend;
}
- hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
+ hIC = (appinfo_t*)get_handle_object( hInternet );
if (NULL == hIC || hIC->hdr.htype != WH_HINIT) {
- INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+ SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
goto lend;
}
workRequest.asyncproc = AsyncInternetOpenUrlProc;
workRequest.hdr = WININET_AddRef( &hIC->hdr );
- req = &workRequest.u.InternetOpenUrlW;
- req->lpszUrl = WININET_strdupW(lpszUrl);
- if (lpszHeaders)
- req->lpszHeaders = WININET_strdupW(lpszHeaders);
- else
- req->lpszHeaders = 0;
+ req = &workRequest.u.InternetOpenUrlW;
+ req->lpszUrl = heap_strdupW(lpszUrl);
+ req->lpszHeaders = heap_strdupW(lpszHeaders);
req->dwHeadersLength = dwHeadersLength;
req->dwFlags = dwFlags;
req->dwContext = dwContext;
/*
* This is from windows.
*/
- INTERNET_SetLastError(ERROR_IO_PENDING);
+ SetLastError(ERROR_IO_PENDING);
} else {
ret = INTERNET_InternetOpenUrlW(hIC, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
}
LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
{
HINTERNET rc = NULL;
-
- INT lenUrl;
- INT lenHeaders = 0;
+ DWORD lenHeaders = 0;
LPWSTR szUrl = NULL;
LPWSTR szHeaders = NULL;
TRACE("\n");
if(lpszUrl) {
- lenUrl = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0 );
- szUrl = HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(WCHAR));
+ szUrl = heap_strdupAtoW(lpszUrl);
if(!szUrl)
return NULL;
- MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl);
}
if(lpszHeaders) {
lenHeaders = MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, NULL, 0 );
- szHeaders = HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(WCHAR));
+ szHeaders = heap_alloc(lenHeaders*sizeof(WCHAR));
if(!szHeaders) {
- HeapFree(GetProcessHeap(), 0, szUrl);
+ heap_free(szUrl);
return NULL;
}
MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, szHeaders, lenHeaders);
rc = InternetOpenUrlW(hInternet, szUrl, szHeaders,
lenHeaders, dwFlags, dwContext);
- HeapFree(GetProcessHeap(), 0, szUrl);
- HeapFree(GetProcessHeap(), 0, szHeaders);
-
+ heap_free(szUrl);
+ heap_free(szHeaders);
return rc;
}
static LPWITHREADERROR INTERNET_AllocThreadError(void)
{
- LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
+ LPWITHREADERROR lpwite = heap_alloc(sizeof(*lpwite));
if (lpwite)
{
if (!TlsSetValue(g_dwTlsErrIndex, lpwite))
{
- HeapFree(GetProcessHeap(), 0, lpwite);
+ heap_free(lpwite);
return NULL;
}
-
return lpwite;
}
*/
void INTERNET_SetLastError(DWORD dwError)
{
- LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
+ LPWITHREADERROR lpwite = TlsGetValue(g_dwTlsErrIndex);
if (!lpwite)
lpwite = INTERNET_AllocThreadError();
*/
DWORD INTERNET_GetLastError(void)
{
- LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
+ LPWITHREADERROR lpwite = TlsGetValue(g_dwTlsErrIndex);
if (!lpwite) return 0;
/* TlsGetValue clears last error, so set it again here */
SetLastError(lpwite->dwError);
TRACE("\n");
- memcpy(&workRequest, lpRequest, sizeof(WORKREQUEST));
- HeapFree(GetProcessHeap(), 0, lpRequest);
+ workRequest = *lpRequest;
+ heap_free(lpRequest);
workRequest.asyncproc(&workRequest);
-
WININET_Release( workRequest.hdr );
+
+ if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
+ {
+ heap_free(TlsGetValue(g_dwTlsErrIndex));
+ TlsSetValue(g_dwTlsErrIndex, NULL);
+ }
return TRUE;
}
* RETURNS
*
*/
-BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
+DWORD INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
{
BOOL bSuccess;
LPWORKREQUEST lpNewRequest;
TRACE("\n");
- lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
+ lpNewRequest = heap_alloc(sizeof(WORKREQUEST));
if (!lpNewRequest)
- return FALSE;
+ return ERROR_OUTOFMEMORY;
- memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
+ *lpNewRequest = *lpWorkRequest;
bSuccess = QueueUserWorkItem(INTERNET_WorkerThreadFunc, lpNewRequest, WT_EXECUTELONGFUNCTION);
if (!bSuccess)
{
- HeapFree(GetProcessHeap(), 0, lpNewRequest);
- INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
+ heap_free(lpNewRequest);
+ return ERROR_INTERNET_ASYNC_THREAD_FAILED;
}
-
- return bSuccess;
+ return ERROR_SUCCESS;
}
*/
LPSTR INTERNET_GetResponseBuffer(void)
{
- LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
+ LPWITHREADERROR lpwite = TlsGetValue(g_dwTlsErrIndex);
if (!lpwite)
lpwite = INTERNET_AllocThreadError();
TRACE("\n");
LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
{
- struct timeval tv;
- fd_set infd;
+ struct pollfd pfd;
BOOL bSuccess = FALSE;
INT nRecv = 0;
LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
TRACE("\n");
- FD_ZERO(&infd);
- FD_SET(nSocket, &infd);
- tv.tv_sec=RESPONSE_TIMEOUT;
- tv.tv_usec=0;
+ pfd.fd = nSocket;
+ pfd.events = POLLIN;
while (nRecv < MAX_REPLY_LEN)
{
- if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
+ if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
{
if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
{
LPDWORD lpdwNumberOfBytesAvailble,
DWORD dwFlags, DWORD_PTR dwContext)
{
- WININETHANDLEHEADER *hdr;
+ object_header_t *hdr;
DWORD res;
TRACE("(%p %p %x %lx)\n", hFile, lpdwNumberOfBytesAvailble, dwFlags, dwContext);
- hdr = WININET_GetObject( hFile );
+ hdr = get_handle_object( hFile );
if (!hdr) {
- INTERNET_SetLastError(ERROR_INVALID_HANDLE);
+ SetLastError(ERROR_INVALID_HANDLE);
return FALSE;
}
index = scheme - INTERNET_SCHEME_FIRST;
if (index >= sizeof(url_schemes)/sizeof(url_schemes[0]))
return NULL;
- return (LPCWSTR)&url_schemes[index];
+ return (LPCWSTR)url_schemes[index];
}
/* we can calculate using ansi strings because we're just
if (lpUrlComponents->lpszUrlPath)
*lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
+ if (lpUrlComponents->lpszExtraInfo)
+ *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, ExtraInfo);
+
return TRUE;
}
if (lpUrlComponents->lpszScheme)
{
len = URL_GET_COMP_LENGTHA(lpUrlComponents, Scheme) + 1;
- urlCompW->lpszScheme = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ urlCompW->lpszScheme = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszScheme,
-1, urlCompW->lpszScheme, len);
}
if (lpUrlComponents->lpszHostName)
{
len = URL_GET_COMP_LENGTHA(lpUrlComponents, HostName) + 1;
- urlCompW->lpszHostName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ urlCompW->lpszHostName = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszHostName,
-1, urlCompW->lpszHostName, len);
}
if (lpUrlComponents->lpszUserName)
{
len = URL_GET_COMP_LENGTHA(lpUrlComponents, UserName) + 1;
- urlCompW->lpszUserName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ urlCompW->lpszUserName = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUserName,
-1, urlCompW->lpszUserName, len);
}
if (lpUrlComponents->lpszPassword)
{
len = URL_GET_COMP_LENGTHA(lpUrlComponents, Password) + 1;
- urlCompW->lpszPassword = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ urlCompW->lpszPassword = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszPassword,
-1, urlCompW->lpszPassword, len);
}
if (lpUrlComponents->lpszUrlPath)
{
len = URL_GET_COMP_LENGTHA(lpUrlComponents, UrlPath) + 1;
- urlCompW->lpszUrlPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ urlCompW->lpszUrlPath = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUrlPath,
-1, urlCompW->lpszUrlPath, len);
}
if (lpUrlComponents->lpszExtraInfo)
{
len = URL_GET_COMP_LENGTHA(lpUrlComponents, ExtraInfo) + 1;
- urlCompW->lpszExtraInfo = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+ urlCompW->lpszExtraInfo = heap_alloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszExtraInfo,
-1, urlCompW->lpszExtraInfo, len);
}
if (!lpUrlComponents || lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
{
- INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
convert_urlcomp_atow(lpUrlComponents, &urlCompW);
if (lpszUrl)
- urlW = HeapAlloc(GetProcessHeap(), 0, *lpdwUrlLength * sizeof(WCHAR));
+ urlW = heap_alloc(*lpdwUrlLength * sizeof(WCHAR));
ret = InternetCreateUrlW(&urlCompW, dwFlags, urlW, lpdwUrlLength);
if (ret)
WideCharToMultiByte(CP_ACP, 0, urlW, -1, lpszUrl, *lpdwUrlLength + 1, NULL, NULL);
- HeapFree(GetProcessHeap(), 0, urlCompW.lpszScheme);
- HeapFree(GetProcessHeap(), 0, urlCompW.lpszHostName);
- HeapFree(GetProcessHeap(), 0, urlCompW.lpszUserName);
- HeapFree(GetProcessHeap(), 0, urlCompW.lpszPassword);
- HeapFree(GetProcessHeap(), 0, urlCompW.lpszUrlPath);
- HeapFree(GetProcessHeap(), 0, urlCompW.lpszExtraInfo);
- HeapFree(GetProcessHeap(), 0, urlW);
-
+ heap_free(urlCompW.lpszScheme);
+ heap_free(urlCompW.lpszHostName);
+ heap_free(urlCompW.lpszUserName);
+ heap_free(urlCompW.lpszPassword);
+ heap_free(urlCompW.lpszUrlPath);
+ heap_free(urlCompW.lpszExtraInfo);
+ heap_free(urlW);
return ret;
}
INTERNET_SCHEME nScheme;
static const WCHAR slashSlashW[] = {'/','/'};
- static const WCHAR percentD[] = {'%','d',0};
+ static const WCHAR fmtW[] = {'%','u',0};
TRACE("(%p,%d,%p,%p)\n", lpUrlComponents, dwFlags, lpszUrl, lpdwUrlLength);
{
WCHAR szPort[MAX_WORD_DIGITS+1];
- sprintfW(szPort, percentD, lpUrlComponents->nPort);
+ sprintfW(szPort, fmtW, lpUrlComponents->nPort);
*lpszUrl = ':';
lpszUrl++;
dwLen = strlenW(szPort);
}
}
-
if (lpUrlComponents->lpszUrlPath)
{
dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
lpszUrl += dwLen;
}
+ if (lpUrlComponents->lpszExtraInfo)
+ {
+ dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, ExtraInfo);
+ memcpy(lpszUrl, lpUrlComponents->lpszExtraInfo, dwLen * sizeof(WCHAR));
+ lpszUrl += dwLen;
+ }
+
*lpszUrl = '\0';
return TRUE;
return ERROR_SUCCESS;
}
+static DWORD zone_preference = 3;
+
+/***********************************************************************
+ * PrivacySetZonePreferenceW (WININET.@)
+ */
+DWORD WINAPI PrivacySetZonePreferenceW( DWORD zone, DWORD type, DWORD template, LPCWSTR preference )
+{
+ FIXME( "%x %x %x %s: stub\n", zone, type, template, debugstr_w(preference) );
+
+ zone_preference = template;
+ return 0;
+}
+
+/***********************************************************************
+ * PrivacyGetZonePreferenceW (WININET.@)
+ */
+DWORD WINAPI PrivacyGetZonePreferenceW( DWORD zone, DWORD type, LPDWORD template,
+ LPWSTR preference, LPDWORD length )
+{
+ FIXME( "%x %x %p %p %p: stub\n", zone, type, template, preference, length );
+
+ if (template) *template = zone_preference;
+ return 0;
+}
+
DWORD WINAPI InternetDialA( HWND hwndParent, LPSTR lpszConnectoid, DWORD dwFlags,
DWORD_PTR* lpdwConnection, DWORD dwReserved )
{