#include "precomp.h" #pragma hdrstop /*++ Copyright (c) 1990 Microsoft Corporation Module Name: cf.c Abstract: 1. Contains code to perform simple text substitutions on a text file. 2. Contains code to append text entries to a text file. This module has no external dependencies and is not statically linked to any part of Setup. Author: Ted Miller (tedm) July 1991 --*/ BOOL WriteData(HANDLE Handle,PVOID Data,DWORD DataSize); BOOL ConfigFileSubstWorker( IN LPSTR File, IN DWORD NumSubsts, IN LPSTR *Substs ) { LPSTR CharPtr,old; LPSTR FileBuf=NULL,FileBufEnd; DWORD *StrLenArray; DWORD FileLength = 0xffffffff; HANDLE FileHandle = (HANDLE)(-1); DWORD rcID; BOOL Match; DWORD x,i; char CRLF[2]; BOOL IsCFGFile; #define ORIGINAL_TEXT(i) Substs[(2*i)] #define REPLACEMENT_TEXT(i) Substs[(2*i)+1] #define ORIGINAL_TEXT_LENGTH(i) StrLenArray[i] CRLF[0] = '\r'; CRLF[1] = '\n'; if((StrLenArray = SAlloc(NumSubsts * sizeof(DWORD))) == NULL) { SetErrorText(IDS_ERROR_DLLOOM); return(FALSE); } for(i=0; i 4) { IsCFGFile = !lstrcmpi(&File[x-4],".cfg"); } CharPtr = FileBuf-1; while(++CharPtr <= FileBufEnd) { // skips NUL while(*CharPtr) { if(*CharPtr == '\r') { CharPtr++; continue; } // ignore comments in .cfg files if(IsCFGFile && (*CharPtr == '/') && (*(CharPtr+1) == '/')) { old = CharPtr; while(*CharPtr && (*CharPtr != '\r')) { CharPtr++; } if(!WriteData(FileHandle,old,(DWORD)(CharPtr - old))) { goto xxx_err1; } if(*CharPtr == '\r') { CharPtr++; } continue; } Match = FALSE; for(i=0; i