-
Notifications
You must be signed in to change notification settings - Fork 0
/
EMAIL0.PAS
72 lines (60 loc) · 1.58 KB
/
EMAIL0.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{$I DIRECT.INC}
unit email0;
interface
uses gentypes;
procedure readcatalogs(re_init:boolean);
var lastread:integer;
m:mailrec;
incoming,outgoing:^catalogrec;
Implementation
uses dosmem, gensubs, subs1, FileLock;
procedure addcatalog (var c:catalogrec; var m:mailrec; fpos:integer);
begin
m.fileindex:=fpos;
if c.nummail=maxcatalogsize
then c.additional:=c.additional+1
else begin
c.nummail:=c.nummail+1;
c.mail[c.nummail]:=m
end
end;
procedure init_mem;
begin
if incoming = nil then
{dos_}getmem(incoming,sizeof(catalogrec));
if outgoing = nil then
{dos_}getmem(outgoing,sizeof(catalogrec));
fillchar(incoming^,sizeof(catalogrec),0);
fillchar(outgoing^,sizeof(catalogrec),0);
end;
procedure deinit_mem;
begin
if incoming <> nil then
{dos_}freemem(incoming,sizeof(catalogrec));
incoming := nil;
if outgoing <> nil then
{dos_}freemem(outgoing,sizeof(catalogrec));
outgoing := nil;
end;
procedure readcatalogs(re_init:boolean);
var m:mailrec;
cnt:integer;
begin
if re_init then deinit_mem;
if incoming <> nil then exit;
init_mem;
seek (mfile,1);
incoming^.nummail:=0;
incoming^.additional:=0;
outgoing^.nummail:=0;
outgoing^.additional:=0;
for cnt:=1 to filesize(mfile)-1 do begin
nread (mfile,m);
if m.sentto=unum
then addcatalog (incoming^,m,cnt);
if match(m.sentby,unam)
then addcatalog (outgoing^,m,cnt)
end
end;
begin
end.