* FUNCTION NAME: inetTransfer() * PURPOSE: * http/ftp file transfer * SPECIAL CONSIDERATIONS: * *****************************************************/
| 834 | * |
| 835 | *****************************************************/ |
| 836 | DWORD __stdcall inetTransfer(void *hw) |
| 837 | { |
| 838 | HINTERNET hSes, hConn, hFile; |
| 839 | HANDLE localFile = NULL; |
| 840 | HWND hDlg = (HWND)hw; |
| 841 | DWORD lastCnt, rslt, err; |
| 842 | static TCHAR hdr[2048]; |
| 843 | TCHAR *host = (TCHAR*)LocalAlloc(LPTR, g_stringsize * sizeof(TCHAR)), |
| 844 | *path = (TCHAR*)LocalAlloc(LPTR, g_stringsize * sizeof(TCHAR)), |
| 845 | *params = (TCHAR*)LocalAlloc(LPTR, g_stringsize * sizeof(TCHAR)), |
| 846 | *user = (TCHAR*)LocalAlloc(LPTR, g_stringsize * sizeof(TCHAR)), |
| 847 | *passwd = (TCHAR*)LocalAlloc(LPTR, g_stringsize * sizeof(TCHAR)); |
| 848 | |
| 849 | URL_COMPONENTS uc = {sizeof(URL_COMPONENTS), NULL, 0, |
| 850 | (INTERNET_SCHEME)0, host, g_stringsize, 0 , user, g_stringsize, |
| 851 | passwd, g_stringsize, path, g_stringsize, params, g_stringsize}; |
| 852 | |
| 853 | if((hSes = InternetOpen(szUserAgent, openType, szProxy, NULL, 0)) != NULL) |
| 854 | { |
| 855 | if(InternetQueryOption(hSes, INTERNET_OPTION_CONNECTED_STATE, &(rslt=0), |
| 856 | &(lastCnt=sizeof(DWORD))) && |
| 857 | (rslt & INTERNET_STATE_DISCONNECTED_BY_USER)) |
| 858 | { |
| 859 | INTERNET_CONNECTED_INFO ci = {INTERNET_STATE_CONNECTED, 0}; |
| 860 | InternetSetOption(hSes, |
| 861 | INTERNET_OPTION_CONNECTED_STATE, &ci, sizeof(ci)); |
| 862 | } |
| 863 | if(timeout > 0) |
| 864 | lastCnt = InternetSetOption(hSes, INTERNET_OPTION_CONNECT_TIMEOUT, &timeout, sizeof(timeout)); |
| 865 | if(receivetimeout > 0) |
| 866 | InternetSetOption(hSes, INTERNET_OPTION_RECEIVE_TIMEOUT, &receivetimeout, sizeof(receivetimeout)); |
| 867 | // 60 sec WinInet.dll detach delay on socket time_wait fix |
| 868 | myFtpCommand = (FTP_CMD) GetWininetProcAddress( |
| 869 | #ifdef UNICODE |
| 870 | "FtpCommandW" |
| 871 | #else |
| 872 | "FtpCommandA" |
| 873 | #endif |
| 874 | ); |
| 875 | while(!popstring(url) && lstrcmpi(url, TEXT("/end")) != 0) |
| 876 | { |
| 877 | // too many customers requested not to do this |
| 878 | // sf(hDlg); |
| 879 | if(popstring(fn) != 0 || lstrcmpi(url, TEXT("/end")) == 0) break; |
| 880 | status = ST_CONNECTING; |
| 881 | cnt = fs = *host = *user = *passwd = *path = *params = 0; |
| 882 | PostMessage(hDlg, WM_TIMER, 1, 0); // show url & fn, do it sync |
| 883 | if(szToStack || (localFile = CreateFile(fn, fput ? GENERIC_READ : GENERIC_WRITE, FILE_SHARE_READ, |
| 884 | NULL, fput ? OPEN_EXISTING : CREATE_ALWAYS, 0, NULL)) != INVALID_HANDLE_VALUE) |
| 885 | { |
| 886 | uc.dwHostNameLength = uc.dwUserNameLength = uc.dwPasswordLength = |
| 887 | uc.dwUrlPathLength = uc.dwExtraInfoLength = g_stringsize; |
| 888 | if(fput) |
| 889 | { |
| 890 | fs = GetFileSize(localFile, NULL); |
| 891 | } |
| 892 | if(InternetCrackUrl(url, 0, 0/*ICU_ESCAPE*/ , &uc)) |
| 893 | { |
nothing calls this directly
no test coverage detected