(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP" BASE 10)
(FILECREATED "17-Feb-88 17:26:18" {ERINYES}<LISP>LYRIC>INTERNAL>LIBRARY>ARCLEANUP.;5 12445  

      changes to%:  (VARS ARCLEANUPCOMS)
                    (FNS AR.CLEANUP)

      previous date%: "16-Feb-88 13:22:19" {ERINYES}<LISP>LYRIC>INTERNAL>LIBRARY>ARCLEANUP.;4)


(* "
Copyright (c) 1984, 1985, 1986, 1987, 1988 by Xerox Corporation.  All rights reserved.
")

(PRETTYCOMPRINT ARCLEANUPCOMS)

(RPAQQ ARCLEANUPCOMS 
       [(FILES AREDIT)
        (COMS 
          
          (* ;; "The main CLEANUP code")

              (FNS AR.CLEANUP AR.PRINT.AND.IP.FILE AR.GET.NUMS.FROM.TDS))
          
          (* ;; "List of names to generate summaries for:")

        (INITVARS (AR.CLEANUP.HACKER.NAMES '(Bane Biggs Brewster Burton Charnley Cude Cutting Daniels 
                                                  Fischer James Kontur Krivacic Lanning Masinter 
                                                  Murage Pavel Pedersen Prolog Raim Shih Snow 
                                                  Sybalsky Sye vanMelle Woz])
(FILESLOAD AREDIT)



(* ;; "The main CLEANUP code")

(DEFINEQ

(AR.CLEANUP
  [LAMBDA (UPDATE.FLG INDEX.LOCAL.DIR SUMMARY.FLG SUMMARY.LOCAL.DIR)
                                                             (* ; "Edited 17-Feb-88 17:25 by ckj")

    (PROG ((LOCAL.AR.INDEX.NAME (if INDEX.LOCAL.DIR
                                    then (PACK* INDEX.LOCAL.DIR 'AR.INDEX)
                                  else NIL))
           INDEX.WINDOW)
          (if LOCAL.AR.INDEX.NAME
              then (printout T "copying old AR index to " LOCAL.AR.INDEX.NAME "...")
                   (COPYFILE AR.INDEX.DEFAULT.FILE.NAME LOCAL.AR.INDEX.NAME)
                   (printout T "done" T))
          [if UPDATE.FLG
              then (PROG ((SAVED.TDS.NAME (PACK* AR.INFO.FILE.NAME '-PROCESSED))
                          NUMBERS INDEX.WINDOW)
                         (if (NOT (INFILEP AR.INFO.FILE.NAME))
                             then (printout T "No TDS file --- AR update aborted" T)
                                  (RETURN))
                         (until (NLSETQ (RENAMEFILE AR.INFO.FILE.NAME SAVED.TDS.NAME))
                            do (printout T "Can't rename TDS file --- trying again" T)
                               (BLOCK 5000))
                         (SETQ NUMBERS (AR.GET.NUMS.FROM.TDS SAVED.TDS.NAME))
                         (SETQ NUMBERS (SORT (INTERSECTION NUMBERS NUMBERS)))
                         (if (NULL NUMBERS)
                             then (printout T "No numbers found in TDS file --- AR update aborted" T)
                                  (RETURN))
                         (printout T "Will update AR numbers:" T NUMBERS T)
          
          (* * update AR index)

                         (SETQ INDEX.WINDOW (CREATEW (CREATEREGION 660 100 350 132)
                                                   "old index"))
                         (AR.QFORM.GROUP.CREATE (if LOCAL.AR.INDEX.NAME
                                                  else AR.INDEX.DEFAULT.FILE.NAME)
                                INDEX.WINDOW)
                         (printout T "updating AR index....")
                         (AR.INDEX.UPDATE INDEX.WINDOW NUMBERS)
                         (CLOSEW INDEX.WINDOW)
                         (printout T "done" T)
                         (if LOCAL.AR.INDEX.NAME
                             then (printout T "deleting old AR index from " LOCAL.AR.INDEX.NAME "..."
                                         )
                                  (DELFILE LOCAL.AR.INDEX.NAME)
                                  (printout T "done" T)
                                  (printout T "copying new index to file server...")
                                  (COPYFILE LOCAL.AR.INDEX.NAME AR.INDEX.DEFAULT.FILE.NAME)
                                  (printout T "done" T]
          (SETQ INDEX.WINDOW (CREATEW (CREATEREGION 660 100 350 132)))
          (AR.QFORM.GROUP.CREATE (if LOCAL.AR.INDEX.NAME
                                   else AR.INDEX.DEFAULT.FILE.NAME)
                 INDEX.WINDOW)
          (if (NULL SUMMARY.FLG)
              then (RETURN))                                 (* make report for 4045)
          [AR.QUERY INDEX.WINDOW '(AND (OR (Status%: IS New)
                                           (Status%: IS Open)
                                           (Status%: IS Open/Unreleased))
                                       (System%: IS 4045]
          (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Priority%: Impact%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW '4045Summary SUMMARY.LOCAL.DIR)
                                                             (* make report for Rooms)
          [AR.QUERY INDEX.WINDOW '(AND (OR (Status%: IS New)
                                           (Status%: IS Open)
                                           (Status%: IS Open/Unreleased))
                                       (System%: IS Rooms]
          (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Priority%: Impact%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW 'RoomsSummary SUMMARY.LOCAL.DIR)
                                                             (* make report for Loops)
          [AR.QUERY INDEX.WINDOW '(AND (OR (Status%: IS New)
                                           (Status%: IS Open)
                                           (Status%: IS Open/Unreleased))
                                       (System%: IS LOOPS]
          (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Priority%: Impact%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW 'LoopsSummary SUMMARY.LOCAL.DIR)
                                                             (* make report for Maiko)
          [AR.QUERY INDEX.WINDOW '(AND (OR (Status%: IS New)
                                           (Status%: IS Open)
                                           (Status%: IS Open/Unreleased))
                                       (System%: IS Maiko]
          (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Priority%: Impact%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW 'MaikoSummary SUMMARY.LOCAL.DIR)
                                                             (* make report for all Absolutely ARs)
          [AR.QUERY INDEX.WINDOW '(AND (OR (Status%: IS New)
                                           (Status%: IS Open)
                                           (Status%: IS Open/Unreleased))
                                       (Priority%: IS Absolutely]
          (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Status%: Impact%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW 'AbsolutelySummary SUMMARY.LOCAL.DIR)
                                                             (* make report for all Fixed ARs)
          (AR.QUERY INDEX.WINDOW '(Status%: IS Fixed))
          (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Priority%: Impact%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW 'FixedSummary SUMMARY.LOCAL.DIR)
                                                             (* print summary of Fixed and Closed 
                                                             for Medley)
          [AR.QUERY INDEX.WINDOW '(AND (OR (Status%: IS Fixed)
                                           (Status%: IS Closed))
                                       (In/By%: HAS Medley]
          (AR.SORT INDEX.WINDOW '(Status%: System%: Subsystem%:))
          (AR.PRINT.AND.IP.FILE INDEX.WINDOW 'ClosedSummary SUMMARY.LOCAL.DIR)
                                                             (* print summaries for each person)
          (for HACKER.NAME in AR.CLEANUP.HACKER.NAMES bind SEARCH.NAME
             do (if (LEQ 3 (NCHARS HACKER.NAME T FILERDTBL))
                    then (SETQ SEARCH.NAME HACKER.NAME)
                  else (SETQ SEARCH.NAME (SUBSTRING HACKER.NAME 1 4)))
                (AR.QUERY INDEX.WINDOW (LIST 'Attn%: 'HAS SEARCH.NAME))
                (AR.SORT INDEX.WINDOW '(System%: Subsystem%: Status%: Priority%: Impact%:))
                (AR.PRINT.AND.IP.FILE INDEX.WINDOW (PACK* HACKER.NAME 'Summary)
                       SUMMARY.LOCAL.DIR])

(AR.PRINT.AND.IP.FILE
  [LAMBDA (QFORM FILENAME SUMMARY.LOCAL.DIR DONTCOPY FIELDS-TO-PRINT)
                                                             (* ; "Edited 20-May-87 18:11 by ckj")
          
          (* ;; "Take a query form and make a summary from it onto FILENAME in SUMMARY.LOCAL.DIR.  Unless DONTCOPY, then copy it all back to the main AR directory.")
          
          (* ;; "FIELDS-TO-PRINT is a listing of field-name & print-length pairs for what's to appear in the summary.  Defaults to whatever AR.PRINT defaults it to.")
                                                             (* mjs "11-Jun-85 10:05")
    (PROG ((LOCALTXTFILE (PACK* SUMMARY.LOCAL.DIR FILENAME '.TXT))
           (REMOTETXTFILE (PACK* '{ERINYES}<LISPARS>SUMMARIES> FILENAME '.TXT))
           (LOCALIPFILE (PACK* SUMMARY.LOCAL.DIR FILENAME '.IP))
           (REMOTEIPFILE (PACK* '{ERINYES}<LISPARS>SUMMARIES> FILENAME '.IP))
           PRINTSTREAM)
          
          (* ;; "Set up the file names")

          (COND
             ((NULL SUMMARY.LOCAL.DIR)                       (* ; 
                         "No Local directory specified, so put 'em right onto the main AR directory.")

              (SETQ LOCALTXTFILE REMOTETXTFILE)
              (SETQ LOCALIPFILE REMOTEIPFILE)))
          
          (* ;; "Generate the summary")

          (printout T "Generating summary file: " FILENAME "... ")
          (SETQ PRINTSTREAM (OPENSTREAM LOCALTXTFILE 'OUTPUT 'NEW))
          (AR.PRINT QFORM PRINTSTREAM FIELDS-TO-PRINT)
          (CLOSEF PRINTSTREAM)
          
          (* ;; "Copy the text form of the summary to the AR directory")

          (COND
             ((AND (NOT DONTCOPY)
                   SUMMARY.LOCAL.DIR)                        (* ; "But only if she wants us to.")

              (printout T "copying... ")
              (COPYFILE LOCALTXTFILE REMOTETXTFILE)))
          
          (* ;; 
       "Now make the interpress version of the summary:  Print it landscape, in the font TERMINAL 6.")

          (printout T "Creating Interpress file... ")
          (PROG (TXT IP)
                (SETQ TXT (OPENSTREAM LOCALTXTFILE 'INPUT 'OLD))
                [SETQ IP (OPENIMAGESTREAM LOCALIPFILE 'INTERPRESS '(LANDSCAPE T]
                (DSPFONT '(TERMINAL 6) IP)
                (for I from 1 to (GETFILEINFO TXT 'LENGTH) do (\OUTCHAR IP (\BIN TXT)))
                (CLOSEF IP)
                (CLOSEF TXT))
          
          (* ;; 
          "Finally, copy the IP file back to the main AR directory and delete the local copies.")

          (COND
             ((AND (NOT DONTCOPY)
                   SUMMARY.LOCAL.DIR)                        (* ; "But only if it's appropriate.")

              (printout T "copying... ")
              (COPYFILE LOCALIPFILE REMOTEIPFILE)
              (DELFILE LOCALTXTFILE)
              (DELFILE LOCALIPFILE)))
          (printout T "done" T])

(AR.GET.NUMS.FROM.TDS
  [LAMBDA (FILENAME)                                         (* ; "Edited 20-Feb-87 11:36 by jds")
          
          (* ;; "Gather the list of ARs that have changed from the %"Tool Driver Script%" file, where AREDIT makes note of edits that people make.")

    (PROG ((FILE (OPENSTREAM FILENAME 'INPUT 'OLD))
           NUMBERS)
          (SETQ NUMBERS (while (FILEPOS "  --  (" FILE NIL NIL NIL T) bind NUM?
                           when [NUMBERP (SETQ NUM? (PROGN (READ FILE)
                                                           (READ FILE] collect NUM?))
          (CLOSEF FILE)
          (RETURN NUMBERS])
)



(* ;; "List of names to generate summaries for:")


(RPAQ? AR.CLEANUP.HACKER.NAMES 
       '(Bane Biggs Brewster Burton Charnley Cude Cutting Daniels Fischer James Kontur Krivacic 
              Lanning Masinter Murage Pavel Pedersen Prolog Raim Shih Snow Sybalsky Sye vanMelle Woz))
(PUTPROPS ARCLEANUP COPYRIGHT ("Xerox Corporation" 1984 1985 1986 1987 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1179 12049 (AR.CLEANUP 1189 . 8375) (AR.PRINT.AND.IP.FILE 8377 . 11371) (
AR.GET.NUMS.FROM.TDS 11373 . 12047)))))
STOP