home *** CD-ROM | disk | FTP | other *** search
- {TUG PDS CERT 1.01 (Pascal)
-
- ==========================================================================
-
- TUG PUBLIC DOMAIN SOFTWARE CERTIFICATION
-
- The Turbo User Group (TUG) is recognized by Borland International as the
- official support organization for Turbo languages. This file has been
- compiled and verified by the TUG library staff. We are reasonably certain
- that the information contained in this file is public domain material, but
- it is also subject to any restrictions applied by its author.
-
- This diskette contains PROGRAMS and/or DATA determined to be in the PUBLIC
- DOMAIN, provided as a service of TUG for the use of its members. The
- Turbo User Group will not be liable for any damages, including any lost
- profits, lost savings or other incidental or consequential damages arising
- out of the use of or inability to use the contents, even if TUG has been
- advised of the possibility of such damages, or for any claim by any
- other party.
-
- To the best of our knowledge, the routines in this file compile and function
- properly in accordance with the information described below.
-
- If you discover an error in this file, we would appreciate it if you would
- report it to us. To report bugs, or to request information on membership
- in TUG, please contact us at:
-
- Turbo User Group
- PO Box 1510
- Poulsbo, Washington USA 98370
-
- --------------------------------------------------------------------------
- F i l e I n f o r m a t i o n
-
- * DESCRIPTION
- Turbo Pascal V4.0 DEARC input/output routines.
-
- * ASSOCIATED FILES
- DEARC.PAS
- DEARCABT.PAS
- DEARCGLB.PAS
- DEARCIO.PAS
- DEARCLZW.PAS
- DEARCUNP.PAS
- DEARCUSQ.PAS
- DEARC.TXT
-
- * CHECKED BY
- DRM 08/08/88
-
- * KEYWORDS
- TURBO PASCAL V4.0
-
- ==========================================================================
- }
- (**
- *
- * Module: dearcio.pas
- * Description: DEARC input/output routines
- *
- * Revision History:
- * 7-26-88 : unitized for turbo 4.0
- *
- **)
-
- unit dearcio;
-
- interface
- uses
- dos,
- dearcglb,
- dearcabt;
-
- procedure open_arc;
- procedure open_ext;
- procedure close_arc;
- procedure close_ext(var hdr : heads);
- procedure fseek(offset : longint; base : integer);
- procedure put_ext(c : byte);
- function get_arc : byte;
- procedure fread(var buf; reclen : integer);
-
- implementation
-
-
- (**
- *
- * Name: procedure Read_Block
- * Description: read a block from the archive file
- * Parameters: none
- *
- **)
- procedure Read_Block;
- var
- res : word;
- begin
- if EOF(arcfile) then
- endfile := TRUE
- else
- BlockRead(arcfile, arcbuf, BLOCKSIZE, res);
-
- arcptr := 1
- end; (* proc read_block *)
-
-
- (**
- *
- * Name: procedure Write_Block
- * Description: write a block to the extracted file
- * Parameters: none
- *
- **)
- procedure Write_Block;
- begin
- BlockWrite(extfile, extbuf, extptr);
- extptr := 1
- end; (* proc write_block *)
-
-
- (**
- *
- * Name: function get_arc : byte
- * Description: read 1 character from the archive file
- * Parameters: none
- * Returns: character read
- *
- **)
- function get_arc : byte;
- begin
- if endfile then
- get_arc := 0
- else
- begin
- get_arc := arcbuf[arcptr];
- if arcptr = BLOCKSIZE then
- Read_Block
- else
- arcptr := arcptr + 1
- end
- end; (* func get_arc *)
-
-
- (**
- *
- * Name: procedure put_ext
- * Description: write 1 character to the extracted file
- * Parameters: value -
- * c : byte - character to write
- *
- **)
- procedure put_ext(c : byte);
- begin
- extbuf[extptr] := c;
- if extptr = BLOCKSIZE then
- Write_Block
- else
- extptr := extptr + 1
- end; (* proc put_ext *)
-
-
- (**
- *
- * Name: procedure open_arc
- * Description: open the archive file for input processing
- * Parameters: none
- *
- **)
- procedure open_arc;
- begin
- {$I-}
- assign(arcfile, arcname);
- {$I+}
- if (ioresult <> 0) then
- abort('Cannot open archive file.');
-
- {$I-}
- reset(arcfile, 1);
- {$I+}
- if (ioresult <> 0) then
- abort('Cannot open archive file.');
-
- endfile := FALSE;
- Read_Block
- end; (* proc open_arc *)
-
-
- (**
- *
- * Name: procedure open_ext
- * Description: open the extracted file for writing
- * Parameters: none
- *
- **)
- procedure open_ext;
- begin
- {$I-}
- assign(extfile, extname);
- {$I+}
- if (ioresult <> 0) then
- abort('Cannot open extract file.');
-
- {$I-}
- rewrite(extfile, 1);
- {$I+}
- if (ioresult <> 0) then
- abort('Cannot open extract file.');
-
- extptr := 1;
- end; (* proc open_ext *)
-
-
- (**
- *
- * Name: procedure close_arc
- * Description: close the archive file
- * Parameters: none
- *
- **)
- procedure close_arc;
- begin
- close(arcfile)
- end; (* proc close_arc *)
-
-
- (**
- *
- * Name: procedure close_ext
- * Description: close the extracted file
- * Parameters: none
- *
- **)
- procedure close_ext(var hdr : heads);
- var
- dt : longint;
- regs : registers;
- handle : word;
- begin
- extptr := extptr - 1;
-
- if (extptr <> 0) then
- Write_Block;
-
- close(extfile);
-
-
- (*
- * pbr - 7-26-88 : added date stamping
- *)
- regs.ax := $3D00; (* open file *)
- regs.ds := seg(hdr);
- regs.dx := ofs(hdr.name);
- MsDos(regs);
-
- handle := regs.ax;
-
- regs.ax := $5701; (* set date/time *)
- regs.bx := handle;
- regs.cx := hdr.time;
- regs.dx := hdr.date;
- MsDos(regs);
-
- regs.ah := $3E; (* close file *)
- regs.bx := handle;
- MsDos(regs);
- end; (* proc close_ext *)
-
-
- (**
- *
- * Name: procedure fseek
- * Description: re-position the current pointer in the archive file
- * Parameters: value -
- * offset : longint - offset to position to
- * base : integer - position from:
- * 0 : beginning of file
- * 1 : current position
- * 2 : end-of-file
- *
- **)
- procedure fseek(offset : longint; base : integer);
- var
- b : longint;
- begin
- case base of
- 0 : b := offset;
- 1 : b := offset + FilePos(arcfile) - BLOCKSIZE + arcptr - 1;
- 2 : b := offset + FileSize(arcfile);
- else
- abort('Invalid parameters to fseek')
- end;
-
- seek(arcfile, b);
- Read_Block;
- end; (* proc fseek *)
-
-
- (**
- *
- * Name: procedure fread
- * Description: read a record from the archive file
- * Parameters: var -
- * buf - buffer for read-in data
- * value -
- * reclen : integer - items to read
- *
- **)
- procedure fread(var buf; reclen : integer);
- var i : integer;
- b : array [1..MaxInt] of byte absolute buf;
- begin
- for i := 1 to reclen do
- b[i] := get_arc
- end; (* proc fread *)
-
- end.
-