ParsePath(gszUrl, szCurrentFile, sizeof(szCurrentFile), TRUE, PP_FILENAME_ONLY);
ProcessWindowsMessages();
int DownloadFiles(char *szInputIniFile,                  char *szDownloadDir,                  char *szProxyServer,                  char *szProxyPort,                  char *szProxyUser,                  char *szProxyPasswd,                  BOOL bShowRetryMsg,                  int *iNetRetries,                  BOOL bIgnoreAllNetworkErrors,                  char *szFailedFile,                  DWORD dwFailedFileSize){  char      szBuf[MAX_BUF];  char      szCurrentFile[MAX_BUF];  char      szSection[MAX_INI_SK];  char      szKey[MAX_INI_SK];  char      szSavedCwd[MAX_BUF_MEDIUM];  int       iCounter;  int       rv;  int       iFileDownloadRetries;  int       iIgnoreFileNetworkError;  DWORD     dwTotalEstDownloadSize;  if(szInputIniFile == NULL)    return(WIZ_ERROR_UNDEFINED);  if(szFailedFile)    ZeroMemory(szFailedFile, dwFailedFileSize);  GetCurrentDirectory(sizeof(szSavedCwd), szSavedCwd);  SetCurrentDirectory(szDownloadDir);  rv                        = WIZ_OK;  dwTotalEstDownloadSize    = 0;  giTotalArchivesToDownload = 0;  glLastBytesSoFar          = 0;  glAbsoluteBytesSoFar      = 0;  gbUrlChanged              = TRUE;  gbDlgDownloadMinimized    = FALSE;  gbDlgDownloadJustMinimized = FALSE;  gbCancelDownload          = FALSE;  gbShowDownloadRetryMsg    = bShowRetryMsg;  gszConfigIniFile          = szInputIniFile;  GetTotalArchivesToDownload(&giTotalArchivesToDownload,                             &dwTotalEstDownloadSize);  glTotalKb                 = dwTotalEstDownloadSize;  InitDownloadDlg();  for(giIndex = 0; giIndex < giTotalArchivesToDownload; giIndex++)  {    /* set (or reset) the counter to 0 in order to read the     * next files's 0'th url from the .idi file */    iCounter     = 0;    gbUrlChanged = TRUE; /* Update the download dialog with new URL */    wsprintf(szSection, "File%d", giIndex);    wsprintf(szKey,     "url%d",  iCounter);    GetPrivateProfileString(szSection,                            szKey,                            "",                            gszUrl,                            sizeof(gszUrl),                            gszConfigIniFile);    if(*gszUrl == '\0')      continue;    GetPrivateProfileString(szSection,                            "desc",                            "",                            gszCurrentDownloadFileDescription,                            sizeof(gszCurrentDownloadFileDescription),                            gszConfigIniFile);    iIgnoreFileNetworkError = GetPrivateProfileInt(szSection,                            "Ignore File Network Error",                            0,                            gszConfigIniFile);    if(gbDlgDownloadMinimized)      SetMinimizedDownloadTitle((int)GetPercentSoFar());    else    {      SetStatusUrl();      SetRestoredDownloadTitle();    }    iFileDownloadRetries = 0;    do    {      /* save the file name to be downloaded */      ParsePath(gszUrl,                szCurrentFile,                sizeof(szCurrentFile),                TRUE,                PP_FILENAME_ONLY);      /* Download starts here */      if((szProxyServer != NULL) && (szProxyPort != NULL) &&         (*szProxyServer != '\0') && (*szProxyPort != '\0'))        /* If proxy info is provided, use HTTP proxy */        rv = DownloadViaProxy(gszUrl,                              szProxyServer,                              szProxyPort,                              szProxyUser,                              szProxyPasswd);      else      {        /* is this an HTTP URL? */        if(strncmp(gszUrl, kHTTP, lstrlen(kHTTP)) == 0)          rv = DownloadViaHTTP(gszUrl);        /* or is this an FTP URL? */        else if(strncmp(gszUrl, kFTP, lstrlen(kFTP)) == 0)          rv = DownloadViaFTP(gszUrl);      }      if(rv == nsFTPConn::E_USER_CANCEL)      {        char szFile[MAX_BUF];        lstrcpy(szFile, szDownloadDir);        AppendBackSlash(szFile, sizeof(szFile));        lstrcat(szFile, szCurrentFile);        if(FileExists(szFile))          DeleteFile(szFile);        /* break out of the do loop */        break;      }      ++iFileDownloadRetries;      if(iFileDownloadRetries > MAX_FILE_DOWNLOAD_RETRIES)      {        /* since the download retries maxed out, increment the counter         * to read the next url for the current file */        ++iCounter;        wsprintf(szKey, "url%d",  iCounter);        GetPrivateProfileString(szSection,                                szKey,                                "",                                gszUrl,                                sizeof(gszUrl),                                gszConfigIniFile);        if(*gszUrl != '\0')        {          /* Found more urls to download from for the current file.           * Update the dialog to show the new url and reset the           * file download retries to 0 since it's a new url. */          gbUrlChanged = TRUE;          iFileDownloadRetries = 0;        }      }    } while((rv != nsFTPConn::E_USER_CANCEL) &&            (rv != nsFTPConn::OK) &&            (iFileDownloadRetries <= MAX_FILE_DOWNLOAD_RETRIES));    if((iFileDownloadRetries > MAX_FILE_DOWNLOAD_RETRIES) && iNetRetries)      /* Keep track of how many retries for only the file that had       * too many retries.       * We don't care about retries unless it's reached the limit       * because each retry should not count as a new download. */      *iNetRetries = iFileDownloadRetries - 1;    if(rv == nsFTPConn::E_USER_CANCEL)    {      if(szFailedFile && ((DWORD)lstrlen(szCurrentFile) <= dwFailedFileSize))        lstrcpy(szFailedFile, gszCurrentDownloadFileDescription);      /* break out of for() loop */      break;    }    if((rv != nsFTPConn::OK) &&       (iFileDownloadRetries > MAX_FILE_DOWNLOAD_RETRIES) &&       !bIgnoreAllNetworkErrors &&       !iIgnoreFileNetworkError)    {      /* too many retries from failed downloads */      char szMsg[MAX_BUF];      if(szFailedFile && ((DWORD)lstrlen(szCurrentFile) <= dwFailedFileSize))        lstrcpy(szFailedFile, gszCurrentDownloadFileDescription);      GetPrivateProfileString("Strings",                              "Error Too Many Network Errors",                              "",                              szMsg,                              sizeof(szMsg),                              szFileIniConfig);      if(*szMsg != '\0')      {        wsprintf(szBuf, szMsg, szCurrentFile);        PrintError(szBuf, ERROR_CODE_HIDE);      }      /* Set return value and break out of for() loop.       * We don't want to continue if there were too       * many network errors on any file. */      rv = WIZ_TOO_MANY_NETWORK_ERRORS;      break;    }    else if(bIgnoreAllNetworkErrors || iIgnoreFileNetworkError)      rv = nsFTPConn::OK;  }  DeInitDownloadDlg();  SetCurrentDirectory(szSavedCwd);  return(rv);}