From a7979f7db223feea7cd2b192be6204da42db3f2a Mon Sep 17 00:00:00 2001 From: rasberryrabbit Date: Sun, 9 Apr 2017 18:36:47 +0900 Subject: [PATCH] Add option Group box and can change chunk_size. --- nginxtool.lpi | 2 +- nginxtool.res | Bin 2320 -> 2324 bytes nginxtool_main.lfm | 99 ++++++++++++++++++++++++++++++--------------- nginxtool_main.pas | 49 ++++++++++++++++++---- 4 files changed, 109 insertions(+), 41 deletions(-) diff --git a/nginxtool.lpi b/nginxtool.lpi index 20b72d5..0f9a7c8 100644 --- a/nginxtool.lpi +++ b/nginxtool.lpi @@ -15,7 +15,7 @@ - + diff --git a/nginxtool.res b/nginxtool.res index 9ba71ea26ea8e472ca322f17c8730a25a68126f2..128fc2d9c8e54da82f2c3551df044fef9a4709ff 100644 GIT binary patch delta 56 zcmbOrG(~7b4I5*{0 then begin + buf:=Copy(buf,1,rx.MatchPos[1]-1)+schunksize+Copy(buf,rx.MatchPos[1]+rx.MatchLen[1]); chunk_modified:=True; end; end else begin @@ -285,7 +295,7 @@ procedure TFormNginxtool.VerboseNginxConfig; try rxrtmp.ModifierI:=True; if rxrtmp.Exec(buf) then begin - buf:=Copy(buf,1,rxrtmp.MatchPos[0]+rxrtmp.MatchLen[0]-1)+#10#9#9'chunk_size 8192;'#10+ + buf:=Copy(buf,1,rxrtmp.MatchPos[0]+rxrtmp.MatchLen[0]-1)+#10#9#9'chunk_size '+schunksize+';'#10+ Copy(buf,rxrtmp.MatchPos[0]+rxrtmp.MatchLen[0]); chunk_modified:=True; end; @@ -368,7 +378,7 @@ procedure TFormNginxtool.FormCreate(Sender: TObject); procedure TFormNginxtool.FormDestroy(Sender: TObject); var fs : TFileStream; - s : string; + s,schunk : string; i : Integer; begin s:='00'; @@ -376,6 +386,7 @@ procedure TFormNginxtool.FormDestroy(Sender: TObject); s[1]:='1'; if CheckBoxModConf.Checked then s[2]:='1'; + s:=s+ComboBoxChunk.Text; if checkflag<>s then begin try fs:=TFileStream.Create('nginxtool.ini',fmOpenWrite or fmCreate or fmShareDenyNone); @@ -472,28 +483,49 @@ procedure TFormNginxtool.CheckBoxModConfClick(Sender: TObject); VerboseNginxConfig; end; +procedure TFormNginxtool.ComboBoxChunkCloseUp(Sender: TObject); +begin + CheckBoxModConfClick(nil); +end; + +procedure TFormNginxtool.ComboBoxChunkKeyPress(Sender: TObject; var Key: char); +begin + if Key=#13 then begin + Key:=#0; + CheckBoxModConfClick(nil); + end; +end; + function ReadINIFile(idx:Integer):Boolean; var fs : TFileStream; s : string; + bsize : Integer; begin - s:='01'; + s:='018192'; if idx>Length(s) then idx:=Length(s); if checkflag='' then begin try fs:=TFileStream.Create('nginxtool.ini',fmOpenRead or fmShareDenyNone); try + bsize:=fs.Size; + if bsize>8 then + bsize:=8; + SetLength(s,bsize); fs.Read(s[1],Length(s)); finally fs.Free; end; except - s:='01'; + s:='018192'; end; checkflag:=s; end; - Result:=checkflag[idx]='1'; + if idx<3 then + Result:=checkflag[idx]='1' + else + Result:=False; end; @@ -505,6 +537,7 @@ procedure TFormNginxtool.FormShow(Sender: TObject); loglist.AddLog(Format('> IP Address: %s',[IPBuf])); CheckBox1.Checked:=ReadINIFile(1); CheckBoxModConf.Checked:=ReadINIFile(2); + ComboBoxChunk.Text:=Copy(checkflag,3); CheckBoxModConf.OnClick:=@CheckBoxModConfClick; VerboseNginxConfig; end;