Back to index

lightning-sunbird  0.9+nobinonly
ifuncns.c
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Sean Su <ssu@netscape.com>
00025  *   Curt Patrick <curt@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "extern.h"
00042 #include "extra.h"
00043 #include "dialogs.h"
00044 #include "shortcut.h"
00045 #include "ifuncns.h"
00046 #include "wizverreg.h"
00047 #include "logging.h"
00048 #include <logkeys.h>
00049 
00050 HRESULT TimingCheck(DWORD dwTiming, LPSTR szSection, LPSTR szFile)
00051 {
00052   char szBuf[MAX_BUF_TINY];
00053 
00054   GetPrivateProfileString(szSection, "Timing", "", szBuf, sizeof(szBuf), szFile);
00055   if(*szBuf != '\0')
00056   {
00057     switch(dwTiming)
00058     {
00059       case T_PRE_DOWNLOAD:
00060         if(stricmp(szBuf, "pre download") == 0)
00061           return(TRUE);
00062         break;
00063 
00064       case T_POST_DOWNLOAD:
00065         if(stricmp(szBuf, "post download") == 0)
00066           return(TRUE);
00067         break;
00068 
00069       case T_PRE_XPCOM:
00070         if(stricmp(szBuf, "pre xpcom") == 0)
00071           return(TRUE);
00072         break;
00073 
00074       case T_POST_XPCOM:
00075         if(stricmp(szBuf, "post xpcom") == 0)
00076           return(TRUE);
00077         break;
00078 
00079       case T_PRE_SMARTUPDATE:
00080         if(stricmp(szBuf, "pre smartupdate") == 0)
00081           return(TRUE);
00082         break;
00083 
00084       case T_POST_SMARTUPDATE:
00085         if(stricmp(szBuf, "post smartupdate") == 0)
00086           return(TRUE);
00087         break;
00088 
00089       case T_PRE_LAUNCHAPP:
00090         if(stricmp(szBuf, "pre launchapp") == 0)
00091           return(TRUE);
00092         break;
00093 
00094       case T_POST_LAUNCHAPP:
00095         if(stricmp(szBuf, "post launchapp") == 0)
00096           return(TRUE);
00097         break;
00098 
00099       case T_PRE_ARCHIVE:
00100         if(stricmp(szBuf, "pre archive") == 0)
00101           return(TRUE);
00102         break;
00103 
00104       case T_POST_ARCHIVE:
00105         if(stricmp(szBuf, "post archive") == 0)
00106           return(TRUE);
00107         break;
00108 
00109       case T_DEPEND_REBOOT:
00110         if(stricmp(szBuf, "depend reboot") == 0)
00111           return(TRUE);
00112         break;
00113     }
00114   }
00115   return(FALSE);
00116 }
00117 
00118 char *BuildNumberedString(DWORD dwIndex, char *szInputStringPrefix, char *szInputString, char *szOutBuf, DWORD dwOutBufSize)
00119 {
00120   if((szInputStringPrefix) && (*szInputStringPrefix != '\0'))
00121     sprintf(szOutBuf, "%s-%s%d", szInputStringPrefix, szInputString, dwIndex);
00122   else
00123     sprintf(szOutBuf, "%s%d", szInputString, dwIndex);
00124 
00125   return(szOutBuf);
00126 }
00127 
00128 void GetUserAgentShort(char *szUserAgent, char *szOutUAShort, DWORD dwOutUAShortSize)
00129 {
00130   char *ptrFirstSpace = NULL;
00131 
00132   memset(szOutUAShort, 0, dwOutUAShortSize);
00133   if((szUserAgent == NULL) || (*szUserAgent == '\0'))
00134     return;
00135 
00136   ptrFirstSpace = strstr(szUserAgent, " ");
00137   if(ptrFirstSpace != NULL)
00138   {
00139     *ptrFirstSpace = '\0';
00140     strcpy(szOutUAShort, szUserAgent);
00141     *ptrFirstSpace = ' ';
00142   }
00143 }
00144 
00145 void CleanupPreviousVersionINIKeys(void)
00146 {
00147   char  szIndex[MAX_BUF];
00148   char  szSection[MAX_BUF];
00149   char  szValue[MAX_BUF];
00150   char  szPath[MAX_BUF];
00151   char  szBuf[MAX_BUF];
00152   char  szDecrypt[MAX_BUF];
00153   char  szMainSectionName[] = "Cleanup Previous Product INIApps";
00154   char  szApp[MAX_BUF];
00155   char  szKey[MAX_BUF];
00156   char  szDirKey[MAX_BUF];
00157   char  szCleanupProduct[MAX_BUF];
00158   char  szCurrentVersion[MAX_BUF_TINY];
00159   char  szUserAgent[MAX_BUF];
00160   char  szIni[MAX_BUF];
00161   BOOL  bFound;
00162   ULONG ulAppsLength, ulIndex;
00163   CHAR* szApps;
00164   HINI  hini = HINI_USERPROFILE;
00165 
00166   strcpy(szPath, sgProduct.szPath);
00167   if(*sgProduct.szSubPath != '\0')
00168   {
00169     AppendBackSlash(szPath, sizeof(szPath));
00170     strcat(szPath, sgProduct.szSubPath);
00171   }
00172   AppendBackSlash(szPath, sizeof(szPath));
00173 
00174   bFound  = FALSE;
00175   ulIndex = -1;
00176   while(!bFound)
00177   {
00178     ++ulIndex;
00179     itoa(ulIndex, szIndex, 10);
00180     strcpy(szSection, szMainSectionName);
00181     strcat(szSection, szIndex);
00182 
00183     GetPrivateProfileString(szSection, "Product Name", "", szValue, sizeof(szValue), szFileIniConfig);
00184     if(*szValue != '\0') {
00185       GetPrivateProfileString(szSection, "Product Name", "", szCleanupProduct, sizeof(szCleanupProduct), szFileIniConfig);
00186       GetPrivateProfileString(szSection, "Current Version", "", szCurrentVersion, sizeof(szCurrentVersion), szFileIniConfig);
00187 
00188       GetPrivateProfileString(szSection, "Key",                "", szBuf,           sizeof(szBuf),           szFileIniConfig);
00189       GetPrivateProfileString(szSection, "Decrypt Key",        "", szDecrypt,       sizeof(szDecrypt),       szFileIniConfig);
00190       memset(szKey, 0, sizeof(szKey));
00191       if(stricmp(szDecrypt, "TRUE") == 0)
00192         DecryptString(szDirKey, szBuf);
00193       else
00194         strcpy(szDirKey, szBuf);
00195 
00196       sprintf(szUserAgent, "%s %s", szCleanupProduct, szCurrentVersion);
00197 
00198       PrfQueryProfileSize(HINI_USERPROFILE, NULL, NULL, &ulAppsLength);
00199       szApps = (char*)malloc(ulAppsLength+1);
00200       PrfQueryProfileString(HINI_USERPROFILE, NULL, NULL, NULL, szApps, ulAppsLength);
00201       szApps[ulAppsLength] = '\0';
00202       while (*szApps) {
00203         if (strncmp(szApps, szCleanupProduct, strlen(szCleanupProduct)) == 0) {
00204           if (strncmp(szApps, szUserAgent, strlen(szUserAgent)) != 0) {
00205             char szKey[MAX_BUF];
00206             PrfQueryProfileString(HINI_USERPROFILE, szApps, szDirKey, "", szKey, MAX_BUF);
00207             if (szKey[0]) {
00208               AppendBackSlash(szKey, sizeof(szKey));
00209               if (stricmp(szKey, szPath) == 0) {
00210                 PrfWriteProfileString(HINI_USER, szApps, NULL, NULL);
00211               }
00212             }
00213           }
00214         }
00215         szApps = strchr(szApps, '\0')+1;
00216       }
00217     } else {
00218       GetPrivateProfileString(szSection, "App", "", szValue, sizeof(szValue), szFileIniConfig);
00219       if(*szValue != '\0') {
00220         GetPrivateProfileString(szSection, "App",                 "", szBuf,           sizeof(szBuf),          szFileIniConfig);
00221         GetPrivateProfileString(szSection, "Decrypt App",         "", szDecrypt,       sizeof(szDecrypt),      szFileIniConfig);
00222         memset(szApp, 0, sizeof(szApp));
00223         if(stricmp(szDecrypt, "TRUE") == 0)
00224           DecryptString(szApp, szBuf);
00225         else
00226           strcpy(szApp, szBuf);
00227   
00228         GetPrivateProfileString(szSection, "Key",                "", szBuf,           sizeof(szBuf),           szFileIniConfig);
00229         GetPrivateProfileString(szSection, "Decrypt Key",        "", szDecrypt,       sizeof(szDecrypt),       szFileIniConfig);
00230         memset(szDirKey, 0, sizeof(szKey));
00231         if(stricmp(szDecrypt, "TRUE") == 0)
00232           DecryptString(szDirKey, szBuf);
00233         else
00234           strcpy(szDirKey, szBuf);
00235   
00236         GetPrivateProfileString(szSection, "INI", "", szIni,  sizeof(szIni),  szFileIniConfig);
00237         if (szIni[0]) {
00238           BOOL bDecryptINI;
00239           GetPrivateProfileString(szSection, "Decrypt INI", "", szBuf,   sizeof(szBuf),   szFileIniConfig);
00240           if(stricmp(szBuf, "FALSE")) {
00241             DecryptString(szBuf, szIni);
00242             strcpy(szIni, szBuf);
00243           }
00244           hini = PrfOpenProfile((HAB)0, szIni);
00245         }
00246   
00247         PrfQueryProfileString(hini, szApp, szDirKey, "", szKey, MAX_BUF);
00248         if (szKey[0]) {
00249           AppendBackSlash(szKey, sizeof(szKey));
00250           if (stricmp(szKey, szPath) == 0) {
00251             PrfWriteProfileString(hini, szApp, NULL, NULL);
00252           }
00253         }
00254         if (szIni[0]) {
00255           PrfCloseProfile(hini);
00256         }
00257       }
00258       else
00259       {
00260         break;
00261       }
00262     }
00263   }
00264 }
00265 
00266 void ProcessFileOps(DWORD dwTiming, char *szSectionPrefix)
00267 {
00268   ProcessUncompressFile(dwTiming, szSectionPrefix);
00269   ProcessCreateDirectory(dwTiming, szSectionPrefix);
00270   ProcessMoveFile(dwTiming, szSectionPrefix);
00271   ProcessCopyFile(dwTiming, szSectionPrefix);
00272   ProcessCopyFileSequential(dwTiming, szSectionPrefix);
00273   ProcessDeleteFile(dwTiming, szSectionPrefix);
00274   ProcessRemoveDirectory(dwTiming, szSectionPrefix);
00275   if(!gbIgnoreRunAppX)
00276     ProcessRunApp(dwTiming, szSectionPrefix);
00277   ProcessOS2INI(dwTiming, szSectionPrefix);
00278   ProcessProgramFolder(dwTiming, szSectionPrefix);
00279   ProcessSetVersionRegistry(dwTiming, szSectionPrefix);
00280 }
00281 
00282 void ProcessFileOpsForSelectedComponents(DWORD dwTiming)
00283 {
00284   DWORD dwIndex0;
00285   siC   *siCObject = NULL;
00286 
00287   dwIndex0  = 0;
00288   siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);
00289   while(siCObject)
00290   {
00291     if(siCObject->dwAttributes & SIC_SELECTED)
00292       /* Since the archive is selected, we need to process the file ops here */
00293       ProcessFileOps(dwTiming, siCObject->szReferenceName);
00294 
00295     ++dwIndex0;
00296     siCObject = SiCNodeGetObject(dwIndex0, TRUE, AC_ALL);
00297   } /* while(siCObject) */
00298 }
00299 
00300 void ProcessFileOpsForAll(DWORD dwTiming)
00301 {
00302   ProcessFileOps(dwTiming, NULL);
00303   ProcessFileOpsForSelectedComponents(dwTiming);
00304   ProcessCreateCustomFiles(dwTiming);
00305 }
00306 
00307 int VerifyArchive(LPSTR szArchive)
00308 {
00309   void *vZip;
00310   int  iTestRv;
00311 
00312   /* Check for the existance of the from (source) file */
00313   if(!FileExists(szArchive))
00314     return(FO_ERROR_FILE_NOT_FOUND);
00315 
00316   if((iTestRv = ZIP_OpenArchive(szArchive, &vZip)) == ZIP_OK)
00317   {
00318     /* 1st parameter should be NULL or it will fail */
00319     /* It indicates extract the entire archive */
00320     iTestRv = ZIP_TestArchive(vZip);
00321     ZIP_CloseArchive(&vZip);
00322   }
00323   return(iTestRv);
00324 }
00325 
00326 HRESULT ProcessSetVersionRegistry(DWORD dwTiming, char *szSectionPrefix)
00327 {
00328   DWORD   dwIndex;
00329   BOOL    bIsDirectory;
00330   char    szBuf[MAX_BUF];
00331   char    szSection[MAX_BUF_TINY];
00332   char    szRegistryKey[MAX_BUF];
00333   char    szPath[MAX_BUF];
00334   char    szVersion[MAX_BUF_TINY];
00335 
00336   dwIndex = 0;
00337   BuildNumberedString(dwIndex, szSectionPrefix, "Version Registry", szSection, sizeof(szSection));
00338   GetPrivateProfileString(szSection, "Registry Key", "", szRegistryKey, sizeof(szRegistryKey), szFileIniConfig);
00339   while(*szRegistryKey != '\0')
00340   {
00341     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
00342     {
00343       GetPrivateProfileString(szSection, "Version", "", szVersion, sizeof(szVersion), szFileIniConfig);
00344       GetPrivateProfileString(szSection, "Path",    "", szBuf,     sizeof(szBuf),     szFileIniConfig);
00345       DecryptString(szPath, szBuf);
00346       if(FileExists(szPath) & FILE_DIRECTORY)
00347         bIsDirectory = TRUE;
00348       else
00349         bIsDirectory = FALSE;
00350 
00351       strcpy(szBuf, sgProduct.szPath);
00352       if(sgProduct.szSubPath != '\0')
00353       {
00354         AppendBackSlash(szBuf, sizeof(szBuf));
00355         strcat(szBuf, sgProduct.szSubPath);
00356       }
00357 
00358       VR_CreateRegistry(VR_DEFAULT_PRODUCT_NAME, szBuf, NULL);
00359       VR_Install(szRegistryKey, szPath, szVersion, bIsDirectory);
00360       VR_Close();
00361     }
00362 
00363     ++dwIndex;
00364     BuildNumberedString(dwIndex, szSectionPrefix, "Version Registry", szSection, sizeof(szSection));
00365     GetPrivateProfileString(szSection, "Registry Key", "", szRegistryKey, sizeof(szRegistryKey), szFileIniConfig);
00366   }
00367   return(FO_SUCCESS);
00368 }
00369 
00370 HRESULT FileUncompress(LPSTR szFrom, LPSTR szTo)
00371 {
00372   char  szBuf[MAX_BUF];
00373   ULONG ulBuf, ulDiskNum, ulDriveMap;
00374   DWORD dwReturn;
00375   void  *vZip;
00376   APIRET rc;
00377 
00378   dwReturn = FO_SUCCESS;
00379   /* Check for the existance of the from (source) file */
00380   if(!FileExists(szFrom))
00381     return(FO_ERROR_FILE_NOT_FOUND);
00382 
00383   /* Check for the existance of the to (destination) path */
00384   dwReturn = FileExists(szTo);
00385   if(dwReturn && !(dwReturn & FILE_DIRECTORY))
00386   {
00387     /* found a file with the same name as the destination path */
00388     return(FO_ERROR_DESTINATION_CONFLICT);
00389   }
00390   else if(!dwReturn)
00391   {
00392     strcpy(szBuf, szTo);
00393     AppendBackSlash(szBuf, sizeof(szBuf));
00394     CreateDirectoriesAll(szBuf, FALSE);
00395   }
00396 
00397   ulBuf = MAX_BUF-3;
00398   rc = DosQueryCurrentDir(0, &szBuf[3], &ulBuf);
00399   // Directory does not start with 'x:\', so add it.
00400   rc = DosQueryCurrentDisk(&ulDiskNum, &ulDriveMap);
00401 
00402   // Follow the case of the first letter in the path.
00403   if (isupper(szBuf[3]))
00404      szBuf[0] = (char)('A' - 1 + ulDiskNum);
00405   else
00406      szBuf[0] = (char)('a' - 1 + ulDiskNum);
00407   szBuf[1] = ':';
00408   szBuf[2] = '\\';
00409 
00410   if (toupper(szBuf[0]) != toupper(szTo[0]))
00411      rc = DosSetDefaultDisk(toupper(szTo[0]) - 'A' + 1);
00412   if(DosSetCurrentDir(szTo) != NO_ERROR)
00413     return(FO_ERROR_CHANGE_DIR);
00414 
00415   if((dwReturn = ZIP_OpenArchive(szFrom, &vZip)) != ZIP_OK)
00416     return(dwReturn);
00417 
00418   /* 1st parameter should be NULL or it will fail */
00419   /* It indicates extract the entire archive */
00420   dwReturn = ExtractDirEntries(NULL, vZip);
00421   ZIP_CloseArchive(&vZip);
00422 
00423   if (toupper(szBuf[0]) != toupper(szTo[0]))
00424      DosSetDefaultDisk(toupper(szBuf[0]) -1 + 'A');
00425   if(DosSetCurrentDir(szBuf) != NO_ERROR)
00426     return(FO_ERROR_CHANGE_DIR);
00427 
00428   return(dwReturn);
00429 }
00430 
00431 HRESULT ProcessXpcomFile()
00432 {
00433   char szSource[MAX_BUF];
00434   char szDestination[MAX_BUF];
00435   DWORD dwErr;
00436 
00437   if(*siCFXpcomFile.szMessage != '\0')
00438     ShowMessage(siCFXpcomFile.szMessage, TRUE);
00439 
00440   if((dwErr = FileUncompress(siCFXpcomFile.szSource, siCFXpcomFile.szDestination)) != FO_SUCCESS)
00441   {
00442     char szMsg[MAX_BUF];
00443     char szErrorString[MAX_BUF];
00444 
00445     if(*siCFXpcomFile.szMessage != '\0')
00446       ShowMessage(siCFXpcomFile.szMessage, FALSE);
00447 
00448     LogISProcessXpcomFile(LIS_FAILURE, dwErr);
00449     GetPrivateProfileString("Strings", "Error File Uncompress", "", szErrorString, sizeof(szErrorString), szFileIniConfig);
00450     sprintf(szMsg, szErrorString, siCFXpcomFile.szSource, dwErr);
00451     PrintError(szMsg, ERROR_CODE_HIDE);
00452     return(dwErr);
00453   }
00454   LogISProcessXpcomFile(LIS_SUCCESS, dwErr);
00455 
00456   /* copy msvcrt.dll and msvcirt.dll to the bin of the Xpcom temp dir:
00457    *   (c:\temp\Xpcom.ns\bin)
00458    * This is incase these files do not exist on the system */
00459   strcpy(szSource, siCFXpcomFile.szDestination);
00460   AppendBackSlash(szSource, sizeof(szSource));
00461   strcat(szSource, "ms*.dll");
00462 
00463   strcpy(szDestination, siCFXpcomFile.szDestination);
00464   AppendBackSlash(szDestination, sizeof(szDestination));
00465   strcat(szDestination, "bin");
00466 
00467   FileCopy(szSource, szDestination, TRUE, FALSE);
00468 
00469   if(*siCFXpcomFile.szMessage != '\0')
00470     ShowMessage(siCFXpcomFile.szMessage, FALSE);
00471 
00472   return(FO_SUCCESS);
00473 }
00474 
00475 HRESULT CleanupXpcomFile()
00476 {
00477   if(siCFXpcomFile.bCleanup == TRUE)
00478     DirectoryRemove(siCFXpcomFile.szDestination, TRUE);
00479 
00480   return(FO_SUCCESS);
00481 }
00482 
00483 HRESULT CleanupArgsRegistry()
00484 {
00485   char  szApp[MAX_BUF];
00486 
00487   sprintf(szApp, "%s %s", sgProduct.szProductNameInternal, sgProduct.szUserAgent);
00488   PrfWriteProfileString(HINI_USERPROFILE, szApp, "browserargs", NULL);
00489   return(FO_SUCCESS);
00490 }
00491 
00492 HRESULT ProcessUncompressFile(DWORD dwTiming, char *szSectionPrefix)
00493 {
00494   DWORD   dwIndex;
00495   BOOL    bOnlyIfExists;
00496   char    szBuf[MAX_BUF];
00497   char    szSection[MAX_BUF];
00498   char    szSource[MAX_BUF];
00499   char    szDestination[MAX_BUF];
00500 
00501   dwIndex = 0;
00502   BuildNumberedString(dwIndex, szSectionPrefix, "Uncompress File", szSection, sizeof(szSection));
00503   GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00504   while(*szBuf != '\0')
00505   {
00506     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
00507     {
00508       DecryptString(szSource, szBuf);
00509       GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
00510       DecryptString(szDestination, szBuf);
00511       GetPrivateProfileString(szSection, "Only If Exists", "", szBuf, sizeof(szBuf), szFileIniConfig);
00512       if(stricmp(szBuf, "TRUE") == 0)
00513         bOnlyIfExists = TRUE;
00514       else
00515         bOnlyIfExists = FALSE;
00516 
00517       if((!bOnlyIfExists) || (bOnlyIfExists && FileExists(szDestination)))
00518       {
00519         DWORD dwErr;
00520 
00521         GetPrivateProfileString(szSection, "Message",     "", szBuf, sizeof(szBuf), szFileIniConfig);
00522         ShowMessage(szBuf, TRUE);
00523         if((dwErr = FileUncompress(szSource, szDestination)) != FO_SUCCESS)
00524         {
00525           char szMsg[MAX_BUF];
00526           char szErrorString[MAX_BUF];
00527 
00528           ShowMessage(szBuf, FALSE);
00529           GetPrivateProfileString("Strings", "Error File Uncompress", "", szErrorString, sizeof(szErrorString), szFileIniConfig);
00530           sprintf(szMsg, szErrorString, szSource, dwErr);
00531           PrintError(szMsg, ERROR_CODE_HIDE);
00532           return(dwErr);
00533         }
00534 
00535         ShowMessage(szBuf, FALSE);
00536       }
00537     }
00538 
00539     ++dwIndex;
00540     BuildNumberedString(dwIndex, szSectionPrefix, "Uncompress File", szSection, sizeof(szSection));
00541     GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00542   }
00543   return(FO_SUCCESS);
00544 }
00545 
00546 HRESULT FileMove(LPSTR szFrom, LPSTR szTo)
00547 {
00548   HDIR            hFile;
00549   FILEFINDBUF3    fdFile;
00550   ULONG           ulFindCount;
00551   ULONG           ulAttrs;
00552   char            szFromDir[MAX_BUF];
00553   char            szFromTemp[MAX_BUF];
00554   char            szToTemp[MAX_BUF];
00555   char            szBuf[MAX_BUF];
00556   BOOL            bFound;
00557 
00558   /* From file path exists and To file path does not exist */
00559   if((FileExists(szFrom)) && (!FileExists(szTo)))
00560   {
00561     
00562     /* @MAK - need to handle OS/2 case where they are not the same drive*/
00563     DosMove(szFrom, szTo);
00564 
00565     /* log the file move command */
00566     sprintf(szBuf, "%s to %s", szFrom, szTo);
00567     UpdateInstallLog(KEY_MOVE_FILE, szBuf, FALSE);
00568 
00569     return(FO_SUCCESS);
00570   }
00571   /* From file path exists and To file path exists */
00572   if(FileExists(szFrom) && FileExists(szTo))
00573   {
00574     /* Since the To file path exists, assume it to be a directory and proceed.      */
00575     /* We don't care if it's a file.  If it is a file, then config.ini needs to be  */
00576     /* corrected to remove the file before attempting a MoveFile().                 */
00577     strcpy(szToTemp, szTo);
00578     AppendBackSlash(szToTemp, sizeof(szToTemp));
00579     ParsePath(szFrom, szBuf, sizeof(szBuf), FALSE, PP_FILENAME_ONLY);
00580     strcat(szToTemp, szBuf);
00581     DosMove(szFrom, szToTemp);
00582 
00583     /* log the file move command */
00584     sprintf(szBuf, "%s to %s", szFrom, szToTemp);
00585     UpdateInstallLog(KEY_MOVE_FILE, szBuf, FALSE);
00586 
00587     return(FO_SUCCESS);
00588   }
00589 
00590   ParsePath(szFrom, szFromDir, sizeof(szFromDir), FALSE, PP_PATH_ONLY);
00591 
00592   strcat(szFrom, "*.*");
00593   ulFindCount = 1;
00594   hFile = HDIR_CREATE;
00595   ulAttrs = FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED;
00596   if((DosFindFirst(szFrom, &hFile, ulAttrs, &fdFile, sizeof(fdFile), &ulFindCount, FIL_STANDARD)) != NO_ERROR)
00597     bFound = FALSE;
00598   else
00599     bFound = TRUE;
00600 
00601   while(bFound)
00602   {
00603     if((stricmp(fdFile.achName, ".") != 0) && (stricmp(fdFile.achName, "..") != 0))
00604     {
00605       /* create full path string including filename for source */
00606       strcpy(szFromTemp, szFromDir);
00607       AppendBackSlash(szFromTemp, sizeof(szFromTemp));
00608       strcat(szFromTemp, fdFile.achName);
00609 
00610       /* create full path string including filename for destination */
00611       strcpy(szToTemp, szTo);
00612       AppendBackSlash(szToTemp, sizeof(szToTemp));
00613       strcat(szToTemp, fdFile.achName);
00614 
00615       DosMove(szFromTemp, szToTemp);
00616 
00617       /* log the file move command */
00618       sprintf(szBuf, "%s to %s", szFromTemp, szToTemp);
00619       UpdateInstallLog(KEY_MOVE_FILE, szBuf, FALSE);
00620     }
00621 
00622     ulFindCount = 1;
00623     if (DosFindNext(hFile, &fdFile, sizeof(fdFile), &ulFindCount) == NO_ERROR) {
00624       bFound = TRUE;
00625     } else {
00626       bFound = FALSE;
00627     }
00628   }
00629 
00630   DosFindClose(hFile);
00631   return(FO_SUCCESS);
00632 }
00633 
00634 HRESULT ProcessMoveFile(DWORD dwTiming, char *szSectionPrefix)
00635 {
00636   DWORD dwIndex;
00637   char  szBuf[MAX_BUF];
00638   char  szSection[MAX_BUF];
00639   char  szSource[MAX_BUF];
00640   char  szDestination[MAX_BUF];
00641 
00642   dwIndex = 0;
00643   BuildNumberedString(dwIndex, szSectionPrefix, "Move File", szSection, sizeof(szSection));
00644   GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00645   while(*szBuf != '\0')
00646   {
00647     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
00648     {
00649       DecryptString(szSource, szBuf);
00650       GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
00651       DecryptString(szDestination, szBuf);
00652       FileMove(szSource, szDestination);
00653     }
00654 
00655     ++dwIndex;
00656     BuildNumberedString(dwIndex, szSectionPrefix, "Move File", szSection, sizeof(szSection));
00657     GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00658   }
00659   return(FO_SUCCESS);
00660 }
00661 
00662 HRESULT FileCopy(LPSTR szFrom, LPSTR szTo, BOOL bFailIfExists, BOOL bDnu)
00663 {
00664   HDIR            hFile;
00665   FILEFINDBUF3    fdFile;
00666   ULONG           ulFindCount;
00667   ULONG           ulAttrs;
00668   char            szFromDir[MAX_BUF];
00669   char            szFromTemp[MAX_BUF];
00670   char            szToTemp[MAX_BUF];
00671   char            szBuf[MAX_BUF];
00672   BOOL            bFound;
00673 
00674   if(FileExists(szFrom))
00675   {
00676     /* The file in the From file path exists */
00677     ParsePath(szFrom, szBuf, sizeof(szBuf), FALSE, PP_FILENAME_ONLY);
00678     strcpy(szToTemp, szTo);
00679     AppendBackSlash(szToTemp, sizeof(szToTemp));
00680     strcat(szToTemp, szBuf);
00681     if (bFailIfExists) {
00682       DosCopy(szFrom, szToTemp, 0);
00683     } else {
00684       DosCopy(szFrom, szToTemp, DCPY_EXISTING);
00685     }
00686     sprintf(szBuf, "%s to %s", szFrom, szToTemp);
00687     UpdateInstallLog(KEY_COPY_FILE, szBuf, bDnu);
00688 
00689     return(FO_SUCCESS);
00690   }
00691 
00692   /* The file in the From file path does not exist.  Assume to contain wild args and */
00693   /* proceed acordingly.                                                             */
00694   ParsePath(szFrom, szFromDir, sizeof(szFromDir), FALSE, PP_PATH_ONLY);
00695 
00696   ulFindCount = 1;
00697   hFile = HDIR_CREATE;
00698   ulAttrs = FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED;
00699   if((DosFindFirst(szFrom, &hFile, ulAttrs, &fdFile, sizeof(fdFile), &ulFindCount, FIL_STANDARD)) != NO_ERROR)
00700     bFound = FALSE;
00701   else
00702     bFound = TRUE;
00703 
00704   while(bFound)
00705   {
00706     if((stricmp(fdFile.achName, ".") != 0) && (stricmp(fdFile.achName, "..") != 0))
00707     {
00708       /* create full path string including filename for source */
00709       strcpy(szFromTemp, szFromDir);
00710       AppendBackSlash(szFromTemp, sizeof(szFromTemp));
00711       strcat(szFromTemp, fdFile.achName);
00712 
00713       /* create full path string including filename for destination */
00714       strcpy(szToTemp, szTo);
00715       AppendBackSlash(szToTemp, sizeof(szToTemp));
00716       strcat(szToTemp, fdFile.achName);
00717 
00718       if (bFailIfExists) {
00719         DosCopy(szFromTemp, szToTemp, 0);
00720       } else {
00721         DosCopy(szFromTemp, szToTemp, DCPY_EXISTING);
00722       }
00723 
00724       /* log the file copy command */
00725       sprintf(szBuf, "%s to %s", szFromTemp, szToTemp);
00726       UpdateInstallLog(KEY_COPY_FILE, szBuf, bDnu);
00727     }
00728 
00729     ulFindCount = 1;
00730     if (DosFindNext(hFile, &fdFile, sizeof(fdFile), &ulFindCount) == NO_ERROR) {
00731       bFound = TRUE;
00732     } else {
00733       bFound = FALSE;
00734     }
00735   }
00736 
00737   DosFindClose(hFile);
00738   return(FO_SUCCESS);
00739 }
00740 
00741 HRESULT FileCopySequential(LPSTR szSourcePath, LPSTR szDestPath, LPSTR szFilename)
00742 {
00743   int             iFilenameOnlyLen;
00744   char            szDestFullFilename[MAX_BUF];
00745   char            szSourceFullFilename[MAX_BUF];
00746   char            szSearchFilename[MAX_BUF];
00747   char            szSearchDestFullFilename[MAX_BUF];
00748   char            szFilenameOnly[MAX_BUF];
00749   char            szFilenameExtensionOnly[MAX_BUF];
00750   char            szNumber[MAX_BUF];
00751   long            dwNumber;
00752   long            dwMaxNumber;
00753   LPSTR           szDotPtr;
00754   HDIR            hFile;
00755   FILEFINDBUF3    fdFile;
00756   ULONG           ulFindCount;
00757   ULONG           ulAttrs;
00758   BOOL            bFound;
00759 
00760   strcpy(szSourceFullFilename, szSourcePath);
00761   AppendBackSlash(szSourceFullFilename, sizeof(szSourceFullFilename));
00762   strcat(szSourceFullFilename, szFilename);
00763 
00764   if(FileExists(szSourceFullFilename))
00765   {
00766     /* zero out the memory */
00767     memset(szSearchFilename, 0,        sizeof(szSearchFilename));
00768     memset(szFilenameOnly, 0,          sizeof(szFilenameOnly));
00769     memset(szFilenameExtensionOnly, 0, sizeof(szFilenameExtensionOnly));
00770 
00771     /* parse for the filename w/o extention and also only the extension */
00772     if((szDotPtr = strstr(szFilename, ".")) != NULL)
00773     {
00774       *szDotPtr = '\0';
00775       strcpy(szSearchFilename, szFilename);
00776       strcpy(szFilenameOnly, szFilename);
00777       strcpy(szFilenameExtensionOnly, &szDotPtr[1]);
00778       *szDotPtr = '.';
00779     }
00780     else
00781     {
00782       strcpy(szFilenameOnly, szFilename);
00783       strcpy(szSearchFilename, szFilename);
00784     }
00785 
00786     /* create the wild arg filename to search for in the szDestPath */
00787     strcat(szSearchFilename, "*.*");
00788     strcpy(szSearchDestFullFilename, szDestPath);
00789     AppendBackSlash(szSearchDestFullFilename, sizeof(szSearchDestFullFilename));
00790     strcat(szSearchDestFullFilename, szSearchFilename);
00791 
00792     iFilenameOnlyLen = strlen(szFilenameOnly);
00793     dwNumber         = 0;
00794     dwMaxNumber      = 0;
00795 
00796     /* find the largest numbered filename in the szDestPath */
00797     ulFindCount = 1;
00798     hFile = HDIR_CREATE;
00799     ulAttrs = FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED;
00800     if((DosFindFirst(szSearchDestFullFilename, &hFile, ulAttrs, &fdFile, sizeof(fdFile), &ulFindCount, FIL_STANDARD)) != NO_ERROR)
00801       bFound = FALSE;
00802     else
00803       bFound = TRUE;
00804 
00805     while(bFound)
00806     {
00807       memset(szNumber, 0, sizeof(szNumber));
00808       if((stricmp(fdFile.achName, ".") != 0) && (stricmp(fdFile.achName, "..") != 0))
00809       {
00810         strcpy(szNumber, &fdFile.achName[iFilenameOnlyLen]);
00811         dwNumber = atoi(szNumber);
00812         if(dwNumber > dwMaxNumber)
00813           dwMaxNumber = dwNumber;
00814       }
00815 
00816       ulFindCount = 1;
00817       if (DosFindNext(hFile, &fdFile, sizeof(fdFile), &ulFindCount) == NO_ERROR) {
00818         bFound = TRUE;
00819       } else {
00820         bFound = FALSE;
00821       }
00822     }
00823 
00824     DosFindClose(hFile);
00825 
00826     strcpy(szDestFullFilename, szDestPath);
00827     AppendBackSlash(szDestFullFilename, sizeof(szDestFullFilename));
00828     strcat(szDestFullFilename, szFilenameOnly);
00829     _itoa(dwMaxNumber + 1, szNumber, 10);
00830     strcat(szDestFullFilename, szNumber);
00831 
00832     if(*szFilenameExtensionOnly != '\0')
00833     {
00834       strcat(szDestFullFilename, ".");
00835       strcat(szDestFullFilename, szFilenameExtensionOnly);
00836     }
00837 
00838     DosCopy(szSourceFullFilename, szDestFullFilename, 0);
00839   }
00840 
00841   return(FO_SUCCESS);
00842 }
00843 
00844 HRESULT ProcessCopyFile(DWORD dwTiming, char *szSectionPrefix)
00845 {
00846   DWORD dwIndex;
00847   char  szBuf[MAX_BUF];
00848   char  szSection[MAX_BUF];
00849   char  szSource[MAX_BUF];
00850   char  szDestination[MAX_BUF];
00851   BOOL  bFailIfExists;
00852   BOOL  bDnu;
00853 
00854   dwIndex = 0;
00855   BuildNumberedString(dwIndex, szSectionPrefix, "Copy File", szSection, sizeof(szSection));
00856   GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00857   while(*szBuf != '\0')
00858   {
00859     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
00860     {
00861       DecryptString(szSource, szBuf);
00862       GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
00863       DecryptString(szDestination, szBuf);
00864 
00865       GetPrivateProfileString(szSection, "Do Not Uninstall", "", szBuf, sizeof(szBuf), szFileIniConfig);
00866       if(stricmp(szBuf, "TRUE") == 0)
00867         bDnu = TRUE;
00868       else
00869         bDnu = FALSE;
00870 
00871       GetPrivateProfileString(szSection, "Fail If Exists", "", szBuf, sizeof(szBuf), szFileIniConfig);
00872       if(stricmp(szBuf, "TRUE") == 0)
00873         bFailIfExists = TRUE;
00874       else
00875         bFailIfExists = FALSE;
00876 
00877       FileCopy(szSource, szDestination, bFailIfExists, bDnu);
00878     }
00879 
00880     ++dwIndex;
00881     BuildNumberedString(dwIndex, szSectionPrefix, "Copy File", szSection, sizeof(szSection));
00882     GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00883   }
00884   return(FO_SUCCESS);
00885 }
00886 
00887 HRESULT ProcessCopyFileSequential(DWORD dwTiming, char *szSectionPrefix)
00888 {
00889   DWORD dwIndex;
00890   char  szBuf[MAX_BUF];
00891   char  szSection[MAX_BUF];
00892   char  szSource[MAX_BUF];
00893   char  szDestination[MAX_BUF];
00894   char  szFilename[MAX_BUF];
00895 
00896   dwIndex = 0;
00897   BuildNumberedString(dwIndex, szSectionPrefix, "Copy File Sequential", szSection, sizeof(szSection));
00898   GetPrivateProfileString(szSection, "Filename", "", szFilename, sizeof(szFilename), szFileIniConfig);
00899   while(*szFilename != '\0')
00900   {
00901     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
00902     {
00903       GetPrivateProfileString(szSection, "Source", "", szBuf, sizeof(szBuf), szFileIniConfig);
00904       DecryptString(szSource, szBuf);
00905 
00906       GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
00907       DecryptString(szDestination, szBuf);
00908 
00909       FileCopySequential(szSource, szDestination, szFilename);
00910     }
00911 
00912     ++dwIndex;
00913     BuildNumberedString(dwIndex, szSectionPrefix, "Copy File Sequential", szSection, sizeof(szSection));
00914     GetPrivateProfileString(szSection, "Filename", "", szFilename, sizeof(szFilename), szFileIniConfig);
00915   }
00916   return(FO_SUCCESS);
00917 }
00918 
00919 void UpdateInstallLog(PSZ szKey, PSZ szString, BOOL bDnu)
00920 {
00921   FILE *fInstallLog;
00922   char szBuf[MAX_BUF];
00923   char szFileInstallLog[MAX_BUF];
00924 
00925   if(gbILUseTemp)
00926   {
00927     strcpy(szFileInstallLog, szTempDir);
00928     AppendBackSlash(szFileInstallLog, sizeof(szFileInstallLog));
00929   }
00930   else
00931   {
00932     strcpy(szFileInstallLog, sgProduct.szPath);
00933     AppendBackSlash(szFileInstallLog, sizeof(szFileInstallLog));
00934     strcat(szFileInstallLog, sgProduct.szSubPath);
00935     AppendBackSlash(szFileInstallLog, sizeof(szFileInstallLog));
00936   }
00937 
00938   CreateDirectoriesAll(szFileInstallLog, FALSE);
00939   strcat(szFileInstallLog, FILE_INSTALL_LOG);
00940 
00941   if((fInstallLog = fopen(szFileInstallLog, "a+")) != NULL)
00942   {
00943     if(bDnu)
00944       sprintf(szBuf, "     ** (*dnu*) %s%s\n", szKey, szString);
00945     else
00946       sprintf(szBuf, "     ** %s%s\n", szKey, szString);
00947 
00948     fwrite(szBuf, sizeof(char), strlen(szBuf), fInstallLog);
00949     fclose(fInstallLog);
00950   }
00951 }
00952 
00953 void UpdateInstallStatusLog(PSZ szString)
00954 {
00955   FILE *fInstallLog;
00956   char szFileInstallStatusLog[MAX_BUF];
00957 
00958   if(gbILUseTemp)
00959   {
00960     strcpy(szFileInstallStatusLog, szTempDir);
00961     AppendBackSlash(szFileInstallStatusLog, sizeof(szFileInstallStatusLog));
00962   }
00963   else
00964   {
00965     strcpy(szFileInstallStatusLog, sgProduct.szPath);
00966     AppendBackSlash(szFileInstallStatusLog, sizeof(szFileInstallStatusLog));
00967     strcat(szFileInstallStatusLog, sgProduct.szSubPath);
00968     AppendBackSlash(szFileInstallStatusLog, sizeof(szFileInstallStatusLog));
00969   }
00970 
00971   CreateDirectoriesAll(szFileInstallStatusLog, FALSE);
00972   strcat(szFileInstallStatusLog, FILE_INSTALL_STATUS_LOG);
00973 
00974   if((fInstallLog = fopen(szFileInstallStatusLog, "a+")) != NULL)
00975   {
00976     fwrite(szString, sizeof(char), strlen(szString), fInstallLog);
00977     fclose(fInstallLog);
00978   }
00979 }
00980 
00981 void UpdateJSProxyInfo()
00982 {
00983   FILE *fJSFile;
00984   char szBuf[MAX_BUF];
00985   char szJSFile[MAX_BUF];
00986 
00987   if((*diAdvancedSettings.szProxyServer != '\0') || (*diAdvancedSettings.szProxyPort != '\0'))
00988   {
00989     strcpy(szJSFile, sgProduct.szPath);
00990     if(*sgProduct.szSubPath != '\0')
00991     {
00992       AppendBackSlash(szJSFile, sizeof(szJSFile));
00993       strcat(szJSFile, sgProduct.szSubPath);
00994     }
00995     AppendBackSlash(szJSFile, sizeof(szJSFile));
00996     strcat(szJSFile, "defaults\\pref\\");
00997     CreateDirectoriesAll(szJSFile, TRUE);
00998     strcat(szJSFile, FILE_ALL_JS);
00999 
01000     if((fJSFile = fopen(szJSFile, "a+")) != NULL)
01001     {
01002       memset(szBuf, 0, sizeof(szBuf));
01003       if(*diAdvancedSettings.szProxyServer != '\0')
01004       {
01005         if(diAdditionalOptions.dwUseProtocol == UP_FTP)
01006           sprintf(szBuf,
01007                    "pref(\"network.proxy.ftp\", \"%s\");\n",
01008                    diAdvancedSettings.szProxyServer);
01009         else
01010           sprintf(szBuf,
01011                    "pref(\"network.proxy.http\", \"%s\");\n",
01012                    diAdvancedSettings.szProxyServer);
01013       }
01014 
01015       if(*diAdvancedSettings.szProxyPort != '\0')
01016       {
01017         if(diAdditionalOptions.dwUseProtocol == UP_FTP)
01018           sprintf(szBuf,
01019                    "pref(\"network.proxy.ftp_port\", %s);\n",
01020                    diAdvancedSettings.szProxyPort);
01021         else
01022           sprintf(szBuf,
01023                    "pref(\"network.proxy.http_port\", %s);\n",
01024                    diAdvancedSettings.szProxyPort);
01025       }
01026 
01027       strcat(szBuf, "pref(\"network.proxy.type\", 1);\n");
01028 
01029       fwrite(szBuf, sizeof(char), strlen(szBuf), fJSFile);
01030       fclose(fJSFile);
01031     }
01032   }
01033 }
01034 
01035 HRESULT CreateDirectoriesAll(char* szPath, BOOL bLogForUninstall)
01036 {
01037   int     i;
01038   int     iLen = strlen(szPath);
01039   char    szCreatePath[MAX_BUF];
01040   HRESULT hrResult = 0;
01041 
01042   memset(szCreatePath, 0, MAX_BUF);
01043   memcpy(szCreatePath, szPath, iLen);
01044   for(i = 0; i < iLen; i++)
01045   {
01046     if((iLen > 1) &&
01047       ((i != 0) && ((szPath[i] == '\\') || (szPath[i] == '/'))) &&
01048       (!((szPath[0] == '\\') && (i == 1)) && !((szPath[1] == ':') && (i == 2))))
01049     {
01050       szCreatePath[i] = '\0';
01051       if(FileExists(szCreatePath) == FALSE)
01052       {
01053         APIRET rc = DosCreateDir(szCreatePath, NULL);  
01054         if (rc == NO_ERROR) {
01055           hrResult = 1;
01056         }
01057 
01058         if(bLogForUninstall)
01059           UpdateInstallLog(KEY_CREATE_FOLDER, szCreatePath, FALSE);
01060       }
01061       szCreatePath[i] = szPath[i];
01062     }
01063   }
01064   return(hrResult);
01065 }
01066 
01067 HRESULT ProcessCreateDirectory(DWORD dwTiming, char *szSectionPrefix)
01068 {
01069   DWORD dwIndex;
01070   char  szBuf[MAX_BUF];
01071   char  szSection[MAX_BUF];
01072   char  szDestination[MAX_BUF];
01073 
01074   dwIndex = 0;
01075   BuildNumberedString(dwIndex, szSectionPrefix, "Create Directory", szSection, sizeof(szSection));
01076   GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
01077   while(*szBuf != '\0')
01078   {
01079     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
01080     {
01081       DecryptString(szDestination, szBuf);
01082       AppendBackSlash(szDestination, sizeof(szDestination));
01083       CreateDirectoriesAll(szDestination, TRUE);
01084     }
01085 
01086     ++dwIndex;
01087     BuildNumberedString(dwIndex, szSectionPrefix, "Create Directory", szSection, sizeof(szSection));
01088     GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
01089   }
01090   return(FO_SUCCESS);
01091 }
01092 
01093 HRESULT FileDelete(LPSTR szDestination)
01094 {
01095   HDIR            hFile;
01096   FILEFINDBUF3    fdFile;
01097   ULONG           ulFindCount;
01098   ULONG           ulAttrs;
01099   char            szBuf[MAX_BUF];
01100   char            szPathOnly[MAX_BUF];
01101   BOOL            bFound;
01102 
01103   if(FileExists(szDestination))
01104   {
01105     /* The file in the From file path exists */
01106     DosDelete(szDestination);
01107     return(FO_SUCCESS);
01108   }
01109 
01110   /* The file in the From file path does not exist.  Assume to contain wild args and */
01111   /* proceed acordingly.                                                             */
01112   ParsePath(szDestination, szPathOnly, sizeof(szPathOnly), FALSE, PP_PATH_ONLY);
01113 
01114   ulFindCount = 1;
01115   hFile = HDIR_CREATE;
01116   ulAttrs = FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED;
01117   if((DosFindFirst(szDestination, &hFile, ulAttrs, &fdFile, sizeof(fdFile), &ulFindCount, FIL_STANDARD)) != NO_ERROR)
01118     bFound = FALSE;
01119   else
01120     bFound = TRUE;
01121 
01122   while(bFound)
01123   {
01124     if(!(fdFile.attrFile & FILE_DIRECTORY))
01125     {
01126       strcpy(szBuf, szPathOnly);
01127       AppendBackSlash(szBuf, sizeof(szBuf));
01128       strcat(szBuf, fdFile.achName);
01129 
01130       DosDelete(szBuf);
01131     }
01132 
01133     ulFindCount = 1;
01134     if (DosFindNext(hFile, &fdFile, sizeof(fdFile), &ulFindCount) == NO_ERROR) {
01135       bFound = TRUE;
01136     } else {
01137       bFound = FALSE;
01138     }
01139   }
01140 
01141   DosFindClose(hFile);
01142   return(FO_SUCCESS);
01143 }
01144 
01145 HRESULT ProcessDeleteFile(DWORD dwTiming, char *szSectionPrefix)
01146 {
01147   DWORD dwIndex;
01148   char  szBuf[MAX_BUF];
01149   char  szSection[MAX_BUF];
01150   char  szDestination[MAX_BUF];
01151 
01152   dwIndex = 0;
01153   BuildNumberedString(dwIndex, szSectionPrefix, "Delete File", szSection, sizeof(szSection));
01154   GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
01155   while(*szBuf != '\0')
01156   {
01157     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
01158     {
01159       DecryptString(szDestination, szBuf);
01160       FileDelete(szDestination);
01161     }
01162 
01163     ++dwIndex;
01164     BuildNumberedString(dwIndex, szSectionPrefix, "Delete File", szSection, sizeof(szSection));
01165     GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
01166   }
01167   return(FO_SUCCESS);
01168 }
01169 
01170 HRESULT DirectoryRemove(LPSTR szDestination, BOOL bRemoveSubdirs)
01171 {
01172   HDIR            hFile;
01173   FILEFINDBUF3    fdFile;
01174   ULONG           ulFindCount;
01175   ULONG           ulAttrs;
01176   char            szDestTemp[MAX_BUF];
01177   BOOL            bFound;
01178 
01179   if(!FileExists(szDestination))
01180     return(FO_SUCCESS);
01181 
01182   if(bRemoveSubdirs == TRUE)
01183   {
01184     strcpy(szDestTemp, szDestination);
01185     AppendBackSlash(szDestTemp, sizeof(szDestTemp));
01186     strcat(szDestTemp, "*");
01187 
01188     ulFindCount = 1;
01189     hFile = HDIR_CREATE;
01190     ulAttrs = FILE_READONLY | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED;
01191     if((DosFindFirst(szDestTemp, &hFile, ulAttrs, &fdFile, sizeof(fdFile), &ulFindCount, FIL_STANDARD)) != NO_ERROR)
01192       bFound = FALSE;
01193     else
01194       bFound = TRUE;
01195     while(bFound == TRUE)
01196     {
01197       if((stricmp(fdFile.achName, ".") != 0) && (stricmp(fdFile.achName, "..") != 0))
01198       {
01199         /* create full path */
01200         strcpy(szDestTemp, szDestination);
01201         AppendBackSlash(szDestTemp, sizeof(szDestTemp));
01202         strcat(szDestTemp, fdFile.achName);
01203 
01204         if(fdFile.attrFile & FILE_DIRECTORY)
01205         {
01206           DirectoryRemove(szDestTemp, bRemoveSubdirs);
01207         }
01208         else
01209         {
01210           DosDelete(szDestTemp);
01211         }
01212       }
01213 
01214       ulFindCount = 1;
01215       if (DosFindNext(hFile, &fdFile, sizeof(fdFile), &ulFindCount) == NO_ERROR) {
01216         bFound = TRUE;
01217       } else {
01218         bFound = FALSE;
01219       }
01220     }
01221 
01222     DosFindClose(hFile);
01223   }
01224   
01225   DosDeleteDir(szDestination);
01226   return(FO_SUCCESS);
01227 }
01228 
01229 HRESULT ProcessRemoveDirectory(DWORD dwTiming, char *szSectionPrefix)
01230 {
01231   DWORD dwIndex;
01232   char  szBuf[MAX_BUF];
01233   char  szSection[MAX_BUF];
01234   char  szDestination[MAX_BUF];
01235   BOOL  bRemoveSubdirs;
01236 
01237   dwIndex = 0;
01238   BuildNumberedString(dwIndex, szSectionPrefix, "Remove Directory", szSection, sizeof(szSection));
01239   GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
01240   while(*szBuf != '\0')
01241   {
01242     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
01243     {
01244       DecryptString(szDestination, szBuf);
01245       GetPrivateProfileString(szSection, "Remove subdirs", "", szBuf, sizeof(szBuf), szFileIniConfig);
01246       bRemoveSubdirs = FALSE;
01247       if(stricmp(szBuf, "TRUE") == 0)
01248         bRemoveSubdirs = TRUE;
01249 
01250       DirectoryRemove(szDestination, bRemoveSubdirs);
01251     }
01252 
01253     ++dwIndex;
01254     BuildNumberedString(dwIndex, szSectionPrefix, "Remove Directory", szSection, sizeof(szSection));
01255     GetPrivateProfileString(szSection, "Destination", "", szBuf, sizeof(szBuf), szFileIniConfig);
01256   }
01257   return(FO_SUCCESS);
01258 }
01259 
01260 HRESULT ProcessRunApp(DWORD dwTiming, char *szSectionPrefix)
01261 {
01262   DWORD dwIndex;
01263   char  szBuf[MAX_BUF];
01264   char  szSection[MAX_BUF];
01265   char  szTarget[MAX_BUF];
01266   char  szParameters[MAX_BUF];
01267   char  szWorkingDir[MAX_BUF];
01268   BOOL  bRunApp;
01269   BOOL  bWait;
01270 
01271   dwIndex = 0;
01272   BuildNumberedString(dwIndex, szSectionPrefix, "RunApp", szSection, sizeof(szSection));
01273   GetPrivateProfileString(szSection, "Target", "", szBuf, sizeof(szBuf), szFileIniConfig);
01274   while(*szBuf != '\0')
01275   {
01276     if(TimingCheck(dwTiming, szSection, szFileIniConfig))
01277     {
01278       DecryptString(szTarget, szBuf);
01279       GetPrivateProfileString(szSection, "Parameters", "", szBuf, sizeof(szBuf), szFileIniConfig);
01280       DecryptString(szParameters, szBuf);
01281 
01282       // If we are given a criterion to test against, we expect also to be told whether we should run
01283       //    the app when that criterion is true or when it is false.  If we are not told, we assume that
01284       //    we are to run the app when the criterion is true.
01285       bRunApp = TRUE;
01286       GetPrivateProfileString(szSection, "Criterion ID", "", szBuf, sizeof(szBuf), szFileIniConfig);
01287       if(stricmp(szBuf, "RecaptureHP") == 0)
01288       {
01289         GetPrivateProfileString(szSection, "Run App If Criterion", "", szBuf, sizeof(szBuf), szFileIniConfig);
01290         if(stricmp(szBuf, "FALSE") == 0)
01291         {
01292           if(diAdditionalOptions.bRecaptureHomepage == TRUE)
01293              bRunApp = FALSE;
01294         }
01295         else
01296         {
01297           if(diAdditionalOptions.bRecaptureHomepage == FALSE)
01298              bRunApp = FALSE;
01299         }
01300       }
01301 
01302       GetPrivateProfileString(szSection, "WorkingDir", "", szBuf, sizeof(szBuf), szFileIniConfig);
01303       DecryptString(szWorkingDir, szBuf);
01304 
01305       GetPrivateProfileString(szSection, "Wait", "", szBuf, sizeof(szBuf), szFileIniConfig);
01306       if(stricmp(szBuf, "FALSE") == 0)
01307         bWait = FALSE;
01308       else
01309         bWait = TRUE;
01310 
01311       if ((bRunApp == TRUE) && FileExists(szTarget))
01312       {
01313         if((dwTiming == T_DEPEND_REBOOT) && (NeedReboot() == TRUE))
01314         {
01315           strcat(szTarget, " ");
01316           strcat(szTarget, szParameters);
01317 #ifdef OLDCODE /* @MAK */
01318           /* Add an object to the startup folder that points to szTarget and uses szParameters */
01319           /* and perhaps an xtra string that only we know (like deleteinstall)
01320           /* Then add code to nsNativeAppSupportOS2.cpp that when it sees this string, it */
01321           /* deletes the object from the startup folder */
01322           /* This is used to allow the app to run automatically on reboot, but clean up */
01323           /* after itself */
01324 #endif
01325         }
01326         else
01327         {
01328           GetPrivateProfileString(szSection, "Message", "", szBuf, sizeof(szBuf), szFileIniConfig);
01329           if ( szBuf[0] != '\0' )
01330             ShowMessage(szBuf, TRUE);  
01331           WinSpawn(szTarget, szParameters, szWorkingDir, bWait);
01332           if ( szBuf[0] != '\0' )
01333             ShowMessage(szBuf, FALSE);  
01334         }
01335       }
01336     }
01337 
01338     ++dwIndex;
01339     BuildNumberedString(dwIndex, szSectionPrefix, "RunApp", szSection, sizeof(szSection));
01340     GetPrivateProfileString(szSection, "Target", "", szBuf, sizeof(szBuf), szFileIniConfig);
01341   }
01342   return(FO_SUCCESS);
01343 }
01344 
01345 HRESULT ProcessOS2INI(ULONG ulTiming, char *szSectionPrefix)
01346 {
01347   char    szBuf[MAX_BUF];
01348   char    szApp[MAX_BUF];
01349   char    szKey[MAX_BUF];
01350   char    szValue[MAX_BUF];
01351   char    szDecrypt[MAX_BUF];
01352   char    szSection[MAX_BUF];
01353   BOOL    bDnu;
01354   ULONG   ulIndex;
01355   ULONG   ulSize;
01356 
01357   ulIndex = 0;
01358   BuildNumberedString(ulIndex, szSectionPrefix, "OS2 INI", szSection, sizeof(szSection));
01359   GetPrivateProfileString(szSection, "App", "", szBuf, sizeof(szBuf), szFileIniConfig);
01360   while(*szBuf != '\0')
01361   {
01362     if(TimingCheck(ulTiming, szSection, szFileIniConfig))
01363     {
01364       GetPrivateProfileString(szSection, "App",                 "", szBuf,           sizeof(szBuf),          szFileIniConfig);
01365       GetPrivateProfileString(szSection, "Decrypt App",         "", szDecrypt,       sizeof(szDecrypt),      szFileIniConfig);
01366       memset(szApp, 0, sizeof(szApp));
01367       if(stricmp(szDecrypt, "TRUE") == 0)
01368         DecryptString(szApp, szBuf);
01369       else
01370         strcpy(szApp, szBuf);
01371 
01372       GetPrivateProfileString(szSection, "Key",                "", szBuf,           sizeof(szBuf),           szFileIniConfig);
01373       GetPrivateProfileString(szSection, "Decrypt Key",        "", szDecrypt,       sizeof(szDecrypt),       szFileIniConfig);
01374       memset(szKey, 0, sizeof(szKey));
01375       if(stricmp(szDecrypt, "TRUE") == 0)
01376         DecryptString(szKey, szBuf);
01377       else
01378         strcpy(szKey, szBuf);
01379 
01380       GetPrivateProfileString(szSection, "Key Value",          "", szBuf,           sizeof(szBuf), szFileIniConfig);
01381       GetPrivateProfileString(szSection, "Decrypt Key Value",  "", szDecrypt,       sizeof(szDecrypt), szFileIniConfig);
01382       memset(szValue, 0, sizeof(szValue));
01383       if(stricmp(szDecrypt, "TRUE") == 0)
01384         DecryptString(szValue, szBuf);
01385       else
01386         strcpy(szValue, szBuf);
01387 
01388       GetPrivateProfileString(szSection, "Size",                "", szBuf,           sizeof(szBuf), szFileIniConfig);
01389       if(*szBuf != '\0')
01390         ulSize = atoi(szBuf);
01391       else
01392         ulSize = 0;
01393 
01394       GetPrivateProfileString(szSection,
01395                               "Do Not Uninstall",
01396                               "",
01397                               szBuf,
01398                               sizeof(szBuf),
01399                               szFileIniConfig);
01400       if(stricmp(szBuf, "TRUE") == 0)
01401         bDnu = TRUE;
01402       else
01403         bDnu = FALSE;
01404 
01405       PrfWriteProfileString(HINI_USERPROFILE, szApp, szKey, szValue);
01406       /* log the win reg command */
01407       sprintf(szBuf, "%s [%s]", szApp, szKey);
01408       UpdateInstallLog(KEY_STORE_INI_ENTRY, szBuf, bDnu);
01409     }
01410 
01411     ++ulIndex;
01412     BuildNumberedString(ulIndex, szSectionPrefix, "OS2 INI", szSection, sizeof(szSection));
01413     GetPrivateProfileString(szSection, "App", "", szBuf, sizeof(szBuf), szFileIniConfig);
01414   }
01415   return(FO_SUCCESS);
01416 }
01417 
01418 /* Helper function that moves a given hobject to the front of */
01419 /* an association string in OS2.INI */
01420 
01421 void MoveHOBJToFront(HOBJECT hobject, char* szApp, char* szKey)
01422 {
01423   CHAR szhobj[CCHMAXPATH];
01424   CHAR *szOrigBuffer, *szNewBuffer, *szCurrNew, *szCurrOrig;
01425   ULONG ulSize;
01426   int i;
01427 
01428   sprintf(szhobj, "%d\0", hobject);
01429   PrfQueryProfileSize(HINI_USERPROFILE, szApp, szKey, &ulSize );
01430   szOrigBuffer = (char*)malloc(sizeof(char)*ulSize);
01431   szNewBuffer = (char*)malloc(sizeof(char)*ulSize);
01432   PrfQueryProfileData(HINI_USERPROFILE, szApp, szKey, szOrigBuffer, &ulSize);
01433   szCurrOrig = szOrigBuffer;
01434   szCurrNew = szNewBuffer;
01435   strncpy(szCurrNew, szhobj, 7);
01436   szCurrNew +=7;
01437   for (i=0; i<ulSize/7; i++) {
01438      if (strcmp(szCurrOrig, szhobj)) {
01439        strncpy(szCurrNew, szCurrOrig, 7);
01440        szCurrNew += 7;
01441      }
01442      szCurrOrig += 7;
01443   }
01444   PrfWriteProfileData(HINI_USERPROFILE, szApp, szKey, szNewBuffer, ulSize);
01445   free(szOrigBuffer);
01446   free(szNewBuffer);
01447 }
01448 
01449 
01450 HRESULT ProcessProgramFolder(DWORD dwTiming, char *szSectionPrefix)
01451 {
01452   DWORD dwIndex0;
01453   DWORD dwIndex1;
01454   char  szIndex1[MAX_BUF];
01455   char  szBuf[MAX_BUF];
01456   char  szBuf2[MAX_BUF];
01457   char  szSection0[MAX_BUF];
01458   char  szSection1[MAX_BUF];
01459   char  szProgramFolder[MAX_BUF];
01460 
01461   char  szClassName[MAX_BUF];
01462   char  szTitle[MAX_BUF];
01463   char  szObjectID[MAX_BUF];
01464   char  szSetupString[MAX_BUF];
01465   char  szLocation[MAX_BUF];
01466   char  szAssocFilters[MAX_BUF];
01467   char  szAssocTypes[MAX_BUF];
01468 
01469   ULONG ulFlags = CO_REPLACEIFEXISTS;
01470 
01471   dwIndex0 = 0;
01472   BuildNumberedString(dwIndex0, szSectionPrefix, "Program Folder", szSection0, sizeof(szSection0));
01473   GetPrivateProfileString(szSection0, "Timing", "", szBuf, sizeof(szBuf), szFileIniConfig);
01474   while(*szBuf != '\0')
01475   {
01476     if(TimingCheck(dwTiming, szSection0, szFileIniConfig))
01477     {
01478       DecryptString(szProgramFolder, szBuf);
01479 
01480       dwIndex1 = 0;
01481       _itoa(dwIndex1, szIndex1, 10);
01482       strcpy(szSection1, szSection0);
01483       strcat(szSection1, "-Object");
01484       strcat(szSection1, szIndex1);
01485       GetPrivateProfileString(szSection1, "Title", "", szBuf, sizeof(szBuf), szFileIniConfig);
01486       while(*szBuf != '\0')
01487       {
01488         *szSetupString = '\0';
01489         DecryptString(szTitle, szBuf);
01490         GetPrivateProfileString(szSection1, "Location",  "", szBuf, sizeof(szBuf), szFileIniConfig);
01491         DecryptString(szLocation, szBuf);
01492         GetPrivateProfileString(szSection1, "File",  "", szBuf, sizeof(szBuf), szFileIniConfig);
01493         DecryptString(szBuf2, szBuf);
01494         if (szBuf2[0]) {
01495           if (szSetupString[0]) {
01496             strcat(szSetupString, ";");
01497           }
01498           strcat(szSetupString, "EXENAME=");
01499           strcat(szSetupString, szBuf2);
01500         }
01501         GetPrivateProfileString(szSection1, "Parameters",  "", szBuf, sizeof(szBuf), szFileIniConfig);
01502         DecryptString(szBuf2, szBuf);
01503         if (szBuf2[0]) {
01504           if (szSetupString[0]) {
01505             strcat(szSetupString, ";");
01506           }
01507           strcat(szSetupString, "PARAMETERS=");
01508           strcat(szSetupString, szBuf2);
01509         }
01510         GetPrivateProfileString(szSection1, "Working Dir",  "", szBuf, sizeof(szBuf), szFileIniConfig);
01511         DecryptString(szBuf2, szBuf);
01512         if (szBuf2[0]) {
01513           if (szSetupString[0]) {
01514             strcat(szSetupString, ";");
01515           }
01516           strcat(szSetupString, "STARTUPDIR=");
01517           strcat(szSetupString, szBuf2);
01518         }
01519         GetPrivateProfileString(szSection1, "Object ID",  "", szObjectID, sizeof(szObjectID), szFileIniConfig);
01520         if (szObjectID[0]) {
01521           if (szSetupString[0]) {
01522             strcat(szSetupString, ";");
01523           }
01524           strcat(szSetupString, "OBJECTID=");
01525           strcat(szSetupString, szObjectID);
01526         }
01527         GetPrivateProfileString(szSection1, "Association Filters",  "", szAssocFilters, sizeof(szAssocFilters), szFileIniConfig);
01528         if (szAssocFilters[0]) {
01529           if (diOS2Integration.oiCBAssociateHTML.bCheckBoxState == TRUE) {
01530             if (szSetupString[0]) {
01531               strcat(szSetupString, ";");
01532             }
01533             strcat(szSetupString, "ASSOCFILTER=");
01534             strcat(szSetupString, szAssocFilters);
01535           }
01536         }
01537         GetPrivateProfileString(szSection1, "Association Types",  "", szAssocTypes, sizeof(szAssocTypes), szFileIniConfig);
01538         if (szAssocTypes[0]) {
01539           if (diOS2Integration.oiCBAssociateHTML.bCheckBoxState == TRUE) {
01540             if (szSetupString[0]) {
01541               strcat(szSetupString, ";");
01542             }
01543             strcat(szSetupString, "ASSOCTYPE=");
01544             strcat(szSetupString, szAssocTypes);
01545           }
01546         }
01547         GetPrivateProfileString(szSection1, "Setup String",  "", szBuf, sizeof(szBuf), szFileIniConfig);
01548         DecryptString(szBuf2, szBuf);
01549         if (szBuf2[0]) {
01550           if (szSetupString[0]) {
01551             strcat(szSetupString, ";");
01552           }
01553           strcat(szSetupString, szBuf2);
01554         }
01555         GetPrivateProfileString(szSection1, "ClassName", "", szBuf, sizeof(szBuf), szFileIniConfig);
01556         if (szBuf[0]) {
01557            strcpy(szClassName, szBuf);
01558         } else {
01559            strcpy(szClassName, "WPProgram");
01560         }
01561 
01562         GetPrivateProfileString(szSection1, "Attributes", "", szBuf, sizeof(szBuf), szFileIniConfig);
01563         if (szBuf[0]) {
01564           if (strcmp(szBuf, "UPDATE") == 0) {
01565             ulFlags = CO_UPDATEIFEXISTS;
01566           } else if (strcmp(szBuf, "FAIL") == 0) {
01567             ulFlags = CO_FAILIFEXISTS;
01568           }
01569         }
01570 
01571         WinCreateObject(szClassName, szTitle, szSetupString, szLocation, ulFlags);
01572 
01573         if (szObjectID[0]) {
01574           strcpy(szBuf, szObjectID);
01575         } else {
01576           strcpy(szBuf, szProgramFolder);
01577           AppendBackSlash(szBuf, sizeof(szBuf));
01578           strcat(szBuf, szTitle);
01579         }
01580         UpdateInstallLog(KEY_OS2_OBJECT, szBuf, FALSE);
01581 
01582         if ((diOS2Integration.oiCBAssociateHTML.bCheckBoxState == TRUE) &&
01583             (szAssocFilters[0] || szAssocTypes[0])) {
01584           HOBJECT hobj = WinQueryObject(szBuf);
01585           if (szAssocFilters[0]) {
01586             char *currFilter = strtok(szAssocFilters, ",");
01587             while (currFilter) {
01588               MoveHOBJToFront(hobj, "PMWP_ASSOC_FILTER", currFilter);
01589               currFilter = strtok(NULL, ",");
01590             }
01591           }
01592           if (szAssocTypes[0]) {
01593             char *currType = strtok(szAssocTypes, ",");
01594             while (currType) {
01595               MoveHOBJToFront(hobj, "PMWP_ASSOC_TYPE", currType);
01596               currType = strtok(NULL, ",");
01597             }
01598           }
01599         }
01600 
01601         ++dwIndex1;
01602         _itoa(dwIndex1, szIndex1, 10);
01603         strcpy(szSection1, szSection0);
01604         strcat(szSection1, "-Object");
01605         strcat(szSection1, szIndex1);
01606         GetPrivateProfileString(szSection1, "Title", "", szBuf, sizeof(szBuf), szFileIniConfig);
01607       }
01608     }
01609 
01610     ++dwIndex0;
01611     BuildNumberedString(dwIndex0, szSectionPrefix, "Program Folder", szSection0, sizeof(szSection0));
01612     GetPrivateProfileString(szSection0, "Program Folder", "", szBuf, sizeof(szBuf), szFileIniConfig);
01613   }
01614   return(FO_SUCCESS);
01615 }
01616 
01617 HRESULT ProcessProgramFolderShowCmd()
01618 {
01619   DWORD dwIndex0;
01620   int   iShowFolder;
01621   char  szBuf[MAX_BUF];
01622   char  szSection0[MAX_BUF];
01623   char  szProgramFolder[MAX_BUF];
01624 
01625   dwIndex0 = 0;
01626   BuildNumberedString(dwIndex0, NULL, "Program Folder", szSection0, sizeof(szSection0));
01627   GetPrivateProfileString(szSection0, "Program Folder", "", szBuf, sizeof(szBuf), szFileIniConfig);
01628   while(*szBuf != '\0')
01629   {
01630     DecryptString(szProgramFolder, szBuf);
01631     GetPrivateProfileString(szSection0, "Show Folder", "", szBuf, sizeof(szBuf), szFileIniConfig);
01632 
01633 #ifdef OLDCODE
01634     if(stricmp(szBuf, "HIDE") == 0)
01635       iShowFolder = SW_HIDE;
01636     else if(stricmp(szBuf, "MAXIMIZE") == 0)
01637       iShowFolder = SW_MAXIMIZE;
01638     else if(stricmp(szBuf, "MINIMIZE") == 0)
01639       iShowFolder = SW_MINIMIZE;
01640     else if(stricmp(szBuf, "RESTORE") == 0)
01641       iShowFolder = SW_RESTORE;
01642     else if(stricmp(szBuf, "SHOW") == 0)
01643       iShowFolder = SW_SHOW;
01644     else if(stricmp(szBuf, "SHOWMAXIMIZED") == 0)
01645       iShowFolder = SW_SHOWMAXIMIZED;
01646     else if(stricmp(szBuf, "SHOWMINIMIZED") == 0)
01647       iShowFolder = SW_SHOWMINIMIZED;
01648     else if(stricmp(szBuf, "SHOWMINNOACTIVE") == 0)
01649       iShowFolder = SW_SHOWMINNOACTIVE;
01650     else if(stricmp(szBuf, "SHOWNA") == 0)
01651       iShowFolder = SW_SHOWNA;
01652     else if(stricmp(szBuf, "SHOWNOACTIVATE") == 0)
01653       iShowFolder = SW_SHOWNOACTIVATE;
01654     else if(stricmp(szBuf, "SHOWNORMAL") == 0)
01655       iShowFolder = SW_SHOWNORMAL;
01656 
01657     if(iShowFolder != SW_HIDE)
01658       if(sgProduct.dwMode != SILENT)
01659         WinSpawn(szProgramFolder, NULL, NULL, TRUE);
01660 
01661 #endif
01662     ++dwIndex0;
01663     BuildNumberedString(dwIndex0, NULL, "Program Folder", szSection0, sizeof(szSection0));
01664     GetPrivateProfileString(szSection0, "Program Folder", "", szBuf, sizeof(szBuf), szFileIniConfig);
01665   }
01666   return(FO_SUCCESS);
01667 }
01668 
01669 HRESULT ProcessCreateCustomFiles(DWORD dwTiming)
01670 {
01671   DWORD dwCompIndex;
01672   DWORD dwFileIndex;
01673   DWORD dwSectIndex;
01674   DWORD dwKVIndex;
01675   siC   *siCObject = NULL;
01676   char  szBufTiny[MAX_BUF_TINY];
01677   char  szSection[MAX_BUF_TINY];
01678   char  szBuf[MAX_BUF];
01679   char  szFileName[MAX_BUF];
01680   char  szDefinedSection[MAX_BUF]; 
01681   char  szDefinedKey[MAX_BUF]; 
01682   char  szDefinedValue[MAX_BUF];
01683 
01684   dwCompIndex   = 0;
01685   siCObject = SiCNodeGetObject(dwCompIndex, TRUE, AC_ALL);
01686 
01687   while(siCObject)
01688   {
01689     dwFileIndex   = 0;
01690     sprintf(szSection,"%s-Configuration File%d",siCObject->szReferenceName,dwFileIndex);
01691     siCObject = SiCNodeGetObject(++dwCompIndex, TRUE, AC_ALL);
01692     if(TimingCheck(dwTiming, szSection, szFileIniConfig) == FALSE)
01693     {
01694       continue;
01695     }
01696 
01697     GetPrivateProfileString(szSection, "FileName", "", szBuf, sizeof(szBuf), szFileIniConfig);
01698     while (*szBuf != '\0')
01699     {
01700       DecryptString(szFileName, szBuf);
01701       if(FileExists(szFileName))
01702       {
01703         DosDelete(szFileName);
01704       }
01705 
01706       /* TO DO - Support a File Type for something other than .ini */
01707       dwSectIndex = 0;
01708       sprintf(szBufTiny, "Section%d",dwSectIndex);
01709       GetPrivateProfileString(szSection, szBufTiny, "", szDefinedSection, sizeof(szDefinedSection), szFileIniConfig);
01710       while(*szDefinedSection != '\0')
01711       {  
01712         dwKVIndex =0;
01713         sprintf(szBufTiny,"Section%d-Key%d",dwSectIndex,dwKVIndex);
01714         GetPrivateProfileString(szSection, szBufTiny, "", szDefinedKey, sizeof(szDefinedKey), szFileIniConfig);
01715         while(*szDefinedKey != '\0')
01716         {
01717           sprintf(szBufTiny,"Section%d-Value%d",dwSectIndex,dwKVIndex);
01718           GetPrivateProfileString(szSection, szBufTiny, "", szBuf, sizeof(szBuf), szFileIniConfig);
01719           DecryptString(szDefinedValue, szBuf);
01720           if(WritePrivateProfileString(szDefinedSection, szDefinedKey, szDefinedValue, szFileName) == 0)
01721           {
01722             char szEWPPS[MAX_BUF];
01723             char szBuf[MAX_BUF];
01724             char szBuf2[MAX_BUF];
01725             if(GetPrivateProfileString("Messages", "ERROR_WRITEPRIVATEPROFILESTRING", "", szEWPPS, sizeof(szEWPPS), szFileIniInstall))
01726             {
01727               sprintf(szBuf, "%s\n    [%s]\n    %s=%s", szFileName, szDefinedSection, szDefinedKey, szDefinedValue);
01728               sprintf(szBuf2, szEWPPS, szBuf);
01729               PrintError(szBuf2, ERROR_CODE_SHOW);
01730             }
01731             return(FO_ERROR_WRITE);
01732           }
01733           sprintf(szBufTiny,"Section%d-Key%d",dwSectIndex,++dwKVIndex);
01734           GetPrivateProfileString(szSection, szBufTiny, "", szDefinedKey, sizeof(szDefinedKey), szFileIniConfig);
01735         } /* while(*szDefinedKey != '\0')  */
01736 
01737         sprintf(szBufTiny, "Section%d",++dwSectIndex);
01738         GetPrivateProfileString(szSection, szBufTiny, "", szDefinedSection, sizeof(szDefinedSection), szFileIniConfig);
01739       } /*       while(*szDefinedSection != '\0') */
01740 
01741       sprintf(szSection,"%s-Configuration File%d",siCObject->szReferenceName,++dwFileIndex);
01742       GetPrivateProfileString(szSection, "FileName", "", szBuf, sizeof(szBuf), szFileIniConfig);
01743     } /* while(*szBuf != '\0') */
01744   } /* while(siCObject) */
01745   return (FO_SUCCESS);
01746 }
01747