DEFINITION MODULE Seid;

FROM K32baseTypes IMPORT

	cardinal16;

EXPORT QUALIFIED

nullNsp,
extentNsp,
terminalNsp,
deviceNsp,
processNsp,
segmentNsp,
subtypeNsp,
kernelNsp,
sameNsp,
lowFileNsp,
highFileNsp,
     seid,
     nspType, uniqId0Type, uniqId1Type,
     makeSeid, namespace, uniqId0, uniqId1;


CONST
	    nullNsp    = 0;      (* null *)
	    extentNsp  = 1;      (* EXTENTS *)
	    terminalNsp= 2;      (* TERMINALS *)
	    deviceNsp  = 3;      (* DEVICES *)
	    processNsp = 4;      (* PROCESSES *)
	    segmentNsp = 5;      (* SEGMENTS *)
	    subtypeNsp = 6;      (* SUBTYPES *)
	    kernelNsp  = 7;      (* Kernel namespace *)
	    sameNsp    = 128;    (* used in UNIX directories only *)
	    lowFileNsp = 129;   (* first nsp for mounted file system*)
	    highFileNsp= 255;   (* last nsp for mounted file system *)

TYPE

	nspType        = [nullNsp .. highFileNsp];
			(* a namespace extracted from the seid *)

	unpackedSeid   = RECORD                (* unpacked seid *)
			  nsp     : nspType;       (* name space *)
			  uniqId0: [-1 .. 254];           (* unique ID *)
			  uniqId1: cardinal16;
			  END;

     seid;		 (* the actual seid *)
     uniqId0Type ;	 (* the unique id 0 extracted from the seid *)
     uniqId1Type ;	 (* the unique id 1 extracted from the seid *)

     (* SEID CONSTRUCTORS *)

PROCEDURE packSeid (unps : unpackedSeid) : seid;
	  (* pack a seid *)

PROCEDURE makeSeid (nsp: nspType; u0 : uniqId0Type; u1 : uniqId1Type) : seid;
     	  (* construct a seid from the three components *)

     (* SEID extractor functions *)

PROCEDURE namespace (theseid: seid) : nspType;
     	  (* extract the namespace from a seid *)
	  
PROCEDURE uniqId0 (theseid: seid) : uniqId0Type;
     	  (* extract the unique id 0 field *)

PROCEDURE uniqId1 (theseid: seid) : uniqId1Type;
     	  (* extract the unique id 1 field *)     	  

PROCEDURE unpackSeid (
	packedSeid: seid;		(* the packed seid *)
	VAR unps  : unpackedSeid	(* an unpacked seid *)
	) : BOOLEAN;			(* TRUE- successful, FALSE- unsuccessful *)

END Seid.
