Skip to content

Commit 4bb47fd

Browse files
committed
Add files
1 parent a6e81c5 commit 4bb47fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+10027
-1449
lines changed

Pascal-Source/Debug.pas

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
unit Debug;
2+
3+
interface
4+
5+
uses Windows,kol,Share;
6+
7+
{$include def.inc}
8+
{$include share.inc}
9+
10+
var
11+
_Init:boolean;
12+
13+
type
14+
{$ifndef _DEBUG_}
15+
TDebug = TObject;
16+
{$else}
17+
TDebug = class
18+
private
19+
public
20+
//ID:Cardinal;
21+
constructor Create;
22+
end;
23+
24+
25+
procedure CallEvent(PT:byte; Event:THI_Event;const Data:TData);
26+
{$endif}
27+
28+
29+
implementation
30+
31+
uses WinSock;
32+
33+
{$ifdef _DEBUG_}
34+
const
35+
EB_NONE = 0;
36+
EB_TRACE = 1;
37+
EB_RUN = 2;
38+
39+
EB_SELECT = 3;
40+
EB_UNSELECT = 4;
41+
42+
type
43+
TEventBuf = record
44+
cmd:cardinal;
45+
Point:cardinal;
46+
PointType:cardinal;
47+
DataType:cardinal;
48+
data:array[0..127]of Char;
49+
end;
50+
51+
var ms:THandle;
52+
53+
constructor TDebug.Create;
54+
{$ifndef _DEBUG_MAIL_}
55+
var SockAddr:TSockAddr;
56+
{$endif}
57+
begin
58+
inherited;
59+
if ms = 0 then
60+
begin
61+
{$ifdef _DEBUG_MAIL_}
62+
ms := CreateMailslot(PChar('\\.\mailslot\hiDebug_'),512,MAILSLOT_WAIT_FOREVER,nil);
63+
SetMailslotInfo(ms,10);
64+
if ms = INVALID_HANDLE_VALUE then
65+
_debug('mail slot failed!');
66+
{$else}
67+
UPD_Init;
68+
ms := socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP);
69+
FillChar(SockAddr,SizeOf(SockAddr),0);
70+
SockAddr.sin_family := AF_INET;
71+
SockAddr.sin_port := htons(_dbServer);
72+
{$endif}
73+
end;
74+
end;
75+
76+
procedure Write(Buf:TEventBuf; size:integer);
77+
var {$ifdef _DEBUG_MAIL_}
78+
hf:cardinal;
79+
nBytesRead:cardinal;
80+
{$else}
81+
SockAddr:TSockAddr;
82+
{$endif}
83+
begin
84+
{$ifdef _DEBUG_MAIL_}
85+
hf := CreateFile(PChar('\\.\mailslot\hiDebug'),GENERIC_WRITE,
86+
FILE_SHARE_READ,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
87+
WriteFile(hf,Buf,size,nBytesRead,nil);
88+
CloseHandle(hf);
89+
{$else}
90+
SockAddr.sin_family := AF_INET;
91+
SockAddr.sin_port := htons(_dbClient);
92+
SockAddr.sin_addr.S_addr := inet_addr('127.0.0.1');
93+
sendto(ms,Buf,size,0,SockAddr,sizeof(SockAddr));
94+
{$endif}
95+
end;
96+
97+
var rBuf:TEventBuf;
98+
99+
function Read(var buf:TEventBuf):boolean;
100+
var
101+
{$ifdef _DEBUG_MAIL_}
102+
nBytesRead:cardinal;
103+
{$else}
104+
FDSet:TFDSet;
105+
tm:TTimeVal;
106+
{$endif}
107+
size:integer;
108+
begin
109+
if buf.point <> 0 then begin sleep(1); Result := true; exit; end;
110+
111+
{$ifdef _DEBUG_MAIL_}
112+
Result := ReadFile(ms, buf, size, nBytesRead, nil );
113+
{$else}
114+
Result := false;
115+
FD_ZERO(FDSet);
116+
FD_SET(ms, FDSet);
117+
tm.tv_sec := 0;
118+
tm.tv_usec := 500;
119+
if select(0,@FDSet,nil,nil,@tm) > 0 then begin
120+
ioctlsocket(ms, FIONREAD, size);
121+
if Size = 0 then
122+
else begin
123+
Recv(ms,buf,8,0);
124+
Result := true;
125+
end;
126+
end;
127+
{$endif}
128+
end;
129+
130+
procedure CallEvent(PT:byte; Event:THI_Event;const Data:TData);
131+
var
132+
Buf:TEventBuf;
133+
len:integer;
134+
s:string;
135+
begin
136+
if not _Init then exit;
137+
138+
Buf.cmd := EB_SELECT;
139+
Buf.Point := Event.dbgPoint;
140+
Buf.PointType := PT;
141+
len := 4*sizeof(cardinal);
142+
buf.DataType := Data.data_type;
143+
case Data.data_type of
144+
data_int :
145+
begin
146+
integer(pointer(@buf.data[0])^) := Data.idata;
147+
inc(len, sizeof(integer));
148+
end;
149+
data_real:
150+
begin
151+
real(pointer(@buf.data[0])^) := Data.rdata;
152+
inc(len, sizeof(real));
153+
end;
154+
data_str:
155+
begin
156+
StrLCopy(@buf.data[0], PChar(Data.sdata), 127);
157+
inc(len, min(128, length(Data.sdata)));
158+
end;
159+
data_stream:
160+
begin
161+
s := 'Size: ' + Int2Str(PStream(Data.idata).Size) + ', Position: ' + int2str(PStream(Data.idata).Position);
162+
StrCopy(@buf.data[0], PChar(s));
163+
end;
164+
data_bitmap:
165+
begin
166+
s := 'Size: ' + Int2Str(PBitmap(Data.idata).Width) + 'x' + Int2Str(PBitmap(Data.idata).Height);
167+
StrCopy(@buf.data[0], PChar(s));
168+
end;
169+
data_types:
170+
begin
171+
s := GetTypeString(PType(data.idata));
172+
StrCopy(@buf.data[0], PChar(s));
173+
end;
174+
else ;
175+
end;
176+
Write(Buf,len);
177+
repeat
178+
if Read(rBuf)and ((rBuf.Point = Event.dbgPoint)or(rBuf.Point = $FFFFFFFF)or(rBuf.cmd = EB_RUN)) then
179+
case rBuf.cmd of
180+
EB_TRACE: break;
181+
EB_RUN: _Init := false;
182+
end;
183+
until not _Init;
184+
rBuf.Point := 0;
185+
186+
Buf.cmd := EB_UNSELECT;
187+
Buf.Point := Event.dbgPoint;
188+
Write(Buf,8);
189+
end;
190+
{$endif}
191+
end.

Pascal-Source/If_arg.pas

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
unit If_arg;
2+
3+
interface
4+
5+
uses kol,Share;
6+
7+
function Compare(Op1,Op2:TData; OpType:byte ):boolean;
8+
9+
implementation
10+
11+
function Compare(Op1,Op2:TData; OpType:byte ):boolean;
12+
var
13+
i:integer;
14+
r:real;
15+
s:string;
16+
begin
17+
Result := false;
18+
case _IsType(op1) of
19+
data_int:
20+
begin
21+
i := ToInteger(op2);
22+
case OpType of
23+
0: Result := op1.idata = i;
24+
1: Result := op1.idata < i;
25+
2: Result := op1.idata > i;
26+
3: Result := op1.idata <= i;
27+
4: Result := op1.idata >= i;
28+
5: Result := op1.idata <> i;
29+
end;
30+
end;
31+
data_str:
32+
begin
33+
s := ToString(op2);
34+
case OpType of
35+
0: Result := op1.sdata = s;
36+
1: Result := StrIComp(PChar(op1.sdata), PChar(s)) < 0;
37+
2: Result := StrIComp(PChar(op1.sdata), PChar(s)) > 0;
38+
3: Result := StrIComp(PChar(op1.sdata), PChar(s)) <= 0;
39+
4: Result := StrIComp(PChar(op1.sdata), PChar(s)) >= 0;
40+
5: Result := op1.sdata <> s;
41+
end;
42+
end;
43+
data_real:
44+
begin
45+
r := ToReal(op2);
46+
case OpType of
47+
0: Result := op1.rdata = r;
48+
1: Result := op1.rdata < r;
49+
2: Result := op1.rdata > r;
50+
3: Result := op1.rdata <= r;
51+
4: Result := op1.rdata >= r;
52+
5: Result := op1.rdata <> r;
53+
end;
54+
end;
55+
data_null: Result := _IsType(op2) = data_null;
56+
end;
57+
end;
58+
59+
end.

Pascal-Source/Kol.dcu

611 KB
Binary file not shown.

0 commit comments

Comments
 (0)