DEFINITION MODULE GKSMInput;

(*
    Title: 	GKS Meta File Input
    LastEdit:	"Tue Feb 26 16:00:40 1985"
    Author: 	jd
		Cambridge University Computer Laboratory
*)

(* These procedures can be used to interpret GKS Metafiles, the stored
   picture representation of GKS. There are two styles of use. In the more
   basic one, GKSM procedures can be called to find each record in the
   metafile in turn, and InterpretRecord can be called to process the
   standard GKS records. In the more convenient style, InterpretFile or
   InterpretStream can be called to process all records except user
   defined records.
*)

FROM Streams IMPORT Stream;

EXPORT QUALIFIED
    RECORDPROC, DiscardRecord,
    InterpretRecord, InterpretStream, InterpretFile;

TYPE RECORDPROC = PROCEDURE (INTEGER, INTEGER): BOOLEAN;
    (* the parameters are record type and length. The procedure returns
       TRUE if it has consumed all the record data, and FALSE if it has
       consumed none of it
    *)

PROCEDURE DiscardRecord (type, length: INTEGER): BOOLEAN;
    (* discards user record of type t and length l *)


PROCEDURE InterpretRecord (type: CARDINAL; length: INTEGER): BOOLEAN;
    (* tells GKS to interpret the current metafile input record
       in the standard way
    *)


PROCEDURE InterpretStream (s: Stream; p: RECORDPROC);
    (* Reads all the records in the input metafile, calling InterpretRecord 
       if they are GKS records, and p otherwise. DiscardRecord is a
       convenient value of p when user records in the metafile are not
       expected.
    *)

PROCEDURE InterpretFile (name: ARRAY OF CHAR; p: RECORDPROC);
    (* Same as InterpretStream, but takes care of opening the file first *)


END GKSMInput.
