MCPcopy Create free account
hub / github.com/EasyIME/PIME / inetTransfer

Function inetTransfer

installer/inetc/Contrib/Inetc/inetc.cpp:841–1028  ·  view source on GitHub ↗

* FUNCTION NAME: inetTransfer() * PURPOSE: * http/ftp file transfer * SPECIAL CONSIDERATIONS: * *****************************************************/

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

GetWininetProcAddressFunction · 0.85
encode_base64Function · 0.85
openFtpFileFunction · 0.85
openHttpFileFunction · 0.85
fileTransferFunction · 0.85
queryStatusFunction · 0.85
popstringFunction · 0.70
pushstringFunction · 0.70

Tested by

no test coverage detected