Google
 

Trailing-Edge - PDP-10 Archives - AP-D348E-SM - sources/execsu.mac
There are 47 other files named execsu.mac in the archive. Click here to see a list.
;<3-EXEC>EXECSU.MAC.252, 18-Apr-78 20:51:19, Edit by ENGEL
;DELETE CHANGES FOR MTOPR FUNCTION IN WAKE-UP MASK
;<3-EXEC>EXECSU.MAC.251,  9-Mar-78 09:21:15, Edit by ENGEL
;CHAGE SFMOD RFMOD TO INCLUDE MTOPR FOR FULL WAKE UP MASK
;<3-EXEC>EXECSU.MAC.249, 10-Nov-77 09:34:12, EDIT BY KIRSCHEN
;UPDATE COPYRIGHT FOR RELEASE 3
;<3-EXEC>EXECSU.MAC.248, 27-Sep-77 20:26:44, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.247, 27-Sep-77 10:49:43, EDIT BY HURLEY
;MAKE THE WORD FUNCTION ALSO ACCEPT CR-LF
;<3-EXEC>EXECSU.MAC.246, 22-Sep-77 18:27:15, EDIT BY HURLEY
;FIX EXEC TO NOT ENABLE PRIVILEGES DURING LOGIN
;<3-EXEC>EXECSU.MAC.245, 16-Sep-77 11:28:01, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.244, 15-Sep-77 20:01:27, EDIT BY P.HURLEY
;MAKE STPUSR NOT DO RCUSR IF NOT NECESSARY
;<3-EXEC>EXECSU.MAC.243,  1-Sep-77 22:42:23, EDIT BY P.HURLEY
;<3-EXEC>EXECSU.MAC.242, 28-Aug-77 14:18:33, EDIT BY OSMAN
;MAKE EXEC NOT KEEL OVER ON "I JO" PRINTOUT IF DIRST FOR CON. DIR. FAILS
;<3-EXEC>EXECSU.MAC.241, 25-Aug-77 14:38:24, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.240, 25-Aug-77 14:17:28, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.239, 25-Aug-77 11:04:17, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.238, 23-Aug-77 15:40:24, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.237, 23-Aug-77 10:16:06, EDIT BY HURLEY
;MAKE %R TAKE EITHER A DIR NUMBER OR A STRING POINTER
;<3-EXEC>EXECSU.MAC.236, 22-Aug-77 18:42:44, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.235, 22-Aug-77 18:40:46, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.234, 22-Aug-77 17:32:34, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.233, 22-Aug-77 17:01:56, EDIT BY HURLEY
;ADD ROUTINES TO GET USER/DIR NAMES ALLOWING WILD CARDS
;<3-EXEC>EXECSU.MAC.232, 16-Aug-77 12:39:48, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.231, 16-Aug-77 11:19:30, EDIT BY OSMAN
;ADD DGFRKS ROUTINE TO DO GFRKS JSYS FOR "INFO PROG" AND "FORK"
;<3-EXEC>EXECSU.MAC.230, 10-Aug-77 12:36:09, EDIT BY HURLEY
;<3-EXEC>EXECSU.MAC.229,  8-Aug-77 16:13:27, EDIT BY OSMAN
;FIX BUG WHEREBY COMMANDS LIKE "EXPUNGE" WERE UNINTENTIONALLY ALLOWING WILDCARDS IN DIRECTORY NAME
;<3-EXEC>EXECSU.MAC.228,  3-Aug-77 14:22:33, EDIT BY CROSSLAND
;MAKE AUTOLOGOUT TIMER NOT GO OFF IF YOU ARE LOGGED IN
;<3-EXEC>EXECSU.MAC.227,  1-Aug-77 12:20:42, EDIT BY OSMAN
;DON'T ALLOW "@FILESPEC" IN COMMAND IF USER ISN'T LOGGED IN
;<3-EXEC-NSW>EXECSU.MAC.1, 22-Jul-77 21:30:16, EDIT BY CALVIN
; Changes for CRJOB/PRARG runtime limit exceeded handling
; and TIMER autologout
;<3-EXEC>EXECSU.MAC.225, 25-Jul-77 16:52:14, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.224, 25-Jul-77 11:17:31, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.223, 25-Jul-77 11:12:24, EDIT BY OSMAN
;ADD GETDIR ROUTINE FOR DOING GTDIR JSYS
;<3-EXEC>EXECSU.MAC.222, 11-Jul-77 21:08:23, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.221, 11-Jul-77 17:57:54, EDIT BY OSMAN
;change $type to "prompt"
;<3-EXEC>EXECSU.MAC.220,  8-Jul-77 11:16:37, EDIT BY OSMAN
;DON'T WAIT FOR END OF LINE BEFORE PRINTING ERROR.  IT BREAKS ^H;<3-EXEC>EXECSU.MAC.219,  7-Jul-77 17:23:14, EDIT BY OSMAN
;ADD $ACCT TO READ ACCOUNTS
;<3-EXEC>EXECSU.MAC.218,  6-Jul-77 16:55:46, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.217,  6-Jul-77 16:31:09, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.216,  6-Jul-77 15:12:01, EDIT BY OSMAN
;remove no-longer-needed things
;<3-EXEC>EXECSU.MAC.215, 29-Jun-77 14:18:16, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.214, 29-Jun-77 12:38:44, EDIT BY OSMAN
;ADD SUBBP ROUTINE TO SUBTRACT TWO BYTE POINTERS
;<3-EXEC>EXECSU.MAC.213, 17-Jun-77 12:29:44, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.212, 16-Jun-77 22:31:02, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.211, 16-Jun-77 21:18:37, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.210, 16-Jun-77 21:15:43, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.209, 16-Jun-77 17:20:07, EDIT BY OSMAN
;ALLOW "@" UNLESS CALLER SAYS DON'T
;<3-EXEC>EXECSU.MAC.208, 16-Jun-77 17:19:42, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.207, 16-Jun-77 17:05:33, EDIT BY OSMAN
;REMOVE ERRONEOUS COJFN UPDATE IN TOUT1
;<3-EXEC>EXECSU.MAC.206, 14-Jun-77 15:28:11, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.205, 13-Jun-77 01:02:09, EDIT BY CROSSLAND
;MERGE ARPANET EXEC COMMANDS
;<3-EXEC>EXECSU.MAC.204,  9-Jun-77 17:15:17, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.203,  7-Jun-77 15:16:30, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.202,  6-Jun-77 10:59:55, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.200,  3-Jun-77 13:19:24, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.199,  3-Jun-77 12:34:25, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.198,  3-Jun-77 11:59:38, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.197,  2-Jun-77 21:39:32, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.196,  2-Jun-77 21:37:37, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.195,  2-Jun-77 21:23:27, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.194,  2-Jun-77 21:17:38, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.193,  2-Jun-77 16:59:44, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.192,  2-Jun-77 15:59:50, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.191,  2-Jun-77 14:43:10, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.190,  2-Jun-77 14:37:48, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.189,  2-Jun-77 13:38:13, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.188,  1-Jun-77 16:55:11, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.187,  1-Jun-77 15:58:41, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.186,  1-Jun-77 15:24:09, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.185,  1-Jun-77 15:22:56, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.184,  1-Jun-77 15:05:58, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.183,  1-Jun-77 14:53:49, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.182,  1-Jun-77 14:36:25, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.181, 23-May-77 09:59:09, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.180, 19-May-77 10:17:32, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.179, 18-May-77 17:16:36, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.178, 18-May-77 16:47:04, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.177, 18-May-77 14:35:18, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.176, 18-May-77 14:22:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.175, 18-May-77 13:58:52, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.174, 18-May-77 11:40:11, EDIT BY OSMAN
;<3-EXEC>FOO.BAR.4, 17-May-77 15:57:44, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.172, 17-May-77 12:40:13, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.171, 16-May-77 14:26:10, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.170, 13-May-77 13:30:12, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.169, 13-May-77 10:49:55, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.168, 12-May-77 21:40:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.167, 12-May-77 21:24:12, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.166, 12-May-77 19:34:49, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.165, 12-May-77 16:16:33, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.164, 10-May-77 17:26:17, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.163, 10-May-77 15:31:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.162, 10-May-77 15:18:50, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.161, 10-May-77 15:15:16, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.160, 10-May-77 14:15:48, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.159, 10-May-77 13:20:49, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.158, 27-Apr-77 17:52:21, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.157, 22-Apr-77 10:51:59, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.156, 21-Apr-77 15:35:36, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.155, 21-Apr-77 11:32:32, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.154, 21-Apr-77 11:21:01, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.153, 15-Apr-77 11:34:07, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.152, 14-Apr-77 16:32:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.151, 14-Apr-77 15:54:01, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.150, 14-Apr-77 14:17:02, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.149, 13-Apr-77 16:08:43, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.148, 13-Apr-77 13:41:30, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.147, 12-Apr-77 14:16:43, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.146, 12-Apr-77 10:36:00, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.145, 12-Apr-77 10:26:34, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.144, 11-Apr-77 21:14:00, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.143, 11-Apr-77 20:58:25, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.142, 11-Apr-77 18:15:06, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.141, 11-Apr-77 17:50:27, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.140, 11-Apr-77 17:32:47, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.139, 11-Apr-77 16:48:50, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.138, 11-Apr-77 14:14:41, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.137, 11-Apr-77 11:52:07, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.136, 11-Apr-77 10:36:46, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.135,  8-Apr-77 14:23:08, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.134,  7-Apr-77 16:21:39, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.133,  6-Apr-77 16:22:24, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.132,  6-Apr-77 10:50:31, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.131,  5-Apr-77 15:08:39, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.130,  4-Apr-77 16:49:04, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.129,  4-Apr-77 16:05:43, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.128, 31-Mar-77 16:40:11, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.127, 31-Mar-77 14:14:04, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.126, 31-Mar-77 14:08:20, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.125, 31-Mar-77 13:32:15, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.124, 31-Mar-77 11:34:36, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.123, 31-Mar-77 10:20:06, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.122, 23-Mar-77 15:16:09, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.121, 23-Mar-77 11:11:27, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.120, 18-Mar-77 16:54:15, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.119, 17-Mar-77 16:50:01, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.118, 11-Mar-77 16:45:20, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.117, 11-Mar-77 16:13:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.116, 10-Mar-77 16:35:44, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.115,  8-Mar-77 16:46:08, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.114,  8-Mar-77 16:32:17, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.113,  3-Mar-77 14:39:36, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.112,  2-Mar-77 14:00:37, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.111,  1-Mar-77 16:49:46, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.110, 24-Feb-77 16:29:07, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.109, 24-Feb-77 16:11:34, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.108, 24-Feb-77 14:48:46, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.107, 23-Feb-77 14:19:29, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.106, 23-Feb-77 13:23:28, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.105, 23-Feb-77 12:55:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.104, 22-Feb-77 16:29:34, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.103, 22-Feb-77 15:14:16, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.102, 22-Feb-77 14:53:54, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.101, 22-Feb-77 14:51:37, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.100, 21-Feb-77 13:58:29, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.99, 21-Feb-77 12:46:36, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.98, 18-Feb-77 18:47:52, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.97, 18-Feb-77 18:34:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.96, 18-Feb-77 18:09:57, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.95, 18-Feb-77 17:39:48, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.94, 18-Feb-77 17:28:29, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.93, 17-Feb-77 17:34:51, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.92, 17-Feb-77 17:17:01, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.91, 17-Feb-77 16:12:28, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.90, 17-Feb-77 13:29:11, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.89, 16-Feb-77 13:48:23, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.88, 16-Feb-77 13:30:30, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.87, 16-Feb-77 11:22:57, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.86, 16-Feb-77 10:54:42, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.85, 15-Feb-77 16:25:44, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.84, 15-Feb-77 11:24:45, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.83, 10-Feb-77 16:55:58, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.82, 10-Feb-77 15:20:14, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.81,  9-Feb-77 17:45:09, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.80,  9-Feb-77 16:39:56, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.79,  9-Feb-77 16:34:50, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.78,  9-Feb-77 14:20:32, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.77,  8-Feb-77 16:57:34, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.76,  8-Feb-77 14:24:18, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.75,  8-Feb-77 13:45:49, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.74,  8-Feb-77 11:59:17, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.73,  8-Feb-77 11:49:39, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.72,  7-Feb-77 15:05:09, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.71,  7-Feb-77 13:53:33, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.55,  2-Feb-77 14:06:19, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.52,  2-Feb-77 11:31:06, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.50,  1-Feb-77 16:01:31, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.49,  1-Feb-77 15:40:57, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.48,  1-Feb-77 15:33:48, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.46,  1-Feb-77 14:00:57, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.45,  1-Feb-77 13:42:45, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.44,  1-Feb-77 00:27:18, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.43, 31-Jan-77 23:35:38, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.42, 31-Jan-77 23:17:39, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.41, 31-Jan-77 22:59:45, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.40, 31-Jan-77 22:48:56, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.38, 31-Jan-77 15:41:10, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.29, 28-Jan-77 14:34:21, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.6, 26-Jan-77 17:18:38, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.5, 26-Jan-77 15:52:39, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.4, 26-Jan-77 14:59:47, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.3, 26-Jan-77 14:37:04, EDIT BY OSMAN
;<3-EXEC>EXECSU.MAC.2, 26-Jan-77 14:14:02, EDIT BY OSMAN
;<2-EXEC>EXECSU.MAC.525,  3-Dec-76 11:57:38, EDIT BY OSMAN
;<2-EXEC>EXECSU.MAC.524,  2-Dec-76 15:59:34, EDIT BY OSMAN
;<2-EXEC>EXECSU.MAC.523,  1-Dec-76 19:29:56, EDIT BY OSMAN
;<2-EXEC>EXECSU.MAC.522, 30-Nov-76 11:38:51, EDIT BY OSMAN
;TCO 1646 - IMPROVE "?" AFTER "COMMAND GARBAGE"
;<2-EXEC>EXECSU.MAC.515,  3-Nov-76 16:05:12, EDIT BY OSMAN
;	TCO 1477 - UNDERSTAND FULL WORD DIR AND USER NUMBERS
;<2-EXEC>EXECSU.MAC.436,  3-Aug-76 22:29:17, Edit by HESS
;<2-EXEC>EXECSU.MAC.425, 31-Jul-76 22:18:36, EDIT BY OSMAN
;	TCO 1480 - ALLOW EDITING BEYOND BEGINNING OF FIELDS
;<2-EXEC>EXECSU.MAC.424, 31-Jul-76 21:20:36, EDIT BY OSMAN
;<2-EXEC>EXECSU.MAC.413, 26-Jul-76 17:53:22, EDIT BY OSMAN
;	TCO 1477 - PUT IN 36-BIT DIR AND USER NUMBERS
;<1B-EXEC>EXECSU.MAC.412, 16-Jun-76 13:33:59, Edit by HESS
;	TCO 1428 - FIX LFJFNS, ALSO REMOVE ESC AT CWRD5
;<1B-EXEC>EXECSU.MAC.411, 14-JUN-76 20:00:16, Edit by HESS
;	TCO 1417 - WRITE PROTECT EXEC
;<1B-EXEC>EXECSU.MAC.410, 10-JUN-76 11:51:22, Edit by HESS
;<1B-EXEC>EXECSU.MAC.409,  8-JUN-76 22:32:10, Edit by HESS
;	TCO 1368
;<1B-EXEC>EXECSU.MAC.408,  7-JUN-76 20:15:59, Edit by HESS
;<EXEC>EXECSU.MAC.407, 13-APR-76 16:39:40, Edit by HESS
;	TCO 1249 (TEXTI BUFFER OVERFLOW)
;<EXEC>EXECSU.MAC.406, 26-MAR-76 02:18:16, Edit by HESS
;<EXEC>EXECSU.MAC.405, 26-MAR-76 00:58:33, Edit by HESS
;<EXEC>EXECSU.MAC.404, 25-MAR-76 23:24:30, Edit by HESS
;<EXEC>EXECSU.MAC.403, 24-MAR-76 15:44:52, Edit by HESS
;<EXEC>EXECSU.MAC.402, 23-MAR-76 17:28:44, Edit by HESS
;	ADD IPCF ROUTINES
;<EXEC>EXECSU.MAC.400, 18-MAR-76 16:13:38, Edit by HESS
;	TCO 1192, CLEANUP ERROR RETRY TYPEOUT
;<EXEC>EXECSU.MAC.399, 17-MAR-76 17:52:04, Edit by HESS
;	TCO 1190
;<EXEC>EXECSU.MAC.398, 15-MAR-76 14:45:42, Edit by HESS
;	TCO 1176
;<EXEC>EXECSU.MAC.397, 11-MAR-76 15:33:12, Edit by HESS
;<EXEC>EXECSU.MAC.396,  9-MAR-76 05:46:30, Edit by HESS
;	TCO 1165,1166
;<EXEC>EXECSU.MAC.395,  8-MAR-76 02:20:50, Edit by HESS
;	TCO 1156
;<EXEC>EXECSU.MAC.394, 27-FEB-76 22:59:07, Edit by HESS
;<EXEC>EXECSU.MAC.393, 27-FEB-76 17:32:02, Edit by HESS
;	TCO 1126
;<EXEC>EXECSU.MAC.392, 19-FEB-76 01:09:28, Edit by HESS
;	ADD TCO'S 1104,1105,1118,1119
;<EXEC>EXECSU.MAC.391, 13-FEB-76 14:47:30, Edit by HESS
;	ADD G1%RCM TO GET CONFIRMATION TEXT BACK (CFN4)
;<EXEC>EXECSU.MAC.390, 20-DEC-75 02:31:03, EDIT BY HESS

;TOPS20 'EXECUTIVE' COMMAND LANGUAGE - SUBROUTINES


;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1976, 1977, 1978 BY DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

	SEARCH MONSYM,XDEF,COMSYM,MACSYM
	.REQUIRE SYS:MACREL
	TTITLE SUBRS

;THIS FILE CONTAINS SUBROUTINES AND SERVICE ROUTINES IN THREE SECTIONS:
; 1. MONITOR-INDEPENDENT LANGUAGE DECODING OPERATIONS
; 2. MONITOR-DEPENDENT OPERATIONS, E.G. I/O
; 3. PSEUDO-INTERRUPT AND ERROR PROCESSORS
;INTERNS -- ROUTINES IN THIS ASSEMBLY

INTERN READY,read1,READY2,REPARS		;PRINT ONE OR TWO READY CHARACTERS (@ OR !)
INTERN PRVCK			;ROUTINE FOR CHECKING PRIVILEGES
INTERN %KEYW			;SERVICE ROUTINE FOR KEYWORD LOOKUP UUO (KEYWD)
INTERN %NOI			;SERV ROUTINE FOR NOISE WORD UUO ("NOISE" MACRO)
INTERN %SBCOM			;UUO TO INPUT AND DISPATCH ON SUBCOMMANDS
INTERN CONF			;TERMINATE AND CONFIRM COMMAND
INTERN SPRTR			;ANALYZE SEPERATOR/TERMINATOR IN ARG LIST
INTERN %TYPE,CTYPE		;TYPE MESSAGE SUBRS & UUOS
DEFINE XX (FOO)
<
INTERN $'FOO
>
ULIST

INTERN COUTFN,CSAVFN,SPECFN,CPFN	;INPUT IN, OUT, SPECIAL, PROG FILE NAMES
INTERN .INFG,$INFGX,DIRARG	;INPUT FILE GROUP DESCRIPTORS
INTERN TYPIF,TYPOK,GNFIL	;ROUTINES FOR STEPPING THRU FILES IN GRP
INTERN DEVN			;COLLECT DEVICE NAME
INTERN TOCT,OCTCOM,TOUT,TOUTD ;NUMBER OUTPUT SUBRS
INTERN BUFFF			;BUFFER LAST FIELD SUITABLY FOR USE AS JSYS ARG
INTERN NOECHO,DOECHO,LTTYMD,RTTYMD ;TTY MODES ETC
INTERN %PRINT			;OUTPUT CHARACTER UUO
INTERN CCHRO			;OUTPUT CHARACTER (OF COMMAND IF "STCF" ON)
INTERN MAPPF			;MAP PAGE OF FORK SUBR
INTERN LOADF			;LOAD WORD FROM FORK SUBR
INTERN STOREF			;STORE WORD INTO FORK SUBR
INTERN %GTB			;convenIENT GETAB JSYS CALL UUO

INTERN USEPSI			;TERMINAL PSI TO PRINT RUNTIME (^T)
INTERN NIYE,NIM,SCREWUP,JERR,JERRC ;VARIOUS ERROR CONDITIONS
INTERN %TRAP			;CHANNEL 1 ERROR PSI MESSAGE UUO
INTERN ILIPSI			;ILLEGAL INSTRUCTION PSI
INTERN EOFPSI			;END-OF-FILE PSEUDO-INTERRUPT ON CHANNEL 1
INTERN DATPSI			;FILE DATA ERROR INTERRUPT
INTERN CCPSI			;^C PSI ON CHANNEL 1
INTERN TLMPSI			;TIME EXCEEDED ON CHANNEL 4
INTERN COBPSI			;^O PSI ON CHANNEL 5
INTERN ALOPSI			;PSI ON CHAN 1 FROM AUTOLOGOUT FORK
INTERN AUTOLO			;ROUTINE TO DO AUTOLOGOUT
INTERN %ERR,%$ERR,%.$ERR	;GENERAL ERROR UUOS (MACROS "ERROR" ETC)
INTERN RERET			;NORMAL AFTER-ERROR ROUTINE FOR CERET TO PT TO
INTERN RLJFNS			;CLOSE & RELEASE JFNS USED BY CURRENT COMMAND
INTERN %ETYPE			;TYPE MESSAGE, INTERPRETING %-CODES
INTERN CERR
INTERN FLOAT			;FLOAT INTEGER IN A
;to do table lookup of next field of command, do:
;
;	helpx <this is what "?" types out>
;	keywd table		;"table" is address of table
;	t foo...		;appropriate "t" macro form of default value
;	 error return
;	success return		;p3 has value from table

%KEYW:	PUSH P,A		;DON'T CLOBBER ANY AC'S
	HLRO A,@-1(P)		;PICK UP POINTER TO DEFAULT FIELD VALUE
	AOS -1(P)		;SKIP THE DEFAULT ON RETURN
	TRNE A,-1		;LEAVE DEFAULT POINTER AS IS IF NO FIELD SUPPLIED
	MOVEM A,CMDEF		;SAVE DEFAULT STRING POINTER
	POP P,A
	ATSAVE			;SAVE AC'S
	HRRZ A,40		;PICK UP ADDRESS OF KEYWORD TABLE
	MOVEM A,CMDAT		;SAVE ADDRESS OF TABLE
	MOVX A,CMKEY	;PREPARE TO PARSE KEYWORD
	SKIPE CMDEF		;IS THERE A DEFAULT?
	TXO A,CM%DPP		;YES, TELL COMND TO READ IT
	skipe cmhlp		;user help message?
	txo a,cm%hpp		;yes, use it
	MOVEM A,CMFNP		;STORE FLAGS
	MOVEI B,FBLOCK		;GET ADDRESS OF FUNCTION BLOCK
	CALL FIELD		;INPUT THE KEYWORD FIELD
	SETZM CMDEF		;DON'T LET SAME DEFAULT BE USED OVER.
	setzm cmhlp		;don't let same help be used over
	TXNE A,CM%NOP		;MAKE SURE FIELD PARSED ALRIGHT
	RET			;DIDN'T, TAKE SINGLE RETURN
	CALL GETKEY		;GET KEYWORD DATA
	RETSKP			;GIVE SKIP RETURN

;ROUTINE TO TAKE TABLE ADDRESS IN B AND RETURN TABLE DATA IN P3.

GETKEY::	HRRZ P3,(B)		;GET ADDRESS OF CONTROL DATA
	MOVE P3,(P3)		;GET THE CONTROL DATA ITSELF
	RET			;GIVE GOOD RETURN

;FIELD INPUT ROUTINE.  CALL IT WITH ADDRESS OF FUNCTION DESCRIPTOR
;BLOCK IN AC "B".  ROUTINE RETURNS WITH "A" CONTAINING PARSE FLAGS

FIELD::	MOVEI A,CCHEOF		;GET EOF DISPATCH ADDRESS
	MOVEM A,EOFDSP		;WHERE TO GO ON END OF FILE
	MOVX A,CM%XIF		;GET BIT SAYING DON'T ALLOW INDIRECTION
	SKIPN CUSRNO		;IS USER LOGGED IN?
	IORM A,CMFLG		;NO, SO DON'T ALLOW "@"
	MOVEI A,SBLOCK		;ADDRESS OF COMMAND STATE BLOCK
	COMND			;DO THE COMND JSYS ITSELF (ONLY ONE IN EXEC! 6/16/77 EO)
	 ERCAL EOFJER		;FAILED, SAY WHY AND DIE
	AOS TTYACF		;NOTE THAT SOME TTY ACTION OCCURED
	SETZM CMDEF		;CLEAR DEFAULT STRING, SO ISN'T USED AGAIN INADVERTANTLY
	SETZM CMHLP		;CLEAR HELP MESSAGE, SO IT ISN'T USED AGAIN
	SETZM CMDAT		;DON'T LET SAME DATA BE ARBITRARILY USED AGAIN
	SETZM EOFDSP		;CLEAR EOF DISPATCH ADDRESS
	MOVX A,CM%XIF
	ANDCAM A,CMFLG		;ALLOW "@" UNLESS CALLER SAYS DON'T
	MOVE A,CMFLG		;RETURN FLAGS IN A
	RET

GETTER::MOVE A,SBLOCK+.CMPTR	;GET POINTER TO REST OF LINE
	ILDB A,A		;GET NEXT CHARACTER AFTER PARSED FIELD
	RET

;ROUTINE WHICH SKIPS IFF LAST FIELD WASN'T TERMINATED WITH ALTMODE.
;THIS ROUTINE ONLY NEEDS TO BE CALLED IN SITUATIONS WHERE IT'S AMBIGUOUS
;AS TO WHETHER USER SHOULD BE PROMPTED FOR NEXT FIELD, OR ALLOWED TO ENTER
;MORE FOR THIS FIELD.  FOR INSTANCE, IN A "COPY" COMMAND, "COPY FOO$":
;SHOULD WE WAIT FOR MORE, DESPITE THE ALTMODE, IN CASE USER WANTS TO
;MAKE IT "COPY FOO,BAR (TO) ...", OR SHOULD WE ASSUME THAT THE ALTMODE
;MEANS DO "COPY FOO (TO)" ?  THE CURRENT ANSWER IS THAT THE ALTMODE MEANS
;GO ON TO THE NEXT FIELD.  OTHERWISE, USER WOULD NEVER SEE "(TO)" PRINTED
;OUT.  ANOTHER EXAMPLE IS A COMMAND LIKE "SET PAGE-ACCESS 1:3$".  ALTHOUGH
;THE USER COULD AT THIS POINT MAKE IT "...1:3,4...", WE ASSUME THAT
;THE ALTMODE MEANS GO ON TO NEXT FIELD, HENCE MAKING IT
;"SET PAGE-ACCESS 1:3 (TO)".  THIS ROUTINE CLOBBERS NO AC'S.

NESC:	ATSAVE			;PRESERVE TEMPY'S
	MOVE A,CMFLG		;GET FLAGS
	TXNE A,CM%ESC		;LAST FIELD END WITH ALTMODE?
	RET			;YES, NO SKIP
	RETSKP			;NO,  SO SKIP

;ROUTINE TO INITIALIZE COMMAND LINE JSYS AND PRINT PROMPT FOR NEW COMMAND.

READY:	MOVEM A,CMDACS		;DON'T CLOBBER ANY AC'S
	HRROI A,[ASCIZ /@/]	;ONE PROMPT FOR REGULAR COMMAND
	SKIPE PRVENF		;BUT IF PRIVILEGES ENABLED,
	HRROI A,[ASCIZ /$/]	;USE A DOLLAR SIGN
	JRST READ1		;JOIN COMMON CODE

READY2:	MOVEM A,CMDACS		;DON'T CLOBBER AC1
	HRROI A,[ASCIZ /@@/]	;TWO ATSIGNS FOR SUBCOMMAND MODE
	SKIPE PRVENF		;DOLLAR SIGNS IF PRIVILEGES ON
	HRROI A,[ASCIZ /$$/]

;enter here for custom prompt characters:

READ1:	MOVEM A,CMRTY		;SET UP PROMPT BUFFER
	POP P,REPARA		;REMEMBER WHERE TO REPRASE TO
	MOVE A,CMDACS		;GET SAVED AC1 (SEE %$TYPE:)
	MOVEM 17,CMDACS+17	;SAVE AC17 AWAY
	MOVEI 17,CMDACS		;MAKE BLT POINTER 0,,CMDACS
	BLT 17,CMDACS+16	;SAVE REST TO AC'S
	MOVE 17,CMDACS+17	;LEAVE AC17 INTACT
	MOVE A,JBUFP		;GET CURRENT LOCATION ON JFN STACK
	MOVEM A,.J		;REMEMBER WHERE WE ARE FOR REPARSE
	HRR A,COJFN		;GET OUTPUT JFN
	HRL A,CIJFN		;AND INPUT
	MOVEM A,CMIOJ
	HRRZ A,CIJFN		;FIND OUT WHERE WE'RE READING FROM
	DVCHR
	LDB B,[221100,,B]	;GET DEVICE TYPE OF INPUT DEVICE
	HRROI A,[0]		;GET NULL STRING
	CAIE B,.DVTTY		;INPUTTING FROM A TERMINAL?
	MOVEM A,CMRTY		;NO PROMPT UNLESS INPUTTING FROM TERMINAL
	MOVX A,CMINI		;DO INITIALIZATION, PRINT PROMPT
	MOVEM A,CMFNP
	MOVEI B,FBLOCK		;SPECIFY FUNCTION BLOCK ADDRESS
	CALL FIELD		;TYPE THE PROMPT
	MOVE A,CMDACS+A
	MOVE B,CMDACS+B		;RESTORE AC'S WE USED
	MOVE C,CMDACS+C		;LEAVE ALL AC'S AS WE FOUND THEM
	JRSTF @REPARA		;RETURN TO CALLER

;GUIDE WORD HANDLER, INVOKED WITH "NOISE" MACRO

%NOI:	ATSAVE			;DON'T CLOBBER AC'S
	HRRO A,40		;GET POINTER TO GUIDE STRING
	MOVEM A,CMDAT		;SET UP GUIDE STRING
	MOVX A,CMNOI		;SPECIFY NOISE FUNCTION
	MOVEM A,CMFNP
	MOVEI B,FBLOCK
	CALL FIELD		;READ THE GUIDE WORDS
	TXNE A,CM%NOP		;MAKE SURE THEY PARSED CORRECTLY
	 CMERRX
	RET
;PRVCK
;SUBROUTINE TO CHECK SPECIAL CAPABILITIES THIS USER HAS AGAINST THOSE
; REQUIRED AS INDICATED BY BITS IN B, GENERALLY FROM
; A KEYWORD TABLE.
;SKIPS UNLESS SPEC CAP(S) ARE REQUIRED BUT USER HAS NONE OF THEM.
;USES: FORK COMMAND (XCMD1.MAC), %KEYWD (JUST ABOVE).

PRVCK:	TLNN B,WHLUO+OPRUO+ERRUO
	RETSKP
	SKIPN CUSRNO		;MUST BE LOGGED IN TO HAVE PRIVILEGES
	RET
	ATSAVE
	MOVE D,B
	MOVEI A,B0
	RPCAP			;READ CAPABILITIES ENABLED FOR THIS PROCESS
	TLNE D,WHLUO
	TXNN	C,SC%WHL
	JRST .+2
	JRST PRVCK8		;WHEEL COMMAND AND "ENABLE"D WHEEL USER
	TLNE D,OPRUO
	TXNN	C,SC%OPR
	JRST .+2
	JRST PRVCK8		;OPERATOR COMMAND AND "ENABLE"D OPERATOR USER
	TLNE D,ERRUO
	TXNN	C,SC%CNF	;TEST "CONFIDENTAIL INFORMATION ACCESS" CAP
	RET
PRVCK8:	RETSKP
;SBCOM UUO
;INPUT AND DISPATCH ON SUBCOMMANDS, USING TABLE EFFECTIVE ADDR POINTS TO
;TERMINATES ON NULL SUBCOMMAND OR ONE WITH 0 DISPATCH ADDRESS
;USES INCLUDE DIRECTORY, COPY, PRINT, CREATE, TYPE/LIST

%SBCOM:	PUSH P,P4
	PUSH P,CERET		;REMEMBER OLD COMMAND ERROR ADDRESS
	PUSH P,.JBUFP		;REMEMBER JFN STACK FRAME
	PUSH P,Q1
	PUSH P,40
	MOVEI A,SBCOM1
	MOVEM A,CERET		;SAY COME BACK HERE AFTER PRINTING ERROR MESSAGE
	MOVE A,JBUFP
	MOVEM A,.JBUFP		;PREVENT ERRONEOUS SUBCOMMANDS FROM CAUSING COMMAND JFNS TO BE FLUSHED
SBCOM1:
	CALL READY2		;TYPE 2 READY CHARACTERS: @@ OR !!
	SETZB P2,Q3		;CLEAR TERMINATOR AND BITS: EOL HERE WOULD
				;MAKE "KEYWD" DEFAULT THO IT SHOULDN'T.
	MOVEI B,[FLDDB. .CMCFM,,,,,fblock]
	MOVEI C,@0(P)		;GET ADDRESS OF KEYWORD TABLE
	movem c,cmdat		;store address of keyword table
	movx a,cmkey		;specify keyword function, no special flags
	movem a,cmfnp		;store function
	CALL FIELD		;READ TYPED IN FIELD
	TXNE A,CM%NOP		;MAKE SURE WE READ A GOOD THING
	 CMERRX <Carriage return or subcommand required>
	LDB C,[331100,,.CMFNP(C)]	;GET FLAVOR OF FIELD THAT WE READ
	cain c,.cmcfm		;did use type blank line?
	jrst endsub		;yes, end subcommands
	;assume that if parse was correct and not cr, then subcommand typed
	HRRZ P3,(B)		;GET ADDRESS OF CONTROL DATA
	MOVE P3,(P3)		;GET THE CONTROL DATA ITSELF
	TLZ Z,F1		;REQUIRED BY SOME COMMANDS, EG "CREATE".
	MOVE P4,P3		;SAVE KEYWORD'S BITS FOR "CONFIRM" ETC
	TLNE P4,ONEWD		;IF "ONE WORD COMMAND" BIT ON,
	CONFIRM			;CONFIRM BEFORE DISPATCH
	MOVE Q1,-1(P)		;PRESERVE Q1 FOR "CREATE"
				;(I DON'T THINK IT CAN GET CLOBBERED ANYWAY)
	TRNN P4,-1
	CALL SBCOM9		;0 DISPATCH ADDRESS MEANS TERMINATE SUBCOMMANDS
	CALL (P4)		;CALL CALLER'S ROUTINE FOR THIS SUBCOMMAND
	MOVEM Q1,-1(P)
	JRST SBCOM1		;GO GET ANOTHER

;TERMINATING SUBCOMMAND INPUT
ENDSUB:
SBCOM9:	POP P,40
	POP P,Q1
	POP P,.JBUFP		;RESTORE JFN STACK FRAME
	POP P,CERET		;RESTORE COMMAND ERROR POINTER
	POP P,P4
	TLZ Z,F1		;SOME COMMANDS EXPECT THIS OFF
	RET

;CONF
;CONFIRMATION AND COMMAND TERMINATION SUBROUTINE
;ALL COMMANDS, EVEN NON-CONFIRMATION ONES, SHOULD CALL THIS.

;IF TYPIST TYPES "?", IT TELLS HIM THAT IT'S WAITING FOR
;CONFIRMATION.  IF HE STARTS WITH ! OR ; (RECOGNIZED COMMENT CHARACTERS
;DUE TO PHASE OF MOON AT TIME OF THIS DOCUMENTATION), IT ALLOWS
;A COMMENT TO PRECEDE THE CONFIRMATION.  (CONFIRMATION ITSELF IS
;CARRIAGE RETURN, LINEFEED, CONTROL-L ETC.)  IF A NON-COMMENT PRECEDES
;THE CONFIRMATION, AN ERROR MESSAGE RESULTS.

;FCONF PRINTS [CONFIRM] THEN FORCES FURTHER CONFIRMATION

FCONF::	prompt <[Confirm]>
FCONFA::
;CONF

CONF:	ATSAVE			;SAVE TEMPORARIES
	CRRX <Confirm with carriage return>
	 CMERRx			;BAD CONFIRMATION TYPED
	RET			;GOOD CONFIRMATION, RETURN.
;SPRTR
;READS END OF LINE, DETECTING COMMA FOR SUBCOMMANDS.  TAKES non-skip RETURN IF COMMA THEN
;CARRIAGE RETURN.  TAKES SKIP IF JUST CARRIAGE RETURN.

SPRTR:	ATSAVE		;DON'T CLOBBER AC'S
	COMMAX <Confirm with carriage return or comma to enter subcommands>
	 JRST SPR1	;NOT COMMA, MAYBE END OF INE
	CRRx <Carriage return to enter subcommands>
	 ERROR <Carriage return required after comma to enter subcommands>
	RET		;REGULAR SKIP IF COMMA SEEN

SPR1:	CRRX		;NO COMMA, CHECK FOR END OF LINE
	 ERROR <Comma or carriage return required>
	RETSKP		;TYPIST ENDED LINE WITH NO COMMA

;GET HERE FOR LINE REPARSE, WHICH HAPPENS WHEN PREVIOUSLY
;PARSED FIELDS ARE REQUIRED TO BE REPARSED.

REPARS:
	MOVE A,.J		;FIX JFN STACK
	MOVEM A,.JBUFP		;RESTORE JFN STACK FRAME
	CALL UNMAP		;UNMAP SPECIAL PAGES
	CALL FLJFNS		;GET RID OF ANY JFN'S THAT WERE USED FOR COMMAND
	MOVSI 17,CMDACS		;MAKE BLT POINTER CMDACS,,0
	BLT 17,17		;RESTORE AC'S TO HOW THEY WERE WHEN THIS PART OF COMMAND STARTED
	JRSTF @REPARA		;RETURN TO BEGINNING OF COMMAND LINE

;EOF WHILE READING COMMAND FILE

CCHEOF:	CALL CIOREL
	JFCL
	ETYPE < End of %1S
>
	CLOSF			;CLOSE INPUT SIDE
	 CALL JERR		;SHOULDN'T FAIL
	JRST CMDIN4		;GO BACK FOR NEXT COMMAND

;ROUTINE TO POP BACK TO LAST EXEC INPUT STREAM.  RETURNS WITH JFN
;OF OLD INPUT IN AC1.
;IT SKIP RETURNS IFF THERE WAS NOTHING TO DELETE (I.E. ONLY ONE
;SET OF JFNS ON THE COMAND STREAM STACK
;IT CLOSES THE OUTPUT SIDE, AND LEAVES RIJFN HOLDING THE INPUT
;SIDE BUT INPUT ISN'T CLOSED YET, SO THAT ERROR MESSAGES ETC. MAY
;DO JFNS ON INPUT JFN BEFORE CLOSING IT.

CIOREL::	MOVE A,IOPT		;GET POINTER TO STREAM STACK
	POP A,B			;GET OLD JFNS
	CAMN A,IOPTB		;ONLY ONE SET ON STACK?
	RETSKP			;YES, SKIP RETURN BUT OTHERWISE DO NOTHING
	MOVE C,(A)		;GET "NEW" ONES
	MOVEM A,IOPT		;STORE UPDATED POINTER
	HRRZM C,COJFN
	HLRZM C,CIJFN		;RESTORE OLD VALUE OF IO CELLS
	HRRZ A,B
	CLOSF			;CLOSE OUTPUT BUT NOT INPUT YET
	 ERCAL JERR
	HLRZ A,B		;RETURN INPUT JFN IN A
	RET

;ROUTINE TO GET RID OF ALL COMMAND JFNS.  THIS HAPPENS, FOR INSTANCE,
;IF USER TYPES ^C DURING "TAKE" COMMAND PROCESSING
;SKIPS IFF THERE ARE NONE TO GET RID OF

CLRIO:	CALL CIOREL		;CLOSE STREAM
	 CAIA			;THERE WAS AT LEAST ONE TO CLOSE
	RETSKP			;NONE TO CLOSE, TAKE SKIP
	PUSH P,A		;SAVE JFN IN CASE LAST ONE
CLR1:	CALL CIOREL		;CLOSE NEXT ONE
	 JRST CLR2		;NEXT ONE WASN'T LAST
	POP P,A			;IT WAS THE LAST ONE, SO RETURN IT
	RET

CLR2:	EXCH A,(P)			;GET THE ONE THAT WASN'T LAST
	CLOSF			;CLOSE THE INPUT SIDE
	 CALL JERR		;SHOULDN'T FAIL
	JRST CLR1		;LOOP BACK TO CLOSE THE REST
;UUO DISPATCH TABLE

CUUOT:	 EXP %ERR,%TYPE,%KEYW
        EXP %NOI,%$TYPE,%LERRO
	EXP 0,%$ERR,%ETYPE,%GTB
	EXP %PRINT,%TRAP,%.$ERR
	EXP %SBCOM
%%U==.-CUUOT
DEFINE XX(UUL)
<
%%X==.
RELOC CUUOT+<U'UUL>_-^D23-20	;;BITS 0-8 CAN'T BE 0
	$'UUL
IFG .-CUUOT-%%U,<%%U==.-CUUOT>
RELOC %%X
>
ULIST
RELOC CUUOT+%%U		;LEAVE ROOM FOR ALL UUO ENTRIES

;UUO DISPATCHER

CUUO::   MOVEM A,CTUUO
        HLRZ A,40
        LSH A,-5
        HRRZ A,CUUOT-20(A)
        EXCH A,CTUUO
        JRST @CTUUO

;SERVICE ROUTINE FOR OUTPUT STRING UUO ("TYPE" MACRO)
;       UTYPE [ASCIZ @TEXT@]

;AND
;SUBROUTINE TO TYPE STRING FOR BYTE PTR IN A (CTYPE)

%TYPE:  PUSH P,A		;UUO SERVICE ENTRY
	HRR A,40
	HRLI A,<POINT 7,0,-1>B53 ;FORM BYTE POINTER TO ARGUMENT
TYP1:   PUSH P,B
TYP2:   ILDB B,A
	JUMPE B,[POP P,B
		POP P,A
		RET]
	CALL CCHRO		;OUTPUT CHARACTER IN B
	JRST TYP2

CTYPE:  PUSH P,A		;SUBR ENTRY
	JRST TYP1

;ROUTINE INVOKED BY "$TYPE <FOO>" MACRO.  IT STARTS A NEW LINE
;PART OF THE COMMAND, WITH THE PROMPT BEING "FOO".


%$TYPE:	MOVEM A,CMDACS		;WE DON'T WANT TO CLOBBER ANYTHING
	MOVEI A,@40		;GET ADDRESS OF PROMPT STRING
	HRLI A,440700		;MAKE BYTE POINTER
	CALLRET READ1		;TYPE PROMPT AND RETURN TO PROGRAM

;SEE ALSO "%ETYPE" IN S3.MAC

;ROUTINES FOR INPUTTING FIELDS OF COMMAND.  INVOKED BY MACROS.
;THESE ROUTINES ARE NAMED $FOO AND %FOO.  ROUTINE $FOO ASSUMES
;THE EFFECTIVE ADDRESS OF THE UUO CONTAINS THE HELP STRING FOR
;THE FIELD.  %FOO ASSUMES THAT THE PREVIOUS HELP STRING IS TO
;BE USED.

;DECIMAL NUMBER...

$DEC:	CALL GETHLP		;SET UP HELP MESSAGE
	MOVEI A,5+5		;RADIX
NUM13:	MOVEM A,CMDAT
	MOVX A,CMNUM
	CALL $WORK		;INPUT THE NUMBER
	 RET			;SINGLE RETURN, NON-NUMBER TYPED
	RETSKP			;SKIP RETURN, GOOD NUMBER TYPED

;OCTAL NUMBER

$OCT:	CALL GETHLP
	MOVEI A,8		;OCTAL RADIX
	JRST NUM13		;JOIN COMMON CODE

;TIME

$TIME:	CALL GETHLP
	MOVX A,CM%ITM		;TIME ONLY
	MOVEM A,CMDAT
	MOVX A,CMTAD		;TIME AND DATE FUNCTION
	CALLRET $WORK

;DATE AND TIME
;IF DATE IS OMITTED, TODAY IS ASSUMED.  IF TIME IS OMITTED, MIDNIGHT
;IS ASSUMED.
;AN ALTERNATE FORM, "+TIME" MAY BE TYPED, WHICH ASSUMES NOW PLUS
;WHATEVER AMOUNT OF TIME IS ENTERED.

$DT:	CALL GETHLP
	MOVX A,CM%IDA+CM%ITM
	MOVEM A,CMDAT		;FIRST FUNCTION IN CHAIN IS DATE AND TIME
	MOVE A,[CMTAD+[FLDDB. .CMTAD,CM%SDH,CM%IDA,,,[
		FLDDB. .CMTAD,CM%SDH,CM%ITM,,,[
		FLDDB. .CMTOK,CM%SDH,<-1,,[ASCIZ /+/]>,<"+" to enter amount of time from now>,,]]]]
	CALL $WORK
	RET			;BAD INPUT TYPED
	LDB C,[331100,,(C)]	;GET FUNCTION FLAVOR
	CAIE C,.CMTOK		;"+"?
	RETSKP			;NO, SO REAL DATE AND TIME TYPED
	TIMEX <Amount of time from now in form hh:mm>
	 RET			;INVALID TIME TYPED AFTER "+" SIGN
	PUSH P,B		;SAVE TIME TYPED
	MOVE A,CSBUFP		;GET SOME STRING SPACE TO USE
	MOVX C,OT%NTM		;WE WANT ONLY THE DATE
	HRROI B,-1		;WE WANT TODAY
	ODTIM			;GET STRING FOR TODAY
	HRROI B,[ASCIZ / 12:0:0AM/]
	MOVEI C,0
	SOUT			;NOW WE'VE GOT STRING FOR BEGINNING OF TODAY
	MOVE A,CSBUFP		;POINT AT ENTIRE STRING
	MOVEI B,0		;NO SPECIAL FLAGS
	IDTIM			;GET INTERNAL FORM FOR BEGINNING OF TODAY
	 ERCAL JERR		;SHOULDN'T FAIL
	POP P,C			;GET WHAT USER TYPED
	SUB C,B		;GET INTERNAL FORM OF WHAT USER TYPED
	GTAD			;GET CURRENT DATE AND TIME
	ADD A,C		;GET ABSOLUTE INTERNAL FORM OF WHAT USER MEANT
	MOVE B,A		;RETURN INTERNAL VALUE IN B
	RETSKP

;QUOTED STRING

$QUOTE:	CALL GETHLP
	MOVX A,CMQST		;QUOTED STRING FUNCTION CODE
	CALLRET $WORK

;USER NAME

$USERS:	MOVX A,CM%DWC		;ALLOW WILD CARDING
	MOVEM A,CMDAT		;STOR IN DATA FIELD
$USER:	CALL GETHLP
	MOVX A,CMUSR		;USER NAME FUNCTION
	CALLRET $WORK

;DIRECTORY NAME

$DIRS:	MOVX A,CM%DWC		;ALLOW WILD CARDING
	MOVEM A,CMDAT		;STOR IN DATA FIELD
$DIR:	CALL GETHLP
	MOVX A,CMDIR
	CALLRET $WORK

;STRUCTURE NAME, LIKE DEVICE BUT NEEDN'T EXIST

$STR:	CALL GETHLP
	MOVX A,CMFLD		;PARSE IT AS A FIELD
	CALL $WORK
	 RET
	PUSH P,ATMBUF
	PUSH P,ATMBUF+1
	PUSH P,ATMBUF+2		;SAVE NAME
	COLONX <Colon to terminate device name>
	 ERROR <Colon required>
	POP P,ATMBUF+2
	POP P,ATMBUF+1
	POP P,ATMBUF
	HRROI A,ATMBUF		;RETURN POINTER IN A TO STRUCTURE NAME
	RETSKP

;DEVICE

$DEV:	CALL GETHLP
	MOVX A,CMDEV
	CALL $WORK
	 RET
	RETSKP

;FILE SPECIFICATION

$FILE:	CALL GETHLP
	MOVX A,CMFIL		;SPECIFY FILE FUNCTION
	CALLRET $WORK

;READ ENTIRE REST OF LINE

$LINE:	CALL GETHLP
	MOVX A,CMTXT		;TEXT FUNCTION
	CALL $WORK
	 RET
	RETSKP

;CONTROL-E

$CTRLE:	HRROI A,[ASCIZ //]	;EXPECTED FIELD
	JRST CHAR		;JOIN COMMON CODE

;PARSE A COMMA

$COMMA:	CALL GETHLP
	MOVX A,CMCMA		;COMMA FUNCTION
	CALLRET $WORK

;PARSE A SLASH

$SLASH:	HRROI A,[ASCIZ ./.]
	JRST CHAR

;PARSE A BACKSLASH

$BSLSH:	HRROI A,[ASCIZ .\.]
	JRST CHAR

;PARSE A DOT

$DOT:	HRROI A,[ASCIZ /./]
	JRST CHAR

;PARSE A COLON

$COLON:	HRROI A,[ASCIZ /:/]
	JRST CHAR

;PARSE CHARACTER PASSED IN AC1

$CHAR:	STKVAR <STRNG>		;STORAGE FOR CHARACTER STRING
	ROT A,-7		;MAKE ASCIZ STRING
	MOVEM A,STRNG		;PUT IT ON STACK
	HRROI A,STRNG		;POINT TO STRING
	JRST CHAR		;FINISH UP

;PARSE A FIELD WHICH IS JUST "*"

$STAR:	HRROI A,[ASCIZ /*/]	;EXPECTED FIELD
CHAR:	MOVEM A,CMDAT
	CALL GETHLP
	MOVX A,CMTOK
	CALL $WORK
	 RET
	RETSKP

;PARSE A HYPHEN

$DASH:	HRROI A,[ASCIZ /-/]
	JRST CHAR		;USE COMMON CODE

;ACCOUNT

$ACCT:	CALL GETHLP		;SET UP HELP TEXT
	MOVX A,CMACT		;SPECIFY ACCOUNT FUNCTION
	CALLRET $WORK

;word

$word:	USTAR @40		;WORD MIGHT BE "*"
	 CAIA			;NON-* TYPED
	RETSKP			;YUP, WAS.
	call gethlp
	movx a,cmfld		;arbitrary field function
	callret $work

;END OF LINE

$CRR:	CALL GETHLP
	MOVX A,CMCFM		;"CONFIRM" FUNCTION
	CALL $WORK
	 RET			;NON-END-OF-LINE TYPED
	RETSKP

$WORK:	MOVEI B,FBLOCK		;GET ADDRES OF FUNCTION BLOCK
$WORKB:	TXO A,CM%HPP+CM%DPP+CM%SDH	;USE OUR OWN HELP AND DEFAULTS
	SKIPN CMDEF		;ANY DEFAULT STRING SUPPLIED?
	TXZ A,CM%DPP		;NO, SO TELL COMND THERE'S NONE
	MOVEM A,CMFNP
	CALL FIELD		;INPUT THE FIELD
	ATSAVE			;SAVE AC'S (THEY CONTAIN PARSED FIELD)
	TXNE A,CM%NOP		;MAKE SURE IT PARSED CORRECTLY
	 RET			;INCORRECT, SINGLE RETURN
	RETSKP			;GOOD, SKIP RETURN

GETHLP:	SKIPN A,@40		;GET HELP STRING
	RET			;USE SAME AS LAST TIME
	HRRO A,40		;GET POINTER TO HELP STRING
	MOVEM A,CMHLP		;SET UP HELP TEXT POINTER
	RET

;service "helpx" macro.  use arg as default help string for next
;field input.

$help:	hrro a,40		;get pointer to string
	movem a,cmhlp		;store help string
	ret

;SERVICE ROUTINE FOR DEXTX MACRO, WHICH SETS UP
;JFN BLOCK WITH DEFAULT EXTENSIONS FOR INPUT AND OUTPUT FILESPECS

$DEXT:		SETZM CJFNBK		;CLEAR OUT JFN BLOCK
	MOVE A,[CJFNBK,,CJFNBK+1]
	BLT A,CJFNBK+JBLEN-1
	HRRO A,40		;GET DEFAULT EXTENSION
	SKIPE @40		;DON'T SET UP POINTER IF NO DEFAULT EXTENSION
	MOVEM A,CJFNBK+.GJEXT	;STORE IT
	RET

;ROUTINE TO SERVICE "DEFX" MACRO, WHICH SETS THE DEFAULT STRING
;VALUE

$DEF:	HRRO A,40		;GET POINTER TO DEFAULT FIELD VALUE
	MOVEM A,CMDEF		;SET UP DEFAULT STRING VALUE
	RET
;MULTI FILE INPUT AND OUTPUT ROUTINES

;SCAN OUTPUT FILESPEC FOR MULTI FILE OP
;IF GROUPF NOT SET, DEFAULTS NAME AND EXT TO INPUT JFN
;RETURNS OUTPUT JFN IN OUTDSG
;IF GROUPF SET, DEFAULTS TO *.*;-1 AND RETURNS JFN IN MCOJFN
MFOUT::
MCOPY0:	MOVE A,[XWD [ASCIZ/*/],[ASCIZ/*/]] ;DEFAULT TO *'S
	MOVE B,INIFH1
	CAME B,INIFH2		;IF EXACTLY 1 TERM, MAYBE USE NAMES
	JRST MCOPY1
	MOVE B,@INIFH1		;GET JFN AND BITS
	TXNN	B,GJ%NAM	;* FOR NAME?
	HRLI A,2		;NO, USE PREVIOUS NAME
	TXNN	B,GJ%EXT	;* FOR EXT?
	HRRI A,2		;NO, USE PREVIOUS EXT
MCOPY1:	MOVEI B,(GJ%FOU+GJ%IFG+GJ%OFG+GJ%MSG)	;DEFAULT TO -1 VERSION
	CALL SPECFN		;COLLECT FILE NAME, GTJFN FLAGS IN RH B.
	 JRST CERR
	MOVEM A,OUTDSG		;DESTINATION JFN
	MOVEM A,MCOJFN		;HERE FOR MULTI FILE COPY
	MOVE B,A		;PUT FILE HANDLE IN B (WITH WILDCARD BITS)
	LDF C,1B2		;BITS TO GET DEVICE FIELD
	TXNE B,GJ%DEV+GJ%UNT	;WILDCARDS USED IN DEVICE FIELD?
	CALL BADSTR		;ERROR IF BAD WILDCARD SYNTAX
	LDF C,1B5		;SPECIFY DIRECTORY
	TXNE B,GJ%DIR		;STAR IN DIRECTORY FIELD?
	CALL BADSTR		;YES, MAKE SURE IT'S LEGAL
	LDF C,1B8		;NAME FIELD
	TXNE B,GJ%NAM
	CALL BADSTR		;MAKE SURE LEGAL STARS IN NAME FIELD
	LDF C,1B11		;TYPE FIELD (EXTENSION)
	TXNE B,GJ%EXT
	CALL BADSTR
	LDF C,1B14		;GENERATION NUMBER
	TXNE B,GJ%VER
	CALL BADSTR		;MAKE SURE LEGAL WILCARDS IN GENERATION FIELD
	HLRZ A,JBUFP		;WILL REQUIRE AT LEAST 1 MORE JFN FOR COMMAND
	CAIN A,-1
	ERROR <Too many JFNs in command>
	RET

;FOLLOWING ROUTINE RETURNS IFF STRING RETURNED BY JFNS CONTAINS
;ONLY "*".  CALL THIS ROUTINE WITH INDEXABLE FILE HANDLE (FLAGS,,JFN)
;IN B, AND JFNS BITS IN C.  AC'S PRESERVED.  THE PURPOSE OF THIS ROUTINE
;IS TO CATCH FANCY FILENAMES THAT WON'T CAUSE EXPECTED RESULT.
;FOR INSTANCE "RENAME *.* (TO BE) X*.*" DOESN'T REALLY PUT "X" IN FRONT
;OF EVERY NAME, SO THIS ROUTINE MAKES SURE YOU'RE NOT TRYING TO DO
;THAT TYPE OF THING.

BADSTR:	PUSH P,A
	PUSH P,B
	PUSH P,C		;SAVE AC'S
	MOVE A,CSBUFP		;GET POINTER TO SOME SPACE TO USE
	JFNS			;GET FIELD
	MOVE A,CSBUFP		;POINT AT FIELD WE JUST WROTE
	HRROI B,[ASCIZ /*/]
	STCMP			;MAKE SURE ONLY "*" AND NOT "F*" ETC.
	JUMPN A,[ERROR <Invalid use of wildcard characters>]
	POP P,C			;RESTORE AC'S
	POP P,B
	POP P,A
	RET			;RETURN SUCCESFULLY

;GET OUTPUT NAME FOR MULTI FILE OPERATION
;GETS JFN INTO OUTDSG, ASSUMES SCANNED
;OUTPUT NAME JFN IN MCOJFN. SKIPS ON SUCCESSFUL GTJFN AFTER
;PRINTING FILESPEC.
;DIRECT RETURN ON GTJFN ERROR, NAME AND MESSAGE ALREADY PRINTED
MFSET::	SKIPN MCOJFN		;MULTI FILE OUTPUT?
	RETSKP			;NO, JFN ALREADY IN OUTDSG
	PUSH P,CSBUFP		;SAVE STRING BUFFER POINTER
	MOVSI A,(GJ%DEV)	;FLAG BIT TO TEST
	MOVE C,[1B2+1B35]	;GET DEVICE
	CALL MCOSTR		;GET STRING
	MOVSI A,(GJ%DIR)
	MOVE C,[1B5+1B35]	;GET DIRECTORY
	CALL MCOSTR
	MOVEI	A,0		;NULL
	MOVE	C,CSBUFP	;GET CURRENT PNTR
	IDPB	A,C		;DEPOSIT IT
	PUSH	P,C		;SAVE PNTR
	MOVSI	A,(GJ%NAM)
	MOVE	C,[1B8+1B35]	;NAME
	CALL	MCOSTR
	POP	P,C		;RESTORE PNTR
	LDB	A,C		;GET CHAR THERE NOW
	JUMPE	A,MFSET1	;IF NULL THEN NO FILESPEC
	MOVSI A,(GJ%EXT)
	MOVE C,[1B11+1B35]	;EXT
	CALL MCOSTR
	MOVSI A,(GJ%VER)
	MOVE C,[1B14+1B35]	;VERSION
	CALL MCOSTR
	MOVE C,[2B17+1B35]	;PROTECTION
	CALL MCOSTO		;GET PROTECTION FROM OUTPUT
	MOVE C,[2B20+1B35]	;ACCOUNT
	CALL MCOSTO
	MOVE C,[1B21+1B35]	;";T"
	CALL MCOSTO
	MOVE C,[JS%ATR!JS%PAF]	;GET ATTRIBUTES
	CALL MCOSTO
MFSET1:	SKIPN TYPGRP		;FORCED PRINT?
	TLNE Z,GROUPF		;NO, ONLY IF GROUP
	UTYPE [ASCIZ/ => /]
	MOVE B,(P)
	MOVSI A,(GJ%FOU!GJ%SHT!GJ%DEL!GJ%FLG!GJ%PHY) ;OUTPUT, SHORT CALL, DELETED OK, PHYSICAL ONLY
	GTJFN
	 JRST [	EXCH A,(P)
		MOVEM A,CSBUFP	;RESTORE STRING SPACE POINTER
		CALL CRIF
		TYPE <Destination GTJFN failure on >
		CALL CTYPE
		POP P,A
		TYPE <
 >
		CALL $ERSTR
		ETYPE<%_>
		RET]
	CALL JFNSTK		;STACK JFN FOR FLUSH ON ^C
	HRRZM A,OUTDSG
	MOVE B,A		;GET FULL JFN INTO B
	TXZ B,GJ%UHV!GJ%NHV!GJ%ULV ;MAKE VERSION NUMBER COME OUT RIGHT
	MOVE A,COJFN		;OUTPUT NAME TO HERE
	MOVE C,[2B2+2B5+2B8+2B11+2B14+2B17+2B20+1B21+JS%ATR+1B35]
	SKIPN TYPGRP		;FORCED PRINT?
	TLNE Z,GROUPF		;NO, ONLY IF GROUP
	JFNS
	POP P,CSBUFP		;RESTORE STRING SPACE POINTER
	HRRZ A,OUTDSG
	DVCHR			;GET DEVICE CHARACTERISTICS OF OUTPUT FILE
	LDB A,[POINT 9,B,17]	;DEVICE TYPE
	CAIE A,.DVDSK		;IF DISK, SPECIAL CHECK
	RETSKP			;ELSE INDICATE SUCCESS
	HRRZ A,OUTDSG
	MOVE B,[1,,.FBCTL]	;GET FLAG WORD
	MOVEI C,A		;INTO A
	CALL $GTFDB
	 SETZ A,		;MAKE SURE FB%NXF OFF IF ACCESS PREVENTED
	TXNN	A,FB%NXF	;NEW FILE?
	TYPE < [Superseding]>	;NO, INFORM USER
	RETSKP

MCOSTR:	TDNN A,MCOJFN		;OUTPUT * HERE?
MCOSTO:	SKIPA B,MCOJFN		;NO, USE OUTPUT FIELD
	HRRZ B,@INIFH1		;YES, USE INPUT FIELD
	MOVE A,CSBUFP		;GET STRING SPACE POINTER
	JFNS			;GET STRING
	MOVEM A,CSBUFP		;STORE STRING SPACE POINTER
	RET

;CALL TO COPY JFN POINTED TO BY INIFH1 TO SECOND JFN
;THEN ADVANCE INIFH1 PAST THAT FILE. USED BY DELETE AND
;RENAME BECAUSE GNJFN DOES NOT WORK AFTER RENAME AND SOME DELETES.
MFINP::	MOVE A,CSBUFP		;POINTER TO STRING SPACE
	HRRZ B,@INIFH1		;JFN
	MOVE C,[1B2+1B5+1B8+1B11+1B14+JS%ATR+1B35] ;DEVICE:<DIR>NAME.EXT;GEN
	JFNS
	CALL GNFIL		;ADVANCE FIRST JFN BEFORE DELETE OR WE GET LOST
	 SETZM INIFH1		;CLEAR THIS TO INDICATE NO MORE JFNS
	MOVSI A,(GJ%OLD+GJ%NS+GJ%PHY+GJ%SHT+GJ%DEL)
	MOVE B,CSBUFP		;GET FILE FROM OTHER JFN
	GTJFN
	 JRST [	PUSH P,A
		CALL CRIF
		TYPE <Source GTJFN failure on >
		MOVE A,CSBUFP
		CALL CTYPE	;PRINT NAME WE TRIED GTJFN ON
		TYPE <
 >		;PRINT ERROR INDENTED ON FOLLOWING LINE
		POP P,A
		CALL $ERSTR	;PRINT ERROR MESSAGE
		ETYPE<%_>
		RET]
	CALL JFNSTK		;STACK JFN FOR RELEASE ON ERROR
	RETSKP			;RETURN WITH JFN IN A
;COLLECT FILE NAMES:
;COUTFN & SPECFN & CPFN & .INFG & INFG & DIRARG & SO ON.
;VARIOUS ENTRIES FOR INPUT, OUTPUT, SPECIAL CASE, & GROUP DESCRIPTORS.
;CAN INPUT LIST OF NAMES SEPERATED BY COMMAS AS WELL AS *.MAC FORMS.

;TAKE: A: RH: 0, 2, OR DEFAULT EXTENSION POINTER
;	      2 => USE EXT OF LAST FILE NAME INPUT AS DEFAULT EXT
;	 LH: 0, -1, -2, 1, 2, OR DEFAULT NAME POINTER
;	      0 => RETURN +1 IF NULL, PRINTING "-" ON ALT MODE
;	      1 => LIKE 0 BUT ALSO RETURN +1 IF "*" INPUT
;	      2 => LIKE 0 BUT USE LAST NAME INPUT AS DEFAULT NAME
;	      -1=> GIVE INPUT TO GTJFN EVEN IF NULL OR *
;	      -2   LIKE -1 BUT GIVE R1 IF NO SUCH FILE
;    ALSO ENTRY "SPECFN" TAKES IN B: LH: DEFAULT VERSION (USUALLY 0)
;	RH: FLAGS FOR GTJFN PLUS:
;	    B15: ALLOW GROUP OF NAMES, ALL BUT LAST TERMINATED WITH ",".
;		 DOES NOT HANDLE ALTMODE-COMMA (USE ^F FOR RECOGNITION),
;		 MAY THUS BE USED WHERE A NOISE WORD, ETC FOLLOWS (COPY)
;	    B16 & B17 ARE HAIRY: THE CASUAL READER SHOULD DISREGARD
;			 THEM.
;	    B16: ALLOW GROUP OF NAMES SEPERATED BY SPACE, ALTMODE, OR
;		 SPACE-COMMA OR ALTMODE-COMMA. IF LAST COMMA IS FOLLOWED
;		 BY ALTMODE OR EOL, GIVE R1 (TO INDICATE SUBCOMMAND
;		 INPUT REQUIRED).
;		 B15 SHOULD ALSO BE ON.
;		 ONLY USEABLE IF LIST IS LAST THING IN COMMAND; CAN
;		 PRE-READ FOLLOWING FIELD
;	    B17: DEFAULTS NULL WITHOUT LETTING THE USER BE AWARE
;		 OF THIS (NO PRINTOUT, RETURN WITH BAKFF ON IF IT
;		 WAS ALT MODE).
;			EG "DIRECTORY$$" AND "DIRECTORY$ *.*$$" ARE =.
;		 ALSO IF AT ENTRY PRECEDING FIELD ENDED IN COMMA OR EOL,
;		 BEHAVE AS THO THAT CHARACTER WERE INPUT HERE &
;		 DEFAULT ACCORDINGLY.
;			EG "DIRECTORY,$", "DIRECTORY ,$" ARE SAME.

;	    B14: IF NO SUCH DEVICE, NO SUCH DIRECTORY,...,
;		NO SUCH GENERATION... RETURN PTR,,-2 IN PLACE OF JFN
;		PTR POINTS TO <CHAR COUNT>,,<ERROR #> FOLLOWED BY
;		BYTE POINTER TO TYPESCRIPT.
;
;
;    ALSO, F3 IN Z  SAYS TO DEFAULT DIRECTORIES TO CONNECT AND LOGIN
;	AFTER INITIAL TRY FAILS --  FOR DEFAULT RUN
;COLLECT FILE NAMES COMMENTS...

;RETURN: +1: NULL INPUT AND 0 OR 1 IN LH OF A, OR "-" INPUT,
;		OR "*" INPUT AND 1 IN LH OF A (INDICATED BY "*" IN A),
;		OR P2=EOL AT ENTRY (IN WHICH CASE NO INPUT),
;		OR -2 IN LH OF A AND NO SUCH FILE,
;		OR B16 ON AND LIST ENDED WITH COMMA.
;		THE FIRST 3 OF THESE RETURN +1 OPTIONS SHOULDN'T
;		BE USED IF B15, B16, OR B17 ON.
;	 +2: SUCCESS, JFN IN A AND ALSO STACKED IN BUFFER "JBUF"
;		(POINTER JBUFP). 1ST LOCATION IN THIS BUFFER
;		(FIRST JFN IN COMMAND) CAN BE ADDRESSED AS CJFN1,...
;		IF AN INPUT GROUP DESCRIPTOR COULD HAVE BEEN INPUT
;		(B11,15,16,OR 17 ON), SETS INIFH1 &2 TO 1ST & LAST USED
;		LOCS IN JBUF, RETURNS FIRST JFN IN A, AND SETS "GROUPF"
;		IF A GROUP WAS SPECIFIED (* OR MORE THAN 1 NAME INPUT).

;	 EITHER: TERMINATOR IN "P2"
;ASSUME NULL INPUT IF LAST TERMINATOR=EOL AND BAKFF OFF,
; AS %KEYW DOES.  SEE %KEYW'S GLITCH NOTE (S1.MAC).

;FLAGS IN AC D
;RH: FROM CALLER
;LH: B0: NULL INPUT UNDER B17 OPTION
;    B1: B16 ON, ALREADY AT LEAST ONE ARG, NOT FOLLOWED BY COMMA
;    B2: DITTO, DITTO, FOLLOWED BY COMMA
;COLLECT FILE NAMES...  ENTRIES.

CSAVFN:	PUSH P,B
	MOVEI B,<GJ%FOU!GJ%MSG>B53+B17	;GTJFN FLAGS FOR OUTPUT FILE NAME
	JRST CFN1

;OUTPUT FILE NAME ENTRY (OLD OR NEW NAME).
;PRINTS WHETHER OLD OR NEW, NO CONFIRMATION.

COUTFN:	PUSH P,B
	MOVEI B,(GJ%FOU!GJ%MSG)	;GTJFN FLAGS FOR OUTPUT FILE NAME
	JRST CFN1

;THE NEXT FOUR ENTRIES INPUT AN INPUT FILE GROUP.
;ALL PERMIT *'S AND ADDITIONAL NAME AFTER ONE TERMINATED BY COMMA.
;NO SPECIAL RETURN FOR "*" OR NULL INPUT.
;THESE EXEMPLIFY USE OF GROUP FEATURES, OTHERS POSS USING "SPECFN".
;COLLECT FILE NAMES...   GROUP ENTRIES

;.INFG
;ACCEPTS COMMAS ONLY IF THEY TERMINATE FILE NAME - 
; THUS ^F MUST BE USED FOR RECOGNITION IF COMMA IS TO FOLLOW.
;SUITABLE FOR USE WHERE ADDITIONAL FIELDS OF COMMAND FOLLOW,
; AS IN 1ST ARG TO "COPY".
;NAME AND EXT DEFAULT TO LAST INPUT (THUS NONE FOR 1ST IN GROUP),
; VERSION TO HIGHEST.
;ONE RETURN ONLY.

;.INFG, BUT WITH NO SEARCH (FOR ACCOUNT, VERSION-RET..., PROTECTION)
INFGNS::PUSH P,B
	MOVE B,[XWD -3,<GJ%OLD!GJ%IFG!GJ%NS!1B14!1B15>B53] ;* VERSION FOR RENAME
	JRST .INFG1

.INFG:	PUSH P,B
	MOVEI B,(GJ%OLD!GJ%IFG!1B15)
.INFG1:	MOVE A,[XWD 2,2]
	CALL SPECFN
	 JRST CERR
	POP P,B
	RET

;$INFGX
;SIMILAR TO ABOVE EXCEPT RETURNS +1 IF LIST ENDED WITH COMMA NOT
;FOLLOWED BY ANOTHER NAME (TO INDICATE SUCCOMMAND INPUT).

$INFGX:	PUSH P,B
	MOVEI B,B2+B11+B14+B15+B16
	MOVE A,[XWD 2,2]
	JRST CFN1

;DIRARG
;FANCIEST INPUT GROUP, LIKE ABOVE EXCEPT:
; DEFAULTS NAME, EXT, VERSION TO "*". ALLOWS DELETED FILE NAMES (UG!).
; IF PRECEDING FIELD ENDED WITH COMMA OR EOL, OR IF A NULL ARG IS
; SEEN, SUPPLIES DEFAULT ARG "*.*;*" BUT HIDES THIS FROM USER.
; ACCEPTS * FOR NAME IN EMPTY DIRECTORY
; SETS NO SEARCH FOR GTJFN

DIRARG:	PUSH P,B
	MOVE A,[XWD [ASCIZ /*/],[ASCIZ /*/]]
	HRLI B,-3		;DEFAULT VERSION: *
	HRRI B,B2+B8+B11+B14+B15+B16+B17
	JRST CFN1
;COLLECT FILE NAMES ENTRIES...

;ENTRY FOR GTJFN FLAGS IN RH OF B, DEFAULT VERSION (NORMALLY 0) IN LH.
; USED IN SPECIAL CASES, EG:
;	DELETED FILE NAME FOR "UNDELETE"
;	ANYWHERE *'S ARE ALLOWED, AS IN "DIRECTORY".

SPECFN:	PUSH P,B

;END OF ENTRIES.  CASES MERGE HERE.

CFN1:	SETZM CJFNBK+2		;NO DEFAULT DEVICE
	SETZM CJFNBK+3		;AND NO DEFAULT DIRECTORY
CFN1A:	MOVEM A,CFNMOD		;SAVE MODE BITS
	PUSH P,CERET
	PUSH P,C		;"CPFN" SETS DEFAULT DEV AND JOINS HERE.
	PUSH P,D
	HRRZ D,B		;SAVE GTJFN AND LOCAL FLAGS IN RH D
				;NOTE: B0 OF LH D USED AS A FLAG IN CONJUNCTION WITH
				;NULL INPUT UNDER B17 OPTION
	TRZ B,B14+B15+B16+B17	;DON'T GIVE LOCAL FLAGS TO GTJFN
	TRNN D,(GJ%OFG)		;IF OUTPUT GROUP THEN NOT INPUT
	TRNN D,B11+B15+B16+B17	;IF AN INPUT GROUP IS BEING REQUESTED,
	SKIPA
	SETZM INIFH1		;SAY NO NAMES HAVE BEEN INPUT YET.
;COLLECT FILE NAMES...
;SET UP GTJFN PARAMETER BLOCK

	MOVSM B,CJFNBK		;FLAGS AND DEFAULT VERSION
	MOVE B,COJFN
	HRL B,CIJFN
	MOVEM B,CJFNBK+1	;XWD INPUT JFN, OUTPUT JFN
	MOVE A,CSBUFP		;SAVE CURRENT STRING BUFFER POINTER,
	MOVEM A,SVCSBP		;SO WE CAN REUSE SPACE
	JRST CFN2

;PASS ERROR BACK UP
CFNLEV:	POP P,D
	POP P,C
	POP P,CERET
	POP P,B
	JRST @CERET


;COME BACK HERE TO GET ANOTHER FILE NAME IN GROUP

CFN2:
	MOVE A,CFNMOD		;RESTORE MODES
	MOVE B,JBUFP
	MOVEM B,.JBUFP

; FORM "DEFAULT STRING POINTER" TO EXTENSION

	HRRZ B,A
	HRLZI C,B11		;ARGUMENT FOR LFJFNS: EXT ONLY, NO PUNCT
	CAIN B,2		;2 SAYS USE EXT OF LAST FILE NAME INPUT
	CALL LFJFNS		;GET A STRING FOR LAST FILE'S EXT
	SKIPE B
	HRLI B,<POINT 7,0,-1>B53
	MOVEM B,CJFNBK+5

; FORM "DEFAULT STRING POINTER" TO DEFAULT NAME

	HLRZ B,A
	HRLZI C,B8		;ARGUMENT FOR LJFNS: NAME ONLY, NO PUNCT.
	CAIN B,2		;2 SAYS USE NAME OF LAST FILE NAME INPUT
	CALL LFJFNS		;GET A STRING FOR LAST FILE'S NAME
	CAIE B,-2
	CAIN B,-1
	SETZ B,
	SKIPE B
	HRLI B,<POINT 7,0,-1>B53
	MOVEM B,CJFNBK+4
;COLLECT FILE NAMES...
;NOW WE MUST READ TEXT UP TO A FILE NAME FIELD TERMINATOR,
; TO ALLOW EDITING, THEN CHECK FOR SPECIAL CASES: NULL, "-", AND "*".
;RETURN HERE TO RETRY AFTER ERROR RETURN FROM GTJFN.

CFN2A:
;COLLECT FILE NAMES...
;HERE WHEN EXCEPTIONS ELIMINATED AND MUST "GTJFN"

CFN4:	HLRZ B,JBUFP		;CHECK SPACE IN JFN BUFFER
	CAIN B,-1
	ERROR <Too many JFNs in command>

	FILEX <FILE NAME>	;TRY TO READ FILE NAME
	 JRST CFNE		;COULDN'T
	MOVE A,B		;PUT JFN INTO A
	CALL JFNSTK		;STACK JFN FOR RELEASE ON ERROR
;COLLECT FILE NAMES...
;CODE FOR THE VARIOUS GROUP CASES

CFN4Z:	TRNN D,(GJ%OFG)
	TRNN D,B11+B15+B16+B17
	JRST CFN8		;NO SUCH OPTIONS ON
	TLZE D,B1+B2		;B16 AND NOT FIRST ARG?
	TLO Z,GROUPF		;YES, SAY GROUP INPUT.
	HRRZ B,JBUFP
	SKIPN INIFH1		;FIRST JFN IN GROUP?
	MOVEM B,INIFH1		;YES, SAVE JBUF POINTER
	TLNE A,<77B5>B53	;ANY *'S INPUT OR DEFAULTED TO?
	TLO Z,GROUPF		;YES, SAY GROUP WAS SPECIFIED.
	TRNN D,B15		;INPUTTING GROUPS OF FILES?
	JRST CFN7Z		;NO
	TRNE D,B16		;INPUTTING UNTIL END OF LINE?
	JRST B16ON		;YES
	MOVE A,CMFLG		;NOT INPUTTING TO END OF LINE, GET FLAGS
	TXNE A,CM%ESC		;DID USER END FILE NAME WITH $ ?
	JRST CFN7Z		;YES, SO WE'RE DONE
			;ACTUALLY, I THINK THIS IS A LOSING SITUATION.
			;THAT IS, WHY SHOULDN'T TYPIST BE ABLE TO USE
			;$ FOR AUTOMATIC COMPLETION OF FILESPEC, WITHOUT
			;ALSO HAVING OPTION TO FOLLOW FILESPEC WITH COMMA
			;AND TYPE IN ANOTHER SPEC??  WITH CURRENT
			;IMPLEMENTATION, THE $ DOES TWO THINGS AT ONCE:
			;IT COMPLETES THE FILESPEC, AND ALSO CAUSES
			;SYSTEM TO ASSUME YOU'RE NOT ABOUT TO TYPE A
			;COMMA AND ANOTHER ONE!!
			;E.O. GROUND HOG DAY, 1977
	COMMAX <Comma to specify another filespec, or next field of command>
			;REGULAR GROUP, SO WE NEED COMMA TO READ ANOTHER NAME
	 JRST CFN7Z		;GROUP BUT NO COMMA AFTER FILE NAME, SO WE'RE DONE
	TLO Z,GROUPF		;NOTE THAT GROUP HAS BEEN INPUT
	JRST CFN2		;GET NEXT FILE AFTER THE COMMA
B16ON:	CRRX <Carriage return to end command
or comma and another filespec
or comma and carriage return to enter subcommands>			;INPUTTING UNTIL END OF LINE, HAVE WE REACHED IT YET?
	 CAIA			;NOT YET
	JRST CFN7Z		;YES
	COMMAX			;COMMA AFTER FILE NAME?
	 JRST CFN2		;NO, MUST BE ANOTHER FILE NAME COMING
	SOS -4(P)		;WAS COMMA, IF CR AFTER COMMA THEN
	CRRX <Carriage return to enter subcommands
or another filespec>			;SUBCOMMANDS, SO WE WANT R1
	 AOSA -4(P)		;NOT CR, SO FORGET THE R1 RETURN
	JRST CFN7Z		;GOT COMMA CR, SO GO RETURN FOR SUBCOMMANDS
	JRST CFN2		;COMMA NOT FOLLOWED BY CR, MUST BE ANOTHER FILE SPEC


CFN7Z:	HRRZ B,JBUFP
	MOVEM B,INIFH2		;RETURN JBUFP VALUE FOR LAST NAME IN GROUP
	MOVE A,@INIFH1		;RETURN FIRST, NOT LAST, JFN IN A
;COLLECT FILE NAMES...
;END OF GROUP CASES CODE. RETURN.

CFN8:	AOS -4(P)		;+2
CFN9:	POP P,D
	POP P,C
	POP P,CERET
	POP P,B			;+1
	RET
;GTJFN ERRORS
;FIRST TEST ERROR CODE FOR EXCEPTIONS.

CFNE:	CALL GETERR		;GET REASON THE GTJFN FAILED

	CAIN A,GJFX3
	ERROR <No JFNs available: You must close some files first>
	CAIN A,GJFX22
	ERROR <JSB full: Try closing some files then repeating command>
	CAIN A,GJFX23
	ERROR <Directory full: Can't create new files until you 
 "DELETE" some files and "EXPUNGE (DIRECTORY)">
	TRNN D,B14		;NO SUCH FILE OK?
	JRST CFNE2		;NO, NO CHECK
	CAIL	A,GJFX16
	CAILE	A,GJFX21
	CAIN	A,GJFX24
	JRST	CFNE1
	CAIE	A,GJFX36
	CAIN	A,GJFX32
	JRST	CFNE1
	CAIN	A,GJFX35	;DIR ACCESS DENIED
	JRST	CFNE1		;YES - DEFER
CFNE2:
	MOVEM A,ERCOD		;SAVE ERROR CODE
	HLRZ A,CFNMOD		;MOST GTJFN ERRORS RETURN +1 IF CALLER GAVE
	CAIN A,-2		;... -2 IN LH OF A.
	JRST [	MOVE A,CFNMOD	; CPFN. 4/30/70)
		JRST CFN9]	;RETURN +1.
	MOVE A,ERCOD		;NOT SPECIAL ERROR CODE, DO GENERAL
	JRST CJERR		;ERROR HANDLING

;IF FLAG B14 ON GIVE GOOD RETURN WITH PTR,,-2 INSTEAD
;OF JFN WHEN GJFX32 ERROR OCCURS.
;USED FOR "DIRECTORY" (DIRARG).

CFNE1:
	PUSH P,B
	PUSH P,C
	PUSH P,D		;SAVE CONTROL FLAGS
	PUSH P,A		;SAVE ERROR CODE
	MOVE A,CMFLG		;GET FLAGS
	TXNE A,CM%ESC		;MAKE SURE NO RECOGNITION WAS ATTEMPTED
	 CMERRX			;LET MONITOR SAY WHAT'S WRONG WITH FILESPEC
	HRRZ B,SVCSBP		;GET FREE SPACE POINTER
	POP P,1(B)		;STORE ERROR CODE IN FIRST WORD
	HRROI A,2(B)		;WHERE TO PUT STRING
	MOVE B,CMABP		;WHERE TO GET STRING
	MOVEI C,ATMLEN*5	;MAXIMUM NUMBER OF CHARS TO MOVE
	MOVEI D,0		;BUT STOP ON NULL IF OCCURS BEFORE THIS
	SOUT			;MOVE CHARS
	MOVEM A,CSBUFP		;STORE NEW STRING SPACE PTR
	SUBI C,ATMLEN*5-1		;CALCULATE NEGATIVE OF NUMBER OF CHARS MOVED
	MOVN B,C		;GET POSITIVE VALUE
	ADJBP B,CMPTR		;MOVE COMMAND POINTER OVER THE BAD FILESPEC
	MOVEM B,CMPTR		;STORE NEW COMMAND POINTER
	ADDM C,CMCNT		;THERE'S LESS ROOM LEFT NOW TOO
	ADDM C,CMINC		;THERE'S ALSO LESS UNPARSED CHARS
	MOVE A,CSBUFP
	EXCH A,SVCSBP		;SAVE POINTER TO STRING HERE ALSO
	MOVSI A,1(A)		;GET POINTER TO ERROR WORD
	HRRI A,-2		;SPECIAL CODE
	POP P,D			;RESTORE CONTROL WORD
	POP P,C
	POP P,B
	CALL JFNSTK		;STACK FAKE JFN
	JRST CFN4Z		;FINISH PROCESSING
;NXFILE
;CHECK FOR FLAG IN PLACE OF JFN (-2)
;IF ON, PRINT ERROR MESSAGE AND TYPESCRIPT

NXFILE::ATSAVE
	HRRZ A,@INIFH1
	CAIE A,-2		;SPECIAL CASE?
	RETSKP			;NO
	CALL %MESS
	HLRZ D,@INIFH1		;GET POINTER TO CSBUF
	HRRZ A,(D)		;GET GTJFN ERROR CODE
	CALL $ERSTR		;PRINT ERROR
	TYPE < - >
	UTYPE 1(D)		;PRINT TYPESCRIPT
	ETYPE<%_>
	AOS A,INIFH1		;SKIP OVER THIS TERM
	CAMLE A,INIFH2		;PAST END?
	SETZM INIFH1		;YES, FLAG SUCH
	RET

$ERSTR::PUSH P,B
	MOVE B,A
	MOVE A,COJFN
	CALL %ERSTR
	POP P,B
	RET

%ERSTR::PUSH P,A
	PUSH P,B
	PUSH P,C
	HRLI B,B0		;CURRENT FORK
	SETZ C,
	ERSTR
	 JRST %ERST1
	 JRST %ERST2
%ERSTE:	POP P,C
	POP P,B
	POP P,A
	RET

%ERST1:	HRROI B,[ASCIZ/
?ERSTR: Unknown error /]
	MOVE A,-2(P)
	SETZ C,
	SOUT
	MOVE B,-1(P)
	MOVEI C,10
	NOUT
	 CALL JERRC
	JRST %ERSTE

%ERST2:	HRROI A,[ASCIZ/
?ERSTR: Internal lossage/]
	PSOUT
	JRST %ERSTE

;LFJFNS: SUBROUTINE FOR CINFN, COUTFN, SPECFN.
;DO A JFNS FOR MUST RECENT PREVIOUSLY INPUT FILE NAME, USING
; JFNS FORMAT SPECIFICATION IN C.
;RETURNS IN B: POINTER TO LEFT-ADJUSTED STRING
;IF LAST JFN NOT ON A DIRECTORY DEVICE, OR NO PREVIOUS JFN FOR THIS
; COMMAND, RETURNS 0 IN B.

LFJFNS:	PUSH P,A
	HRRZ B,JBUFP		;JFN STACK POINTER
	CAIN B,JBUF-1		;HAS A NAME BEEN INPUT YET?
	JRST LFJF9		;NO, GO RETURN 0 POINTER
	HRRZ A,(B)		;PICK UP JFN OF LAST NAME INPUT
	CAIE A,-2
	CAIN A,-1
	JRST LFJF9		;-1, -2 ISN'T A JFN BUT MIGHT GET HERE
	HRRZ A,CSBUFP		;STRING BUFFER POINTER RH
	ADD A,[POINT 7,1,-1]	;BEGINNING OF NEXT WORD
	MOVEM A,CSBUFP
	MOVE B,JBUFP
	MOVE B,(B)		;PICK UP JFN AGAIN
	JFNS			;DO THE JFN TO STRING CONVERSION
	CAMN A,CSBUFP		;EXPLICIT NULL STRING?
	JRST LFJF9		;YES - RETURN 0
	SETZ B,
	IDPB B,A		;APPEND NULL TO STRING
	EXCH A,CSBUFP		;UPDATE BUFFER PTR, GET STRING BEGINNING
	SKIPA B,A		;RETURN STRING POINTER IN B
LFJF9:	SETZ B,			;RETURN 0 IF CAN'T RETURN A STRING
	POP P,A
	RET
;CPFN: COLLECT PROGRAM FILE NAME
;TAKES: A: 0 OR WORD POINTER TO DEFAULT DEVICE NAME.
;NO DEFAULT NAME, DEFAULT EXTENSION ALWAYS ".SAV".
;RETURNS +1 ON GTJFN FAILURE.

CPFN:	PUSH P,B
	MOVEI B,100000
	JUMPE A,.+2
	HRLI A,<POINT 7,0,-1>B53 ;IF NON-0, FILL OUT BYTE PTR
	MOVEM A,CJFNBK+2	;DEFAULT DEVICE
	HRRI A,[GETSAVE()]	;DEFAULT EXT
	HRLI A,-2		;SAY RETURN +1 ON GTJFN FAILURE
	JRST CFN1A		;JOIN CINFN & COUTFN
;TYPIF: TYPE NAME OF CURRENT FILE IN INPUT FILE GROUP
; BUT NOT IF NOT A GROUP (IE ONLY ONE NAME AND NO *'S INPUT)
;RETURNS JFN IN A

TYPIF:	HRRZ A,@INIFH1		;GET CURRENT JFN
	SKIPN TYPGRP		;FORCED PRINT?
	TLNE Z,GROUPF		;NO, SKIP IF NON-GROUP
	ETYPE < %1S>		;%S: TYPE NAME FOR JFN
	RET

;TYPOK: TYPES [OK] CORRESPONDING TO TYPIF ABOVE
;SHOULD BE CALLED ONCE FOR EACH CALL ON TYPIF, BUT
;ONLY AFTER SUCCESFULL COMPLETION OF FILE
TYPOK:	SKIPN TYPGRP
	TLNE Z,GROUPF
	TYPE < [OK]
>
	RET

;GNFIL
;GET NEXT INPUT FILE OF GROUP WHICH MAY CONTAIN *'S OR MULTIPLE NAMES.
;R1 IF NO MORE FILES. R2 WITH NEXT JFN IN A.
;CLOSES PREVIOUS FILE IF OPEN. DOESN'T RELEASE JFN (RLFJNS DOES THIS).

GNFIL:	PUSH P,A
	PUSH P,B
	HRRZ A,@INIFH1
	GTSTS
	JUMPGE B,GNFIL3		;JUMP IF NOT OPEN
	TLO A,B0		;SAY DON'T RELEASE JFN
	CLOSF
	 CALL JERR
GNFIL3:	MOVE A,@INIFH1
	TLNN A,<77B5>B53	;NO *-FLAGS, SKIP GNJFN AND ITS BUGS
	JRST GNFIL5
	CAME A,[-2]		;-2 MEANS "NO FILES AT ALL" IN CERTAIN CASES
				;(THAT SHOULDN'T GET HERE ANYWAY)
	GNJFN			;STEP TO NEXT FILE IN *-GROUP
	 JRST GNFIL5		;NO MORE
	JRST GNFIL8

GNFIL5:	AOS A,INIFH1		;NEXT NAME IN GROUP
	CAMLE A,INIFH2		;ARE THERE MORE?
	JRST [	POP P,B		;NO
		POP P,A
		RET]
GNFIL8:	HRRZ A,@INIFH1		;RETURN NEXT JFN IN A
	AOS -2(P)
	POP P,B
	SUB P,[XWD 1,1]
	RET
;ROUTINE WHICH RETURNS DEVICE DESIGNATOR FOR CONNECTED STRUCTURE IN
;"B".
;CSBUFP IS ALWAYS LEFT POINTING TO THE CONNECTED STRUCTURE STRING.

CONST::	GJINF			;GET CONNECTED DIRECTORY NUMBER
	MOVE A,CSBUFP		;POINT TO SOME FREE SPACE
	DIRST			;GET STR:<DIR>
	 ERJMP CJERRE		;GO TELL USER WHY IT FAILED (PROBABLY STRUCTURE DISMOUNTED)
	MOVE A,CSBUFP		;POINTER TO STRING
	STDEV			;GET DEVICE DESIGNATOR FOR STRUCTURE
	 ERJMP CJERRE		;COULDN'T, SAY WHY AND DIE
	RET

;DEVN
;INPUT AND VERIFY A DEVICE NAME.
;READS STRING, ACCEPTING ALT MODE (ECHO COLON), EOL, SPACE, COLON, SEMI
; AS TERMINATOR.
;DOES NOT DISTINGUISH PHYSICAL NAMES AND ALREADY-DEFINED SYNONYMS.
;RETURNS:
;  A:  DEVICE DESIGNATOR
;  B:  CHARACTERISTICS WORD AS RETURNED BY "DVCHR". HIGHLIGHTS THEREOF:
;	B5: ON IF AVAILABLE OR ASSIGNED TO THIS JOB
;	B6: ON IF ASSIGNED
;	    BOTH B5 & B6 ON IF ASSIGNED TO SELF
;  C:  JOB # ASSIGNED TO IF B6 OF B ON

;ENTRY

DEVN:

;RETURN HERE TO TRY AGAIN AFTER TYPING " ? " AFTER ERROR.

DEVN1:	DEVX <Device name>
	 CMERRX
	MOVE A,B
	DVCHR			;GET CHARACTERISTICS WORD
	HLRE C,C
	RET
;ROUTINE TO GET DIRECTORY INFORMATION
;ACCEPTS IN AC1/	DIRECTORY NUMBER
;	    AC2/	POINTER TO PASSWORD STRING (GETDRP ONLY)
;RETURNS +1:	FAILED
;	 +2:	OK

GETDIR::MOVEI B,0		;NO PASSWORD GIVEN
GETDRP::PUSH P,B		;SAVE THE POINTER TO THE PASSWORD STRING
	CALL DIRINI		;INIT GROUP POINTERS AND GROUP BUFFERS
	POP P,B			;GET BACK POINTER TO PASSWORD
	MOVE C,CSBUFP		;COPY PASSWORD TO THIS STRING
GETDR1:	ILDB D,B		;GET NEXT CHAR
	IDPB D,C		;STORE IN PASSWORD STRING
	JUMPN D,GETDR1		;LOOP BACK TIL PASSWORD STRING COPIED
	MOVEI B,GTDLN		;SET UP LENGTH OF BUFFER
	MOVEM B,GTBUF+.CDLEN	;IN FIRST WORD OF BUFFER
	MOVEI B,GTBUF		;BUFFER POINTER
	MOVE C,CSBUFP		;WHERE TO PUT PASSWORD (POINTER RETURNED IN BUFFER)
	GTDIR			;GET ALL THE INFO INTO THAT BLOCK
	 ERJMP R		;IF FAILED, RETURN NO-SKIP
	RETSKP

;INITIALIZE BUFFER FOR GTDIR (ALSO FOR NEW DIR DEFAULTS)

DIRINI::	PUSH P,A
	SETZM GTBUF
	MOVE A,[GTBUF,,GTBUF+1]
	BLT A,GTBUF+GTDLN-1
	MOVEI A,UGBUF
	MOVEM A,.CDUGP+GTBUF
	MOVEI A,DGBUF
	MOVEM A,.CDDGP+GTBUF
	MOVEI A,SGBUF
	MOVEM A,.CDCUG+GTBUF
	HRROI A,ACTBUF		;POINTER TO ACCOUNT STRING AREA
	MOVEM A,.CDDAC+GTBUF	;DESIGNATE AREA INTO WHICH TO WRITE ACCOUNT
	SETZM ACTBUF		;INITIALIZE ACCOUNT BUFFER
	MOVEI A,UGBUFL		;LENGTH OF BUFFER
	MOVEM A,UGBUF
	MOVEI A,DGBUFL
	MOVEM A,DGBUF
	MOVEI A,SGBUFL
	MOVEM A,SGBUF
	MOVEI A,GTDLN		;SET UP LENGTH OF BUFFER
	MOVEM A,GTBUF+.CDLEN	;IN FIRST WORD OF BUFFER
	POP P,A
	RET

;DIRNAM
;INPUT A DIRECTORY (INCLUDES USER) NAME, WITH RECOGINITION.
;SKIP RETURNS WITH ENTIRE WORDS FROM RCDIR OR RCUSR IN A AND C ON SUCCESS.
;	AND THE POINTER TO THE DIR/USER NAME STRING IN B.
;USED IN CONNECT, WHERE, ^EPRINT COMMANDS.
;PRESERVES Q1 (FOR DIRECTORY).
;CALL WITH F1 OFF FOR DEFAULTING TO LOGGED-IN USER NAME OR CURRENT
;CONNECTED DIRECTORY.  CALL WITH F1 ON FOR NO DEFAULTING.

USRNMS::TLOA Z,F5		;ALLOW WILD CARDING
USRNAM::TLZ Z,F5		;NO WILD CARDING
	TLZA Z,F6		;DO NOT RETURN IF AMBIGUOUS
USRNMX::TLOA Z,F6		;ENTRY FOR FAILURE RETURN IF AMBIGUOUS
	TLZA Z,F4		;NO DEFAULT
	TLZ Z,F4!F5		;NO DEFAULT AND NO WILD CARDS
	MOVE A,CSBUFP		;POINTER FOR DEFAULT
	SKIPE CUSRNO		;NO DEFAULTING ALLOWED IF NOT LOGGED IN
	TLNE Z,F1		;DEFAULTING ALLOWED?
	JRST NODDF1		;NO
	MOVEM A,CMDEF		;DEFAULT WANTED, SET UP POINTER
	MOVNI A,1		;PREPARE TO READ ONE JOB DATUM
	HRROI B,A		;WE'LL READ DATUM INTO A
	MOVEI C,.JIUNO		;DEFAULT TO CURRENT USER
	GETJI			;GET INTERNAL FORM OF DEFAULT
	 CALL JERR		;SHOULD NEVER FAIL
	MOVE B,A		;PUT DEFAULT INTO B
	MOVE A,CMDEF		;GET POINTER TO DEFAULT STRING AREA
	DIRST			;MAKE DEFAULT STRING
	IBP A			;LEAVE NULL AFTER IT
	MOVEM A,CSBUFP		;MARK SPACE USED
NODDF1:	TLNE Z,F5		;ALLOW WILD CARDS?
	JRST [	USERSX <User name>
		 RET		;FAILED
		JRST NODDF2]
	USERX <User name>
	 RET			;SINGLE RETURN ON FAILURE
NODDF2:	MOVE C,B		;RETURN USER NUMBER IN C
	PUSH P,A		;SAVE A
	CALL BUFFF		;COPY STRING FROM ATOM BUFFER
	MOVE B,A		;RETURNS STRING POINTER IN B
	POP P,A			;RESTORE A
	RETSKP			;TAKE SKIP RETURN ON SUCCESS

CURNMS::TLOA Z,F5		;ALLOW WILD CARDING
CURNAM::TLZ Z,F5		;DO NOT ALLOW WILD CARDING
	TLZ Z,F6
	TLO Z,F4		;FLAG DEFAULT TO CONNECTED DIR
	JRST DIRNA0

DIRNMS::TLOA Z,F5		;ALLOW WILD CARDING
DIRNAM::TLZ Z,F5		;NO WILD CARDING
	TLZA Z,F6		;DO NOT RETURN IF AMBIGUOUS
DIRNMX::TLOA Z,F6		;ENTRY FOR FAILURE RETURN IF AMBIGUOUS
	TLZA Z,F4		;NO DEFAULT
	TLZ Z,F4!F5		;NO DEFAULT AND NO WILD CARDS
DIRNA0:				;CALLER MUST CHECK TERMINATOR
	MOVE A,CSBUFP		;POINTER FOR DEFAULT
	SKIPE CUSRNO		;NO DEFAULTING ALLOWED IF NOT LOGGED IN
	TLNE Z,F1		;DEFAULTING ALLOWED?
	JRST NODDF		;NO
	MOVEM A,CMDEF		;DEFAULT WANTED, SET UP POINTER
	MOVNI A,1		;PREPARE TO READ ONE JOB DATUM
	HRROI B,A		;WE'LL READ DATUM INTO A
	MOVEI C,.JIDNO		;FIRST ASSUME DEFAULT TO CONNECTED DIRECTORY
	TLNN Z,F4		;DEFAULT TO LOGGED-IN?
	MOVEI C,.JILNO		;YES, GET LOGGED-IN DIRECTORY NUMBER
	GETJI			;GET INTERNAL FORM OF DEFAULT
	 CALL JERR		;SHOULD NEVER FAIL
	MOVE B,A		;PUT DEFAULT INTO B
	MOVE A,CMDEF		;GET POINTER TO DEFAULT STRING AREA
	DIRST			;MAKE DEFAULT STRING
	IBP A			;LEAVE NULL AFTER IT
	MOVEM A,CSBUFP		;MARK SPACE USED
NODDF:	TLNE Z,F5		;ALLOW WILD CARDING?
	JRST [	DIRSX <Directory name>
		 RET		;FAILED
		JRST DIRNA1]	;GOT ONE
	DIRX <Directory name>
	 RET			;SINGLE RETURN ON FAILURE
DIRNA1:	CALL BUFFF		;MAKE A COPY OF THE STRING
	PUSH P,A		;SAVE THE POINTER TO THE STRING
	MOVE B,A		;GET POINTER TO DIR NAME AGAIN
	MOVX A,RC%EMO!RC%AWL	;EXACT MATCH AND ALLOW WILD CARDS
	RCDIR			;GET INFO ON THIS DIRECTORY
	 ERJMP [POP P,(P)
		RET]		;IF FAILS, NO SUCH DIR
	POP P,B			;RETURN THE STRING POINTER IN B
	TXNE A,RC%NOM!RC%AMB!RC%NMD
	RET			;NONE FOUND
	RETSKP			;TAKE SKIP RETURN ON SUCCESS


;ROUTINES TO STEP USER AND DIRECTORY NUMBERS WITH RCDIR
;ACCEPTS IN A/	DIR NUMBER
;	    B/	STRING POINTER TO WILD CARD STRING
;	CALL STPDIR	OR	CALL STPUSR
;RETURNS +1:	NO MORE
;	 +2:	A/	NEW DIR NUMBER

STPDIR::SKIPA D,[RCDIR]		;STEP THE DIR NUMBER
STPUSR::MOVE D,[RCUSR]		;STEP THE USER NUMBER
	STKVAR <STPSTP>
	MOVEM B,STPSTP		;SAVE THE STRING POINTER
	MOVE C,A		;GET DIR NUMBER INTO C
STPUS1:	ILDB A,STPSTP		;GET NEXT CHAR OF STRING
	CAIE A,"*"		;IS IT A WILD CARD?
	CAIN A,"%"		;...
	JRST STPUS2		;YES, GO TRY TO STEP THIS STRING
	JUMPN A,STPUS1		;NO, KEEP LOOKING
	RET			;NONE FOUND, THEN DO NOT DO THE JSYS

STPUS2:	MOVX A,RC%AWL!RC%STP	;STEP THE DIR
	XCT D
	 ERJMP R		;FAILED, NO MORE DIRS
	TXNN A,RC%NMD		;ANY MORE DIR'S?
	TXNE A,RC%NOM!RC%AMB	;FOUND ONE?
	RET			;NO
	MOVE A,C		;RETURN THE NEW NUMBER
	RETSKP
;$GTFDB
;SUBROUTINE TO DO GTFDB JSYS AND SKIP UNLESS
;AN INSTRUCTION TRAP WITH "LIST ACCESS NOT ALLOWED"
;ERROR OCCURED.
;USED IN DIRECTORY, UNDELETE, DSKSTAT, COPY/APPEND, LIST/TYPE.
;SHOULD BE IN SAME PAGE AS DSKDIR CAUSE ITS IN A LOOP THERE.

$GTFDB::GTFDB
	 ERJMP FDBILI
	RETSKP

;TRAP OCCURRED, CHECK ERROR CODE

FDBILI:	CALL %GETER		;GET ERROR CODE
	PUSH P,A
	HRRZ A,ERCOD
	CAIE A,GFDBX3		;"LIST ACCESS NOT ALLOWED"?
	JRST [	POP P,(P)
		JRST JERRE]
	POP P,A
	RET

;$CHFDB - AS ABOVE FOR CHFDB

$CHFDB::CHFDB
	 ERJMP CHFD1
	RETSKP			;SUCCESSFUL RETURN

CHFD1:	CALL %GETER
	HRRZ A,ERCOD		;RETURN ERROR CODE ON FAILURE
	RET
;"OCTCOM": 36-BIT OCTAL INPUT CONVERSION,
;ALLOWING ONE FIELD, OR TWO 18-BIT HALF-WORDS SEPERATED BY
; SPACE, ALT MODE, COMMA, OR TWO COMMAS.
;TERMINATORS ACCEPTED: ALT MODE, SPACE, EOL.
;CAN READ FIELD AFTER VALUE, HENCE GENERALLY ONLY VALID IF NUMBER
; IS LAST FIELD IN COMMAND.

OCTCOM:	OCTX <Octal number>
	 CMERRX
	PUSH P,B		;VALUE IN PUSHDOWN
	COMMAX <Comma to separate left and right halves,
 or octal value for right half>
	 JRST OCC1		;NOT COMMA NEXT, MAYBE ANOTHER NUMBER
	COMMAX <Second comma to separate left and right halves,
or octal value for right half>
	 JFCL			;PERHAPS UP TO TWO COMMAS
	MOVSS (P)		;WE'VE SEEN NON-CR, SO FIRST VALUE IS LEFT HALF
	DEFX <0>		;DEFAULT RIGHT HALF IS 0
	OCTX <Octal value for right half of word>
	 CMERRX			;RIGHT HALF REUIRED AFTER COMMAS
	HRRM B,(P)		;COMBINE RIGHT HALF WITH LEFT
OCCOM8:	POP P,A			;RETURN VALUE IN A
	RET

;WE'VE SEEN A NUMBER FOLLOWED BY A NON-COMMA.  IF THE NON-COMMA
;IS ANOTHER NUMBER, THE FIRST NUMBER WAS MEANT AS A LEFT HALF.
;IF THE NON-COMMA ISN'T A NUMBER EITHER, THEN IT'S THE NEXT FIELD,
;AND WE SHOULD INTERPRET THE FIRST NUMBER AS A RIGHT HALF (WHOLE
;WORD)

OCC1:	OCTX <Octal value for right half of word,
or nothing if first number is entire value>
	 jrst occom8		;not a number, so just return first number
	hrlm b,(p)		;store number as right half
	movss (p)		;put halves on correct side
	jrst occom8		;go return

;routine to input list of octal number ranges in the form:
;n1,n2:n3,n4:n5,n6...
;"rlist" starts with count of number of numbers, followed by the
;numbers themselves.  numbers are all two-Word pairs showing beginning
;and end of range.  for instance, "n1,n2:n3,n4,n5:n6" would get
;stored like this:
;
;	rlist/	8	;8 numbers altogether (4 pairs)
;	rlist+1/n1
;	rlist+2/n1	;note that first pair goes from n1 to n1!
;	rlist+3/n2
;	rlist+4/n3
;	rlist+5/n4
;	rlist+6/n4
;	rlist+7/n5
;	rlist+8/n6
;THIS ROUTINE RETURNS IF THE USER ENDS A RANGE WITH $.  THIS IS NECESSARY
;TO ALLOW THE USER TO BE PROMPTED FOR THE NEXT FIELD.

octlst::
	SETZM RLIST	;START WITH 0 NUMBERS
octl2:	octx <Octal number>
	 cmerrx		;at least one number must be entered
	call numstr	;store the number in the list
	CALL NESC	;SKIP IF ESCAPE DIDN'T TERMINATE NUMBER
	 JRST OCTL5	;IT DID, SO DON'T INPUT MORE
	COLONX <":" to enter range, or "," for another number, or next field of command>
	 CAIA		;NO COLON TYPED
	JRST OCTL4	;COLON TYPED, GO GET END OF RANGE
	COMMAX <"," to enter another number, or next field of command>
	 JRST OCTL5	;NO COMMA OR COLON AFTER NUMBER, MUST BE END OF LIST
	CALL NUMREP	;REPEAT LAST NUMBER
	JRST OCTL2	;GO GET NEXT SET (REQUIRED BECAUSE WE SAW COMMA)
OCTL4:	OCTX <Octal number for end of range>
	 CMERRX
	CALL NUMSTR	;STORE END OF RANGE
	CALL NESC	;DID NUMBER END WITH ESCAPE?
	 JRST OCTL6	;YES, SO GO ON TO NEXT FIELD OF COMMAND
	COMMAX <Comma to enter another number, or next field of command>
	 JRST OCTL6	;NO COMMA AFTER RANGE, MUST BE END OF LIST
	JRST OCTL2	;COMMA, SO GET ANOTHER PAIR

;SINGLE NUMBER FOLLOWED BY NON-COMMA AND NON-COLON

OCTL5:	CALL NUMREP	;REPEAT PREVIOUS NUMBER
OCTL6:	RET		;ALL DONE

NUMREP:	MOVE D,RLIST		;TO REPEAT LAST NUMBER, GET END OF LIST
	MOVE B,RLIST(D)		;GET LAST NUMBER, AND FALL INTO REGULAR NUMBER STORE ROUTINE...

numstr:	AOS D,RLIST		;INCREASE NUMBER OF NUMBERS
	movem b,rlist(d)	;save number
	RET
;OUTPUT OCTAL NUMBER FROM B, NO LEADING ZEROES OR SPACES.

TOCT:	PUSH P,A
	PUSH P,C
	MOVE A,COJFN		;DESTINATION
	MOVE C,[1B0+10]		;"MAGINITUDE" FLAG AND RADIX
	NOUT
	 CALL JERRC		;GENERAL JSYS ERROR, CODE IN C
	POP P,C
	POP P,A
	RET

;TYPE SYSTEM DOWN TIME IF SET

DWNTYP::GJINF
	JUMPN A,R		;NO TYPE IF ALREADY LOGGED IN
DWNPNT::MOVEI D,0		;GET ITEM 0 FROM DWNTIM TABLE
	GTB DWNTIM
	JUMPE A,R		;DO NOTHING IF NOT SET
	ETYPE < System shutdown scheduled for %1W>
	MOVEI D,1		;GET ITEM 1
	GTB DWNTIM
	JUMPE A,DWNTY1		;JUMP IF UPTIME NOT SET
	ETYPE <,
 Up again at %1W>
DWNTY1:	ETYPE<%_>
	RET
;BUFFF
;SUBROUTINE TO BUFFER LAST FIELD IN A MANNER SUITABLE FOR JSYS'S AND
;  RETURN A BYTE PTR TO IT IN A.
;COPIES TO SEPERATE BUFFER SPACE, PUTS NULL BYTE AT END.

BUFFF:	PUSH P,B
	PUSH P,C
	PUSH P,D
	MOVE A,CSBUFP		;STRING BUFFER POINTER

	HRROI B,ATMBUF		;POINT TO THE FIELD
	MOVEI C,0		;END ON NULL BYTE
	SOUT			;COPY FIELD TO CSBUF FROM ATMBUF

	IBP A			;LEAVE THE NULL AFTER THE STRING
	EXCH A,CSBUFP		;GET POINTER TO BEGINING OF STRING
	POP P,D
	POP P,C
	POP P,B
	RET
;SUBROUTINE TO CAUSE WAKEUP ON EVERY FIELD.  THIS MUST BE DONE
;FOR COMMANDS TO TAKE PASSWORDS WITHOUT ECHOING.  IF WAKING UP
;DIDN'T OCCUR BEFORE PASSWORD FIELD, EXEC WOULDN'T GET A CHANCE
;TO TURN OFF ECHOING!
;ACTUALLY, THIS IS ONLY DONE IF JOB IS NOT LOGGED IN, SO THAT THE
;FORM OF LOGIN "LOG USER PASS ACC<CR>" WILL HAVE ECHOING OFF FOR PASSWORD INPUT.
;WHEN LOGGED IN, WAKING UP WILL NOT BE DONE ON EVERY FIELD, BECAUSE
;THE FIRST FIELD OF EVERY LINE WOULD HAVE TO BE WOKEN UP ON, WHICH
;IS QUITE A MACHINE BRAIN DRAIN.  SO, USERS WILL HAVE TO TRAIN THEMSELVES
;TO TYPE AN ALTMODE OR SOMETHING BEFORE PASSWORDS IF THEY WANT TO
;PREVENT ECHOING DURING "CONNECT", "ATTACH" ETC.  SINCE "CONNECT"
;IS USUALLY NOT GIVEN WITH PASSWORD, AND SINCE "ATTACH" IS OFTEN
;GIVEN BEFORE BEING LOGGED IN, FEW PROBLEMS SHOULD BE OBSERVED.

WAKE::	MOVX A,CM%WKF		;BIT FOR WAKING UP ON EVERY FIELD
	SKIPN CUSRNO		;NEVER WAKE UP ON EVERY FIELD IF LOGGED IN
	IORM A,CMFLG		;TURN ON BIT IN FLAG WORD
	RET

;WHENEVER EXEC DECIDES NO MORE PASSWORDS POSSIBLE ON REST OF COMMAND
;LINE, WAKING UP NEEDN'T HAPPEN ON EVERY FIELD ANYMORE...

NOWAKE::	MOVX A,CM%WKF
	ANDCAM A,CMFLG		;TURN OF BIT
	RET

;SUBROUTINE TO TURN OFF ECHOING BEFORE PASSWORD INPUT

NOECHO:	PUSH P,C
	TLO Z,NECHOF		;SAY ECHOING OFF (TESTED IN %NOI)
	MOVEI C,0		;SAY NO ECHOING NOHOW
	JRST ECHOST		;JOIN "DOECHO"

;SUBROUTINE TO TURN ON ECHOING AFTER PASSWORD INPUT

DOECHO:	PUSH P,C
	TLZ Z,NECHOF		;SAY ECHOING NOT SUPPRESSED
	MOVEI C,2		;SAY IMMEDIATE OR DEFERRED ECHOING
ECHOST:	PUSH P,A		;ENTRY TO SET ECHO BITS FROM C
	PUSH P,B
	MOVE A,CIJFN
	RFMOD			;READ TELETYPE MODE WORD
	DPB C,[POINT 2,B,25]
	SFMOD			;SET TTY MODE WORD
	POP P,B
	POP P,A
	POP P,C
	RET
;LTTYMD - LOAD TELETYPE MODES
;AC Q1 POINTS TO 11-WORD BLOCK OF VALUES TO PUT INTO EFFECT:
;SEE EXECDE FOR STRUCTURE OF BLOCK

LTTYMD:	SKIPN (Q1)		;DO NOTHING IF BLOCK IS 0 DUE TO A BUG OR
	RET			;A STRANGE INTERRUPT-RESTART SEQUENCE
	ATSAVE
	MOVEI A,.CTTRM
	MOVE B,TTWMOD(Q1)	;FILE MODE WORD
	TLZ B,B0		;ENSURE NO OUTPUT SUPPRESS
	SFMOD
	MOVE B,TTWCOC(Q1)	;2 CCOC WORDS
	MOVE C,TTWCOC+1(Q1)
	SFCOC
	MOVEI A,.FHSLF
	RPCAP
	MOVEI A,.FHJOB
	MOVE B,TTWJTI(Q1)	;SET JOB TIW
	TXNE	C,SC%CTC	;CAN'T SET JOB TIW IF NO ^C PRIV
	STIW
	MOVE A,TTWSNM(Q1)	;GET SUBSYS NAME
	MOVE B,TTWPNM(Q1)	;GET PROGRAM NAME
	SETSN			;SET THEM
	 CALL JERR
	RET

;RTTYMD - STORE CURRENT TTY MODE, TAB STOPS, CCOC
; INTO 6-WORD BLOCK THAT AC Q1 POINTS TO.

RTTYMD:	ATSAVE
	MOVEI A,.CTTRM
	RFMOD
	MOVEM B,TTWMOD(Q1)
	MOVEI A,.CTTRM
	RFCOC
	MOVEM B,TTWCOC(Q1)
	MOVEM C,TTWCOC+1(Q1)
	MOVEI A,.FHJOB
	RTIW
	MOVEM B,TTWJTI(Q1)
	SETO A,			;SAY THIS JOB
	MOVE B,[-2,,C]		;SAY 2 WORDS INTO C AND D
	MOVEI C,.JISNM		;STARTING WITH SUBSYS NAME
	GETJI			;GET SUBSYS AND PROGRAM NAME
	 CALL JERR
	MOVEM C,TTWSNM(Q1)	;SAVE THEM
	MOVEM D,TTWPNM(Q1)
	RET

;NOTE: ALL MODE STUFF IN EXEC IS DONE WITH OUTPUT FILE, WHICH IS
;LESS LIKELY TO BE REDIRECTED TO NON-TTY THAN INPUT.
;MODE IS UNLIKELY TO NEED CHANGING FOR NON-TTY INPUT FILE;
;TO CHANGE IT USER MUST: A) USE A PROGRAM, SUCH AS DDT, OR B) TEMP SET
; OUTFILE=INFILE (IF PSEUDO-ECHOING DOESN'T INTERFERE). 4/22/70.
;UUO TO OUTPUT SINGLE ASCII CHARACTER FROM EFFECTIVE ADDRESS

%PRINT:	PUSH P,A
	PUSH P,B
	AOS TTYACF		;TELL AUTOLOGOUT CODE THAT TTY IS ACTIVE
	MOVE A,COJFN
	HRRZ B,40
	BOUT
	MOVEM A,COJFN		;IN CASE IT'S A BYTE POINTER
	AOS TTYACF		;AGAIN IN CASE BLOCKED DUE TO FULL BUFFER
	POP P,B
	POP P,A
	RET

;SUBR TO OUTPUT CHARACTER FROM B.

CCHRO:	JRST COUTC

;FOLLOWS CCHRO...
;OUTPUT CHARACTER FROM B WITHOUT STORAGE FLAG TEST (USED?)

COUTC::	PUSH P,A
	AOS TTYACF		;TELL AUTOLOGOUT THAT THERE'S BEEN TTY ACTIVITY
	MOVE A,COJFN		;FILE NUMBER OF PRIMARY OUTPUT FILE
	BOUT			;MONITOR CALL TO OUTPUT CHARACTER
	AOS TTYACF
	MOVEM A,COJFN		;UPDATE IN CASE BYTE POINTER
	POP P,A
	RET
;TBOUT, TSOUT0 -- USED INSTEAD OF BOUT AND SOUT WHERE TEXT
;MAY CONTAIN EOL'S.

TBOUT::	BOUT
	RET

;SOUT WHERE C=0, I.E. TERMINATE ON NULL

TSOUT0::PUSH P,B
	HLRZ B,B
	CAIN B,-1		;DEFAULT BYTE PTR LH?
	JRST [	MOVSI B,(<POINT 7,0>) ;YES, SETUP 7 BIT
		HLLM B,0(P)
		JRST .+1]
TSOUT1:	ILDB B,0(P)		;GET NEXT CHAR
	JUMPE B,[POP P,B	;NULL TERMINATES, RESTORE UPDATED PTR
		RET]
	BOUT
	JRST TSOUT1
;MAP A PAGE OF A FORK
;TAKES:	AC A:	AN ADDRESS IN THE PAGE, OR -1 TO CLEAR BUFFER
;	CELL "FORK": FORK HANDLE
;RETS:	AC A:	ACCESS AND EXISTENCE BITS IN B2-5, RH PRESERVED
;	BUFFER PAGEN: THE PAGE MAPPED

MAPPF:	PUSH P,C
	PUSH P,B
	PUSH P,A
	JUMPL A,MPPF1
	MOVEI A,0(A)
	CAIG A,17
	JRST MAPACS
	LSH A,-^D9		;SEPERATE PAGE #
	HRL A,FORK		;FORK HANDLE OF PAGE WE WANT
	SKIPGE FORK		;IS THERE A CURRENT FORK?
	ERROR <No program>	;NO.
	TLO A,B0		;SAY FORK HANDLE NOT JFN
MPPF1:	MOVEI B,PAGEN		;GENERATE DESTINATION PAGE IDENTIFIER
	LSH B,-^D9		;...MUST SHIFT AT RUN TIME CAUSE EXTERNAL
	TLO B,B0		;...SAY THIS FORK
	HRLZI C,B2+B3+B4	;REQUEST ALL ACCESS, NORMAL DISPOSAL
	CAME A,NPAGE		;SAVE TIME IF ALREADY MAPPED
	PMAP			;MAP IT
	MOVEM A,NPAGE		;SAY ITS MAPPED
	CAMN A,[-1]
	JRST	MPPF8
	RPACS			;GET ACCESS/EXISTENCE OF MAPPED PAGE
	SKIPN	B		;ANY BITS?
	TXO	B,PA%WT		;NO - SET WRITE ACCESS (NEW PAGE)
MPPF8:	POP P,A			;RH A TRANSPARENT
	HLL A,B			;ACCESS IN LH A
	POP P,B
	POP P,C
	RET

;REFERENCE IS TO AN AC. READ ACS INTO PAGEN WITH "RFACS".
;IN THIS CASE CALLER MUST USE SFACS IF HE WISHES TO CHANGE A LOCATION.

MAPACS:	SETO A,
	CALL MAPPF		;UNMAP PAGE IN BUFFER, IF ANY.
	SKIPGE A,FORK
	ERROR <No program>
	MOVEI B,PAGEN
	RFACS			;READ FORK ACS INTO "PAGEN"
	HRLZI B,B2+B3+B4+B5	;SIMULATE ALL ACCESS BITS
	JRST MPPF8

;LOAD SINGLE WORD FROM FORK, GIVEN ADDRESS IN A

LOADF:	CALL MAPPF
	TLNN A,B5
	ERROR <No such page>
	TLNN A,B2
	ERROR <Can't read that page>
	ANDI A,777
	MOVE A,PAGEN(A)
	RET

;STORE SINGLE WORD FROM B INTO FORK, ADDRESS IN A

STOREF:	CALL MAPPF
	TLNE A,B5		;OK TO STORE IF PAGE NON-EXISTENT
	TLNE A,B3+B9		;OR IF WRITE ACCESS OR COPY ON WRITE PERMITTED
	CAIA
	ERROR <Can't write into page>
	ANDI A,777
	MOVEM B,PAGEN(A)
	RET
;%GTB
;UUO TO DO A "GETAB" JSYS WITH A REASONABLE CALLING SEQUENCE.
;TABLE # IN C(Q1), INDEX IN RH OF D, ONE RETURN WITH WORD IN A.
;TYPICAL USAGE: LH D CONTAINS AOBJN COUNTER, B AND C ARE FREE
;	FOR USE IN OTHER JSYS CALLS INSIDE LOOP.

%GTB:	HRL A,D
	HRR A,@40
	GETAB
	 CALL JERR
	RET

;ERROR, PSEUDO-INTERRUPT, %-MESSAGE-TYPING STUFF

;PSI ROUTINE FOR TERMINAL CHARACTER THAT PRINTS RUNTIME (^T)

USEPSI:	PUSH P,[[DEBRK]]		;FAKE UP RETURN
STAT,<	AOS STBUF	>;THIS INDEX FOR ^T
	ATSAVE
	PUSH P,40
	SKIPE A,COMAND		;COMMAND BEING EXECUTED?
	JRST USEPS9		;YES, DIFFERENT MESSAGE
	SKIPGE A,FORK
	JRST USEPS2		;NO INFERIOR
	MOVE B,PTTYMD+TTWPNM	;GET PROGRAM NAME
	ETYPE < %2' >		;TYPE PROGRAM NAME
	CALL FSTAT		;PRINT STATUS & PC OF INFERIOR (HANDLE IN A)
	PRINT " "		;FSTAT IS IN XMAIN.MAC
USEPS2:	ETYPE < Used %V in %C
>
	POP P,40
	RET

;IF ^T DURING COMMAND EXECUTION, TELL USER WHAT COMMAND IS BEING
;EXECUTED.

USEPS9:	HLR B,(A)		;GET POINTER TO COMMAND NAME
	HRLI B,350700		;MAKE BYTE POINTER
	LDB C,B			;GET FIRST CHARACTER
	JUMPN C,USEPS8		;IF NON-NULL, WE'VE FOUND COMMAND NAME
	AOJ B,			;NULL, SO MUST BE FLAG WORD, LOOK AT NEXT
USEPS8:	HRLI B,440700		;MAKE POINTER TO BEGINNING OF COMMAND NAME
	ETYPE < %2M command >
	JRST USEPS2		;JOIN COMMON CODE
;GET TO "CERR" IF NO PROGRAMMER HAS DECIDED ON A BETTER MESSAGE
;YET.  WHEN YOU DO, CHANGE THE "JRST CERR" TO "ERROR MUMBLE" OR
;"CMERRX MUMBLE"

CERR:	ERROR < >

;ROUTINE TO HANDLE CMERRx MACRO CALL.

$CMERR:	MOVE B,@40		;GET MESSAGE
	MOVEI A,@40		;GET ADDRESS OF MESSAGE
	CALL %GETER		;GET MONITOR'S ERROR NUMBER
	CALL ERFRST		;INITALIZE ERROR HANDLER
	SKIPE @A		;NO "?" IN FRONT OF BLANK LINE PLEASE!
	CALL CRIF		;GET TO LEFT MARGIN IF NOT THERE YET
	UETYPE @A		;PRINT PROGRAMMER-SUPPLIED MESSAGE
	CALL SYSERA		;THEN PRINT MONITOR'S VERSION 
	JRST ERRFIN		;FINISH

;NOT IMPLEMENTED YET ERROR
;DISPATCH TO HERE AUTOMATICALLY SUPPLIED BY COMMAND TABLE ENTRY MACRO
; IF NO ROUTINE IS DEFINED FOR THE COMMAND.

NIM:
NIYE:	ERROR <Not implemented yet>

;INTERNAL ERROR

SCREWUP:HRRZ Q1,(P)		;PC (GET HERE WITH PUSHJ)
	SUBI Q1,1
	ERROR <Internal error at %5P>

;ERROR RETURN FROM A JSYS, SYSTEM ERROR # IN 1.
;PRINTS SYSTEM MESSAGE AND GOES BACK TO COMMAND INPUT.
;MOST ERROR RETURNS WILL REQUIRE SOME SPECIAL CASE CHECKS
; BEFORE COMING TO THIS GENERAL ROUTINE.
;NOTE: ERROR NUMBER IN A IS USED INSTEAD OF -1 ARG TO "ERSTR"
; BECAUSE THIS ROUTINE IS ALSO USED WITH SUBROUTINES THAT SIMULATE
; JSYS'S. 6/26/70.

JERR:	MOVEM A,ERCOD		;SAVE ERROR NUMBER
JERR1:	CALL ERFRST		;GET SET TO TYPE MSG
	CALL CRIF		;EOL UNLESS AT LEFT
	HRRZ Q2,(P)		;PC (GOT TO JERR WITH PUSHJ)
	SUBI Q2,2		;PROBABLE LOC OF JSYS
	ETYPE <JSYS error at %6P>
	CALL SYSERA		;GO TYPE SYSTEM ERROR MESSAGE
	JRST ERRFIN		;FINISH

JERRC:	MOVEM C,ERCOD		;"JERR" FOR ERROR CODE IN C
	JRST JERR1		;  (AS AFTER "NOUT")

;ROUTINES FOR USE WITH ERJMP AND ERCAL JSYS RETURNS
;GET ERROR CODE FROM SYSTEM AND STORE IN ERCOD
;THEN CALL REGULAR ERROR PRINT
JERRE::	CALL %GETER
	JRST JERR1

CJERRE::CALL %GETER
	JRST CJERR1

;ERROR RETURN FROM JSYS WHERE ERROR MESSAGE FROM JSYS SHOULD BE
;MEANINGFUL TO USER

CJERR::	MOVEM A,ERCOD
CJERR1:	CALL ERFRST		;INIT ERROR STUFF
	CALL SYSERA		;PRINT JSYS MSG ONLY
	JRST ERRFIN		;FINISH

;ROUTINE TO PRINT WARNING ABOUT FAILING JSYS.
;PUT "JWARN" AFTER ANY JSYS THAT ISN'T EXPECTED TO FAIL, BUT FOR WHICH
;YOU DON'T REALLY CARE IF IT DOES, EXCEPT THAT YOU WANT THE USER TO KNOW
;WHY.

RJWARN::	PUSH P,A
	PUSH P,B
	PUSH P,C
	TYPE <
%Unexpected error:
 >
	MOVE A,COJFN		;GET OUTPUT DESIGNATOR
	MOVE B,[SETZ -1]	;SPECIFY "LAST ERROR FOR THIS FORK"
	MOVEI C,0		;NO LIMIT FOR MESSAGE SIZE
	ERSTR			;PRINT THE ERROR
	 ERJMP JERR		;UNEXPECTED ERROR
	 ERJMP JERR		;"
	TYPE <
 proceeding...
>
	POP P,C
	POP P,B
	POP P,A
	RET			;RETURN TO CALLER
;ERROR PSEUDO-INTERRUPT ON LEVEL 1 UUO SERVICE ROUTINE
;DEBREAK IMMEDIATELY BECAUSE IF ANOTHER TRAP WERE TO OCCUR DURING
;THIS ONE, MONITOR MIGHT HAVE TROUBLE HANDLING IT.
;THEN TYPE TEXT EFF ADDR POINTS TO, "TRAP IN EXEC",
;  TYPE SYSTEM ERROR MESSAGE WITH
;  REGULAR ROUTINE, AND RETURN TO COMMAND INPUT.

%TRAP:	PUSH P,D
	PUSH P,Q1
	LDB Q1,[POINT 4,40,12]	;GET AC FIELD
	CAILE Q1,0
	CAILE Q1,3		;LEGAL LEVEL?
	SKIPA Q1,[0,,-1]	;NO, GIVE -1
	HRRZ Q1,PCTAB(Q1)	;YES, GET PC
	CIS			;CLEAR THIS INTERRUPT, ALSO CLEAR LOWER-LEVEL INTRPTS
				;SUCH AS ^T AND CARRIER-OFF.  NOPS IF NOT ON A PSI,
				;WHICH CAN HAPPEN VIA SPECIAL CASE IL INST STUFF.
	MOVE D,NERET		;CHANGE ERROR ROUTINE RETURN
	MOVEM D,CERET		;...TO "REGULAR"
	SETZM .JBUFP		;SAY FLUSH ALL JFNS

;HERE WE MUST CHECK FOR EOF IN COMMAND FILE AND HANDLE SPECIALLY.
;ALSO I'M SURE MANY OTHER EXECEPTIONAL CASES WILL TURN UP.

	MOVE D,40		;SAVE TEXT ADDRESS
	CALL ERFRST		;DO THINGS NEEDED BEFORE TYPING MESSAGE
	CALL CRIF		;EOL IF CARRIAGE NOT AT LEFT MARGIN
	UTYPE (D)		;TYPE CHANNEL-SPECIFIC MESSAGE
	ETYPE	< internal trap at %5P>
	POP P,Q1
	POP P,D
	PUSH P,[ERRFIN]		;WHERE TO GO AFTER ERROR MESSAGE PRINTING
	PUSH P,[U$ERR]		;NO MESSAGE
	JRST ERR1		;GO FINISH ERROR PROCESSING

;NOTE: EXCEPT FOR ^O, THERE ARE NO INTERRUPTS WHICH DEBREAK TO THE POINT
;OF INTERRUPTION.  HENCE WE NEEDN'T WORRY ABOUT CELLS SUCH AS "RERET"
;BEING CHANGED.  BUT WE DO HAVE TO CODE ROUTINES SUCH AS "RLJFNS" TO
;WORK OK IF INTERRUPTED IN THE MIDDLE AND RESTARTED.
;ILLEGAL INSTRUCTION PSI
;GO TO SPECIAL CASE ROUTINE ILIDSP POINTS TO, IF NON-0,ELSE
;TREAT LIKE OTHER ERROR PSI'S.
;ILIDSP USED, FOR INSTANCE, TO DETECT "LIST ACCESS NOT ALLOWED" FROM
; GTFDB JSYS.
;SPECIAL ROUTINE GETS PC IN ERPC, ERROR CODE IN ERCOD.
;IF SPECIAL ROUTINE ISN'T INTERESETED IN THIS PARTICULAR ERROR,
; IT CAN JRST TO ILIPSI AGAIN.

ILIPSI:	SKIPE ILIDSP		;IS THERE A SPECIAL DISPATCH?
	JRST ILIDO		;YES, DO IT
	PUSH P,D
	MOVE D,NERET		;RESET ERROR RETURN
	MOVEM D,CERET
	SETZM .JBUFP		;RETURN ALL JFNS
	CALL ERFRST		;GET SET FOR ERROR
	HRRZ D,PCTAB+LV.ILI	;GET ERROR PC
	ETYPE <Internal illegal instruction trap at %4P>
	POP P,D
	CALL SYSERM		;GO FINISH WITH SYSTEM ERROR CODE
	JRST ERRFIN		;FINISH

ILIDO:	CIS			;CLEAR THE INTERRUPT (NOPS IF NONE), CLEAR LOWER
				;LEVEL INTERRUPTS SUCH AS ^T AND CARRIER OFF.
	PUSH P,ILIDSP		;SAVE SPECIAL DISPATCH ADDR FOR "RET" BELWOW
	ATSAVE
	HRRZ A,PCTAB+LV.ILI
	MOVEM A,ERPC		;LOCATION OF ERROR, FOR SPECIAL ROUTINE.
	MOVE A,[CALL CUUO]	;RESET UUO DISPATCH TO PROTECT
	MOVEM A,41		;IT FROM MALICIOUS USERS
	SETZM ILIDSP		;CLEAR SPECIAL DISPATCH
	MOVEI A,B0
	GETER			;GET ERROR CODE
	HRRZM B,ERCOD		;ERROR CODE, FOR SPECIAL ROUTINE
	RET			;DISPATCH TO SPECIAL ROUTINE

;END-OF-FILE INTERRUPT
;DEBREAK TO SPECIAL ROUTINE "EOFDSP" POINTS AT, OR,
; IF EOFDSP ZERO, TREAT LIKE OTHER ERROR PSEUDO-INTERRUPTS.
;"EOFDSP" IS NORMALLY ZERO BUT IS SET NON-0 FOR FILE-COPYING COMMANDS.

EOFPSI:	PUSH P,A
	MOVEI A,EOFPS1		;DISMISS INTERRUPT BUT DON'T GO ANYWHERE
	MOVEM A,PCTAB+LV.EOF	;OLD PC IS LOST
	DEBRK			;FALL THROUGH IN NON-INTERRUPT MODE
EOFPS1:	POP P,A
	JRST EOFCHK		;GO SEE WHAT TO DO ABOUT END OF FILE CONDITION

;CALL THE FOLLOWING ROUTINE AFTER A FAILING TEXTI.  IT CHECKS THE
;ERROR CODE FOR END-OF-FILE CONDITION, HANDLING SPECIALLY.  OTHER ERRORS
;ARE HANDLED STANDARDLY.

EOFJER::
	CALL GETERR		;GET ERROR CODE
	CAIE A,IOX4		;END OF FILE?
	CALL CJERRE		;NO, TREAT AS UNEXPECTED ERROR
	POP P,(P)		;THROW AWAY THE CALL TO THIS ROUTINE
	JRST EOFCHK

;ROUTINE TO HANDLE END OF FILE CONDITION.

EOFCHK:	SKIPN A,EOFDSP
	TRAP LV.EOF,<Unexpected end-of-file> ;NO SPEC DISPATCH, TREAT AS ERROR
	SETZM EOFDSP		;DON'T ALLOW FURTHER INTERRUPTS
	JRST @A			;SERVICE THE END OF FILE CONDITION
;QUOTA EXCEEDED INTERUPT
;DISPATCH ON QTADSP IF NON-ZERO, ELSE TREAT LIKE OTHER
;"PSEUDO-INTERUPTS". QTADSP IS USUALLY NON-ZERO DURING ROUTINES
;WHICH WOULD CREATE PAGES AND WISH TO HELP THE USER.

QTAPSI::	PUSH P,A		;SAVE A REG
	SKIPN QTADSP
	CIS			;CLEAR INTERRUPTS IF NO SPECIAL DISPATCH ADDRESS
	SKIPN QTADSP		;CHECK ROUTINE ADDRS
	ERROR <Quota exceeded or disk full>
	MOVE A,QTADSP		;GET ADDRS OF SPECIAL ROUTINE
	HRRM A,PCTAB+LV.QTA	;SET UP FOR DEBRK
	SETZM QTADSP		;ONLY ONCE
	POP P,A			;RESTORE
	DEBRK			;BYE
;FILE DATA ERROR INTERRUPT
;TYPES A MORE USER-ORIENTED MESSAGE THAN "TRAP" UUO.
;IF A COPY OPERATION, ETC, IS IN PROGRESS, IT GETS ABORTED AND
;  FILES ARE CLOSED, SO OUTPUT FILE IS TRUNCATED.

DATPSI:	CIS			;CLEAR INTERRUPT (AND LOWER ONES!)
	SKIPN DATDSP
	JRST DATPS1		;NO DISPATCH, TYPE ERROR MESSAGE
	PUSH P,DATDSP		;SAVE SPECIAL DISPATCH ADDR FOR "RET" BELOW
	PUSH P,PCTAB+LV.DAT
	POP P,ERPC		;LOCATION OF ERROR, FOR SPECIAL ROUTINE.
	SETZM DATDSP		;CLEAR SPECIAL DISPATCH
	RET			;DISPATCH TO SPECIAL ROUTINE

DATPS1:	MOVE Q1,NERET
	MOVEM Q1,CERET		;RESET ERROR RETURN TO "NORMAL"
	SETZM .JBUFP
	HRRZ Q1,PCTAB+LV.DAT
	ERROR <File data error, at PC %5P>
				;SHOULD GET JFN (GETER?) AND PUT NAME IN ABOVE MESSAGE
				;AND PROBOBLY ELIMINATE PC. ___________

;CLEAR OUTPUT BUFFER PSI
;ISSUES CFOBF ON PRIMARY OUTPUT JFN
;NORMALLY INVOKED BY ^O

COBPSI:	PUSH P,A
	PUSH P,B
	PUSH P,C
	MOVE A,COJFN
	RFMOD			;GET PRESENT TTY MODES
	TLCE B,(1B0)		;COMPLEMENT SUPPRESS FLAG
	JRST [	SFMOD		;WAS ON BEFORE, TURN IT OFF AND PROCEED
		JRST COBPS1]
	PUSH P,B
	CFOBF			;CLEAR OUTBUF OF TTY (PRESUMABLY)
	HRROI B,[ASCIZ / ^O...
/]
	SETZ C,
	SOUT			;NOTE WHAT HAPPENED FOR USER
	POP P,B			;RECOVER TTY MODES
	SFMOD			;SET OUTPUT SUPPRESS
COBPS1:	POP P,C
	POP P,B
	POP P,A
	SKIPE ADVFLG
	JRST ADVCTO		;GO TO ADVISE CODE
	DEBRK
;SUPER-PANIC CHARACTER (CURRENTLY ^C) PSEUDO-INTERRUPT ROUTINE.
;CHANNEL 1, LEVEL 1

CCPSI:	TLOE Z,CTLCF1		;SAY WE'VE SEEN AN ^C
	TLO Z,CTLCF2		;IF ITS THE SECOND ONE, SAY SO
				;(CTLCF2 CAUSES OUTBUF TO BE CLEARED BELOW).
	SETZM ILIDSP		;CLEAR SPECIAL IL INST DISPATCH ADDRESS
	CIS			;CLEAR THIS INTERRUPT, AND ANY LOWER LEVEL ONES SUCH AS
				;^T OR CARRIER OFF. DOING THIS RIGHT OFF CAUSES
				;MULTIPLE ^C'S TO BE DETECTED PROPERLY AND MAKES IL
				;INST TRAP WORK DURING ^C ROUTINE.
	MOVE A,[CALL CUUO]	;RESET UUO DISPATCH (BECAUSE IF PAGE 0 IS IN PMF
	MOVEM A,41		;(WHICH IT ISN'T), MALICOUS USERS CAN PATCH 41
				;TO MAKE EXEC TRANSFER TO ANY CODE THEY WISH).
	TLNN Z,RUNF		;PROGRAM RUNNING?
	JRST [	TLO Z,CTLCF2	;NO, ^C FROM EXEC.  DO CLEAR OUTBUF
		JRST CCDB3]

;*** NEED TO SET CTLCF2 HERE IFF FORK WAS IN TTY INPUT WAIT ***

	SKIPG	A,RUNFK		;USE THIS IF ANY
	MOVE	A,FORK
	FFORK			;FREEZE THE WORLD
	ERCAL	[TYPE <% Process disappeared>
		 ETYPE<%_>
		 RET]
	MOVEI Q1,PTTYMD
	CALL RTTYMD		;STORE TTY MODES FOR "CONTINUE".
	TLZ Z,RUNF		;DON'T DO TTY MODES ON 2ND ^C!
CCDB3:	MOVEI Q1,ETTYMD		;PUT EXEC'S TTY MODES INTO EFFECT.
	CALL LTTYMD		;MUST ALWAYS BE DONE: EG GTJFN LEAVES THEM BAD.
	MOVE A,COJFN
	TLNE Z,CTLCF2		;2ND ^C?
	CFOBF			;YES, CLEAR OUTPUT BUFFER.

;USE REGULAR ERROR ROUTINE TO CLEAR INBUF, TYPE "^C", RELEASE JFNS, 
;AND GENERALLY CLEAN UP.
;RETURNS TO FOLLOWING LOCATION BECAUSE WE SET "CERET" ABOVE.

	SETZM ERRMF		;CLEAR "PROCESSING AN ERROR" FLAG, BECAUSE
				;ANOTHER ^C WHILE PROCESSING EARLIER ONE IS OK.
	MOVEI A,CCERET		;SET ERROR ROUTINE TO SPECIAL ^C VALUE
	MOVEM A,CERET		;..
	SETZM .JBUFP		;SAY FLUSH ALL JFN'S USED IN CURRENT COMMAND
	CALL CLRIO		;CHECK AND RELEASE EXEC IO
	 CALL CIOER1		;GET RID OF "TAKE" JFN
	.$ERROR <^C>		;NO CLEAR INBUF, NO CR FIRST

;WAIT FOR OUTBUF TO EMPTY BEFORE CLEARING ^C FLAGS,
; FOR PROPER DETECTION OF 2ND ^C.

CCERET:	MOVE A,COJFN
	TLNN Z,CTLCF2		;BUT DON'T WAIT IF 2ND ^C
	DOBE
	TLZ Z,CTLCF1+CTLCF2
	JRST @NERET		;GO TO STANDARD ERROR HANDLER
;TIME LIMIT EXCEEDED INTERUPT COMES HERE
TLMPSI:	SETZM .JBUFP		;SAY FLUSH ALL JFN'S USED IN CURRENT COMMAND
	MOVE A,[CALL CUUO]	;RESET UUO DISPATCH (BECAUSE IF PAGE 0 IS IN PMF
	MOVEM A,41		;(WHICH IT ISN'T), MALICOUS USERS CAN PATCH 41
				;TO MAKE EXEC TRANSFER TO ANY CODE THEY WISH).
	TLNN Z,RUNF		;PROGRAM RUNNING?
	JRST [	TLO Z,CTLCF2	;NO, ^C FROM EXEC.  DO CLEAR OUTBUF
		JRST TLMPS1]

;*** NEED TO SET CTLCF2 HERE IFF FORK WAS IN TTY INPUT WAIT ***

	MOVE A,FORK
	FFORK			;FREEZE THE WORLD
	MOVEI Q1,PTTYMD
	CALL RTTYMD		;STORE TTY MODES FOR "CONTINUE".
	TLZ Z,RUNF		;DON'T DO TTY MODES ON 2ND ^C!
TLMPS1:	MOVEI Q1,ETTYMD		;PUT EXEC'S TTY MODES INTO EFFECT.
	CALL LTTYMD		;MUST ALWAYS BE DONE: EG GTJFN LEAVES THEM BAD.
	MOVE A,COJFN
	TLNE Z,CTLCF2		;2ND ^C?
	CFOBF			;YES, CLEAR OUTPUT BUFFER.

;USE REGULAR ERROR ROUTINE TO CLEAR INBUF, TYPE "^C", RELEASE JFNS, 
;AND GENERALLY CLEA