home *** CD-ROM | disk | FTP | other *** search
- {$A+,B+,D+,E-,F-,G+,I-,L+,N-,O-,R-,S-,V-,X-}
- {$M 16384,0,300000}
- program CalcCRC32;
-
- { A quick and dirty hack for the MAKETIC batch file }
- { SRC can be freely used.... if you have the same units :-(( }
-
- uses dos, ansi_crc, tpdos, dosv2, netzwerk, utils;
-
- const MAGICFILE = 'MAGIC.DAT';
- FILEIDDIZ = 'FILE_ID.DIZ';
-
- var CRC : PCrc;
- lChk : LongInt;
- szFile : String;
- magic : String;
- replaces : String;
- lZeit : LongInt;
-
- { ######################################################################### }
-
- Procedure Fileid_Diz; { scanns the file_id.diz for entrys }
-
- var hIn : Text;
- szLine : String;
- bFirst : Boolean;
-
- begin { Fileid_Diz }
- if not exists(FILEIDDIZ) then exit;
- assign(hIn, FILEIDDIZ);
- if ioresult <> 0 then exit;
- reset(hIn);
- bFirst := FALSE;
-
- repeat
- readln(hIn, szLine);
- if not bFirst then
- begin
- writeln('DESC ',szLine);
- bFirst := TRUE;
- end;
- writeln('LDESC ',szLine);
- until eof(hIn);
- close(hIn);
-
- end; { Fileid_Diz }
-
- { ----[ FileLength ]----------------------------------------------------- }
-
- function FileLength(szFile: String) : LongInt;
-
- var f : File;
- l : LongInt;
-
- begin
- FileLength := 0;
- l := 0;
-
- assign(f, szFile);
- if ioresult <> 0 then exit;
- reset(f,1);
- if ioresult = 0 then l := FileSize(f);
- close(f);
-
- FileLength := l;
-
- end;
-
- { ######################################################################### }
-
- function GetMagic(szWhat: String) : String;
-
- var szFile : String;
- hIn : Text;
- szWork : String;
- found : String;
- t : Byte;
-
- label breakit;
-
- begin { GetMagic }
-
- GetMagic := '';
- found := '';
-
- if not existonpath(MAGICFILE, szFile) then goto breakit;
-
- assign(hIn, szFile);
- reset(hIn);
-
- while not (eof(hIn)) do
- begin
- readln(hIn, szWork);
- t := pos(' ', szWork);
- if copy(szWork, 1, t-1) = szWhat
- then found := copy(szWork, t+1, 255);
- end;
-
- close(hIn);
-
- breakit:
- if found = '' then
- begin
- write('■ Enter MAGIC for ',szWhat,': ');
- readln(found);
- found := KillSpace(upper(found));
- if found <> '' then
- begin
- assign(hIn, szFile);
- append(hIn);
- writeln(hIn, szWhat,' ', found);
- close(hIn);
- end;
- end;
-
- GetMagic := found;
- end; { GetMagic }
-
- { ######################################################################### }
-
- function ReplaceMagic(filename: String; oldMagic: String) : String;
-
- var szFile : String;
- hIn : Text;
- szWork : String;
- found : String;
- t : Byte;
-
- begin { ReplaceMagic }
-
- ReplaceMagic := '';
- found := '';
-
- if not existonpath(MAGICFILE, szFile) then exit;
-
- assign(hIn, szFile);
- reset(hIn);
-
- while not (eof(hIn)) do
- begin
- readln(hIn, szWork);
- t := pos(' ', szWork);
- if (KillSpace(copy(szWork, t+1, 255)) = oldMagic)
- and (copy(szWork, 1, t-1) <> filename)
- then found := copy(szWork, 1, t-1);
- end;
-
- close(hIn);
-
- ReplaceMagic := found;
-
- end; { ReplaceMagic }
-
- function todec(iTmp :integer) : String;
-
- var szT : String;
-
- begin
- str(iTmp, szT);
- if iTmp<10 then szT := '0'+szT;
- todec := KillSpace(szT);
-
- end;
-
- { ######################################################################### }
-
- begin { main }
- if paramcount <> 1 then
- begin
- writeln('CRC32 Version 1.20, (C)0ded 1995-97 by R0$E Softwareentwicklung');
- writeln;
- writeln('Usage: CRC32 file');
- halt;
- end;
-
- szFile := Upper(paramstr(paramcount));
- writeln('■ Proceeding file: ',szFile,'/',FileNameSplit(szFile));
-
- magic := GetMagic(FileNameSplit(szFile));
- replaces := ReplaceMagic(FileNameSplit(szFile), Magic);
-
- if magic <> '' then
- writeln('■ Magic: ',magic);
- if replaces <> '' then
- writeln('■ Replaces: ',replaces);
-
- crt2con; { redirect stdout }
-
- NEW(CRC, Init( CRCPOLY_Def )); { Build Up Objekt }
- lChk := Crc^.CheckSumme(szFile);
- Dispose(crc, Done); { Speicher wieder freigeben }
-
- writeln('CRC ', hex(lChk,8));
- writeln('FILE ', FileNameSplit(szFile));
- if magic <> '' then
- begin
- writeln('MAGIC ', magic);
- end;
- if replaces <> '' then
- begin
- writeln('REPLACES ',replaces);
- end;
-
- fileid_diz;
- if magic <> '' then
- Writeln('LDESC ■ Magic/Filename: ',magic,', ',FileNameSplit(szFile));
- if replaces <> '' then
- Writeln('LDESC ■ Replaces: ',replaces);
-
- write('LDESC ■ Size: ',Format(filelength(szFile)),' bytes, ');
- lzeit := FileLength(szFile) div 2990 + 1;
- writeln(todec(lZeit div 60),':',todec(lZeit mod 60),' min @ 28.8 KB');
- end.
-