Skip to content

Latest commit

 

History

History
271 lines (253 loc) · 7.8 KB

sepmsgs.pas

File metadata and controls

271 lines (253 loc) · 7.8 KB
 
Nov 18, 2000
Nov 18, 2000
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
uses crt,dos;
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
{$M 50000,0,90000} { Declared here suffices for all Units as well! }
{$I rec16e1.pas}
var systatf:file of systatrec;
systat:systatrec;
bf:file of boardrec;
brd:boardrec;
sp:string;
i:integer;
c:char;
abort:boolean;
procedure tc(i:integer);
begin
textcolor(i);
end;
procedure star(s:astr);
begin
tc(9); write('þ ');
tc(11); writeln(s);
end;
procedure ttl(s:string);
begin
writeln;
textcolor(9); write('ÄÄ[');
textbackground(1); textcolor(15);
write(' '+s+' ');
textbackground(0); textcolor(9);
write(']');
repeat write('Ä') until wherex=80;
writeln;
end;
function cstr(i:integer):astr;
var c:astr;
begin
str(i,c);
cstr:=c;
end;
function freek(d:integer):longint; (* See disk space *)
{var r:registers;}
begin
freek:=diskfree(d) div 1024;
{ r.ax:=$3600;
r.dx:=d;
msdos(dos.registers(r));
freek:=trunc(1.0*r.bx*r.ax*r.cx/1024.0);}
end;
function exdrv(s:astr):byte;
begin
s:=fexpand(s);
exdrv:=ord(s[1])-64;
end;
procedure movefile(srcname,destpath:string);
var buffer:array[1..16384] of byte;
dfs,nrec:integer;
src,dest:file;
dd:dirstr;
dn:namestr;
de:extstr;
procedure dodate;
var r:registers;
od,ot,ha:integer;
begin
srcname:=srcname+#0;
destpath:=destpath+#0;
with r do begin
ax:=$3d00; ds:=seg(srcname[1]); dx:=ofs(srcname[1]); msdos(dos.registers(r));
ha:=ax; bx:=ha; ax:=$5700; msdos(dos.registers(r));
od:=dx; ot:=cx; bx:=ha; ax:=$3e00; msdos(dos.registers(r));
ax:=$3d02; ds:=seg(destpath[1]); dx:=ofs(destpath[1]); msdos(dos.registers(r));
ha:=ax; bx:=ha; ax:=$5701; cx:=ot; dx:=od; msdos(dos.registers(r));
ax:=$3e00; bx:=ha; msdos(dos.registers(r));
end;
end;
begin
fsplit(srcname,dd,dn,de);
destpath:=destpath+dn+de;
assign(src,srcname);
{$I-} reset(src,1); {$I+}
if (ioresult<>0) then begin
writeln;
star('"'+srcname+'": File not found.'^G^G);
halt(1);
end else begin
dfs:=freek(exdrv(destpath));
{rcg11172000 don't have LONGfilesize()...}
{if (trunc(longfilesize(src)/1024.0)+1>=dfs) then begin}
if (trunc(filesize(src)/1024.0)+1>=dfs) then begin
writeln;
star('"'+srcname+'": Disk full.');
halt(1);
end else begin
assign(dest,destpath); rewrite(dest,1);
repeat
blockread(src,buffer,16384,nrec);
blockwrite(dest,buffer,nrec);
until (nrec<16384);
close(dest);
close(src);
dodate;
erase(src);
end;
end;
end;
procedure moveprivmail(npath:astr);
var j,k:integer;
s,s1,odir:astr;
mailfile:file of mailrec;
mr:mailrec;
f:file;
lastm,thism:messages; {* keep track of mass-mail duplicates *}
begin
while copy(npath,length(npath),1)='\' do
npath:=copy(npath,1,length(npath)-1);
getdir(0,odir);
{$I-} chdir(npath); {$I+}
if ioresult=0 then begin
chdir(odir);
star('Using existing subdirectory ("'+npath+'")');
end else begin
star('Creating new subdirectory ("'+npath+'")');
{$I-} mkdir(npath); {$I+}
end;
if (ioresult=0) then begin
assign(mailfile,systat.gfilepath+'email.dat');
{$I-} reset(mailfile); {$I+}
if (ioresult=0) then begin
k:=0;
writeln;
for j:=filesize(mailfile)-1 downto 0 do begin {* will sort messages in
* the order of
* newest-->oldest *}
seek(mailfile,j); read(mailfile,mr);
with mr.msg do begin
s:=ltr+cstr(number)+'.'+cstr(ext);
s1:=systat.pmsgpath+s;
thism:=mr.msg;
gotoxy(wherex,wherey-1); clreol;
inc(k);
star('Message file #'+cstr(k)+' of '+
cstr(filesize(mailfile))+': '+npath+'\'+s);
if ((thism.ltr<>lastm.ltr) or
(thism.number<>lastm.number) or
(thism.ext<>lastm.ext)) then begin
assign(f,s1);
{$I-} reset(f); {$I+}
if ioresult=0 then begin
close(f);
movefile(s1,npath+'\');
lastm:=thism;
end else star('File does not exist: '+s1);
lastm:=thism;
end;
end;
end;
close(mailfile);
end else star('Unable to open file: '+systat.gfilepath+'EMAIL.DAT');
end else star('Unable to create subdirectory: '+npath);
end;
procedure movemsgbase(brd:boardrec; npath:astr; i:integer);
var j,k:integer;
s,s1,odir:astr;
f:file;
mary:array[0..200] of messagerec;
begin
while copy(npath,length(npath),1)='\' do
npath:=copy(npath,1,length(npath)-1);
with brd do begin
getdir(0,odir);
{$I-} chdir(npath); {$I+}
if ioresult=0 then begin
chdir(odir);
star('Using existing subdirectory ("'+npath+'")');
end else begin
star('Creating new subdirectory ("'+npath+'")');
{$I-} mkdir(npath); {$I+}
end;
if ioresult=0 then begin
assign(f,systat.gfilepath+brd.filename+'.BRD');
{$I-} reset(f,sizeof(messagerec)); {$I+}
if ioresult=0 then begin
writeln;
blockread(f,mary[0],1);
blockread(f,mary[1],mary[0].message.number);
close(f);
k:=0;
for j:=mary[0].message.number downto 1 do {* will sort messages in
* the order of
* newest-->oldest *}
with mary[j].message do begin
s:=ltr+cstr(number)+'.'+cstr(ext);
s1:=systat.pmsgpath+s;
assign(f,s1);
{$I-} reset(f); {$I+}
if ioresult=0 then begin
close(f);
gotoxy(wherex,wherey-1); clreol;
inc(k);
star('Message file #'+cstr(k)+' of '+
cstr(mary[0].message.number)+': '+npath+'\'+s);
movefile(s1,npath+'\');
end else star('File does not exist: '+s1);
end;
end else star('Unable to open file: '+systat.gfilepath+brd.filename+'.BRD');
end else star('Unable to create subdirectory: '+npath);
end;
end;
begin
getdir(0,sp);
assign(systatf,'status.dat');
reset(systatf); read(systatf,systat); close(systatf);
star('Each message base in Telegard can now occupy its own, seperate directory');
star('path on your drive. Seperating the messages into seperate directorys');
star('will speed up seek-time for messages considerably.');
writeln;
star('This program can do all the work of seperating all the messages');
star('in each base into their own directories.');
writeln;
star('Message directories will be created off of your current Telegard MSGS\');
star('directory according to the *.BRD FILENAMEs of each message base.');
writeln;
star('Example:');
star('"'+systat.pmsgpath+'EMAIL\" for private mail');
star('"'+systat.pmsgpath+'GENERAL\" for message base #1');
star(' (if msg base #1 filename is "GENERAL")');
star('"'+systat.pmsgpath+'MISC\" for message base #2');
star(' (if msg base #2 filename is "MISC")');
star('And so on.');
writeln;
write('Continue and do this? [Yes] : ');
repeat c:=upcase(readkey) until c in ['Y','N',^M];
abort:=(c='N');
writeln(c);
if (abort) then halt;
writeln;
writeln;
ttl('Moving public message bases into seperate directory paths');
assign(bf,systat.gfilepath+'boards.dat');
reset(bf);
for i:=0 to filesize(bf)-1 do begin
seek(bf,i); read(bf,brd);
brd.msgpath:=brd.msgpath+brd.filename+'\';
seek(bf,i); write(bf,brd);
star('Moving messages in '+brd.filename+'.BRD ('+brd.name+') to "'+brd.msgpath+'"');
movemsgbase(brd,brd.msgpath,i+1);
end;
close(bf);
chdir(sp);
ttl('Moving private mail into "'+systat.pmsgpath+'EMAIL\"');
moveprivmail(systat.pmsgpath+'EMAIL\');
systat.pmsgpath:=systat.pmsgpath+'EMAIL\';
rewrite(systatf); write(systatf,systat); close(systatf);
end.