home *** CD-ROM | disk | FTP | other *** search
- { dump file in hex from file in to file out }
- { Scott Loftesness - 8/28/82 }
- {$include:'a:filkqq.inc'}
- {$include:'a:filuqq.inc'}
- program dumpfile(in_file,output);
- uses filkqq, filuqq;
- {$line+}
-
- const
- ENDFILE = -1;
- NEWLINE = 10; { ASCII value }
- bpl = 16; { Number of bytes to dump per line }
-
- type
- ascii = set of char;
-
- var in_file: file of byte;
- i: integer;
- inbyte: byte;
- addr: word;
- l: lstring(255);
- error: word;
- line: lstring(5+(bpl*3));
- bufr: lstring(bpl*2);
- flag: boolean;
- c: char;
- asc: ascii;
- aline: lstring(bpl);
-
- { getparm -- get parms from command line }
- procedure getparm;
- begin
- error:=ppmuqq(0,adr null,l);
- writeln('This was on the command line:',l)
- end; {getparm}
-
- { dump -- dump in_file file to output in hex format }
- procedure dump;
- begin
- addr:=0;
- line:=null;
- aline:=null;
- asc:=[' '..'~'];
- reset(in_file);
- writeln('Hex Dump of file: ',in_file.name);
- writeln;
- while (not eof(in_file)) do begin
- flag:=encode(line,addr:4:16);
- addr:=addr+bpl;
- concat(line,' ');
- for i:=1 to bpl do begin
- inbyte:=in_file^;
- flag:=encode(bufr,inbyte:2:16);
- concat(line,bufr);
- concat(line,' ');
- c:=chr(inbyte);
- if c in asc then concat(aline,c)
- else concat(aline,'.');
- get(in_file);
- if eof(in_file) then break;
- end;
- line.len:=5+bpl*3;
- writeln(line,' ',aline);
- copystr(' ',line);
- line:=null;
- aline:=null;
- end
- end; { dump }
-
- begin { main program }
- dump
- end.