(FILECREATED "30-Jul-86 19:25:12" {QV}<NOTECARDS>1.3K>FGHPATCH096.;2 8692   

      changes to:  (VARS FGHPATCH096COMS)
		   (FNS NC.RobustReadCardPart NC.BuildBadCardsList)

      previous date: "30-Jul-86 19:07:12" {QV}<NOTECARDS>1.3K>FGHPATCH096.;1)


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

(PRETTYCOMPRINT FGHPATCH096COMS)

(RPAQQ FGHPATCH096COMS ((* * Fix to remove errant calls to NCP.ValidCardType)
			  (FNS NC.RobustReadCardPart NC.BuildBadCardsList)))
(* * Fix to remove errant calls to NCP.ValidCardType)

(DEFINEQ

(NC.RobustReadCardPart
  (LAMBDA (NoteFile ReadSubstancesFlg MessageWin EndPtr)     (* fgh: "30-Jul-86 19:10")

          (* * Assume stream is positioned at start of a card part. Try to read one and modify scavenger array according to 
	  what we find.)



          (* * rht 9/17/85: Now returns ID rather than litatom SUCCESS is wins.)



          (* * rht 12/1/85: Updated to handle new notefile and card object formats.)



          (* * rht 3/22/86: substance ptrs for bad card types are no longer put on card type's prop list.
	  Now they're stored in an assoc list hung off a WINDOWPROP.)



          (* * fgh 5/1/86 Fixed bug in previous fix. Code was bombing the first time it tried to put something on a 
	  nonexistent assoc list. Put in a COND to create the assoc list if it isn't already created.)



          (* * fgh 7/30/86 Replaced call to NCP.ValidCardType with call to NCP.CardTypeP)


    (LET ((Stream (fetch (NoteFile Stream) of NoteFile))
	  IdentifierAndVersionNum IdentifierAtom Date UID Card Title ToLinks FromLinks GlobalLinks 
	  PropList Type SubstanceLength CardPartLength CurPtr UnknownCardTypesSubstancePtrs)
         (OR EndPtr (SETQ EndPtr (GETEOFPTR Stream)))
         (SETQ CurPtr (GETFILEPTR Stream))
         (if (AND (SETQ CardPartLength (NC.ReadPtr Stream 3))
		      (LEQ (PLUS CurPtr CardPartLength)
			     EndPtr)
		      (SETQ IdentifierAndVersionNum (NC.RobustReadItemIdentifier Stream))
		      (if (GEQ (CDR IdentifierAndVersionNum)
				   1)
			  then (SETQ Date (NC.RobustReadDate Stream))
			else T)
		      (SETQ UID (NC.RobustReadUID Stream))
		      (SETQ Card (OR (NC.CardFromUID UID NoteFile)
					 (NC.GetNewCard NoteFile NIL UID))))
	     then (SETQ Date (CAR Date))
		    (SETQ IdentifierAtom (CAR IdentifierAndVersionNum))
		    (if (COND
			    ((EQ IdentifierAtom NC.TitlesIdentifier)
                                                             (* Hoping to get a healthy title.)
			      (if (AND (SETQ Title (NC.RobustReadString Stream))
					   (NC.AtEndOfItemP Stream EndPtr))
				  then (NC.SetScavengerTitleInfo Card
								     (CONS (LIST CurPtr Date 
										     Title)
									     (
								       NC.FetchScavengerTitleInfo
									       Card)))))
			    ((EQ IdentifierAtom NC.PropsIdentifier)
                                                             (* Hoping to get a healthy prop list.)
			      (if (AND (SETQ PropList (NC.RobustReadList Stream))
					   (NC.AtEndOfItemP Stream))
				  then (NC.SetScavengerPropListInfo
					   Card
					   (CONS (LIST CurPtr Date (LENGTH (CAR PropList)))
						   (NC.FetchScavengerPropListInfo Card)))))
			    ((EQ IdentifierAtom NC.LinksIdentifier)
                                                             (* Hoping to get healthy links.
							     Try to read three lists: ToLinks, FromLinks, and 
							     Global links.)
			      (if (AND (SETQ ToLinks (NC.RobustReadLinks Stream NoteFile))
					   (SETQ FromLinks (NC.RobustReadLinks Stream NoteFile))
					   (SETQ GlobalLinks (NC.RobustReadLinks Stream NoteFile))
					   (NC.AtEndOfItemP Stream EndPtr))
				  then (NC.SetScavengerLinksInfo
					   Card
					   (CONS (LIST CurPtr Date (LIST (LENGTH
										 (CAR ToLinks))
									       (LENGTH
										 (CAR FromLinks))
									       (LENGTH
										 (CAR GlobalLinks)))
							   )
						   (NC.FetchScavengerLinksInfo Card)))))
			    ((EQ IdentifierAtom NC.ItemIdentifier)
                                                             (* Hoping to get healthy substance.)
			      (if (AND (SETQ Type (CAR (NC.RobustReadAtom Stream)))
					   (NC.RobustReadRegion Stream EndPtr)
					   (SETQ SubstanceLength (NC.CheckForValidSubstance
					       Stream EndPtr Card Type ReadSubstancesFlg))
					   (NC.AtEndOfItemP Stream))
				  then (if (NOT (NCP.CardTypeP Type))
					     then          (* Code for this card part type has not been loaded.)
						    (WINDOWADDPROP MessageWin (QUOTE 
									     UNKNOWNCARDTYPESLIST)
								     Type)
                                                             (* Save the pointer to the substance card part on an 
							     assoc list)
						    (COND
						      ((SETQ UnknownCardTypesSubstancePtrs
							  (WINDOWPROP MessageWin (QUOTE 
								    UNKNOWNCARDTYPESSUBSTANCEPTRS)))
							(LISTPUT UnknownCardTypesSubstancePtrs Type
								   (CONS CurPtr (LISTGET 
								    UnknownCardTypesSubstancePtrs 
											     Type))))
						      (T (WINDOWPROP MessageWin (QUOTE 
								    UNKNOWNCARDTYPESSUBSTANCEPTRS)
								       (LIST Type (LIST CurPtr))))
						      ))
					 (NC.SetScavengerMainDataInfo
					   Card
					   (CONS (LIST CurPtr Date Type (OR SubstanceLength
										  (QUOTE 
										  UNKNOWNCARDTYPE)))
						   (NC.FetchScavengerMainDataInfo Card))))))
			then Card)))))

(NC.BuildBadCardsList
  (LAMBDA (NoteFile MessageWin FirstTimeFlg InterestedWindow)
                                                             (* fgh: "30-Jul-86 19:10")

          (* * Returns a list of all IDs with illegal index pointers, i.e. pointers not to valid data areas recorded in 
	  ScavengerArray. Also record those IDs with pointers beyond checkpoint ptr.)



          (* * rht 9/17/85: Now takes MessageWin argument so can extract the MaxIDNum off its props.)



          (* * rht 12/7/85: Modified to reflect new card and notefile object formats.)



          (* * fgh 2/4/86 Fixed minor bug where UNKNOWNCARDTYPE apeeared in a singleton list.)



          (* * rht 7/16/86: Added InterestedWindow arg.)



          (* * fgh 7/30/86 Replaced call to NCP.ValidCardType with call to NCP.CardTypeP)


    (LET ((CardTotal (SUB1 (fetch (NoteFile NextIndexNum) of NoteFile)))
	  (CheckptPtr (fetch (NoteFile CheckptPtr) of NoteFile))
	  (Num 0)
	  Results)
         (NC.PrintMsg InterestedWindow T "Building bad cards list ..." (CHARACTER 13)
			"Processing item number " 1 " out of " CardTotal ".")
         (NC.MapCards NoteFile
			(FUNCTION (LAMBDA (Card)
			    (LET (Problems)
			         (SETQ Num (ADD1 Num))
			         (if (ZEROP (IREMAINDER Num 100))
				     then (NC.PrintMsg InterestedWindow T 
							   "Building bad cards list ..."
							   (CHARACTER 13)
							   "Processing item number " Num " out of " 
							   CardTotal "."))
                                                             (* If card is not worthless, has reasonable status, 
							     and at least one problem, then make a bad card entry 
							     for it.)
			         (if (AND (NOT (NC.WorthlessCardP Card))
					      (FMEMB (NC.FetchStatus Card)
						       (QUOTE (ACTIVE DELETED SPECIAL BADPOINTER 
									NIL)))
					      (SETQ Problems
						(LET ((IndexLocsProblems (NC.CheckIndexLocs Card 
										       MessageWin 
										       CheckptPtr 
										     FirstTimeFlg))
						      (Type (NC.FetchTypeFromScavengerInfo Card)))
						     (if (AND Type (NOT (NCP.CardTypeP Type)))
							 then (CONS (QUOTE UNKNOWNCARDTYPE)
									IndexLocsProblems)
						       else IndexLocsProblems))))
				     then (push Results (BQUOTE (, Card , (NC.FetchStatus
									   Card)
									 ,
									 (NC.EncodeCardProblems
									   Problems)
									 ,@ Problems))))))))
         (NC.ClearMsg InterestedWindow T)
     Results)))
)
(PUTPROPS FGHPATCH096 COPYRIGHT ("Xerox Corporation" 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (560 8610 (NC.RobustReadCardPart 570 . 5935) (NC.BuildBadCardsList 5937 . 8608)))))
STOP