* Only download jars if not already in the local machine */ if(LocateJar(siCObject, NULL, 0, gbPreviousUnfinishedDownload) == AP_NOT_FOUND)
* Only download jars if not already in the local machine. * Also if the last file being downloaded should be resumed. * The resume detection is done automatically. */ if((LocateJar(siCObject, NULL, 0, gbPreviousUnfinishedDownload) == AP_NOT_FOUND) || (lstrcmpi(szPartiallyDownloadedFilename, siCObject->szArchiveName) == 0))
long RetrieveArchives(){  DWORD     dwIndex0;  DWORD     dwFileCounter;  BOOL      bDone;  BOOL      bDownloadTriggered;  siC       *siCObject = NULL;  long      lResult;  char      szFileIdiGetArchives[MAX_BUF];  char      szSection[MAX_BUF];  char      szCorruptedArchiveList[MAX_BUF];  char      szFailedFile[MAX_BUF];  char      szBuf[MAX_BUF];  int       iCRCRetries;  int       iNetRetries;  int       iRv;  /* retrieve the redirect.ini file */  RetrieveRedirectFile();  ZeroMemory(szCorruptedArchiveList, sizeof(szCorruptedArchiveList));  lstrcpy(szFileIdiGetArchives, szTempDir);  AppendBackSlash(szFileIdiGetArchives, sizeof(szFileIdiGetArchives));  lstrcat(szFileIdiGetArchives, FILE_IDI_GETARCHIVES);  bDownloadTriggered = FALSE;  lResult            = WIZ_OK;  dwIndex0           = 0;  dwFileCounter      = 0;  siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);  while(siCObject)  {    if(siCObject->dwAttributes & SIC_SELECTED)    {      /* If a previous unfinished setup was detected, then       * include the TEMP dir when searching for archives.       * Only download jars if not already in the local machine */      if(LocateJar(siCObject, NULL, 0, gbPreviousUnfinishedDownload) == AP_NOT_FOUND)      {        wsprintf(szSection, "File%d", dwFileCounter);        if((lResult = AddArchiveToIdiFile(siCObject,                                          szSection,                                          szFileIdiGetArchives)) != 0)          return(lResult);        ++dwFileCounter;      }    }    ++dwIndex0;    siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);  }  SetDownloadState();  /* iCRCRetries is initially set to 0 because the first attemp at downloading   * the archives is not considered a "retry".  Subsequent downloads are   * considered retries. */  iCRCRetries = 0;  iNetRetries = 0;  bDone = FALSE;  do  {    /* the existence of the getarchives.idi file determines if there are       any archives needed to be downloaded */    if(FileExists(szFileIdiGetArchives))    {      bDownloadTriggered = TRUE;      lResult = DownloadFiles(szFileIdiGetArchives,               /* input idi file to parse                 */                              szTempDir,                          /* download directory                      */                              diAdvancedSettings.szProxyServer,   /* proxy server name                       */                              diAdvancedSettings.szProxyPort,     /* proxy server port                       */                              diAdvancedSettings.szProxyUser,     /* proxy server user (optional)            */                              diAdvancedSettings.szProxyPasswd,   /* proxy password (optional)               */                              iCRCRetries,                        /* show retry message                      */                              &iNetRetries,                       /* receive the number of network retries   */                              FALSE,                              /* ignore network error                    */                              szFailedFile,                       /* buffer to store the name of failed file */                              sizeof(szFailedFile));              /* size of failed file name buffer         */      if(lResult == WIZ_OK)      {        /* CRC check only the archives that were downloaded.         * It will regenerate the idi file with the list of files         * that have not passed the CRC check. */        iRv = CRCCheckDownloadedArchives(szCorruptedArchiveList,                                         sizeof(szCorruptedArchiveList),                                         szFileIdiGetArchives);        switch(iRv)        {          case WIZ_CRC_PASS:            bDone = TRUE;            break;          default:            bDone = FALSE;            break;        }      }      else      {        int iComponentIndex = SiCNodeGetIndexDS(szFailedFile);        siC *siCObject      = SiCNodeGetObject(iComponentIndex, TRUE, AC_ALL);        ++siCObject->iNetRetries;        /* Download failed.  Error message was already shown by DownloadFiles().         * Simple exit loop here  */        bDone = TRUE;      }    }    else      /* no idi file, so exit loop */      bDone = TRUE;    if(!bDone)    {      ++iCRCRetries;      if(iCRCRetries > MAX_CRC_FAILED_DOWNLOAD_RETRIES)        bDone = TRUE;    }  } while(!bDone);  if(iCRCRetries > MAX_CRC_FAILED_DOWNLOAD_RETRIES)  {    /* too many retries from failed CRC checks */    char szMsg[MAX_BUF];    LogISComponentsFailedCRC(szCorruptedArchiveList, W_DOWNLOAD);    GetPrivateProfileString("Strings", "Error Too Many CRC Failures", "", szMsg, sizeof(szMsg), szFileIniConfig);    if(*szMsg != '\0')      PrintError(szMsg, ERROR_CODE_HIDE);    lResult = WIZ_CRC_FAIL;  }  else  {    if(bDownloadTriggered)      LogISComponentsFailedCRC(NULL, W_DOWNLOAD);  }  if(lResult == WIZ_OK)  {    if(bDownloadTriggered)      LogISDownloadStatus("ok", NULL);    UnsetDownloadState();  }  else if(bDownloadTriggered)  {    wsprintf(szBuf, "failed: %d", lResult);    LogISDownloadStatus(szBuf, szFailedFile);  }  LogMSDownloadStatus(lResult);  return(lResult);}