(FILECREATED "28-Jan-86 01:39:39" {ERIS}<LISPUSERS>KOTO>REMOTEPSW.;3 16733  

      changes to:  (FNS \REMOTE.PSWOP.SELECTED)

      previous date: " 5-Dec-85 18:29:13" {ERIS}<LISPUSERS>KOTO>REMOTEPSW.;2)


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

(PRETTYCOMPRINT REMOTEPSWCOMS)

(RPAQQ REMOTEPSWCOMS ((FNS REMOTE.PROCESS.STATUS.WINDOW)
                      (COURIERPROGRAMS PROCESS)
                      (DECLARE: DONTCOPY (RECORDS PROCESSDATA REMOTE.PSW.MENUS))
                      (FNS REMOTE.PROCESS.BACKTRACE REMOTE.PSW.REDISPLAY \REMOTE.GET.PROCESS.DATA 
                           \REMOTE.PROCESS.BACKTRACE \REMOTE.PROCESS.KILL \REMOTE.PROCESS.RESTART 
                           \REMOTE.PROCESS.SUSPEND \REMOTE.PROCESS.TTY \REMOTE.PROCESS.WAKE 
                           \REMOTE.PSW.SELECTED \REMOTE.PSWOP.SELECTED)
                      (FILES COURIERDEFS)))
(DEFINEQ

(REMOTE.PROCESS.STATUS.WINDOW
  [LAMBDA (HOST)                                             (* cdl " 5-Dec-85 17:57")
    (LET (COURIERSTREAM WINDOW PROCESSDATA PMENU OPMENU SELECTED WIDTH)
         (SETQ COURIERSTREAM (COURIER.OPEN HOST))
         (SETQ WINDOW (CREATEW (CREATEREGION 0 0 100 100)
				   HOST NIL T))
         (WINDOWPROP WINDOW (QUOTE COURIERSTREAM)
		       COURIERSTREAM)
         [WINDOWADDPROP WINDOW (QUOTE CLOSEFN)
			  (FUNCTION (LAMBDA (WINDOW)
			      (CLOSEF? (WINDOWPROP WINDOW (QUOTE COURIERSTREAM]
         (REMOTE.PSW.REDISPLAY WINDOW)
         (MOVEW WINDOW)
     WINDOW])
)

(COURIERPROGRAM PROCESS (1199 0)
    TYPES
      [[PROCESSDATA (RECORD (SELECTED PROCESS)
                           (PROCESSES (SEQUENCE PROCESS]
       (PROCESS ATOM)
       (STATUS ATOM)
       (COMMAND (ENUMERATION (BT 0)
                       (BTV 1)
                       (BTV* 7)
                       (BTV! 39]
    INHERITS
      (INTERLISP)
    PROCEDURES
      ((GET.PROCESS.DATA 0 NIL RETURNS (PROCESSDATA)
              REPORTS NIL IMPLEMENTEDBY \REMOTE.GET.PROCESS.DATA)
       (BACKTRACE 1 (PROCESS COMMAND BULK.DATA.SINK)
              RETURNS NIL REPORTS NIL IMPLEMENTEDBY \REMOTE.PROCESS.BACKTRACE)
       (KILL 2 (PROCESS)
             RETURNS NIL REPORTS (NO.SUCH.PROCESS TTY.PROCESS SYSTEM.PROCESS)
             IMPLEMENTEDBY \REMOTE.PROCESS.KILL)
       (RESTART 3 (PROCESS)
              RETURNS NIL REPORTS (NO.SUCH.PROCESS)
              IMPLEMENTEDBY \REMOTE.PROCESS.RESTART)
       (WAKE 4 (PROCESS STATUS)
             RETURNS NIL REPORTS (NO.SUCH.PROCESS)
             IMPLEMENTEDBY \REMOTE.PROCESS.WAKE)
       (SUSPEND 5 (PROCESS)
              RETURNS NIL REPORTS (NO.SUCH.PROCESS)
              IMPLEMENTEDBY \REMOTE.PROCESS.SUSPEND)
       [GET.TTY.PROCESS 6 NIL RETURNS (PROCESS)
              REPORTS NIL IMPLEMENTEDBY (LAMBDA NIL (BQUOTE (RETURN , (if (TTY.PROCESS)
                                                                          then
                                                                          (PROCESS.NAME (TTY.PROCESS]
       (SET.TTY.PROCESS 7 (PROCESS)
              RETURNS NIL REPORTS (NO.SUCH.PROCESS)
              IMPLEMENTEDBY \REMOTE.PROCESS.TTY))
    ERRORS
      ((NO.SUCH.PROCESS 0)
       (TTY.PROCESS 1)
       (SYSTEM.PROCESS 3)))
(DECLARE: DONTCOPY 
[DECLARE: EVAL@COMPILE 

(RECORD PROCESSDATA (SELECTED PROCESSES))

(RECORD REMOTE.PSW.MENUS (COMMANDMENU PROCESSMENU))
]
)
(DEFINEQ

(REMOTE.PROCESS.BACKTRACE
  [LAMBDA (PROCESS CMD WINDOW)                               (* cdl " 3-Dec-85 18:44")
    (PROG (PLACE REGION BACKTRACEWINDOW BULK.DATA.STREAM)
	    (if [NOT (WINDOWP (SETQ BACKTRACEWINDOW (CAR (ATTACHEDWINDOWS WINDOW]
		then (SETQ REGION (WINDOWPROP WINDOW (QUOTE REGION)))
		       (SETQ BACKTRACEWINDOW (CREATEW (create
							    REGION
							    BOTTOM ←
							    (if (LESSP (fetch (REGION BOTTOM)
									      of REGION)
									   PROCBACKTRACEHEIGHT)
								then (SETQ PLACE (QUOTE TOP))
								       (fetch (REGION TOP)
									  of REGION)
							      else (SETQ PLACE (QUOTE BOTTOM))
								     (DIFFERENCE
								       (fetch (REGION BOTTOM)
									  of REGION)
								       PROCBACKTRACEHEIGHT))
							    HEIGHT ← PROCBACKTRACEHEIGHT
							     using REGION)
							  "Process backtrace" NIL T))
		       (ATTACHWINDOW BACKTRACEWINDOW WINDOW PLACE (QUOTE JUSTIFY)
				       (QUOTE LOCALCLOSE))
		       (DSPSCROLL (QUOTE OFF)
				    BACKTRACEWINDOW)
		       (DSPFONT [OR BACKTRACEFONT (FONTCREATE (QUOTE (GACHA 8]
				  BACKTRACEWINDOW))
	    (DSPRESET BACKTRACEWINDOW)
	    (SETQ BULK.DATA.STREAM (COURIER.CALL (WINDOWPROP WINDOW (QUOTE COURIERSTREAM))
						     (QUOTE PROCESS)
						     (QUOTE BACKTRACE)
						     PROCESS CMD NIL))
	    (COPYBYTES BULK.DATA.STREAM BACKTRACEWINDOW)
	    (CLOSEF BULK.DATA.STREAM])

(REMOTE.PSW.REDISPLAY
  [LAMBDA (WINDOW PROCESSDATA)                               (* cdl " 5-Dec-85 18:12")
    (PROG (COURIERSTREAM PMENU OPMENU SELECTED WIDTH)
	    (SETQ COURIERSTREAM (WINDOWPROP WINDOW (QUOTE COURIERSTREAM)))
	    [if (NULL PROCESSDATA)
		then (SETQ PROCESSDATA (COURIER.CALL COURIERSTREAM (QUOTE PROCESS)
							   (QUOTE GET.PROCESS.DATA]
	    (for ATTACHEDWINDOW in (WINDOWPROP WINDOW (QUOTE ATTACHEDWINDOWS))
	       do (DETACHWINDOW ATTACHEDWINDOW)
		    (CLOSEW ATTACHEDWINDOW))
	    (with REMOTE.PSW.MENUS (WINDOWPROP WINDOW (QUOTE MENU))
		    (if COMMANDMENU
			then (SETQ OPMENU COMMANDMENU)
		      else (SETQ OPMENU
			       (create MENU
					 ITEMS ←(QUOTE (BT WHO? KILL BTV KBD← RESTART BTV* INFO 
							     WAKE BTV! UPDATE SUSPEND))
					 WHENSELECTEDFN ←(FUNCTION \REMOTE.PSWOP.SELECTED)
					 CENTERFLG ← T
					 MENUCOLUMNS ← 3)))
		    (if PROCESSMENU
			then (DELETEMENU PROCESSMENU NIL WINDOW)))
	    (SETQ PMENU (create MENU
				    ITEMS ←(with PROCESSDATA PROCESSDATA PROCESSES)
				    WHENSELECTEDFN ←(FUNCTION \REMOTE.PSW.SELECTED)
				    MENUFONT ← DEFAULTFONT
				    CENTERFLG ← T))
	    [SHAPEW WINDOW (create REGION
				       WIDTH ←[WIDTHIFWINDOW (SETQ WIDTH
								 (MAX (fetch IMAGEWIDTH
									   of PMENU)
									(fetch IMAGEWIDTH
									   of OPMENU]
				       HEIGHT ←(HEIGHTIFWINDOW (PLUS (fetch IMAGEHEIGHT
									    of PMENU)
									 (fetch IMAGEHEIGHT
									    of OPMENU)
									 4)
								 T)
				using (WINDOWPROP WINDOW (QUOTE REGION]
	    (if (NULL (with REMOTE.PSW.MENUS (WINDOWPROP WINDOW (QUOTE MENUS))
				  COMMANDMENU))
		then (ADDMENU OPMENU WINDOW (create POSITION
							  XCOORD ←(QUOTIENT (DIFFERENCE
										WIDTH
										(fetch IMAGEWIDTH
										   of OPMENU))
									      2)
							  YCOORD ← 0)))
	    (ADDMENU PMENU WINDOW (create POSITION
					      XCOORD ←(QUOTIENT (DIFFERENCE (with REGION
											(
										DSPCLIPPINGREGION
											  NIL WINDOW)
											WIDTH)
										(fetch IMAGEWIDTH
										   of PMENU))
								  2)
					      YCOORD ←(PLUS (fetch IMAGEHEIGHT of OPMENU)
							      4)))
	    (if (SETQ SELECTED (with PROCESSDATA PROCESSDATA SELECTED))
		then (if (FMEMB SELECTED (with PROCESSDATA PROCESSDATA PROCESSES))
			   then (SHADEITEM SELECTED PMENU SELECTIONSHADE)))
	    (WINDOWPROP WINDOW (QUOTE PROCESSDATA)
			  PROCESSDATA])

(\REMOTE.GET.PROCESS.DATA
  [LAMBDA NIL                                                (* cdl " 5-Dec-85 18:00")
    (BQUOTE (RETURN (, (PROCESS.NAME (TTY.PROCESS))
			   ,
			   (in \PROCESSES collect PROCESS.NAME])

(\REMOTE.PROCESS.BACKTRACE
  [LAMBDA (COURIERSTREAM PROGRAM PROCEDURE PROCESS COMMAND BULK.DATA.STREAM)
                                                             (* cdl " 5-Dec-85 18:28")
    (if (NULL (SETQ PROCESS (FIND.PROCESS PROCESS)))
	then (QUOTE (ABORT NO.SUCH.PROCESS))
      else (LET (STKP (PLVLFILEFLG T)
			(FX (fetch (PROCESS PROCFX) of PROCESS)))
	          (BAKTRACE (if (ZEROP FX)
				  then                     (* The currently active proc!)
					 (FUNCTION \REMOTE.PROCESS.BACKTRACE)
				else (SETQ STKP (\MAKESTACKP NIL FX)))
			      NIL NIL (SELECTQ COMMAND
						 (BT 0)
						 (BTV 1)
						 (BTV* 7)
						 (BTV! 39)
						 0)
			      BULK.DATA.STREAM)
	          (if STKP
		      then (RELSTK STKP)))
	     (QUOTE (RETURN])

(\REMOTE.PROCESS.KILL
  [LAMBDA (COURIERSTREAM PROGRAM PROCEDURE PROCESS)          (* cdl " 3-Dec-85 18:59")
    (if (NOT (SETQ PROCESS (FIND.PROCESS PROCESS)))
	then (QUOTE (ABORT NO.SUCH.PROCESS))
      elseif (EQ PROCESS (TTY.PROCESS))
	then (QUOTE (ABORT TTY.PROCESS))
      elseif (fetch PROCSYSTEMP of PROCESS)
	then (QUOTE (ABORT SYSTEM.PROCESS))
      else (DEL.PROCESS PROCESS)
	     (QUOTE (RETURN)))])

(\REMOTE.PROCESS.RESTART
  [LAMBDA (COURIERSTREAM PROGRAM PROCEDURE PROCESS)          (* cdl " 3-Dec-85 19:09")
    (if (NOT (SETQ PROCESS (FIND.PROCESS PROCESS)))
	then (QUOTE (ABORT NO.SUCH.PROCESS))
      else (RESTART.PROCESS PROCESS)
	     (QUOTE (RETURN)))])

(\REMOTE.PROCESS.SUSPEND
  [LAMBDA (COURIERSTREAM PROGRAM PROCEDURE PROCESS)          (* cdl " 3-Dec-85 19:16")
    (if (NOT (SETQ PROCESS (FIND.PROCESS PROCESS)))
	then (QUOTE (ABORT NO.SUCH.PROCESS))
      else (if (NEQ PROCESS (THIS.PROCESS))
		 then (SUSPEND.PROCESS PROCESS))
	     (QUOTE (RETURN)))])

(\REMOTE.PROCESS.TTY
  [LAMBDA (COURIERSTREAM PROGRAM PROCEDURE PROCESS)          (* cdl " 5-Dec-85 18:09")
    (if (NOT (SETQ PROCESS (FIND.PROCESS PROCESS)))
	then (QUOTE (ABORT NO.SUCH.PROCESS))
      else (TTY.PROCESS PROCESS)
	     (QUOTE (RETURN])

(\REMOTE.PROCESS.WAKE
  [LAMBDA (COURIERSTREAM PROGRAM PROCEDURE PROCESS STATUS)   (* cdl " 3-Dec-85 19:12")
    (if (NOT (SETQ PROCESS (FIND.PROCESS PROCESS)))
	then (QUOTE (ABORT NO.SUCH.PROCESS))
      else (WAKE.PROCESS PROCESS STATUS)
	     (QUOTE (RETURN)))])

(\REMOTE.PSW.SELECTED
  [LAMBDA (ITEM MENU BUTTON)                                 (* cdl " 3-Dec-85 20:00")
    (with PROCESSDATA (WINDOWPROP (WFROMMENU MENU)
				      (QUOTE PROCESSDATA))
	    (if (AND SELECTED (NEQ ITEM SELECTED))
		then (SHADEITEM SELECTED MENU WHITESHADE))
	    (SHADEITEM ITEM MENU SELECTIONSHADE)
	    (SETQ SELECTED ITEM])

(\REMOTE.PSWOP.SELECTED
  [LAMBDA (ITEM MENU BUTTON)                                               (* lmm 
                                                                           "28-Jan-86 01:39")
    (ALLOW.BUTTON.EVENTS)
    (LET [VALUE PROCESS ERROR NEWPROCESSDATA (WINDOW (WFROMMENU MENU))
                (COURIERSTREAM (WINDOWPROP (WFROMMENU MENU)
                                      (QUOTE COURIERSTREAM]
         (with PROCESSDATA (WINDOWPROP WINDOW (QUOTE PROCESSDATA))
               (if [NOT (EQUAL PROCESSES (fetch (PROCESSDATA PROCESSES) of (SETQ NEWPROCESSDATA
                                                                            (COURIER.CALL
                                                                             COURIERSTREAM
                                                                             (QUOTE PROCESS)
                                                                             (QUOTE GET.PROCESS.DATA]
                   then (if (MEMB SELECTED (fetch (PROCESSDATA PROCESSES) of NEWPROCESSDATA))
                            then (replace (PROCESSDATA SELECTED) of NEWPROCESSDATA with SELECTED))
                        (REMOTE.PSW.REDISPLAY WINDOW NEWPROCESSDATA)))
         (with
          PROCESSDATA
          (WINDOWPROP WINDOW (QUOTE PROCESSDATA))
          (if [NOT (EQUAL PROCESSES (fetch (PROCESSDATA PROCESSES) of (SETQ NEWPROCESSDATA
                                                                       (COURIER.CALL COURIERSTREAM
                                                                              (QUOTE PROCESS)
                                                                              (QUOTE GET.PROCESS.DATA
                                                                                     ]
              then (if (MEMB SELECTED (fetch (PROCESSDATA PROCESSES) of NEWPROCESSDATA))
                       then (replace (PROCESSDATA SELECTED) of NEWPROCESSDATA with SELECTED))
                   (REMOTE.PSW.REDISPLAY WINDOW NEWPROCESSDATA))
          (SELECTQ ITEM
              (WHO? (if (SETQ PROCESS (COURIER.CALL COURIERSTREAM (QUOTE PROCESS)
                                             (QUOTE GET.TTY.PROCESS)))
                        then (with REMOTE.PSW.MENUS (WINDOWPROP WINDOW (QUOTE MENU))
                                   (\REMOTE.PSW.SELECTED PROCESS PROCESSMENU))
                      else (PROMPTPRINT "No process has the tty!!!")))
              (UPDATE NIL)
              (if SELECTED
                  then
                  (SELECTQ ITEM
                      (KBD← (if (SETQ ERROR (COURIER.CALL COURIERSTREAM (QUOTE PROCESS)
                                                   (QUOTE SET.TTY.PROCESS)
                                                   SELECTED T))
                                then (PROMPTPRINT ERROR)))
                      ((BT BTV BTV* BTV!) 
                           (REMOTE.PROCESS.BACKTRACE SELECTED ITEM WINDOW))
                      (INFO (PROMPTPRINT "Not yet implemented"))
                      (KILL (if (SETQ ERROR (COURIER.CALL COURIERSTREAM (QUOTE PROCESS)
                                                   (QUOTE KILL)
                                                   SELECTED T))
                                then (PROMPTPRINT ERROR)
                              else (REMOTE.PSW.REDISPLAY WINDOW)))
                      (RESTART (if (SETQ ERROR (COURIER.CALL COURIERSTREAM (QUOTE PROCESS)
                                                      (QUOTE RESTART)
                                                      SELECTED T))
                                   then (PROMPTPRINT ERROR)))
                      (WAKE (PROG NIL
                                  (if
                                   (SETQ ERROR
                                    (COURIER.CALL
                                     COURIERSTREAM
                                     (QUOTE PROCESS)
                                     (QUOTE WAKE)
                                     SELECTED
                                     (SELECTQ [MENU (OR PROCOP.WAKEMENU
                                                        (SETQ PROCOP.WAKEMENU
                                                         (create MENU
                                                                ITEMS ←(QUOTE ((NIL (QUOTE NULL))
                                                                               T Other))
                                                                TITLE ←"WakeUp Value"
                                                                CENTERFLG ← T]
                                         (NIL (RETURN))
                                         (NULL NIL)
                                         (T T)
                                         (Other (CAR (OR (LISTP (PROCESS.READ 
                                                                 "Value to return to woken process: "
                                                                       ))
                                                         (RETURN))))
                                         NIL)))
                                      then (PROMPTPRINT ERROR))))
                      (SUSPEND (if (SETQ ERROR (COURIER.CALL COURIERSTREAM (QUOTE PROCESS)
                                                      (QUOTE SUSPEND)
                                                      SELECTED T))
                                   then (PROMPTPRINT ERROR)))
                      NIL])
)
(FILESLOAD COURIERDEFS)
(PUTPROPS REMOTEPSW COPYRIGHT ("Xerox Corporation" 1985 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (905 1590 (REMOTE.PROCESS.STATUS.WINDOW 915 . 1588)) (3449 16624 (
REMOTE.PROCESS.BACKTRACE 3459 . 5044) (REMOTE.PSW.REDISPLAY 5046 . 7798) (\REMOTE.GET.PROCESS.DATA 
7800 . 8048) (\REMOTE.PROCESS.BACKTRACE 8050 . 8907) (\REMOTE.PROCESS.KILL 8909 . 9409) (
\REMOTE.PROCESS.RESTART 9411 . 9723) (\REMOTE.PROCESS.SUSPEND 9725 . 10095) (\REMOTE.PROCESS.TTY 10097
 . 10398) (\REMOTE.PROCESS.WAKE 10400 . 10713) (\REMOTE.PSW.SELECTED 10715 . 11115) (
\REMOTE.PSWOP.SELECTED 11117 . 16622)))))
STOP