source: oup/releases/0.19a/src/Unit10_leveldb.pas@ 33

Last change on this file since 33 was 8, checked in by alloc, 18 years ago

Uploaded old revs and structdefs.

File size: 28.1 KB
Line 
1UNIT Unit10_leveldb;
2INTERFACE
3USES
4 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
5 Dialogs, ComCtrls, StdCtrls;
6
7TYPE
8 TForm10 = Class(TForm)
9 group_progress: TGroupBox;
10 progress: TProgressBar;
11 lbl_progress: TLabel;
12 btn_abortok: TButton;
13 lbl_estimation: TLabel;
14 PROCEDURE btn_abortokClick(Sender: TObject);
15 PRIVATE
16 PROCEDURE HandleFile(ext:String; fileid:LongWord; dir_dat2db:Boolean);
17 PROCEDURE stop_convert;
18 PUBLIC
19 PROCEDURE CreateDatabase(FileName:String);
20 END;
21
22
23VAR
24 Form10: TForm10;
25
26IMPLEMENTATION
27{$R *.dfm}
28USES SQLiteTable3, Unit1_main, Unit2_functions, Unit3_data;
29TYPE
30 THandler=PROCEDURE(fileid:LongWord; dir_dat2db:Boolean);
31 TConvertHandlers=RECORD
32 Ext:String[4];
33 needed:Boolean;
34 Handler:THandler;
35 END;
36VAR
37 ConvertHandlers:Array OF TConvertHandlers;
38 loaded_filename:String;
39 converting:Boolean=False;
40 abort:Boolean=False;
41 filestream:TFileStream;
42 dat_stream,mem:TMemoryStream;
43
44PROCEDURE TForm10.HandleFile;
45 VAR
46 i:Byte;
47 BEGIN
48 FOR i:=1 TO Length(ConvertHandlers) DO
49 IF UpperCase(ConvertHandlers[i].Ext)=UpperCase(ext) THEN
50 IF ConvertHandlers[i].needed THEN BEGIN
51 ConvertHandlers[i].Handler(fileid, dir_dat2db);
52 Break;
53 END ELSE
54 Break;
55 END;
56
57PROCEDURE TForm10.CreateDatabase(FileName:String);
58 VAR
59 i,j:LongWord;
60 temps,temps2:String;
61 data:Tdata;
62 absolutebegintime,begintime:Double;
63 step:Byte;
64 CONST
65 steps:Byte=4;
66 PROCEDURE DoStep(stepname:String);
67 BEGIN
68 Inc(step);
69 IF stepname<>'FIN' THEN
70 group_progress.Caption:='Creating DB (Step '+IntToStr(step)+'/'+IntToStr(steps)+': '+stepname+')'
71 ELSE
72 group_progress.Caption:='Creating DB (FINISHED)';
73 END;
74 BEGIN
75 Form10.Visible:=True;
76 Form1.Visible:=False;
77 step:=0;
78 converting:=True;
79 abort:=False;
80 loaded_filename:=FileName;
81 btn_abortok.Caption:='&Abort...';
82 btn_abortok.Default:=False;
83
84 absolutebegintime:=Time;
85
86 DB:=TSQLiteDatabase.Create(FileName);
87 DB.ExecSQL('PRAGMA synchronous = 0;');
88 DB.ExecSQL('PRAGMA temp_store = 2;');
89 DB.ExecSQL('DROP TABLE globals;');
90 DB.ExecSQL('DROP TABLE linkmap;');
91 DB.ExecSQL('DROP TABLE rawmap;');
92 DB.ExecSQL('DROP TABLE datfiles;');
93 DB.ExecSQL('DROP TABLE extlist;');
94 DB.ExecSQL('VACUUM;');
95
96 DoStep('Creating tables');
97 progress.Position:=0;
98 lbl_progress.Caption:='';
99 lbl_estimation.Caption:='Estimated finishing time: unknown';
100 Application.ProcessMessages;
101
102 DB.ExecSQL('CREATE TABLE globals (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR (20), value VARCHAR (50) );');
103 DB.ExecSQL('CREATE TABLE linkmap (id INTEGER PRIMARY KEY AUTOINCREMENT, src_id INTEGER, src_link_offset INTEGER, target_id INTEGER );');
104 DB.ExecSQL('CREATE TABLE rawmap (id INTEGER PRIMARY KEY AUTOINCREMENT, src_id INTEGER, src_link_offset INTEGER, data BLOB );');
105 DB.ExecSQL('CREATE TABLE datfiles (id INTEGER PRIMARY KEY, extension VARCHAR(4), name VARCHAR(128), contenttype INTEGER, data BLOB );');
106 DB.ExecSQL('CREATE TABLE extlist (id INTEGER PRIMARY KEY AUTOINCREMENT, ext VARCHAR(4), ident VARCHAR(16) );');
107
108 DB.ExecSQL('INSERT INTO globals (name,value) VALUES ("dbversion","'+dbversion+'");');
109 SetLength(data,Length(dat_header.Ident));
110 FOR i:=0 TO High(dat_header.Ident) DO data[i]:=dat_header.Ident[i];
111 temps:=CreateHexString(data,True);
112 DB.ExecSQL('INSERT INTO globals (name,value) VALUES ("ident","'+temps+'");');
113 data:=LoadDatFile(0);
114 i:=data[7];
115 i:=i DIV 2;
116 DB.ExecSQL('INSERT INTO globals (name,value) VALUES ("lvl","'+IntToStr(i)+'");');
117
118 DoStep('Writing extensionslist');
119 progress.Max:=dat_header.Extensions;
120 Application.ProcessMessages;
121
122 FOR i:=0 TO dat_header.Extensions-1 DO BEGIN
123 SetLength(data,Length(dat_extensionsmap[i].Ident));
124 FOR j:=0 TO High(dat_extensionsmap[i].Ident) DO data[j]:=dat_extensionsmap[i].Ident[j];
125 temps:=CreateHexString(data,True);
126 temps2:=dat_extensionsmap[i].Extension[3]+dat_extensionsmap[i].Extension[2]+dat_extensionsmap[i].Extension[1]+dat_extensionsmap[i].Extension[0];
127 DB.ExecSQL('INSERT INTO extlist (ext,ident) VALUES ("'+temps2+'","'+temps+'");');
128 progress.Position:=i;
129 lbl_progress.Caption:='Extensions done: '+IntToStr(i)+'/'+IntToStr(dat_header.Extensions);
130 Application.ProcessMessages;
131 IF abort THEN BEGIN
132 stop_convert;
133 Exit;
134 END;
135 END;
136 lbl_progress.Caption:='';
137
138 DoStep('Loading .dat into memory');
139 Application.ProcessMessages;
140
141 progress.Position:=0;
142 lbl_progress.Caption:='Files done: '+IntToStr(0)+'/'+IntToStr(dat_header.Files);
143 lbl_estimation.Caption:='Estimated finishing time: unknown';
144
145 filestream:=TFileStream.Create(dat_filename, fmOpenRead);
146 dat_stream:=TMemoryStream.Create;
147 dat_stream.CopyFrom(filestream,0);
148 dat_stream.Seek(0,soFromBeginning);
149 filestream.Free;
150
151 progress.Max:=dat_header.Files;
152 begintime:=Time;
153 DoStep('Writing .dat-fileslist');
154 Application.ProcessMessages;
155
156 FOR i:=0 TO dat_header.Files-1 DO BEGIN
157 DB.ExecSQL('INSERT INTO datfiles (id,extension,name,contenttype) VALUES ('+IntToStr(i)+',"'+dat_files[i].Extension+'","'+dat_files[i].Name+'","'+IntToHex(dat_files[i].FileType,8)+'");');
158 IF (dat_files[i].FileType AND $02)=0 THEN BEGIN
159 dat_stream.Seek(dat_files[i].DatAddr,soFromBeginning);
160 mem:=TMemoryStream.Create;
161 mem.CopyFrom(dat_stream,dat_files[i].Size);
162 mem.Seek(0,soFromBeginning);
163 DB.UpdateBlob('UPDATE datfiles SET data = ? WHERE id='+IntToStr(i)+';',mem);
164 HandleFile(dat_files[i].Extension,i,True);
165 mem.Free;
166 END;
167 IF ( (i MOD 50)=0 ) AND (i>=100) THEN
168 lbl_estimation.Caption:='Estimated finishing time: '+TimeToStr((Time-begintime)/i*dat_header.Files+begintime);
169 IF (i MOD 5)=0 THEN BEGIN
170 progress.Position:=i;
171 lbl_progress.Caption:='Files done: '+IntToStr(i)+'/'+IntToStr(dat_header.Files);
172 Application.ProcessMessages;
173 END;
174 IF abort THEN BEGIN
175 stop_convert;
176 Exit;
177 END;
178 END;
179 progress.Position:=dat_header.Files;
180 lbl_progress.Caption:='Files done: '+IntToStr(dat_header.Files)+'/'+IntToStr(dat_header.Files);
181 lbl_estimation.Caption:='FINISHED (duration: '+TimeToStr(Time-absolutebegintime)+')';
182
183 DoStep('FIN');
184 btn_abortok.Caption:='&OK';
185 btn_abortok.Default:=True;
186
187 loaded_filename:='';
188 converting:=False;
189 dat_stream.Free;
190 DB.Free;
191 END;
192
193PROCEDURE TForm10.stop_convert;
194 BEGIN
195 btn_abortok.Caption:='&Close';
196 btn_abortok.Default:=True;
197 converting:=False;
198 lbl_estimation.Caption:='ABORTED';
199 group_progress.Caption:='Creating DB (ABORTED)';
200 IF MessageBox(Self.Handle, PChar('Delete the unfinished DB-file?'), PChar('Delete file?'), MB_YESNO)=IDYES THEN BEGIN
201 DB.Free;
202 DeleteFile(loaded_filename);
203 END;
204 END;
205
206PROCEDURE TForm10.btn_abortokClick(Sender: TObject);
207 BEGIN
208 IF converting THEN BEGIN
209 IF MessageBox(Self.Handle, PChar('Do you really want to cancel the convert-progress?'), PChar('Warning: Converting'), MB_YESNO)=IDYES THEN
210 abort:=True;
211 END ELSE BEGIN
212 Form10.Visible:=False;
213 Form1.Visible:=True;
214 END;
215 END;
216
217
218PROCEDURE LoadFilePart(offset,size:LongWord; target:Pointer);
219 BEGIN
220 mem.Seek(offset,soFromBeginning);
221 mem.Read(target^,size);
222 END;
223
224PROCEDURE InsertDatLinkToDB(fileid:LongWord; offset:LongWord);
225 VAR
226 link:LongWord;
227 BEGIN
228 LoadFilePart(offset,4,@link);
229 IF link=0 THEN
230 link:=$FFFFFFFF
231 ELSE
232 link:=link DIV 256;
233 DB.ExecSQL('INSERT INTO linkmap (src_id,src_link_offset,target_id) VALUES ('+IntToStr(fileid)+','+IntToStr(offset)+','+IntToStr(link)+');');
234 END;
235
236PROCEDURE InsertRawFileToDB(fileid:LongWord; src_offset,raw_addr,size:LongWord);
237 VAR
238 localmem:TMemoryStream;
239 BEGIN
240 localmem:=TMemoryStream.Create;
241 filestream:=TFileStream.Create(raw_filename,fmOpenRead);
242 filestream.Seek(raw_addr,soFromBeginning);
243 localmem.CopyFrom(filestream,size);
244 filestream.Free;
245 DB.ExecSQL('INSERT INTO rawmap (src_id,src_link_offset) VALUES ('+IntToStr(fileid)+','+IntToStr(src_offset)+');');
246 DB.UpdateBlob('UPDATE rawmap SET data = ? WHERE src_id='+IntToStr(fileid),localmem);
247 localmem.Free;
248 END;
249
250
251
252PROCEDURE AGDB(fileid:LongWord; dir_dat2db:Boolean);
253 VAR
254 link:LongWord;
255 links:LongWord;
256 i:LongWord;
257 BEGIN
258 IF dir_dat2db THEN BEGIN
259 LoadFilePart($1C,4,@links);
260 links:=links*2;
261 FOR i:=0 TO links-1 DO BEGIN
262 LoadFilePart($20+i*4,4,@link);
263 InsertRawFileToDB(fileid,$20+i*4,link,1{????????????????????????????????});
264 END;
265 END ELSE BEGIN
266 END;
267 END;
268PROCEDURE AKEV(fileid:LongWord; dir_dat2db:Boolean);
269 VAR
270 i:LongWord;
271 BEGIN
272 IF dir_dat2db THEN BEGIN
273 FOR i:=0 TO 16 DO InsertDatLinkToDB(fileid,$8+i*4);
274 END ELSE BEGIN
275 END;
276 END;
277PROCEDURE AKOT(fileid:LongWord; dir_dat2db:Boolean);
278 VAR
279 i:LongWord;
280 BEGIN
281 IF dir_dat2db THEN BEGIN
282 FOR i:=0 TO 4 DO InsertDatLinkToDB(fileid,$8+i*4);
283 END ELSE BEGIN
284 END;
285 END;
286PROCEDURE BINA(fileid:LongWord; dir_dat2db:Boolean);
287 VAR
288 link:LongWord;
289 datasize:LongWord;
290 BEGIN
291 IF dir_dat2db THEN BEGIN
292 LoadFilePart($0C,4,@link);
293 LoadFilePart($08,4,@datasize);
294 InsertRawFileToDB(fileid,$0C,link,datasize);
295 END ELSE BEGIN
296 END;
297 END;
298PROCEDURE CBPI(fileid:LongWord; dir_dat2db:Boolean);
299 VAR
300 i:LongWord;
301 BEGIN
302 IF dir_dat2db THEN BEGIN
303 FOR i:=0 TO 56 DO InsertDatLinkToDB(fileid,$8+i*4);
304 END ELSE BEGIN
305 END;
306 END;
307PROCEDURE CBPM(fileid:LongWord; dir_dat2db:Boolean);
308 VAR
309 i:LongWord;
310 BEGIN
311 IF dir_dat2db THEN BEGIN
312 FOR i:=0 TO 18 DO InsertDatLinkToDB(fileid,$8+i*4);
313 END ELSE BEGIN
314 END;
315 END;
316PROCEDURE CONS(fileid:LongWord; dir_dat2db:Boolean);
317 VAR
318 i:LongWord;
319 BEGIN
320 IF dir_dat2db THEN BEGIN
321 FOR i:=0 TO 1 DO InsertDatLinkToDB(fileid,$24+i*4);
322 END ELSE BEGIN
323 END;
324 END;
325PROCEDURE CRSA(fileid:LongWord; dir_dat2db:Boolean);
326 VAR
327 packages:LongWord;
328 i:LongWord;
329 BEGIN
330 IF dir_dat2db THEN BEGIN
331 LoadFilePart($14,4,@packages);
332 IF packages>0 THEN
333 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*1100+$A0);
334 END ELSE BEGIN
335 END;
336 END;
337PROCEDURE DOOR(fileid:LongWord; dir_dat2db:Boolean);
338 BEGIN
339 IF dir_dat2db THEN BEGIN
340 InsertDatLinkToDB(fileid,$08);
341 InsertDatLinkToDB(fileid,$10);
342 END ELSE BEGIN
343 END;
344 END;
345PROCEDURE DPGE(fileid:LongWord; dir_dat2db:Boolean);
346 BEGIN
347 IF dir_dat2db THEN BEGIN
348 InsertDatLinkToDB(fileid,$40);
349 END ELSE BEGIN
350 END;
351 END;
352PROCEDURE HPGE(fileid:LongWord; dir_dat2db:Boolean);
353 BEGIN
354 IF dir_dat2db THEN BEGIN
355 InsertDatLinkToDB(fileid,$0C);
356 END ELSE BEGIN
357 END;
358 END;
359PROCEDURE IGHH(fileid:LongWord; dir_dat2db:Boolean);
360 BEGIN
361 IF dir_dat2db THEN BEGIN
362 InsertDatLinkToDB(fileid,$24);
363 InsertDatLinkToDB(fileid,$28);
364 END ELSE BEGIN
365 END;
366 END;
367PROCEDURE IGPA(fileid:LongWord; dir_dat2db:Boolean);
368 VAR
369 links:LongWord;
370 i:LongWord;
371 BEGIN
372 IF dir_dat2db THEN BEGIN
373 LoadFilePart($1C,4,@links);
374 IF links>0 THEN
375 FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
376 END ELSE BEGIN
377 END;
378 END;
379PROCEDURE IGPG(fileid:LongWord; dir_dat2db:Boolean);
380 VAR
381 i:LongWord;
382 BEGIN
383 IF dir_dat2db THEN BEGIN
384 FOR i:=0 TO 1 DO InsertDatLinkToDB(fileid,$1C+i*4);
385 END ELSE BEGIN
386 END;
387 END;
388PROCEDURE IGSA(fileid:LongWord; dir_dat2db:Boolean);
389 VAR
390 links:LongWord;
391 i:LongWord;
392 BEGIN
393 IF dir_dat2db THEN BEGIN
394 LoadFilePart($1C,4,@links);
395 IF links>0 THEN
396 FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
397 END ELSE BEGIN
398 END;
399 END;
400PROCEDURE IMPT(fileid:LongWord; dir_dat2db:Boolean);
401 BEGIN
402 IF dir_dat2db THEN BEGIN
403 InsertDatLinkToDB(fileid,$10);
404 END ELSE BEGIN
405 END;
406 END;
407PROCEDURE IPGE(fileid:LongWord; dir_dat2db:Boolean);
408 BEGIN
409 IF dir_dat2db THEN BEGIN
410 InsertDatLinkToDB(fileid,$0C);
411 END ELSE BEGIN
412 END;
413 END;
414PROCEDURE KEYI(fileid:LongWord; dir_dat2db:Boolean);
415 VAR
416 i:LongWord;
417 BEGIN
418 IF dir_dat2db THEN BEGIN
419 FOR i:=0 TO 9 DO InsertDatLinkToDB(fileid,$08+i*4);
420 END ELSE BEGIN
421 END;
422 END;
423PROCEDURE M3GA(fileid:LongWord; dir_dat2db:Boolean);
424 VAR
425 links:LongWord;
426 i:LongWord;
427 BEGIN
428 IF dir_dat2db THEN BEGIN
429 LoadFilePart($1C,4,@links);
430 IF links>0 THEN
431 FOR i:=0 TO links-1 DO InsertDatLinkToDB(fileid,$20+i*4);
432 END ELSE BEGIN
433 END;
434 END;
435PROCEDURE M3GM(fileid:LongWord; dir_dat2db:Boolean);
436 VAR
437 i:LongWord;
438 BEGIN
439 IF dir_dat2db THEN BEGIN
440 FOR i:=0 TO 6 DO InsertDatLinkToDB(fileid,$0C+i*4);
441 END ELSE BEGIN
442 END;
443 END;
444PROCEDURE MTRL(fileid:LongWord; dir_dat2db:Boolean);
445 BEGIN
446 IF dir_dat2db THEN BEGIN
447 InsertDatLinkToDB(fileid,$10);
448 END ELSE BEGIN
449 END;
450 END;
451PROCEDURE OBOA(fileid:LongWord; dir_dat2db:Boolean);
452 VAR
453 packages:Word;
454 i:LongWord;
455 BEGIN
456 IF dir_dat2db THEN BEGIN
457 LoadFilePart($1E,2,@packages);
458 IF packages>0 THEN
459 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*240);
460 END ELSE BEGIN
461 END;
462 END;
463PROCEDURE OFGA(fileid:LongWord; dir_dat2db:Boolean);
464 VAR
465 packages:LongWord;
466 i:LongWord;
467 BEGIN
468 IF dir_dat2db THEN BEGIN
469 LoadFilePart($1C,4,@packages);
470 IF packages>0 THEN
471 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*12+$04);
472 END ELSE BEGIN
473 END;
474 END;
475PROCEDURE ONCC(fileid:LongWord; dir_dat2db:Boolean);
476 VAR
477 i:LongWord;
478 BEGIN
479 IF dir_dat2db THEN BEGIN
480 END ELSE BEGIN
481 END;
482 END;
483PROCEDURE ONCV(fileid:LongWord; dir_dat2db:Boolean);
484 BEGIN
485 IF dir_dat2db THEN BEGIN
486 InsertDatLinkToDB(fileid,$08);
487 END ELSE BEGIN
488 END;
489 END;
490PROCEDURE ONLV(fileid:LongWord; dir_dat2db:Boolean);
491 VAR
492 i:LongWord;
493 BEGIN
494 IF dir_dat2db THEN BEGIN
495 FOR i:=0 TO 5 DO InsertDatLinkToDB(fileid,$48+i*4);
496 FOR i:=0 TO 5 DO InsertDatLinkToDB(fileid,$64+i*4);
497 InsertDatLinkToDB(fileid,$300);
498 END ELSE BEGIN
499 END;
500 END;
501PROCEDURE ONOA(fileid:LongWord; dir_dat2db:Boolean);
502 VAR
503 packages:LongWord;
504 i:LongWord;
505 BEGIN
506 IF dir_dat2db THEN BEGIN
507 LoadFilePart($1C,4,@packages);
508 IF packages>0 THEN
509 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*8+$04);
510 END ELSE BEGIN
511 END;
512 END;
513PROCEDURE ONSK(fileid:LongWord; dir_dat2db:Boolean);
514 BEGIN
515 IF dir_dat2db THEN BEGIN
516 InsertDatLinkToDB(fileid,$08);
517 InsertDatLinkToDB(fileid,$0C);
518 InsertDatLinkToDB(fileid,$10);
519 InsertDatLinkToDB(fileid,$14);
520 InsertDatLinkToDB(fileid,$18);
521 InsertDatLinkToDB(fileid,$20);
522 InsertDatLinkToDB(fileid,$44);
523 END ELSE BEGIN
524 END;
525 END;
526PROCEDURE ONVL(fileid:LongWord; dir_dat2db:Boolean);
527 VAR
528 packages:LongWord;
529 i:LongWord;
530 BEGIN
531 IF dir_dat2db THEN BEGIN
532 LoadFilePart($1C,4,@packages);
533 IF packages>0 THEN
534 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
535 END ELSE BEGIN
536 END;
537 END;
538PROCEDURE ONWC(fileid:LongWord; dir_dat2db:Boolean);
539 BEGIN
540 IF dir_dat2db THEN BEGIN
541 InsertDatLinkToDB(fileid,$28);
542 InsertDatLinkToDB(fileid,$34);
543 InsertDatLinkToDB(fileid,$54);
544 InsertDatLinkToDB(fileid,$58);
545 InsertDatLinkToDB(fileid,$5C);
546 InsertDatLinkToDB(fileid,$60);
547 InsertDatLinkToDB(fileid,$6FC);
548 InsertDatLinkToDB(fileid,$700);
549 END ELSE BEGIN
550 END;
551 END;
552PROCEDURE OPGE(fileid:LongWord; dir_dat2db:Boolean);
553 BEGIN
554 IF dir_dat2db THEN BEGIN
555 InsertDatLinkToDB(fileid,$1C);
556 END ELSE BEGIN
557 END;
558 END;
559PROCEDURE OSBD(fileid:LongWord; dir_dat2db:Boolean);
560 VAR
561 link:LongWord;
562 datasize:LongWord;
563 BEGIN
564 IF dir_dat2db THEN BEGIN
565 LoadFilePart($08,4,@datasize);
566 LoadFilePart($0C,4,@link);
567 InsertRawFileToDB(fileid,$0C,link,datasize);
568 END ELSE BEGIN
569 END;
570 END;
571PROCEDURE PSPC(fileid:LongWord; dir_dat2db:Boolean);
572 BEGIN
573 IF dir_dat2db THEN BEGIN
574 InsertDatLinkToDB(fileid,$50);
575 END ELSE BEGIN
576 END;
577 END;
578PROCEDURE PSPL(fileid:LongWord; dir_dat2db:Boolean);
579 VAR
580 packages:LongWord;
581 i:LongWord;
582 BEGIN
583 IF dir_dat2db THEN BEGIN
584 LoadFilePart($1C,4,@packages);
585 IF packages>0 THEN
586 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$24+i*8);
587 END ELSE BEGIN
588 END;
589 END;
590PROCEDURE PSUI(fileid:LongWord; dir_dat2db:Boolean);
591 VAR
592 i:LongWord;
593 BEGIN
594 IF dir_dat2db THEN BEGIN
595 FOR i:=0 TO 43 DO InsertDatLinkToDB(fileid,$08+i*4);
596 END ELSE BEGIN
597 END;
598 END;
599PROCEDURE SNDD(fileid:LongWord; dir_dat2db:Boolean);
600 VAR
601 link:LongWord;
602 datasize:LongWord;
603 BEGIN
604 IF dir_dat2db THEN BEGIN
605 LoadFilePart($40,4,@datasize);
606 LoadFilePart($44,4,@link);
607 InsertRawFileToDB(fileid,$44,link,datasize);
608 END ELSE BEGIN
609 END;
610 END;
611PROCEDURE SUBT(fileid:LongWord; dir_dat2db:Boolean);
612 VAR
613 baselink,link:LongWord;
614 links:LongWord;
615 i,j:LongWord;
616 data:Tdata;
617 BEGIN
618 IF dir_dat2db THEN BEGIN
619 LoadFilePart($18,4,@baselink);
620 LoadFilePart($1C,4,@links);
621 IF links>0 THEN BEGIN
622 FOR i:=0 TO links-1 DO BEGIN
623 LoadFilePart($20+i*4,4,@link);
624 SetLength(data,1024);
625 LoadRawFilePart(baselink+link,1024,@data[0]);
626 FOR j:=0 TO 1024 DO BEGIN
627 IF data[j]=$00 THEN Break;
628 END;
629 IF j<1024 THEN
630 InsertRawFileToDB(fileid,$20+i*4,baselink+link,j)
631 ELSE
632 ShowMessage('Error: Didn''t find message-end-marker...');
633 END;
634 END;
635 END ELSE BEGIN
636 END;
637 END;
638PROCEDURE STNA(fileid:LongWord; dir_dat2db:Boolean);
639 VAR
640 packages:Word;
641 i:LongWord;
642 BEGIN
643 IF dir_dat2db THEN BEGIN
644 LoadFilePart($1E,2,@packages);
645 IF packages>0 THEN
646 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
647 END ELSE BEGIN
648 END;
649 END;
650PROCEDURE TRAC(fileid:LongWord; dir_dat2db:Boolean);
651 VAR
652 packages:Word;
653 i:LongWord;
654 BEGIN
655 IF dir_dat2db THEN BEGIN
656 InsertDatLinkToDB(fileid,$18);
657 LoadFilePart($1E,2,@packages);
658 IF packages>0 THEN
659 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*12+8);
660 END ELSE BEGIN
661 END;
662 END;
663PROCEDURE TRAM(fileid:LongWord; dir_dat2db:Boolean);
664 VAR
665 i:Byte;
666 link:LongWord;
667 BEGIN
668 IF dir_dat2db THEN BEGIN
669 FOR i:=0 TO 11 DO BEGIN
670 LoadFilePart($0C+i*4,4,@link);
671 InsertRawFileToDB(fileid,$0C+i*4,link,1{????????????????????????????????});
672 END;
673 LoadFilePart($13C,4,@link);
674 InsertRawFileToDB(fileid,$13C,link,1{????????????????????????????????});
675 END ELSE BEGIN
676 END;
677 END;
678PROCEDURE TRAS(fileid:LongWord; dir_dat2db:Boolean);
679 BEGIN
680 IF dir_dat2db THEN BEGIN
681 InsertDatLinkToDB(fileid,$08);
682 END ELSE BEGIN
683 END;
684 END;
685PROCEDURE TRBS(fileid:LongWord; dir_dat2db:Boolean);
686 VAR
687 i:LongWord;
688 BEGIN
689 IF dir_dat2db THEN BEGIN
690 FOR i:=0 TO 4 DO InsertDatLinkToDB(fileid,$08+i*4);
691 END ELSE BEGIN
692 END;
693 END;
694PROCEDURE TRCM(fileid:LongWord; dir_dat2db:Boolean);
695 VAR
696 i:LongWord;
697 BEGIN
698 IF dir_dat2db THEN BEGIN
699 FOR i:=0 TO 2 DO InsertDatLinkToDB(fileid,$5C+i*4);
700 END ELSE BEGIN
701 END;
702 END;
703PROCEDURE TRGA(fileid:LongWord; dir_dat2db:Boolean);
704 VAR
705 i:LongWord;
706 packages:Word;
707 BEGIN
708 IF dir_dat2db THEN BEGIN
709 LoadFilePart($1E,2,@packages);
710 IF packages>0 THEN
711 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
712 END ELSE BEGIN
713 END;
714 END;
715PROCEDURE TRGE(fileid:LongWord; dir_dat2db:Boolean);
716 BEGIN
717 IF dir_dat2db THEN BEGIN
718 InsertDatLinkToDB(fileid,$20);
719 END ELSE BEGIN
720 END;
721 END;
722PROCEDURE TRIG(fileid:LongWord; dir_dat2db:Boolean);
723 BEGIN
724 IF dir_dat2db THEN BEGIN
725 InsertDatLinkToDB(fileid,$18);
726 InsertDatLinkToDB(fileid,$24);
727 InsertDatLinkToDB(fileid,$28);
728 END ELSE BEGIN
729 END;
730 END;
731PROCEDURE TRMA(fileid:LongWord; dir_dat2db:Boolean);
732 VAR
733 i:LongWord;
734 packages:Word;
735 BEGIN
736 IF dir_dat2db THEN BEGIN
737 LoadFilePart($1E,2,@packages);
738 IF packages>0 THEN
739 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
740 END ELSE BEGIN
741 END;
742 END;
743PROCEDURE TRSC(fileid:LongWord; dir_dat2db:Boolean);
744 VAR
745 i:LongWord;
746 packages:Word;
747 BEGIN
748 IF dir_dat2db THEN BEGIN
749 LoadFilePart($1E,2,@packages);
750 IF packages>0 THEN
751 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
752 END ELSE BEGIN
753 END;
754 END;
755PROCEDURE TSFF(fileid:LongWord; dir_dat2db:Boolean);
756 VAR
757 i:LongWord;
758 packages:LongWord;
759 BEGIN
760 IF dir_dat2db THEN BEGIN
761 LoadFilePart($1C,4,@packages);
762 IF packages>0 THEN
763 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
764 END ELSE BEGIN
765 END;
766 END;
767PROCEDURE TSFT(fileid:LongWord; dir_dat2db:Boolean);
768 BEGIN
769 IF dir_dat2db THEN BEGIN
770 InsertDatLinkToDB(fileid,$1C);
771 END ELSE BEGIN
772 END;
773 END;
774PROCEDURE TURR(fileid:LongWord; dir_dat2db:Boolean);
775 BEGIN
776 IF dir_dat2db THEN BEGIN
777 InsertDatLinkToDB(fileid,$60);
778 InsertDatLinkToDB(fileid,$6C);
779 InsertDatLinkToDB(fileid,$74);
780 END ELSE BEGIN
781 END;
782 END;
783PROCEDURE TXAN(fileid:LongWord; dir_dat2db:Boolean);
784 VAR
785 i:LongWord;
786 packages:LongWord;
787 BEGIN
788 IF dir_dat2db THEN BEGIN
789 LoadFilePart($1C,4,@packages);
790 IF packages>0 THEN
791 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
792 END ELSE BEGIN
793 END;
794 END;
795PROCEDURE TXMA(fileid:LongWord; dir_dat2db:Boolean);
796 VAR
797 i:LongWord;
798 packages:LongWord;
799 BEGIN
800 IF dir_dat2db THEN BEGIN
801 LoadFilePart($1C,4,@packages);
802 IF packages>0 THEN
803 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
804 END ELSE BEGIN
805 END;
806 END;
807PROCEDURE TXMB(fileid:LongWord; dir_dat2db:Boolean);
808 VAR
809 i:LongWord;
810 packages:LongWord;
811 BEGIN
812 IF dir_dat2db THEN BEGIN
813 LoadFilePart($1C,4,@packages);
814 IF packages>0 THEN
815 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
816 END ELSE BEGIN
817 END;
818 END;
819PROCEDURE TXMP(fileid:LongWord; dir_dat2db:Boolean);
820 VAR
821 link:LongWord;
822 x,y:Word;
823 storetype:Byte;
824 datasize:LongWord;
825 BEGIN
826 IF dir_dat2db THEN BEGIN
827 LoadFilePart($8C,SizeOf(x),@x);
828 LoadFilePart($8E,SizeOf(y),@y);
829 LoadFilePart($90,SizeOf(storetype),@storetype);
830 LoadFilePart($9C,4,@link);
831 CASE storetype OF
832 0,1,2: datasize:=x*y*2;
833 8: datasize:=x*y*4;
834 9: datasize:=x*y DIV 2;
835 END;
836 InsertRawFileToDB(fileid,$9C,link,datasize);
837 InsertDatLinkToDB(fileid,$94);
838 InsertDatLinkToDB(fileid,$98);
839 END ELSE BEGIN
840 END;
841 END;
842PROCEDURE TXTC(fileid:LongWord; dir_dat2db:Boolean);
843 BEGIN
844 IF dir_dat2db THEN BEGIN
845 InsertDatLinkToDB(fileid,$08);
846 END ELSE BEGIN
847 END;
848 END;
849PROCEDURE WMCL(fileid:LongWord; dir_dat2db:Boolean);
850 BEGIN
851 IF dir_dat2db THEN BEGIN
852 InsertDatLinkToDB(fileid,$24);
853 END ELSE BEGIN
854 END;
855 END;
856PROCEDURE WMMB(fileid:LongWord; dir_dat2db:Boolean);
857 VAR
858 i:LongWord;
859 packages:LongWord;
860 BEGIN
861 IF dir_dat2db THEN BEGIN
862 LoadFilePart($1C,4,@packages);
863 IF packages>0 THEN
864 FOR i:=0 TO packages-1 DO InsertDatLinkToDB(fileid,$20+i*4);
865 END ELSE BEGIN
866 END;
867 END;
868PROCEDURE WPGE(fileid:LongWord; dir_dat2db:Boolean);
869 BEGIN
870 IF dir_dat2db THEN BEGIN
871 InsertDatLinkToDB(fileid,$08);
872 InsertDatLinkToDB(fileid,$0C);
873 END ELSE BEGIN
874 END;
875 END;
876
877PROCEDURE InsertHandler(ext:String; needed:Boolean; handler:THandler);
878 BEGIN
879 SetLength(ConvertHandlers,Length(ConvertHandlers)+1);
880 ConvertHandlers[High(ConvertHandlers)].Ext:=ext;
881 ConvertHandlers[High(ConvertHandlers)].needed:=needed;
882 ConvertHandlers[High(ConvertHandlers)].handler:=handler;
883 END;
884
885BEGIN
886 InsertHandler('ABNA',False,NIL);
887// InsertHandler('AGDB',True,AGDB);
888 InsertHandler('AGDB',False,NIL);
889 InsertHandler('AGQC',False,NIL);
890 InsertHandler('AGQG',False,NIL);
891 InsertHandler('AGQR',False,NIL);
892 InsertHandler('AISA',False,NIL);
893 InsertHandler('AITR',False,NIL);
894 InsertHandler('AKAA',False,NIL);
895 InsertHandler('AKBA',False,NIL);
896 InsertHandler('AKBP',False,NIL);
897 InsertHandler('AKDA',False,NIL);
898 InsertHandler('AKEV',True,AKEV);
899 InsertHandler('AKOT',True,AKOT);
900 InsertHandler('AKVA',False,NIL);
901 InsertHandler('BINA',True,BINA);
902 InsertHandler('CBPI',True,CBPI);
903 InsertHandler('CBPM',True,CBPM);
904 InsertHandler('CONS',True,CONS);
905 InsertHandler('CRSA',True,CRSA);
906 InsertHandler('DOOR',True,DOOR);
907 InsertHandler('DPGE',True,DPGE);
908 InsertHandler('ENVP',False,NIL);
909 InsertHandler('FILM',False,NIL);
910 InsertHandler('HPGE',True,HPGE);
911 InsertHandler('IDXA',False,NIL);
912 InsertHandler('IGHH',True,IGHH);
913 InsertHandler('IGPA',True,IGPA);
914 InsertHandler('IGPG',True,IGPG);
915 InsertHandler('IGSA',True,IGSA);
916 InsertHandler('IMPT',True,IMPT);
917 InsertHandler('IPGE',True,IPGE);
918 InsertHandler('KEYI',True,KEYI);
919 InsertHandler('M3GA',True,M3GA);
920 InsertHandler('M3GM',True,M3GM);
921 InsertHandler('MTRL',True,MTRL);
922 InsertHandler('OBAN',False,NIL);
923 InsertHandler('OBDC',False,NIL);
924 InsertHandler('OBOA',True,OBOA);
925 InsertHandler('OFGA',True,OFGA);
926 InsertHandler('ONCC',True,ONCC);
927 InsertHandler('ONCP',False,NIL);
928 InsertHandler('ONCV',True,ONCV);
929 InsertHandler('ONFA',False,NIL);
930 InsertHandler('ONGS',False,NIL);
931 InsertHandler('ONIA',False,NIL);
932 InsertHandler('ONLD',False,NIL);
933 InsertHandler('ONLV',True,ONLV);
934 InsertHandler('ONMA',False,NIL);
935 InsertHandler('ONOA',True,ONOA);
936 InsertHandler('ONSA',False,NIL);
937 InsertHandler('ONSK',True,ONSK);
938 InsertHandler('ONTA',False,NIL);
939 InsertHandler('ONVL',True,ONVL);
940 InsertHandler('ONWC',True,ONWC);
941 InsertHandler('OPGE',True,OPGE);
942 InsertHandler('OSBD',True,OSBD);
943 InsertHandler('OTIT',False,NIL);
944 InsertHandler('OTLF',False,NIL);
945 InsertHandler('PLEA',False,NIL);
946 InsertHandler('PNTA',False,NIL);
947 InsertHandler('PSPC',True,PSPC);
948 InsertHandler('PSPL',True,PSPL);
949 InsertHandler('PSUI',True,PSUI);
950 InsertHandler('QTNA',False,NIL);
951 InsertHandler('SNDD',True,SNDD);
952 InsertHandler('STNA',True,STNA);
953 InsertHandler('SUBT',True,SUBT);
954 InsertHandler('TRAC',True,TRAC);
955 InsertHandler('TRAM',True,TRAM);
956 InsertHandler('TRAS',True,TRAS);
957 InsertHandler('TRBS',True,TRBS);
958 InsertHandler('TRCM',True,TRCM);
959 InsertHandler('TRGA',True,TRGA);
960 InsertHandler('TRGE',True,TRGE);
961 InsertHandler('TRIA',False,NIL);
962 InsertHandler('TRIG',True,TRIG);
963 InsertHandler('TRMA',True,TRMA);
964 InsertHandler('TRSC',True,TRSC);
965 InsertHandler('TRTA',False,NIL);
966 InsertHandler('TSFF',True,TSFF);
967 InsertHandler('TSFL',False,NIL);
968 InsertHandler('TSFT',True,TSFT);
969 InsertHandler('TSGA',False,NIL);
970 InsertHandler('TSTR',False,NIL);
971 InsertHandler('TURR',True,TURR);
972 InsertHandler('TXAN',True,TXAN);
973 InsertHandler('TXCA',False,NIL);
974 InsertHandler('TXMA',True,TXMA);
975 InsertHandler('TXMB',True,TXMB);
976 InsertHandler('TXMP',True,TXMP);
977 InsertHandler('TXTC',True,TXTC);
978 InsertHandler('VCRA',False,NIL);
979 InsertHandler('WMCL',True,WMCL);
980 InsertHandler('WMDD',False,NIL);
981 InsertHandler('WMM_',False,NIL);
982 InsertHandler('WMMB',True,WMMB);
983 InsertHandler('WPGE',True,WPGE);
984END.
Note: See TracBrowser for help on using the repository browser.