xref: /csrg-svn/usr.bin/pascal/libpc/unixio.i (revision 62105)
147970Sbostic (*
2*62105Sbostic  * Copyright (c) 1979, 1993
3*62105Sbostic  *	The Regents of the University of California.  All rights reserved.
447970Sbostic  *
547970Sbostic  * %sccs.include.redist.c%
647970Sbostic  *
7*62105Sbostic  *	@(#)unixio.i	8.1 (Berkeley) 06/06/93
847970Sbostic  *)
93906Smckusick 
103906Smckusick const
11*62105Sbostic sccsid = '@(#)unixio.i 8.1 06/06/93';
123906Smckusick 
133906Smckusick type
143906Smckusick fileptr = record
153906Smckusick 	cnt :integer
163906Smckusick 	end;
173906Smckusick 
183906Smckusick function TELL(
193906Smckusick var	fptr :text)
203906Smckusick {returns} :fileptr;
213906Smckusick 
223906Smckusick var
233906Smckusick filesize, headsize, tailsize :integer;
243906Smckusick result :fileptr;
253906Smckusick 
263906Smckusick begin
273906Smckusick tailsize := 0;
283906Smckusick while not eof(fptr) do begin
293906Smckusick 	get(fptr);
303906Smckusick 	tailsize := tailsize + 1
313906Smckusick 	end;
323906Smckusick filesize := 0;
333906Smckusick reset(fptr);
343906Smckusick while not eof(fptr) do begin
353906Smckusick 	get(fptr);
363906Smckusick 	filesize := filesize + 1
373906Smckusick 	end;
383906Smckusick reset(fptr);
393906Smckusick for headsize := 1 to filesize - tailsize do
403906Smckusick 	get(fptr);
413906Smckusick result.cnt := headsize;
423906Smckusick TELL := result
433906Smckusick end;
443906Smckusick 
453906Smckusick procedure SEEK(
463906Smckusick  var	fptr :text;
473906Smckusick  var	cnt :fileptr);
483906Smckusick 
493906Smckusick var
503906Smckusick i :integer;
513906Smckusick 
523906Smckusick begin
533906Smckusick reset(fptr);
543906Smckusick for i := 1 to cnt.cnt do
553906Smckusick 	get(fptr)
563906Smckusick end;
573906Smckusick 
583906Smckusick procedure APPEND(
593906Smckusick  var	fptr :text);
603906Smckusick 
613906Smckusick var
623906Smckusick tmp :text;
633906Smckusick 
643906Smckusick begin
653906Smckusick rewrite(tmp);
663906Smckusick reset(fptr);
673906Smckusick while not eof(fptr) do begin
683906Smckusick 	if eoln(fptr) then
693906Smckusick 		writeln(tmp)
703906Smckusick 	else
713906Smckusick 		write(tmp, fptr^);
723906Smckusick 	get(fptr)
733906Smckusick 	end;
743906Smckusick reset(tmp);
753906Smckusick rewrite(fptr);
763906Smckusick while not eof(tmp) do begin
773906Smckusick 	if eoln(tmp) then
783906Smckusick 		writeln(fptr)
793906Smckusick 	else
803906Smckusick 		write(fptr, tmp^);
813906Smckusick 	get(tmp)
823906Smckusick 	end
833906Smckusick end;
84