From 6a4a6d7b1c3773257787111d0924f5a3cc55fd11 Mon Sep 17 00:00:00 2001 From: The Wine Synchronizer Date: Mon, 14 Jan 2008 16:50:34 +0000 Subject: [PATCH] Autosyncing with Wine HEAD svn path=/trunk/; revision=31797 --- reactos/dll/win32/wininet/ftp.c | 58 +++++++++++++++------- reactos/dll/win32/wininet/http.c | 30 +++-------- reactos/dll/win32/wininet/internet.c | 20 +++++++- reactos/dll/win32/wininet/urlcache.c | 5 +- reactos/dll/win32/wininet/wininet.rbuild | 2 + reactos/dll/win32/wininet/wininet_ros.diff | 8 +-- 6 files changed, 74 insertions(+), 49 deletions(-) diff --git a/reactos/dll/win32/wininet/ftp.c b/reactos/dll/win32/wininet/ftp.c index ad42abc49c5..bec4596c550 100644 --- a/reactos/dll/win32/wininet/ftp.c +++ b/reactos/dll/win32/wininet/ftp.c @@ -845,13 +845,12 @@ BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDire } } ret = FtpGetCurrentDirectoryW(hFtpSession, lpszCurrentDirectory?dir:NULL, lpdwCurrentDirectory?&len:NULL); - if(lpdwCurrentDirectory) { - *lpdwCurrentDirectory = len; - if(lpszCurrentDirectory) { - WideCharToMultiByte(CP_ACP, 0, dir, len, lpszCurrentDirectory, *lpdwCurrentDirectory, NULL, NULL); - HeapFree(GetProcessHeap(), 0, dir); - } - } + + if (ret && lpszCurrentDirectory) + WideCharToMultiByte(CP_ACP, 0, dir, -1, lpszCurrentDirectory, len, NULL, NULL); + + if (lpdwCurrentDirectory) *lpdwCurrentDirectory = len; + HeapFree(GetProcessHeap(), 0, dir); return ret; } @@ -886,12 +885,30 @@ BOOL WINAPI FtpGetCurrentDirectoryW(HINTERNET hFtpSession, LPWSTR lpszCurrentDir TRACE("len(%d)\n", *lpdwCurrentDirectory); lpwfs = (LPWININETFTPSESSIONW) WININET_GetObject( hFtpSession ); - if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype) + if (NULL == lpwfs) + { + INTERNET_SetLastError(ERROR_INVALID_HANDLE); + goto lend; + } + + if (WH_HFTPSESSION != lpwfs->hdr.htype) { INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); goto lend; } + if (!lpdwCurrentDirectory) + { + INTERNET_SetLastError(ERROR_INVALID_PARAMETER); + goto lend; + } + + if (lpszCurrentDirectory == NULL) + { + INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); + goto lend; + } + if (lpwfs->download_in_progress != NULL) { INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS); @@ -948,8 +965,6 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC /* Clear any error information */ INTERNET_SetLastError(0); - ZeroMemory(lpszCurrentDirectory, *lpdwCurrentDirectory); - hIC = lpwfs->lpAppInfo; if (!FTP_SendCommand(lpwfs->sndSocket, FTP_CMD_PWD, NULL, lpwfs->hdr.lpfnStatusCB, &lpwfs->hdr, lpwfs->hdr.dwContext)) @@ -961,7 +976,7 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC if (nResCode == 257) /* Extract directory name */ { DWORD firstpos, lastpos, len; - LPWSTR lpszResponseBuffer = WININET_strdup_AtoW(INTERNET_GetResponseBuffer()); + LPWSTR lpszResponseBuffer = WININET_strdup_AtoW(INTERNET_GetResponseBuffer()); for (firstpos = 0, lastpos = 0; lpszResponseBuffer[lastpos]; lastpos++) { @@ -971,14 +986,19 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszC firstpos = lastpos; else break; - } + } } + len = lastpos - firstpos; + if (*lpdwCurrentDirectory >= len) + { + memcpy(lpszCurrentDirectory, &lpszResponseBuffer[firstpos + 1], len * sizeof(WCHAR)); + lpszCurrentDirectory[len - 1] = 0; + *lpdwCurrentDirectory = len; + bSuccess = TRUE; + } + else INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); - len = lastpos - firstpos - 1; - lstrcpynW(lpszCurrentDirectory, &lpszResponseBuffer[firstpos+1], *lpdwCurrentDirectory); HeapFree(GetProcessHeap(), 0, lpszResponseBuffer); - *lpdwCurrentDirectory = len; - bSuccess = TRUE; } else FTP_SetResponseError(nResCode); @@ -2335,7 +2355,7 @@ INT FTP_ReceiveResponse(LPWININETFTPSESSIONW lpwfs, DWORD_PTR dwContext) if(lpszResponse[3] != '-') break; else - { /* Start of multiline repsonse. Loop until we get "nnn " */ + { /* Start of multiline response. Loop until we get "nnn " */ multiline = TRUE; memcpy(firstprefix, lpszResponse, 3); firstprefix[3] = ' '; @@ -3411,7 +3431,7 @@ static BOOL FTP_ParseDirectory(LPWININETFTPSESSIONW lpwfs, INT nSocket, LPCWSTR TRACE("\n"); - /* Allocate intial file properties array */ + /* Allocate initial file properties array */ *lpafp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FILEPROPERTIESW)*(sizeFilePropArray)); if (!*lpafp) return FALSE; @@ -3443,7 +3463,7 @@ static BOOL FTP_ParseDirectory(LPWININETFTPSESSIONW lpwfs, INT nSocket, LPCWSTR tmpafp = HeapReAlloc(GetProcessHeap(), 0, *lpafp, sizeof(FILEPROPERTIESW)*indexFilePropArray); - if (NULL == tmpafp) + if (NULL != tmpafp) *lpafp = tmpafp; } *dwfp = indexFilePropArray; diff --git a/reactos/dll/win32/wininet/http.c b/reactos/dll/win32/wininet/http.c index 7002e95254f..5e73714fe1c 100644 --- a/reactos/dll/win32/wininet/http.c +++ b/reactos/dll/win32/wininet/http.c @@ -264,7 +264,7 @@ static LPWSTR HTTP_BuildHeaderRequestString( LPWININETHTTPREQW lpwhr, LPCWSTR ve LPWSTR requestString; DWORD len, n; LPCWSTR *req; - INT i; + UINT i; LPWSTR p; static const WCHAR szSpace[] = { ' ',0 }; @@ -283,7 +283,7 @@ static LPWSTR HTTP_BuildHeaderRequestString( LPWININETHTTPREQW lpwhr, LPCWSTR ve req[n++] = path; req[n++] = http1_1 ? g_szHttp1_1 : g_szHttp1_0; - /* Append custom request heades */ + /* Append custom request headers */ for (i = 0; i < lpwhr->nCustHeaders; i++) { if (lpwhr->pCustHeaders[i].wFlags & HDR_ISREQUEST) @@ -725,7 +725,7 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest, } /* read any content returned by the server so that the connection can be - * resued */ + * reused */ static void HTTP_DrainContent(LPWININETHTTPREQW lpwhr) { DWORD bytes_read; @@ -1415,7 +1415,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, } if (NULL != lpszReferrer && strlenW(lpszReferrer)) - HTTP_ProcessHeader(lpwhr, HTTP_REFERER, lpszReferrer, HTTP_ADDHDR_FLAG_COALESCE); + HTTP_ProcessHeader(lpwhr, HTTP_REFERER, lpszReferrer, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ); if (lpszAcceptTypes) { @@ -1438,22 +1438,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs, else if (strlenW(lpszVerb)) lpwhr->lpszVerb = WININET_strdupW(lpszVerb); - if (NULL != lpszReferrer && strlenW(lpszReferrer)) - { - WCHAR buf[MAXHOSTNAME]; - URL_COMPONENTSW UrlComponents; - - memset( &UrlComponents, 0, sizeof UrlComponents ); - UrlComponents.dwStructSize = sizeof UrlComponents; - UrlComponents.lpszHostName = buf; - UrlComponents.dwHostNameLength = MAXHOSTNAME; - - InternetCrackUrlW(lpszReferrer, 0, 0, &UrlComponents); - if (strlenW(UrlComponents.lpszHostName)) - HTTP_ProcessHeader(lpwhr, szHost, UrlComponents.lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); - } - else - HTTP_ProcessHeader(lpwhr, szHost, lpwhs->lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDREQ_FLAG_REPLACE | HTTP_ADDHDR_FLAG_REQ); + HTTP_ProcessHeader(lpwhr, szHost, lpwhs->lpszHostName, HTTP_ADDREQ_FLAG_ADD | HTTP_ADDHDR_FLAG_REQ); if (lpwhs->nServerPort == INTERNET_INVALID_PORT_NUMBER) lpwhs->nServerPort = (dwFlags & INTERNET_FLAG_SECURE ? @@ -1785,7 +1770,7 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev if (index >= 0) lphttpHdr = &lpwhr->pCustHeaders[index]; - /* Ensure header satisifies requested attributes */ + /* Ensure header satisfies requested attributes */ if (!lphttpHdr || ((dwInfoLevel & HTTP_QUERY_FLAG_REQUEST_HEADERS) && (~lphttpHdr->wFlags & HDR_ISREQUEST))) @@ -1797,7 +1782,7 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev if (lpdwIndex) (*lpdwIndex)++; - /* coalesce value to reuqested type */ + /* coalesce value to requested type */ if (dwInfoLevel & HTTP_QUERY_FLAG_NUMBER) { *(int *)lpBuffer = atoiW(lphttpHdr->lpszValue); @@ -3032,6 +3017,7 @@ static INT HTTP_GetResponseHeaders(LPWININETHTTPREQW lpwhr) a bit different */ NETCON_recv(&lpwhr->netConnection, buffer, buflen, MSG_PEEK, &rc); #endif + /* * We should first receive 'HTTP/1.x nnn OK' where nnn is the status code. */ diff --git a/reactos/dll/win32/wininet/internet.c b/reactos/dll/win32/wininet/internet.c index 59139b7a836..b0357a2b55c 100644 --- a/reactos/dll/win32/wininet/internet.c +++ b/reactos/dll/win32/wininet/internet.c @@ -1070,7 +1070,8 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags, TRACE("(%s %u %x %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents); - if (!lpszUrl || !*lpszUrl) + if (!lpszUrl || !*lpszUrl || !lpUrlComponents || + lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSA)) { INTERNET_SetLastError(ERROR_INVALID_PARAMETER); return FALSE; @@ -1088,6 +1089,7 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags, MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength); memset(&UCW,0,sizeof(UCW)); + UCW.dwStructSize = sizeof(URL_COMPONENTSW); if(lpUrlComponents->dwHostNameLength!=0) UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength; if(lpUrlComponents->dwUserNameLength!=0) @@ -2329,6 +2331,20 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d } } break; + case INTERNET_OPTION_VERSION: + { + TRACE("INTERNET_OPTION_VERSION\n"); + if (*lpdwBufferLength < sizeof(INTERNET_VERSION_INFO)) + INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); + else + { + static const INTERNET_VERSION_INFO info = { 6, 0 }; + memcpy(lpBuffer, &info, sizeof(info)); + *lpdwBufferLength = sizeof(info); + bSuccess = TRUE; + } + break; + } default: FIXME("Stub! %d\n", dwOption); break; @@ -2793,7 +2809,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe if (lpszUrl == NULL) { /* - * According to the doc we are supost to use the ip for the next + * According to the doc we are supposed to use the ip for the next * server in the WnInet internal server database. I have * no idea what that is or how to get it. * diff --git a/reactos/dll/win32/wininet/urlcache.c b/reactos/dll/win32/wininet/urlcache.c index 852ac87faa4..7dfb20aec10 100644 --- a/reactos/dll/win32/wininet/urlcache.c +++ b/reactos/dll/win32/wininet/urlcache.c @@ -113,7 +113,7 @@ typedef struct _URL_CACHEFILE_ENTRY /* packing to dword align start of next field */ /* CHAR szSourceUrlName[]; (url) */ /* packing to dword align start of next field */ - /* CHAR szLocalFileName[]; (local file name exluding path) */ + /* CHAR szLocalFileName[]; (local file name excluding path) */ /* packing to dword align start of next field */ /* CHAR szHeaderInfo[]; (header info) */ } URL_CACHEFILE_ENTRY; @@ -171,7 +171,7 @@ typedef struct _URLCACHECONTAINER LPWSTR path; /* path to url container directory */ HANDLE hMapping; /* handle of file mapping */ DWORD file_size; /* size of file when mapping was opened */ - HANDLE hMutex; /* hande of mutex */ + HANDLE hMutex; /* handle of mutex */ } URLCACHECONTAINER; @@ -2796,6 +2796,7 @@ INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern, LPINTERNET_CACHE_ENTRY_INFOW lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize) { FIXME("(%s, %p, %p): stub\n", debugstr_w(lpszUrlSearchPattern), lpFirstCacheEntryInfo, lpdwFirstCacheEntryInfoBufferSize); + SetLastError(ERROR_FILE_NOT_FOUND); return 0; } diff --git a/reactos/dll/win32/wininet/wininet.rbuild b/reactos/dll/win32/wininet/wininet.rbuild index 4df6c0a3a2a..29700bafdee 100644 --- a/reactos/dll/win32/wininet/wininet.rbuild +++ b/reactos/dll/win32/wininet/wininet.rbuild @@ -1,5 +1,6 @@ + @@ -33,3 +34,4 @@ version.rc wininet.spec + diff --git a/reactos/dll/win32/wininet/wininet_ros.diff b/reactos/dll/win32/wininet/wininet_ros.diff index ea9d5f385b7..1a26b9f5a41 100644 --- a/reactos/dll/win32/wininet/wininet_ros.diff +++ b/reactos/dll/win32/wininet/wininet_ros.diff @@ -23,7 +23,7 @@ Index: http.c WINE_DEFAULT_DEBUG_CHANNEL(wininet); static const WCHAR g_szHttp1_0[] = {' ','H','T','T','P','/','1','.','0',0 }; -@@ -3027,14 +3028,21 @@ +@@ -3010,7 +3011,11 @@ /* * HACK peek at the buffer */ @@ -32,10 +32,10 @@ Index: http.c + a bit different */ NETCON_recv(&lpwhr->netConnection, buffer, buflen, MSG_PEEK, &rc); +#endif + /* * We should first receive 'HTTP/1.x nnn OK' where nnn is the status code. - */ - buflen = MAX_REPLY_LEN; +@@ -3019,6 +3024,9 @@ memset(buffer, 0, MAX_REPLY_LEN); if (!NETCON_getNextLine(&lpwhr->netConnection, bufferA, &buflen)) goto lend; @@ -305,7 +305,7 @@ Index: wininet.rbuild =================================================================== --- wininet.rbuild (revision 30893) +++ wininet.rbuild (working copy) -@@ -18,6 +18,7 @@ +@@ -19,6 +19,7 @@ ntdll secur32 crypt32