(FILECREATED "20-Nov-85 19:38:53" {QV}<NOTECARDS>1.3K>FGHPATCH004.;4 7479   

      changes to:  (FNS NC.ReadUID NC.MakeUID NC.InitializeUID NC.MakeHashKey NC.BuildHashArray 
			NC.UIDPutProp NC.UIDRemProp NC.UIDGetProp NC.WriteUID NC.SameUIDP 
			NC.CreateUIDHashArray)
		   (VARS FGHPATCH004COMS)
		   (RECORDS UID)

      previous date: "20-Nov-85 19:01:37" {QV}<NOTECARDS>1.3K>FGHPATCH004.;1)


(* Copyright (c) 1985 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT FGHPATCH004COMS)

(RPAQQ FGHPATCH004COMS ((* * Redefined from NCDATABASE for UID implementation as datatype)
			  (FNS NC.ReadUID NC.WriteUID NC.SameUIDP NC.MakeUID NC.InitializeUID 
			       NC.BuildHashArray)
			  (INITVARS (NC.NoteFilesHashArray (NC.CreateUIDHashArray 
									NC.NoteFilesHashArraySize)))
			  (* * New fns for UID implementation for NCDATABASE)
			  (RECORDS UID)
			  (FNS NC.MakeHashKey NC.CreateUIDHashArray)
			  (FNS NC.UIDPutProp NC.UIDRemProp NC.UIDGetProp)))
(* * Redefined from NCDATABASE for UID implementation as datatype)

(DEFINEQ

(NC.ReadUID
  (LAMBDA (NoteFileOrStream)                                 (* fgh: "20-Nov-85 19:30")

          (* * Get a UID off of the file. Since UIDs are BIGNUMs less than {EXPT 2 112} just read their 112 bits from the 
	  file.)


    (LET ((Stream (OR (STREAMP NoteFileOrStream)
			(fetch (NoteFile Stream) of NoteFileOrStream))))
         (PROG1 (create UID
			    UID0 ←(BIN16 Stream)
			    UID1 ←(BIN16 Stream)
			    UID2 ←(BIN16 Stream)
			    UID3 ←(BIN16 Stream)
			    UID4 ←(BIN16 Stream)
			    UID5 ←(BIN16 Stream)
			    UID6 ←(BIN16 Stream))

          (* * skip past CR following UID)


		  (BIN Stream)))))

(NC.WriteUID
  (LAMBDA (NoteFileOrStream UID)                             (* fgh: "20-Nov-85 18:52")

          (* * Write a UID out to Stream. Since UIDs are BIGNUMs less than {EXPT 2 112} just write their 112 bits to the 
	  file.)



          (* * rht 11/12/85: Handles new notefile format.)


    (LET ((Stream (OR (STREAMP NoteFileOrStream)
			(fetch (NoteFile Stream) of NoteFileOrStream))))
         (AND (type? UID UID)
		(BOUT16 Stream (ffetch (UID UID0) of UID))
		(BOUT16 Stream (ffetch (UID UID1) of UID))
		(BOUT16 Stream (ffetch (UID UID2) of UID))
		(BOUT16 Stream (ffetch (UID UID3) of UID))
		(BOUT16 Stream (ffetch (UID UID4) of UID))
		(BOUT16 Stream (ffetch (UID UID5) of UID))
		(BOUT16 Stream (ffetch (UID UID6) of UID)))

          (* * End with a CR)


         (BOUT Stream 13))))

(NC.SameUIDP
  (LAMBDA (UID1 UID2)                                        (* fgh: "20-Nov-85 18:51")

          (* * Return non-nil if UIDs are the same.)


    (AND (type? UID UID1)
	   (type? UID UID2)
	   (EQP (ffetch (UID UID0) of UID1)
		  (ffetch (UID UID0) of UID2))
	   (EQP (ffetch (UID UID1) of UID1)
		  (ffetch (UID UID1) of UID2))
	   (EQP (ffetch (UID UID2) of UID1)
		  (ffetch (UID UID2) of UID2))
	   (EQP (ffetch (UID UID3) of UID1)
		  (ffetch (UID UID3) of UID2))
	   (EQP (ffetch (UID UID4) of UID1)
		  (ffetch (UID UID4) of UID2))
	   (EQP (ffetch (UID UID5) of UID1)
		  (ffetch (UID UID5) of UID2))
	   (EQP (ffetch (UID UID6) of UID1)
		  (ffetch (UID UID6) of UID2)))))

(NC.MakeUID
  (LAMBDA NIL                                                (* fgh: "20-Nov-85 19:23")

          (* * Return a new unique identifier composed of the NS host number, a logon time stamp, and a global counter since 
	  login.)


    (COND
      ((OR (NULL NC.UIDCtr)
	     (NULL NC.UIDBasis))
	(NC.InitializeUID)))
    (SETQ NC.UIDCtr (ADD1 NC.UIDCtr))
    (create UID copying NC.UIDBasis UID5 ←(LOGAND (LRSH NC.UIDCtr 16)
							(CONSTANT (SUB1 (EXPT 2 16))))
			    UID6 ←(LOGAND NC.UIDCtr (CONSTANT (SUB1 (EXPT 2 16)))))))

(NC.InitializeUID
  (LAMBDA NIL                                                (* fgh: "20-Nov-85 19:22")

          (* * Initialize the UID mechanism)


    (LET ((IDate (IDATE)))
         (SETQ NC.UIDCtr 1)
         (SETQ NC.UIDBasis (create UID
				       UID0 ←(CADR \MY.NSHOSTNUMBER)
				       UID1 ←(CADDR \MY.NSHOSTNUMBER)
				       UID2 ←(CADDDR \MY.NSHOSTNUMBER)
				       UID3 ←(LOGAND (LRSH IDate 16)
						       (CONSTANT (SUB1 (EXPT 2 16))))
				       UID4 ←(LOGAND IDate (CONSTANT (SUB1 (EXPT 2 16))))
				       UID5 ← 0
				       UID6 ← 0))
         (ADDTOVAR \SYSTEMCACHEVARS NC.UIDBasis NC.UIDCtr))))

(NC.BuildHashArray
  (LAMBDA (NoteFile QuietFlg)                                (* fgh: "20-Nov-85 19:03")

          (* * Create a hash array and fill it from the index array on NoteFile.)


    (replace (NoteFile HashArray) of NoteFile with (NC.CreateUIDHashArray
							   (fetch (NoteFile HashArraySize)
							      of NoteFile)))
    (NC.GetHashArray NoteFile QuietFlg)))
)

(RPAQ? NC.NoteFilesHashArray (NC.CreateUIDHashArray NC.NoteFilesHashArraySize))
(* * New fns for UID implementation for NCDATABASE)

[DECLARE: EVAL@COMPILE 

(DATATYPE UID ((UID0 WORD)
		 (UID1 WORD)
		 (UID2 WORD)
		 (UID3 WORD)
		 (UID4 WORD)
		 (UID5 WORD)
		 (UID6 WORD)
		 (UserData POINTER)))
]
(/DECLAREDATATYPE (QUOTE UID)
		  (QUOTE (WORD WORD WORD WORD WORD WORD WORD POINTER))
		  (QUOTE ((UID 0 (BITS . 15))
			  (UID 1 (BITS . 15))
			  (UID 2 (BITS . 15))
			  (UID 3 (BITS . 15))
			  (UID 4 (BITS . 15))
			  (UID 5 (BITS . 15))
			  (UID 6 (BITS . 15))
			  (UID 8 POINTER)))
		  (QUOTE 10))
(DEFINEQ

(NC.MakeHashKey
  (LAMBDA (UID)                                              (* fgh: "20-Nov-85 19:25")

          (* * make a hash key from a UID)


    (COND
      ((NOT (type? UID UID))
	(ERROR UID "Not a UID"))
      (T (LOGXOR (ffetch (UID UID0) of UID)
		   (ffetch (UID UID1) of UID)
		   (ffetch (UID UID2) of UID)
		   (ffetch (UID UID3) of UID)
		   (ffetch (UID UID4) of UID)
		   (ffetch (UID UID5) of UID)
		   (ffetch (UID UID6) of UID))))))

(NC.CreateUIDHashArray
  (LAMBDA (MinKeys OverFlow)                                 (* fgh: "20-Nov-85 18:59")
    (HASHARRAY MinKeys OverFlow (FUNCTION NC.MakeHashKey)
		 (FUNCTION NC.SameUIDP))))
)
(DEFINEQ

(NC.UIDPutProp
  (LAMBDA (UID Prop Value)                                   (* fgh: "20-Nov-85 19:09")
    (LET ((PropList (fetch (UID UserData) of UID)))
         (COND
	   ((PropList (LISTPUT PropList Prop Value)))
	   (T (replace (UID UserData) of UID with (LIST Prop Value)))))))

(NC.UIDRemProp
  (LAMBDA (UID Prop)                                         (* fgh: "20-Nov-85 19:10")
    (NC.UIDPutProp UID Prop NIL)))

(NC.UIDGetProp
  (LAMBDA (UID Prop)                                         (* fgh: "20-Nov-85 19:10")
    (LISTGET (fetch (UID UserData) of UID)
	       Prop)))
)
(PUTPROPS FGHPATCH004 COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1056 5329 (NC.ReadUID 1066 . 1770) (NC.WriteUID 1772 . 2714) (NC.SameUIDP 2716 . 3576) 
(NC.MakeUID 3578 . 4202) (NC.InitializeUID 4204 . 4908) (NC.BuildHashArray 4910 . 5327)) (5953 6727 (
NC.MakeHashKey 5963 . 6506) (NC.CreateUIDHashArray 6508 . 6725)) (6728 7397 (NC.UIDPutProp 6738 . 7061
) (NC.UIDRemProp 7063 . 7212) (NC.UIDGetProp 7214 . 7395)))))
STOP