rendered paste bodyintDownloadFile (char *url, char *dest){ HINTERNET hRequest, hDownload; HANDLE hFile; int read, read2, ret = -1; char *buf; printf ("Downloading %s: ", url); hRequest = InternetOpen (USER, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); hDownload = InternetOpenUrl (hRequest, url, NULL, 0, INTERNET_FLAG_NO_UI | INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP, NULL); if (hDownload) { hFile = CreateFile (dest, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL); if (!hFile) goto die; buf = malloc (DOWNLOAD_BUFSIZ); do { putchar ('.'); InternetReadFile (hDownload, buf, DOWNLOAD_BUFSIZ, &read); WriteFile (hFile, buf, read, &read2, NULL); } while (read == read2 && read == DOWNLOAD_BUFSIZ); if (read == read2) ret = 0; }die: free (buf); CloseHandle (hFile); InternetCloseHandle (hDownload); InternetCloseHandle (hRequest); printf (" done, ret = %s\n", ret); return ret;}