;;; -*- Mode:LISP; Package:USER; Base:10; Readtable:CL -*-

(defun print-network-files ()
  (let ((tcpa:*imagen-default-copies* 1)
	(tcpa:*imagen-default-form-length* 66.)
	(tcpa:*imagen-default-form-width* 132.)
	(tcpa:*imagen-default-line-wrapping* t)
	(tcpa:*imagen-default-forms-per-page* 2)
	(tcpa:*imagen-default-left-margin* 7)
	(tcpa:*imagen-default-line-numbers* t)
	(tcpa:*imagen-default-page-headings* t)
	;;3 seconds between polls (20 per minute) and 600 polls before giving up means that 30 minutes will
	;;pass before you are thrown into the error handler.  Time to add paper...
	(tcpa:*imagen-status-ok-wait* 3)
	(tcpa:*imagen-status-ok-wait-tries* 600.)
	(cutoff-date nil)
	)
    (flet ((print-file (directory file)
	     (let* ((pathname (string-append "sys:" directory file ".lisp#>"))
		    (dl (dolist (elt (fs:directory-list pathname))
			  (when (car elt)
			    (return (cdr elt)))))
		    (date (getf dl :creation-date)))
	       (cond ((null dl)
		      (format t "~&~S not found" pathname))
		     ((or (null cutoff-date)
			  (null date)
			  (<= cutoff-date date))
		      (format t "~&Printing ~S" pathname)
		      (hardcopy-file pathname))
		     (t
		      ;;File found but too old
		      )))))
      (fresh-line *standard-input*)
      (let ((string (read-line *standard-input* t nil nil '((:prompt "Print files later than: ")))))
	(when (plusp (string-length string))
	  (setq cutoff-date (time:parse-universal-time string))))
      (let ((directory "network;"))
	(dolist (file '("host" "packages" "supdup" "table" "transparent"))
	  (print-file directory file)))
      (let ((directory "network;chaos;"))
	(dolist (file '("chsaux" "chsncp" "chuse" "peekch" "qfile"))
	  (print-file directory file)))
      (let ((directory "network;drivers;"))
	(dolist (file '("3com" "cadr" "driver-process" "excelan" "explorer" "loopback" "share"))
	  (print-file directory file)))
      (let ((directory "network;ip-tcp;kernel;"))
	(dolist (file '("easy" "generic-server" "icmp" "ip" "ports" "tcp" "tcp-stream" "udp" "udp-stream"))
	  (print-file directory file)))
      (let ((directory "network;ip-tcp;server;"))
	(dolist (file '("bytes" "disk" "finger" "ftp" "smtp" "telnet" "termcap" "telnet-utilities" "time" "udp-namespace-server" "udp-rwho-server"))
	  (print-file directory file)))
      (let ((directory "network;ip-tcp;user;"))
	(dolist (file '("chaos-server" "ftp" "ftp-access" "ftp-syms" "imagen" "quick-telnet" "smtp" "tcp-test" "telnet"))
	  (print-file directory file)))
      (let ((directory "network;kernel;"))
	(dolist (file '("arp" "configure" "defs" "library" "netspy" "netstat" "network-interface" "network-protocol" "packets" "transport-protocol"))
	  (print-file directory file))))))
