Skip to content

Commit

Permalink
Beginning to separate server side from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
drapid committed Oct 7, 2020
1 parent 97de354 commit 16cf4c4
Show file tree
Hide file tree
Showing 19 changed files with 2,143 additions and 1,860 deletions.
78 changes: 19 additions & 59 deletions classesLib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
interface

uses
iniFiles, types, strUtils, sysUtils, classes, math,
iniFiles, types, strUtils, sysUtils, classes,
system.Generics.Collections,
OverbyteIcsWSocket, OverbyteIcshttpProt,
hslib, hfsGlobal;
hslib, srvConst;

type
Tip2av = Tdictionary<string,Tdatetime>;
Expand All @@ -46,17 +46,6 @@ TantiDos = class
function accept(conn:ThttpConn; address:string=''):boolean;
end;

TfastStringAppend = class
protected
buff: string;
n: integer;
public
function length():integer;
function reset():string;
function get():string;
function append(s:string):integer;
end;

PcachedIcon = ^TcachedIcon;
TcachedIcon = record
data: string;
Expand Down Expand Up @@ -97,10 +86,10 @@ Thasher = class(TstringList)

TstringToIntHash = class(ThashedStringList)
constructor create;
function getInt(s:string):integer;
function getInt(const s:string):integer;
function getIntByIdx(idx:integer):integer;
function incInt(s:string):integer;
procedure setInt(s:string; int:integer);
function incInt(const s:string):integer;
procedure setInt(const s:string; int:integer);
end;

PtplSection = ^TtplSection;
Expand Down Expand Up @@ -133,8 +122,8 @@ Ttpl = class
procedure clear();
public
onChange: TNotifyEvent;
constructor create(txt: RawByteString=''; over:Ttpl=NIL); OverLoad;
constructor create(txt: String; over:Ttpl=NIL); OverLoad;
constructor create(const txt: RawByteString=''; over:Ttpl=NIL); OverLoad;
constructor create(const txt: String; over:Ttpl=NIL); OverLoad;
destructor Destroy; override;
property txt[section:string]:string read getTxt; default;
property fullText: RawByteString read toRaw write fromRaw;
Expand All @@ -146,7 +135,7 @@ Ttpl = class
function getSection(section:string; inherit:boolean=TRUE):PtplSection;
function getSections():TStringDynArray;
procedure appendString(txt: String);
function getStrByID(id:string):string;
function getStrByID(const id:string):string;
function me():Ttpl;
end; // Ttpl

Expand Down Expand Up @@ -233,7 +222,7 @@ Tsessions = class

ThashFunc = function(s:string):string;

TconnDataMain = class // data associated to a client connection
TconnDataMain = class // data associated to a client connection
public
class function getSafeHost(cd:TconnDataMain):string;
public
Expand Down Expand Up @@ -274,7 +263,8 @@ implementation
uses
windows, dateUtils, forms, ansiStrings,
RDFileUtil, RDUtils,
utilLib, hfsVars;
utilLib, hfsGlobal, hfsVars,
srvUtils;


class constructor TantiDos.Create;
Expand Down Expand Up @@ -305,7 +295,8 @@ function TantiDos.accept(conn:ThttpConn; address:string=''):boolean;
if ip2availability = NIL then
ip2availability:=Tip2av.create();
try
if ip2availability[address] > now() then // this specific address has to wait?
if ip2availability.ContainsKey(address) then
if ip2availability[address] > now() then // this specific address has to wait?
begin
reject();
exit(FALSE);
Expand Down Expand Up @@ -537,37 +528,6 @@ procedure TiconsCache.purge(olderThan:Tdatetime);
end;
end; // purge

//////////// TfastStringAppend

function TfastStringAppend.length():integer;
begin result:=n end;

function TfastStringAppend.get():string;
begin
setlength(buff, n);
result:=buff;
end; // get

function TfastStringAppend.reset():string;
begin
result:=get();
buff:='';
n:=0;
end; // reset

function TfastStringAppend.append(s:string):integer;
var
ls, lb: integer;
begin
ls := system.length(s);
lb := system.length(buff);
if n+ls > lb then
setlength(buff, lb+ls+20000);
MoveChars(s[1], buff[n+1], ls);
inc(n, ls);
result:=n;
end; // append

//////////// Thasher

procedure Thasher.loadFrom(path:string);
Expand Down Expand Up @@ -616,17 +576,17 @@ constructor TstringToIntHash.create;
function TstringToIntHash.getIntByIdx(idx:integer):integer;
begin if idx < 0 then result:=0 else result:=integer(objects[idx]) end;

function TstringToIntHash.getInt(s:string):integer;
function TstringToIntHash.getInt(const s:string):integer;
begin result:=getIntByIdx(indexOf(s)) end;

procedure TstringToIntHash.setInt(s:string; int:integer);
procedure TstringToIntHash.setInt(const s:string; int:integer);
begin
beginUpdate();
objects[add(s)]:=Tobject(int);
endUpdate();
end; // setInt

function TstringToIntHash.incInt(s:string):integer;
function TstringToIntHash.incInt(const s:string):integer;
var
i: integer;
begin
Expand All @@ -640,14 +600,14 @@ function TstringToIntHash.incInt(s:string):integer;

//////////// Ttpl

constructor Ttpl.create(txt: RawByteString=''; over:Ttpl=NIL);
constructor Ttpl.create(const txt: RawByteString=''; over:Ttpl=NIL);
begin
sections:=Tstr2section.Create();
fullText:=txt;
self.over:=over;
end;

constructor Ttpl.create(txt: String; over:Ttpl=NIL);
constructor Ttpl.create(const txt: String; over:Ttpl=NIL);
begin
sections:=Tstr2section.Create();
fullTextS:=txt;
Expand All @@ -660,7 +620,7 @@ destructor Ttpl.destroy;
inherited;
end; // destroy

function Ttpl.getStrByID(id:string):string;
function Ttpl.getStrByID(const id:string):string;
begin
if strTable = NIL then
begin
Expand Down
1 change: 1 addition & 0 deletions clear.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
@IF EXIST "Prefs\*.bak" del /q Prefs\*.bak
@IF EXIST "Prefs\*.dcu" del /q Prefs\*.dcu
@IF EXIST "__history\*" del /q __history\*
@IF EXIST "srv\__history\*" del /q srv\_history\*

@rem exit
4 changes: 2 additions & 2 deletions compressHFS.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@copy hfs.exe "HFS319_RD.exe"
upx.exe -9 --lzma "HFS319_RD.exe"
@copy hfs.exe "HFS320_RD.exe"
upx.exe -9 --lzma "HFS320_RD.exe"
Loading

0 comments on commit 16cf4c4

Please sign in to comment.