*****************************************************************
***             TextReplace NSIS plugin v1.1                  ***
*****************************************************************

2006 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)


Features:
- Fast search/replacement in text file
- Case sensitive/insensitive replacement 
- Supports strings and pointers to the buffer
- If no changes possible, output file will be untouched
- Checks if input file is a binary file


**** Output variables ****
.r0-.r9 == $0-$9
.R0-.R9 == $R0-$R9


**** Search in file ****
textreplace::FindInFile "[InputFile]" "[FindIt]" "[Options]" .r0

"[InputFile]"   - Input file

"[FindIt]"      - string to find or pointer to the buffer if used option /PI=1

"[Options]"     - Search options

	/S=[0|1]
		/S=0  - Case insensitive (default)
		/S=1  - Case sensitive (faster)
	/PI=[0|1]
		/PI=0  - FindIt is a string (default)
		/PI=1  - FindIt is a pointer to the text buffer

.r0  - $0=number of founded
       $0=-3   ReplaceIt string is empty
       $0=-4   can't open input file for reading
       $0=-5   can't get file size of the input file
       $0=-6   can't allocate buffer for input file text
       $0=-7   can't read input file
       $0=-8   input file is binary or wide character Unicode file 


**** Replace in file ****
textreplace::ReplaceInFile "[InputFile]" "[OuputFile]" "[ReplaceIt]" "[ReplaceWith]" "[Options]" .r0

"[InputFile]"   - Input file

"[OutputFile]"  - Output file, can be equal to InputFile

"[ReplaceIt]"   - string to replace or pointer to the buffer if used option /PI=1

"[ReplaceWith]" - replace with this string or pointer to the buffer if used option /PO=1

"[Options]"     - Replace options

	/S=[0|1]
		/S=0  - Case insensitive (default)
		/S=1  - Case sensitive (faster)
	/C=[1|0]
		/C=1  - Copy the file if no changes made (default)
		/C=0  - Don't copy the file if no changes made
	/AI=[1|0]
		/AI=1  - Copy attributes from the InputFile to OutputFile (default)
		/AI=0  - Don't copy attributes
	/AO=[0|1]
		/AO=0  - Don't change OutputFile attributes (error "-9" possible) (default)
		/AO=1  - Change OutputFile attributes to normal before writting
	/PI=[0|1]
		/PI=0  - ReplaceIt is a string (default)
		/PI=1  - ReplaceIt is a pointer to the text buffer
	/PO=[0|1]
		/PO=0  - ReplaceWith is a string (default)
		/PO=1  - ReplaceWith is a pointer to the text buffer

.r0  - $0=number of replacements
       $0=-1   ReplaceIt pointer is incorrect
       $0=-2   ReplaceWith pointer is incorrect
       $0=-3   ReplaceIt string is empty
       $0=-4   can't open input file for reading
       $0=-5   can't get file size of the input file
       $0=-6   can't allocate buffer for input file text
       $0=-7   can't read input file
       $0=-8   input file is binary or wide character Unicode file 
       $0=-9   can't open output file for writting
       $0=-10  can't allocate buffer for output file text
       $0=-11  can't write to the output file


**** Put text file contents to the buffer ****
textreplace::FillReadBuffer "[File]" .r0

"[File]"   - Input file

.r0  - $0=pointer to the buffer
       $0=-4   can't open input file for reading
       $0=-5   can't get file size of the input file
       $0=-6   can't allocate buffer for input file text
       $0=-7   can't read input file
       $0=-8   input file is binary or wide character Unicode file 


**** Free buffer ****
textreplace::FreeReadBuffer "[Pointer]"

"[Pointer]"  - pointer to the buffer
