(*
    Title: 	UnixArchive - Definitions
    LastEdit:	"Mon Sep 17 16:32:32 1984"
    Author: 	Mick Jordan
		Cambridge University Computer Laboratory

    This module provides an interface to 'ar' archives.
*)

DEFINITION MODULE UnixArchive;

FROM Streams IMPORT Stream;

EXPORT QUALIFIED 
    ArchiveId, MemberId,
    OpenArchive, CloseArchive, FindNextMember, FindMember,
    CreateInput, CreateFastInput;

TYPE ArchiveId;
(*  hidden type used to identify an archive
*)
    MemberId;
(*  hidden type used to identify members in archive
*)
PROCEDURE OpenArchive(name: ARRAY OF CHAR; VAR arcid: ArchiveId): BOOLEAN;
(*  open the archive file called 'name', returning an archiveid
    which should be passed as argument to the following functions
    to identify the archive.  Returns FALSE if archive cannot be opened.
*)
PROCEDURE CloseArchive(a: ArchiveId);
(*  close the archive file identified by 'a'.
*)
PROCEDURE FindNextMember(a: ArchiveId; VAR name: ARRAY OF CHAR;
                            VAR memberid: MemberId): BOOLEAN
                            (* RAISES {SYSTEM.ArrayIndexFault} *);
(*  this provides serial access to the archive 'a'
    and if called repetively will provide the names of all the files 
    in the archive in the order in which they are stored.  
    'name' is set to a string containing the name of the next member and
    'memberid' to its internal identity.  
    It returns FALSE when there are no more members.
*)
PROCEDURE FindMember(a: ArchiveId; 
                    name: ARRAY OF CHAR; VAR memberid: MemberId): BOOLEAN;
(*  searches the archive for a particular member called 'name',
    returning TRUE if found.
*)
PROCEDURE CreateInput(a: ArchiveId; name: ARRAY OF CHAR): Stream;
(*  given that 'name' exists in the archive, this function
    returns a stream from which the contents of the member can
    be read.  
*)
PROCEDURE CreateFastInput(a: ArchiveId; memberid: MemberId): Stream;
(*  given that the member has already been looked up giving 'memberid'
    this opens a stream to the member.
*)

END UnixArchive.
