
      HED KILLID
* THE KILLID ROUTINE IS USED TO REMOVE ID CODES FROM THE SYSTEM 
* IDTABLE. THE FORMAT IS: 
* 
*     KILLID - IDCODE 
* 
* IDCODE A000 CANNOT BE KILLED BY THIS COMMAND. 
* GROUP LIBRARIANS CANNOT BE KILLED IF ANY MEMBER OF
* THEIR GROUP IS LOGGED ON. 
* 
* KILLID PERFORMS THE FOLLOWING FUNCTIONS:
* 
* 1. THE ID-CODE IS REMOVED FROM THE IDT. 
* 2. ANY USERS LOGGED ON WITH THIS NUMBER ARE DUMPED. 
* 3. ALL LIBRARY SPACE ALLOCATED TO THIS ID IS RETURNED TO THE
*    SYSTEM.
      SPC 2 
      ORG LIBRA 
      JSB GETID     TRANSLATE THE IDCODE. 
      JMP LFRER     ERROR IF NO CR FOLLOWD. 
      LDA ID        TEST FOR A000.
      CPA A000
      JMP KID31 
* 
*     CHECK FOR GROUP LIBRARIAN 
* 
      AND B1777     MASK TO NUMBER PART 
      CLB 
      DIV .100
      SZB           SKIP IF EVEN HUNDRED
      JMP KIDAA     NOT EVEN, NOT GROUP LIBRARIAN 
* 
*     CHECK TO SEE IF ANY OF HIS SUBJECTS ARE ON
* 
      LDA M32       COUNT OF USERS
      STA KIDC
      LDB DTTY0     => FIRST TTY TABLE
      ADB .+?ID     => FIRST ID 
KIDAD EQU * 
      STB KIDP      SAVE POINTER
      LDA B,I       GET THE ID OF THIS USER 
      CPA ID        THE SAME? 
      JMP KIDAF     YES, HE GETS KILLED ANYWAY
      AND B1777     LEAVE THE NUMBER PART 
      CLB 
      DIV .100
      MPY .100      TURN BACK INTO NUMBER 
      LDB A         SAVE IN B 
      LDA KIDP,I    GET THE ID AGAIN
      AND M2000     LEAVE LETTER PART 
      IOR B         CONSTRUCT THE GROUP ID
      CPA ID        IS THIS ONE IN HIS GROUP? 
      JMP KIDAN     YES, DISALLOW THE KILL
KIDAF EQU * 
      LDB KIDP      GET THE POINTER 
      ADB .+TTY01-TTY00 
      ISZ KIDC      CHECK COUNTER 
      JMP KIDAD     BACK TO CHECK REST
KIDAA EQU * 
* 
* SEARCH IDT. 
* 
      LDB IDTLN,I 
      CMB,INB 
      ADB LIBD
      LDA ID
KID33 CPB LIBD      TEST FOR NOT THERE. 
      JMP KID32 
      ADB .-8       TEST FOR FOUND. 
      CPA 1,I 
      RSS           FOUND IT. 
      JMP KID33 
* 
* REMOVE ID FROM TABLE. 
* 
      STB MOVED 
      ADB .+8 
      STB MOVES 
      ADB MLIBD 
      ADB IDTLN,I 
      JSB MOVEW 
* 
* WRITE BACK TO DISC. 
* 
      LDA IDTLN,I 
      ADA .+8 
      STA IDTLN,I 
      STA MWORD 
      LDA IDTAD 
      LDB LIBD
      JSB DISCZ,I 
      JSB DEADP,I 
* 
* SEARCH TTY TABLES FOR ANY USER TO BE DUMPED.
* 
      LDA M32       SET COUNTER 
      STA KIDC
      CCA           SET KIDT TO SAY NONE
      STA KIDT       FOUND YET. 
      LDB DTTY0 
      ADB .+?ID 
KID34 LDA 1,I       GET ID FROM TABLE.
      CPA ID        IS IT THIS USER?
      JMP KID35     YES--GO DUMP HIM. 
KID37 ADB .+TTY01-TTY00 
      ISZ KIDC      ANY MORE TO TEST? 
      JMP KID34     YES.
      ISZ KIDT      NEED TO WRITE BACK FUSS?
      JMP KID36     YES--TRANSFER TO NEXT PART
      JMP KILBR     NO, NO USERS WERE DUMPED
* 
* DUMP THE USER.
* 
KID35 STB KIDB      SAVE POINTER TO TABLE.
      CLF 0         INHIBIT INTERRUPT.
      CLA           CLEAR USER'S ID.
      STA 1,I 
      ADB .+?STAT-?ID 
      LDA .-2       SET USER'S STATUS TO -2 TO FORCE
      STA 1,I       DISCONNECT. 
      ADB .-?STAT 
      LDA 1,I       SET COM14 BIT 
      IOR COM14       TO FLAG 
      STA 1,I           SCHEDULER 
      ADB .+?LINK 
      JSB KIDEQ,I   REMOVE FROM QUEUE.
      STF 0 
      ISZ KIDT      IS FUSS TABLE IN CORE?
      JMP KID38     YES.
      LDA M2000     NO, READ IT IN
      STA MWORD 
      LDA FUSS
      LDB LIBDI 
      JSB DISCZ,I 
      JSB DEADP,I 
* 
KID38 LDA KIDC      COMPUTE LOCATION OF USER'S FUSS 
      ADA .+32        AREA
      ALF,ALS 
      ADA LIBD
      STA KIDP
      LDB M32       ZERO OUT USER'S FUSS AREA 
      CLA 
      STA KIDP,I
      ISZ KIDP
      INB,SZB 
      JMP *-3 
* 
      LDB KIDB      GET POINTER AGAIN.
      JMP KID37     GO TEST NEXT USER.
* 
KIDEQ DEF DEQUE 
* 
KID31 LDA KIDM1     PRINT "A000 NOT ALLOWED"
      LDB .-17
      JMP KIDAZ 
KID32 LDA KIDM2     PRINT "NO SUCH ID"
      LDB .-11
      JMP KIDAZ 
KIDAN LDA KIDM3     PRINT " GROUP LIBRARY IN USE" 
      LDB .-21
KIDAZ EQU * 
      STB KIDC
      STA MOVES 
      LDA T35B1 
      STA MOVED 
      BRS 
      JSB MOVEW 
      LDA KIDC
      CMA,INA 
      LDB T35B1 
      JMP LEND2 
* 
KIDM1 DEF *+1 
      OCT 5101
      ASC 8,000 NOT ALLOWED 
KIDM2 DEF *+1 
      OCT 5116
      ASC 5,O SUCH ID 
KIDM3 DEF *+1 
      OCT 5107
      ASC 10,ROUP LIBRARY IN USE
* 
      SKP 
KID36 LDA FUSS      WRITE BACK FUSS 
      LDB LIBD       IF ANY USERS 
      JSB DISCZ,I       WERE DUMPED 
      JSB DEADP,I 
* 
* 
* WE HAVE NOW GOTTEN RID OF THE USER.  THE NEXT STEP IS TO
* RELEASE ANY SYSTEM SPACE CONSUMED BY THE USER.
* 
* THIS SECTION HAS THE JOB OF REMOVING ALL
* FILES BELONGING TO THE ID BEING KILLED FROM THE USER LIBRARY, AND 
* UPDATING THE ADT APPROPRIATELY. 
* 
KILBR EQU * 
      LDA KDIRL     TEST INDIVIDUAL DIRECTORIES 
KID4  STA KIDI      KIDI POINTS TO THE ONE TESTED.
KIDRE EQU * 
      DLD KIDI,I    GET LENGTH AND FIRST ID.
      STB KIDT      SAVE FIRST ID FOR LATER.
      CLE 
      ADB MID       B=FIRST ID- KEYID 
      SZA           FORGET TRACK IF IT'S EMPTY
      SEZ,SZB         OR IF FIRSTID>KEYID 
      RSS 
      JMP KID2
KID1  LDA KIDI
      CPA KDIR0 
      JMP LEND
      ADA .-7       BUMP TO NEXT TRACK. 
      JMP KID4
* 
* PROCESS DIRECTORY TRACK IN ORDER TO REMOVE KEY ID ENTRIES. THE
* DIRECTORY IS READ INTO THE BEGINNING OF THE WORKSPACE AND IS
* SCANNED IN REVERSE ORDER.  A TABLE OF PATCHES IS BUILT UP 
* STARTING AT LIBUS+8192. 
*     THE FOLLOWING POINTERS ARE USED:
* 
* KIDP1 => DIRECTORY ENTRY BEING TESTED 
* KIDP2 => FIRST ENTRY FOLLOWING LAST KID ENTRY 
* KIDP3 => LAST ENTRY IN DIRECTORY
* KIDP4 => LAST ENTRY IN PATCH TABLE
* 
KID2  EQU * 
      STA MWORD     SET UP LENGTH FOR DISC TRANSFER 
      CMA,INA 
      ADA LIBD
      ADA .-12      SET KIDP3 TO POINT TO LAST
      STA KIDP3      ENTRY IN DIRECTORY.
      STA KIDP1     SET POINTER TO CURRENT ENTRY. 
      LDA L8192     INITIALIZE PATCH TABLE
      STA KIDP4      POINTER. 
      CLA 
      STA KIDLN     SET PATCH TABLE LENGTH
      LDA KIDI      GET DIRECTORY 
      ADA .+5         DISC ADDRESS
      LDB LIBDI       ADDRESS OF WORKSPACE
      JSB DISCZ,I   READ DISC 
      JSB DEADP,I 
* 
KID7  LDA KIDP1,I   GET ID OF NEXT ENTRY
      ELA,CLE,ERA 
      ADA MID       COMPARE WITH KEY ID.
      SSA           TEST FOR <
      JMP KID6
      SZA           TEST FOR >
      JMP KID8
* 
* FOUND AN ENTRY FOR KID. NOW REMOVE IT.
* 
      LDB KIDP1     IF THIS IS THE FIRST
      ADB .+12       SUCH ENTRY, SET KIDP2 AS 
      LDA KIDP4       STATED ABOVE. 
      CPA L8192     SET ONLY IF PATCH TABLE EMPTY 
      STB KIDP2 
      CPA LULEN 
      JMP KIDE
* 
      LDA KIDI,I    ADJUST THE DIRECTORY LENGTH.
      ADA .+12
      STA KIDI,I
      STA MWORD 
* 
      LDB KIDP1 
      LDA B,I       GET THE 
      STA KIDP4,I     USER ID 
      ISZ KIDP4         AND STORE IT
      ADB .+11      => LENGTH 
      LDA B,I       A = LENGTH
      STA KIDP4,I   SAVE IN PATCH TABLE 
      ISZ KIDP4 
      ADB .-3       => DISK ADDRESS 
      DLD B,I       GET DISK ADDRESS
      DST KIDP4,I   SAVE IN PATCH TABLE 
      ISZ KIDP4 
      ISZ KIDP4 
      ISZ KIDLN     INCREMENT ENTRY COUNT 
* 
KID8  LDB KIDP1     TEST FOR FINISHED 
      CPB LIBD       EXAMINING DIRECTORY ENTRIES. 
      JMP KID6      FINISHED !!!
      ADB .-12      IF NOT, MOVE POINTER BACK TO
      STB KIDP1     NEXT ENTRY. 
      JMP KID7
* 
* MAKE ROOM BY PUSHING UP PARTIALLY EXAMINED DIRECTORY. 
* 
KIDE  EQU * 
      LDB KIDP1     SET UP
      ADB .+12
      STB MOVED      DEST AND 
      LDB KIDP2       SOURCE. 
      STB MOVES 
      CMB           COMPUTE # 
      ADB KIDP3      OF WORDS 
      CMB             TO MOVE 
      ADB .-12         AND
      JSB MOVEW        DO IT. 
* 
      LDA KIDI      => DIREC ENTRY
      ADA .+5       => DISC ADDRESS 
      LDB LIBD
      JSB DISCZ,I 
      JSB DEADP,I 
      LDA KIDLN     GET ENTRY COUNT 
      CMA,INA 
      STA KIDLN     SET NEGATIVE FOR OTHER USERS
      JSB KIDRR     CHECK LENGTHS FOR BLOCK SIZE
      JSB RTAD,I    RESTORE DISC SPACE
      JMP KIDRE     CONTINUE ON 
* 
* THE PATCH TABLE IS NOW BUILT. THE NEXT STEP IS TO FIXUP THE DIREC.
* 
KID6  EQU * 
      LDA KIDLN     CHECK LENGTH OF PATCH TABLE 
      CMA,INA,SZA,RSS 
      JMP KID18 
      STA KIDLN     SET NEGATIVE COUNT
* 
      LDA KIDI,I
      SZA,RSS       IF LENGTH=0 WE DONT HAVE TO 
      JMP KID10      WRITE IT BACK OUT. 
      STA MWORD     SET UP FOR DISC DRIVER
* 
* WE FIRST HAVE TO CLOSE UP THE HOLE.  THERE ARE 2
* CASES, DEPENDING UPON WHETHER THE HOLE IS AT THE
* BEGINNING OR IN THE MIDDLE. 
* 
      LDA KIDP2     WE WILL MOVE FROM KIDP2 IN
      STA MOVES      ANY CASE.
      LDB KIDT      GET FIRST ID IN B.
      CPB ID        IF = HOLE IS AT BEGINNING 
      JMP KID11     GO SET NEW FIRST ID.
      LDA KIDP1     SET DEST. TO BE RIGHT AFTER 
      ADA .+12       LAST ENTRY EXAMINED
      CPA MOVES     FORGET IT IF SAME AS SOURCE.
      JMP KID12 
      LDB KIDP3     COMPUTE # OF WORDS TO MOVE. 
      CMB,INB 
      ADB KIDP2 
      ADB .-12
      JMP KID13     GO MOVE IT. 
* 
KID11 LDA KIDI      SET UP NEW FIRST ID.
      INA 
      LDB .-4 
KID13 STA MOVED 
      JSB MOVEW 
* 
* NOW WRITE DIRECTORY BACK TO DISC. 
* 
KID12 LDB LIBD      DETERMINE CORE ADDRESS. 
      LDA ID
      CPA KIDT
      LDB KIDP2 
      LDA KIDI      GET DISC ADDRESS. 
      ADA .+5 
      JSB DISCZ,I 
      JSB DEADP,I 
* 
KID10 EQU * 
      JSB KIDRR     CHECK LENGTHS FOR BLOCK SIZE
* 
* WRITE ADT TO DISC 
* 
      JSB RTAD,I    RESTORE DISC SPACE
      LDA KIDT      IF FIRST DISC ENTRY 
      CPA ID         WAS NOT ID, WERE DONE. 
      JMP KID1
KID18 CLF 0 
      JMP LEND
* 
* MAKE SURE ALL LENGTHS ARE IN BLOCKS 
* 
KIDRR NOP 
      LDA KIDLN     GET COUNT OR ENTRIES
      STA KIDP
      LDB L8192     GET TABLE BEGINNING POINTER 
      INB           => LENGTH 
KIDRS EQU * 
      STB KIDP1     SET A CONVENIENT POINTER
      LDA KIDP1,I   GET LENGTH
      SSA,RSS       SKIP IF NEGATIVE ( WORD COUNT ) 
      JMP KIDRW     POSITIVE ( BLOCK COUNT )
      CCB 
      ASR 8         MAKE INTO BLOCK COUNT 
      CMA,INA 
      STA KIDP1,I   ALTER TABLE FOR DISK SPACE RETURN 
KIDRW EQU * 
      LDB KIDP1     GET PATCH TABLE POINTER 
      ADB .+4       ADVANCE TO NEXT ENTRY 
      ISZ KIDP      CHECK FOR END 
      JMP KIDRS     NOT END, PROCESS NEXT 
      JMP KIDRR,I   RETURN
* 
* 
KDIR0 DEF DIREC 
KDIRL DEF DIREL 
KIDP  EQU LTEMP+1 
KIDI  EQU LTEMP+2 
KIDT  EQU LTEMP+3 
KIDLN EQU LTEMP+5 
KIDP1 EQU LTEMP+6 
KIDP2 EQU LTEMP+7 
KIDP3 EQU LTEMP+8 
KIDP4 EQU LTEMP+9 
KIDC  EQU LTEMP+10
KIDB  EQU LTEMP+11
$KID  EQU * 
