         SYSTEM  SIG7
         SYSTEM   BPM
*
* THIS SUBROUTINE WILL OPEN THE LOGIN FILE AND KEY-READ A RECORD;  THEN
* IT WILL STORE INFORMATION FROM THE LOGON RECORD INTO JIT. IF THE
* ROUTINE IS ABLE TO DO THIS OPERATION SUCCESSFULLY A ZERO WILL BE
* PLACED INTO SR3. IF THE OPERATION IS UNSUCCESSFUL THE CONTENTS OF SR3
* WILL BE NON-ZERO. THIS SUBROUTINE WILL ALSO CREATE A LOGIN FILE FOR
* THE MANAGEMENT ACCOUNT IF A FILE DOES NOT ALREADY EXIST.
*
DEBUG    EQU      0
         DEF      LOGRT
         DEF      CLOSLOG
         DEF      LOGSZ
         DEF      OPLOG
         DEF      CONCAT
         DEF      KEYBUFF
         REF      JACCN
         REF,1    JB:PRIV
         REF      J:XP
         REF      :AMHED            ASSIGN MERGE HEAD(INDEX TO AVLB AREA)
         REF      :LOGSZ            LOGON RECORD SIZE
LOGSZ    EQU      :LOGSZ+:LOGSZ+:LOGSZ+:LOGSZ
         REF      J:JIT
         REF      PRDCRM,PRDPRM,TMDCRM,TMDPRM
         REF      TMPDCPK,TMPDPPK
         REF      JUNAME
         REF      M:EO
         REF      DATEON            DEF IN JOBR,START DATE(YY,DD)
         REF      USRNM             DEF IN JOBR, TO FORM THE KEY
         REF      LGNTM             DEF IN JOBR,LOGON TIME
         REF      EXTACC            DEF IN JOBR,EXTENDED ACCNT. INFO.
         REF      LMXCDCD
         REF      ACCNER
         REF      J:ASSIGN
*
         REF      SV:FTYM
         REF      SH:SYMT
         REF,2    JH:LDCF
         REF      SV:RSIZ
         REF      SH:RNM
         REF      JB:MAX
         REF      Y8
         REF      JB:CUR
         REF      TSTACK
         REF      SV:LIM
         REF      SL:NAME
         REF      J:TITLE
         REF      YFFFE
         REF      Y002
         REF      Y03
         REF      XFFFF
         REF      ATITLE
         REF      MRT
         REF      MPPO
         REF      MPO
         REF      MDPO
         REF      MUPO
         REF,1    JB:NFPOOL
         REF      BLANK
         REF      WAMR
         REF      NRESERR
*
         DEF      ASMGBUF           DATA AREA FOR A-M READ WRITE
*                                   (ONLY THE HEAD,I.E.22 WDS)
M:XX     EQU      M:EO
LR:FG    EQU      5                 READ ALL AND FLAG FIELDS
LR:BIL   EQU      15                BILLING
LR:PRIV  EQU      16                PRIVILEGE
LR:ACRAD EQU      18                ACCU PERM RAD SPACE
LR:DMR   EQU      20                DEF AND MAX FILE RETENTION PERIODS
LR:ACDIS EQU      22                ACCU PERM DISK SPACE
LR:EACCT EQU      24                EXTENDED ACCOUNTING INFORMATION
LR:UNMR  EQU      94
LR:UBMR  EQU      102
LR:UPFLGS EQU     122
LR:UNMP  EQU      114
LR:UNML  EQU      30
LR:UBML  EQU      46
***********************************************************************
R0       EQU      0
R1       EQU      1
R2       EQU      2
R3       EQU      3
R4       EQU      4
R5       EQU      5
R6       EQU      6
R7       EQU      7
SR1      EQU      8
SR2      EQU      9
SR3      EQU      10
SR4      EQU      11
D1       EQU      12
D2       EQU      13
D3       EQU      14
D4       EQU      15
***********************************************************************
XFF      DATA     X'FF'
X7F      DATA     X'7F'
TIMKWD   TEXT     'TIME'
TXTPSTO  TEXT     'PSTO'
TXTPDIS  TEXT     'PDIS'
*
RECORD   EQU      %
         TEXT     ':SYS    LBE         '   LOGON NEEDS THIS
         DO1      11
         DATA     0
         DATA,1   X'C0',X'C0',0,0  AND THIS
*                                   WHEN CCI WRITES FIRST REC'D OF FILE.
         DO1      109
         DATA     0
KEYBUFF  DO1      6
         DATA     0
*ASSIGN MERGE TABLE
ASMGBUF  DO1      8                 FIRST 8  WORDS IN A-M TABLE
         DATA     0
         DATA     0                 DATE(YY,DD) AT JOB START
         DO1      3                 USERS NAME,3 WDS
         DATA     X'40404040'
         DATA     0                 LOGON TIME
         DATA     0                 BILLING
         DO1      6                 EXTENDED ACCNT. INFO.FIELD
         DATA     X'40404040'
         DATA     0                 PERM RMNG RAD SPACE ALLCTED
         DATA     0                 PERM RMNG DISK SPACE ALCTD
*
***********************************************************************
*
* PLIST FOR OPENING THE LOGON FILE
*
         CSECT    1
OPLOG    GEN,8,7,17 X'14',0,M:XX
         DO       DEBUG
         DATA     X'CF480019'
         ELSE
         GEN,8,8,8,8  X'CF',X'48',X'02',X'19' FOR UTS
         FIN
         GEN,1,31 1,R6              ERROR RETURN
         GEN,1,31 1,R7              ABNORMAL RETURN
         GEN,32   10                MAXIMUM RECOVERY TRIES
         GEN,32   2                 KEYED FILE
         GEN,32   2                 DIRRECT ACCESS
         GEN,1,14,17 1,0,R1         WHEN R1=1,MODE=IN;R1=8,MODE=OUTIN
         GEN,32   2                 SAVE
         GEN,32   21                MAXIMUM KEY LENGHT
         GEN,8,8,8,8 1,0,2,2        FILE NAME
          TEXTC     ':USERS'
         GEN,8,8,8,8    2,0,2,2
SECAT    EQU      %
         DO       DEBUG
         TEXT     'F65123CK'
         ELSE
         TEXT     ':SYS'
         TEXT      '    '
         FIN
         DO       DEBUG
         DATA     0
         DATA     0
         DATA     0
         ELSE
         GEN,8,8,8,8 3,0,2,2        PASSWORD
         DATA     X'DFEF803F',X'AFC0BF9F'
         FIN
         GEN,8,8,8,8 5,1,1,1        READ ACCOUNT NUMBER
         TEXT     'NONE'
*
*
* PLIST FOR READING THE LOGON FILE
*
KEYREAD  GEN,8,24 X'10',M:XX
         DATA     X'F8000010'
         DATA     NOACCESS          PHYSICAL IO ERROR RETURN
         DATA     OPNABRT           ABNORMAL RETURN
         DATA     RECORD            BUFFER ADDRESS
         DATA     LOGSZ             BUFFER SIZE NOW EXPANDED
         DATA     KEYBUFF           KEY ADDRESS
*
* PLIST FOR WRITING A RECORD
*
WRITLOG  GEN,8,24 X'11',M:XX
         DATA     X'B8000020'
         GEN,15,17 0,NOACCESS       PHYSICAL IO ERROR RETURN
         GEN,15,17  0,RECORD        BUFFER ADDRESS
         DATA     LOGSZ             BUFFER SIZE NOW EXPANDED
         DATA     KEYBUFF           KEY ADDRESS
*
* PLIST FOR CLOSING THE LOGIN FILE
*
CLOSLOG  GEN,8,7,17 X'15',0,M:XX
         GEN,1,31 1,0
         GEN,32   2                 ALWAYS SAVE THE FILE
*
*
*        PUSH OF PULL N WORDS SPECIFIED BY 1ST ARGUMENT
*        INTO REG'S STARTING AT 2ND ARGUMENT
PUSH     CNAME    X'9',X'B'
PULL     CNAME    X'8',X'A'
         PROC
         DO       NUM(AF)=1
LF       GEN,1,7,4,3,17 0,NAME(1),AF(1),0,TSTACK
         ELSE
         DO       AF(1)=1
LF       GEN,1,7,4,3,17 0,NAME(1),AF(2),0,TSTACK
         ELSE
         DO       AF(1)=16
LF       LCI      0
         ELSE
LF       LCI      AF(1)
         FIN
         GEN,1,7,4,3,17 0,NAME(2),AF(2),0,TSTACK
         FIN
         FIN
         PEND
***PLIST FOR RELEASING RESOURCES
L500     GEN,1,7,8,16 1,X'15',0,R6  RELEASED QUANTITY IN SR1
         PAGE
***********************************************************************
***********************************************************************
*
LOGRT    EQU      %
         LI,R4    0                 CLEAR COUNTER FOR KEY
         LI,R3    KEYBUFF           LOAD ADDRESS OF KEY BUFFER
         LI,R7    8                 LOAD LENGHT LIMIT FOR ACCOUNT
         LI,R2    J:JIT+JACCN       LOAD ADDRESS OF ACCOUNT
         BAL,SR1  CONCAT            GO PUT ACCOUNT INTO THE KEY
         AI,R4     1                 INSERT SPACE CHR
         LI,R6     X'40'             .BETWEEN ACCOUNT
         STB,R6    *R3,R4            ..AND NAME FIELDS.
         LI,R7    12                LOAD LENGHT LIMIT FOR NAME
         LI,R2    J:JIT+JUNAME      **FOR TESTING ONLY**
         BAL,SR1  CONCAT            GO PUT NAME INTO THE KEY
         STB,R4   *R3               PUT KEY LENGHT INTO KEY
         LCI      2
         LM,D3    SECAT             GET SECRET  ACCOUNT
         XW,D3    J:JIT+JACCN       EXCHANGE SECRET ACCT. WITH JIT ACCT.
         XW,D4    J:JIT+JACCN+1     EXCHANGE SECRET ACCT. WITH JIT ACCT.
         LI,R1    1                 SET MODE TO IN
         LI,R6    NOACCESS          LOAD ERROR RETURN ADDR.
         LI,R7    OPNABRT           LOAD ABN. RETURN ADDR.
OPN      LI,SR3   0
         CAL1,1   OPLOG
         CAL1,1   KEYREAD           KEY READ THE LOGIN FILE
         CAL1,1   CLOSLOG           CLOSE THE LOGIN FILE
         LCI      2
         STM,D3   J:JIT+JACCN       PUT ORIGINAL ACCT. BACK INTO JIT
*PROCESS EXTENDED ACCOUNTING
         LW,R1    EXTACC            USE EXT. ACTG. FROM !JOB IF SPEC.
         CW,R1    BLANK
         BNE      L007
         LI,R1    -6                NOT SPECIFIED
L005     EQU      %
         LW,R2    RECORD+LR:EACCT+6,R1 HENCE, USE EXT. ACCTG. FROM :USERS REC.
         BEZ      L007
         STW,R2   EXTACC+6,R1
         BIR,R1   L005
L007     EQU      %
*PROCESS SERVICE LIMITS
         LI,R2    15                PRESET SCAN COUNTER.
L010     EQU      %
         LW,R3    RECORD+LR:UNML,R2 DOES CURRENT ENTRY CONTAIN
         BNEZ     L030              .AUTHORIZED SERVICE NAME.-YES.
L020     EQU      %
         BDR,R2   L010              -NO. IS SCAN FINISHED.-NO
         B        L100              -YES. END.
L030     EQU      %
         BAL,SR1  SLSRCH            WAS USER LIMIT NAME FOUND IN SL:NAME
         BNE      L020              NO, GET NEXT
         LW,R4    RECORD+LR:UBML,R2 USE USERS SERVICE LIMIT
         STW,R4   J:TITLE,R1
         LI,R7    J:JIT
         LW,R3    LIMINFO,R1        GET STORAGE INFO.
         LB,R6    R3                SHIFT VALUE AND RESOLUTION
         SCS,R4   0,R6              VALUE TO PROPER FIELD IN JIT
         SLS,R6   -6                RESOLUTION
         LI,R5    -1                LOAD PROPER MASK
         CI,R1    LIMINFOA
         BGE      %+2
         LW,R5    YFFFE
         EXU      LIMSTORE,R6       STORE IT
         BDR,R2   L010              GET NEXT
* SET PROPER MAX. IN J:TITLE FOR PSTORE AND PDISK WHEN NOT SPEC'D
* IN USERS FILE. MAX. USED BY LIMR.
L100     EQU      %
         LI,R2    15                CALC. MAX FOR PSTORE
         LW,R3    TXTPSTO
L102     EQU      %
         CW,R3    RECORD+LR:UNML,R2  WAS PSTORE FOUND IN USERS
         BE       L103              YES, DONT SET MAX
         BDR,R2   L102
         BAL,SR1  SLSRCH            SEARCH SL:NAME TABLE FOR PSTORE
         BNE      L103
         LW,R2    J:TITLE,R1        GET SYS. MAX
         SW,R2    RECORD+LR:ACRAD
         BGEZ     %+2
         LI,R2    0
         STW,R2   J:TITLE,R1        SET MAX=SYS MAX-ACCU.
L103     EQU      %
         LI,R2    15                CALC. MAX FOR PDISK
         LW,R3    TXTPDIS
L104     EQU      %
         CW,R3    RECORD+LR:UNML,R2  WAS PDISK FOUND IN USERS
         BE       L105              YES, DONT SET MAX
         BDR,R2   L104
         BAL,SR1  SLSRCH            SEARCH SL:NAME TABLE FOR PDISK
         BNE      L105
         LW,R2    J:TITLE,R1        GET SYS. MAX
         SW,R2    RECORD+LR:ACDIS
         BGEZ     %+2
         LI,R2    0
         STW,R2   J:TITLE,R1        SET MAX=SYS MAX-ACCU.
*PROCESS RESOURCE LIMITS
L105     EQU      %
         LI,R1    SV:RSIZ           SET COUNT TO CYCLE THRU
*                                   .RESOURCE NAME TABLE.
L110     EQU      %
         LH,R6    SH:RNM,R1         IS CURRENT
         BNEZ     L200              .ENTRY ZERO. -NO.
L120     EQU      %
         BDR,R1   L110              -YES. END OF TABLE. -NO.
         STB,R1   JB:MAX            BYTE 0 RESET MEANS RES. PROC. O.K.
**PRIVILEGE                         -YES.
         LI,R3    BA(RECORD+LR:PRIV) GET ADDR OF PRIV. LEVEL.
         LB,R2    0,R3              GET PRIV LEVEL FROM LOGON RECORD
         CI,R2    0                 DOES THE BYTE HAVE SOMETHING IN IT
         BEZ      %+3               NO
         LI,R3    JB:PRIV
         STB,R2   0,R3              STORE PRIVELEGE INTO JIT
**FILE READ ('ALL' OPTION)
         LW,R2    RECORD+LR:FG      GET THE DESIRED WORD
         CW,R2    =X'80000000'
         BAZ      %+3               OPTION BIT NOT SET(I.E. READ ALL)
         LW,R3    =X'10000000'
         STS,R3   J:ASSIGN          SET BIT 3 IN J:ASSIGN(READ NONE)
**TRANS. PROCESSOR(TP),EXEC. ONLY(XOS),RESTR. PROCESSOR(RP),SECURITY(SE)
         REF      JPUF
         LI,R3    X'10'
         STS,R2   J:JIT+JPUF        SET TP FLG  10 BIT
*
         LI,R3    2                 IF SE BIT SET
         AND,R3   R2
         BEZ      L125
         LI,R4    JB:PRIV           SET BIT 2 IN JB:PRIV
         LB,R7    0,R4
         OR,R7    R3
         STB,R7   0,R4
L125     EQU      %
         SLS,R2   22                SET XOS AND RP BITS IN JIT
         LW,R3    Y03
         STS,R2   J:ASSIGN
** PERM RAD SPACE RMNG=PERM RAD SPACE LIMIT-ACCU PERM RAD SPACE
         LW,R2    J:JIT+PRDCRM      GET LIMIT FROM JIT
         SW,R2    RECORD+LR:ACRAD   GET ACCU. RAD SPACE FROM :USERS
         BGEZ     PERM5
         LI,R2    0                 MINUS ACCU. SET=0
PERM5    EQU      %
         STW,R2   J:JIT+PRDCRM      RMNG SPACE TO JIT
** PERM PACK SPACE RMNG=PERM PACK LIMIT-ACCU. PERM PACK SPACE
         LW,R2    J:JIT+PRDPRM      GET LIMIT FROM JIT
         SW,R2    RECORD+LR:ACDIS   GET ACCU. PACK SPACE FROM :USERS
         BGEZ     PERM10
         LI,R2    0                 MINUS ACCU. SET=0
PERM10   EQU      %
         STW,R2   J:JIT+PRDPRM      RMNG SPACE TO JIT
*PROCESS LOGICAL LIMITS
         LI,R7    0                 AUTHORIZE DEVICES FOR BATCH
         LI,R4    RECORD+LR:UNMP    ADDR OF :UNMP TABLE.
         LI,R5    RECORD+LR:UPFLGS  ADDR OF :UPFLGS.
         PUSH     SR4
         BAL,SR4  SETLDCF           SET BITS IN JH:LDCF FOR
*                                   .PERIPHERALS SPEC'D IN :USERS
         PULL     SR4
**FILE RETENTION PERIODS
**** NONE--0(DEFAULT), NEVER--FFFF
RETENT   EQU      %
         LH,R2    RECORD+LR:DMR     GET DEF. RETN PERIOD
         BEZ      %+2               IF ZERO,USE DEFAULT IN JIT
         STH,R2   J:XP              STORE DEF. RETN. INTO JIT
         LI,R3    1                 HW INDEX
         LH,R2    RECORD+LR:DMR,R3  GET MAX RETN PERIOD
         BEZ      %+2               USE DEFAULT
         STH,R2   J:XP,R3           STORE MAX RETN INTO JIT
*NOW THAT ALL NEC. INFO. IN LOG REC PROCESSED,
*PREPARE AND WRITE THE ASSIGN-MERGE RECORD
*
BAM      LI,R2    :AMHED            FIRST ENTRY PTR.
         STW,R2   ASMGBUF           0TH WD=INDEX TO AVLBL AREA
*
         LW,R2    DATEON            START DATE FROM JOBR
         STW,R2   ASMGBUF+8
*
         LI,R3    -3
W1       LW,R2    USRNM+3,R3        STORE USER NAME FROM USRNM IN JOBR
         STW,R2   ASMGBUF+12,R3       TO ASSIGN-MERGE RECORD
         BIR,R3   W1
*
         LW,R2    LGNTM             STORE LOGON TIME FORM JOBR
         STW,R2   ASMGBUF+12          TO ASSIGN-MERGE RECORD
*
         LI,R3    BA(RECORD+LR:BIL) GET RATE STRUCTURE FROM LOGON REC.
         LB,R2    0,R3
         BEZ      %+2               EMPTY
         STH,R2   ASMGBUF+13        INTO A-M REC(LEFT HALFWD)
*
         LI,R3    1
         LH,R2    J:JIT,R3          GET SID
         STH,R2   ASMGBUF+13,R3     INTO A-M REC(RIGHT HALFWD)
         LI,R3    -6
W2       LW,R2    EXTACC+6,R3
         STW,R2   ASMGBUF+20,R3     STORE EXT.ACCT.INFO. FROM JOBR
         BIR,R3   W2                  INTO ASSIGN-MERGE RECORD
*
         LW,R2    J:JIT+PRDCRM      PERM RAD SPACE REMAINING
         STW,R2   ASMGBUF+20
*
         LW,R2    J:JIT+PRDPRM      OERM DISK SPACE REMAINING
         STW,R2   ASMGBUF+21
*
         PUSH     3,SR2
         LW,R3    Y002              CLOSE :USERS FILE IF OPEN
         CW,R3    M:XX
         BAZ      W4
         CAL1,1   CLOSLOG
W4       EQU      %
         LI,SR2   ASMGBUF           BUFFER ADDRESS
         BAL,SR4  WAMR              WRITE A/M RECORD
         STW,SR3  R3                SAVE A/M WRITE CODE TEMP.
         PULL     3,SR2
         CI,SR3   0                 ANY ERRORS PRIOR TO A/M WRITE
         BNE      W5                YES
         LW,SR2   R3                NO, HONOR A/M WRITE ERROR IF ANY
         LW,SR3   R3
W5       EQU      %
*
*NOW CLOSE THE LOGON FILE
*
*  AND PROVIDE ADDRESS OF COPY OF LOGON RECORD
*   FOR THE INSTALLATION ACCOUNTING ROUTINE
*
         LI,R3    RECORD
*
         B        *SR4              EXIT LOGRT
         REF      SETCLS
*
*
NOACCESS EQU      %                 USER NOT ABLE TO ACCESS USERS FILE
         LCI      2
         STM,D3   J:JIT+JACCN       RESTORE USER'S ACCT. TO JIT
         LI,SR3   1                 PUT A ONE INTO SR3
         LI,SR2   ACCNER            ERROR CODE FOR ACCOUNT
         B        BAM               *BUILD AM BEFORE ABORT
*
OPNABRT  SLS,SR3  -17               AN ABNORMAL CONDITION OCCURRED
         CI,SR3   X'A01'            WAS THE FILE BEING UPDATED
         BNE      OPNABRT5          NO
         M:WAIT   1                 YES, WAIT 1.2 SEC.
         B        OPN               TRY TO OPEN IT AGAIN
OPNABRT5 EQU      %
         SLS,SR3  -7                NO; SHIFT OFF END BYTE
         CI,SR3   3                 DOES THE FILE EXIST
         BNE      NOACCESS          YES,THERE WAS SOME OTHER ABNOMAL
         CW,D3    L(C':SYS')
         BNE      NOACCESS          NOT MANAGER,SO NO ACCESS
         CW,D4    =X'40404040'      TEST 2ND WORD IN ACCOUNT
         BNE      NOACCESS          IT IS NOT SO NO ACCESS
         LW,R2    USRNM             USRNM DEFINED IN JOBR
         LW,R2    J:JIT+JUNAME      **FOR TESTING ONLY**
         CW,R2    L(C'LBE ')        SEE IF IT'S MANAGER'S NAME
         BNE      NOACCESS          IT ISN'T SO NO ACCESS
* USER IS :SYS,LBE, AND 1ST TIME AROUND
* CREATE A LOGON RECORD FOR HIM
*
         LI,R1    8                 OPEN IN OUTIN MODE
         LI,R6    NOACCESS          LOAD ERROR RETURN ADDR.
         LI,R7    OPNABRT           LOAD ABN. RETURN ADDR.
         CAL1,1   OPLOG
         CAL1,1   WRITLOG           WRITE FIRST RECORD
         CAL1,1   CLOSLOG           CLOSE THE LOGIN FILE
         LCI      2
         STM,D3   J:JIT+JACCN       RESTORE USER'S ACCT TO JIT
         LI,SR3   0
         B        LOGRT             WAS *SR2;SO THAT NO MORE FIRST
*                                   TIME PROBLEM
*
*
CONCAT   EQU      %                 THIS ROUTINE CREATES A KEY
         LI,R5    0                 LOAD POINTER TO FIELD
DOIT     LB,R6    *R2,R5            GET A CHARACTER FROM FIELD
         AI,R5    1                 INCREMENT POINTER
         CI,R6    X'40'
         BE       *SR1              YES; GO BACK TO MAIN ROUTINE
         AI,R4    1                 INCREMENT BYTE COUNT FOR KEY
         STB,R6   *R3,R4            STORE THE CHARACTER INTO THE KEY
         CW,R5    R7                HAS THE END OF FIELD BEEN REACHED
         BE       *SR1              YES; GO BACK TO THE MAIN ROUTINE
         B        DOIT              NO;
*
* EXIT HERE AND CLOSE LOGON FILE IF USER VIOLATED
*  AUTHORIZATION RECORD
*   ERROR CODE ALREADY SET UP IN SR2
*
VIOLATE  EQU      %
         LI,SR3   -1                ERROR, SET GEN-ACCTG. FLAG
         B        BAM               BUILD A-M BEFORE ABORT
L200     EQU      %
         LI,R2    15                :UNML SIZE.
L210     EQU      %
*                                   COMPARE RESOURCE NAME
*                                   .TABLE ITEM AGAINST
         CH,R6    RECORD+LR:UNMR,R2 ..RESOURCE LIMIT
         BE       L212              ...NAME. -EQ.
         BDR,R2   L210              END RNM TABLE. -NO/
         B        L330              -YES.
L212     EQU      %
         AND,R6   XFFFF
         LB,SR1   JB:MAX,R1         -EQ. IS MAX A SYSTEM
         CB,SR1   Y8                .DEFAULT OR USER SPEC'D.
         BAZ      L370              -USER SPEC'D.
         AND,SR1  X7F               -SYSTEM DEFAULT.
         LB,R7    RECORD+LR:UBMR,R2 IS SYSTEM DEFAULT GRTR.
         CI,R6    X'C3D6'           IF RESOURCE IS CORE
         BNE      L215
         SLS,R7   -1
L215     EQU      %
         CW,SR1   R7                ..THAN USERS
         BLE      L340              ...REQUIREMENT. -NO.
         STW,SR1  R3
         SW,SR1   R7                -YES. RELEASE RESOURCES
         CI,R6    X'C3D6'           IS RESOURCE CORE
         BNE      L220
         SLS,SR1  1                 MUST CONVERT TO PAGES
         SLS,R3   1                 BEFORE RELEASING CORE
L220     EQU      %
         STB,R3   JB:MAX,R1         STORE RESOURCE
         LI,R7    0                 MUST ZERO CUR BEFORE RELEASING CORE
         STB,R7   JB:CUR,R1
         CAL1,8   L500              .NOT NEEDED BY USER.
         B        L120
L300     EQU      %
         LI,R7    0                 ZERO OUT CURRENT
         STB,R7   JB:CUR,R1         .RESOURCE COUNT.
         LH,R7    SH:RNM,R1         IS THIS
         AND,R7   XFFFF             SYSTEM
         CI,R7    X'C3D6'           RESOURCE
         BNE      L120              ..CORE. -NO.
         LB,R6    JB:MAX,R1         -YES. CHANGE
         SLS,R6   1                 .TO PAGES
         STB,R6   JB:MAX,R1         NO. SO STORE.
         B        L120
* COME HERE IF NO RESOURCE SPECIFIED IN :USERS RECORD.
L330     EQU      %                 -YES.
         LB,SR1   JB:MAX,R1         IS MAXIMUM A SYSTEM
         CB,SR1   Y8                .DEFAULT OR USER SPEC'D.
         BAZ      L350              .USER SPEC'D.
         AND,SR1  X7F               SET FLAG TO INDICATE
L340     EQU      %
         STB,SR1  JB:MAX,R1         .USER SPECIFIED.
         B        L300
L350     EQU      %
         CB,SR1   JB:CUR,R1         IS USER SPEC'D MAX
         BLE      L300              .GRTR THAN SYSTEM MAX.
L360     EQU      %
         STW,R6   NRESERR           SAVE NAME OF RESOURCE FOR ERROR
*                                   FLAGGING WHEN SCANNING LIMIT CC.
         LI,R7    0                 CLEAR
L365     EQU      %
         STB,R7   JB:CUR,R1         REMAINING ENTRIES.
         LB,SR2   JB:MAX,R1         RESET DEFAULT BITS.
         AND,SR2  X7F
         LH,R6    SH:RNM,R1         GET RESOURCE NAME
         AND,R6   XFFFF
         CI,R6    X'C3D6'           IF RESOURCE IS CORE
         BNE      %+2
         SLS,SR2  1                 CONVERT TO PAGES
         STB,SR2  JB:MAX,R1
         BDR,R1   L365
         STB,R1   JB:MAX            SET CORE-CONVERTED-PAGES FLAG (=0)
         LI,SR2   LMXCDCD           LIMIT VALUE ERROR.
         B        VIOLATE           ABORT AFTER A/M WRITE
L370     EQU      %
         CI,R6    X'C3D6'           IF RESOURCE IS CORE
         BNE      L375
         SLS,SR1  1                 CONVERT TO PAGES
L375     EQU      %
         CB,SR1   RECORD+LR:UBMR,R2 COMPARE USER SPEC'D LIMIT
         BLE      L300              WITH AUTHORIZED LIMIT
         B        L360
         PAGE
* THE SETLDCF ROUTINE AUTHORIZES ACCESS TO LOGICAL DEVICE PERIPHERALS
* BY SETTING PERTINENT BITS IN JIT (JH:LDCF) FOR THOSE PERIPHERALS
* SPECIFIED IN THE :USERS FILE.
*        ENTER    BAL,SR4  SETLDCF
*        INPUT    R7=0 - AUTHORIZE DEVICES FOR BATCH.
*                 R7=1 - AUTHORIZE DEVICES FOR ON-LINE.
*                 R7=2 - AUTHORIZE DEVICES FOR GHOST.
*                 R4= - ADDRESS OF :UNMP TABLE IN :USERS FILE.
*                 R5= - ADDRESS OF :UPFLGS TABLE IN :USERS FILE.
*                 REG.USED R1,R2,R3,R6
*
SETLDCF  RES      0
         LI,R1    SV:FTYM           GET LOGICAL DEVICE LIMIT TABLE SIZE
         STB,R7   SR4               SAVE FLAG TEMPORARILY
SETLDCF2 LH,R2    SH:SYMT,R1        GET PERIPHERAL DEVICE NAME
         LI,R3    15
SETLDCF4 CH,R2    *R4,R3            WAS DEVICE NAME IN :USERS FILE
         BE       SETLDCF6          YES, SET FLAG
         BDR,R3   SETLDCF4
         B        SETLDCF8          NO, GET NEXT DEVICE NAME
*
SETLDCF6 LB,R6    *R5,R3            GET PERIPHERAL FLAF FROM :USERS
         AI,R7    8
         SLS,R6   0,R7              SHIFT SPEC. FLAG(BATCH,O/L,GHOST) TO
*                                   BIT 16
         LCW,R3   R1                SHIFT MASK FOR PERIPHERAL FLAG
         LI,R7    X'8000'
         SLS,R7   0,R3
         SLS,R6   0,R3              SHIFT PERIPHERAL FLAG
*
         LI,R2    JH:LDCF           GET LOGICAL DEVICE CONTROL FLAGS
         LH,R3    0,R2
         STS,R6   R3
         STH,R3   0,R2
         LB,R7    SR4               RESTORE FLAG
SETLDCF8 BDR,R1   SETLDCF2          GET NEXT DEVICE NAME
         B        *SR4
* THE SLSRCH ROUTINE SEARCHES THE SL:NAME TABLE FOR A SPECIFIED
* SERVICE LIMIT.
*        ENTER    BAL,SR1  SLSRCH
*        INPUT    R3 - SERVICE LIMIT NAME TO SEARCH FOR
*        OUTPUT   R1 - INDEX OF SERVICE LIMIT NAME
*        REGS. USED R1
SLSRCH   EQU      %
         LI,R1    SV:LIM            PRESET SCAN COUNTER
SLSRCH5  EQU      %
         CW,R3    SL:NAME,R1        DOES USER LIMIT NAME MATCH
         BE       *SR1              YES, RETURN
         BDR,R1   SLSRCH5           NO, GET NEXT
         B        *SR1
         PAGE
*DRIVE TABLES FOR LIMIT DEFAULT STORING.
*THE POSITION OF ENTRY WITHIN THE TABLE IS KEYED DIR. TO TABLE SL:NAME.
LIM      COM,2,6,24 CF(2),AF(1),AF(2)
LIMSTORE EQU      %
         STS,R4   *R7,R3
         STB,R4   *R7,R3
         STH,R4   *R7,R3
         BAL,SR1  0,R3
LIMINFO  RES      1
         LIM,SPEC 0,TIMST           TIME
         LIM,WORD 17,MPPO           LO
         LIM,WORD 17,MPO            PO
         LIM,WORD 17,MDPO           DO
         LIM,WORD 17,MUPO           UO
LIMINFOA EQU      %-LIMINFO
         LIM,SPEC 0,PSTST           PSTORE
         LIM,SPEC 0,TSTST           TSTORE
         LIM,BYTE 0,JB:NFPOOL-BA(J:JIT) FPOOL
         LIM,SPEC 0,TSTDI           TDISK
         LIM,SPEC 0,PDIST           PDISK
WORD     EQU      0
BYTE     EQU      1
SPEC     EQU      3
PSTST    EQU      %
         STW,R4   PRDCRM,R7         PERM RAD SPACE
         SW,R4    RECORD+LR:ACRAD   CALC. PROPER MAX(USERS-ACCU=MAX)
         BGEZ     %+2
         LI,R4    0
         STW,R4   J:TITLE,R1        STORE IN J:TITLE FOR USE BY LIMR
         B        *SR1
TSTST    EQU      %
         STW,R4   TMDCRM,R7         TEMP DISC SPACE
         STW,R4   TMPDCPK,R7        PEAK TEMP RAD SPACE USED
         B        *SR1
TSTDI    EQU      %
         STW,R4   TMDPRM,R7
         STW,R4   TMPDPPK,R7        PEAK TEMP PACK SPACE USED
         B        *SR1
PDIST    EQU      %
         STW,R4   PRDPRM,R7         PERM DISK SPACE
         SW,R4    RECORD+LR:ACDIS   CALC. PROPER MAX(USERS-ACCU=MAX)
         BGEZ     %+2
         LI,R4    0
         STW,R4   J:TITLE,R1        STORE IN J:TITLE FOR USE BY LIMR
         B        *SR1
*SYSTEM DEFAULT FOR TIME PROVIDED BY SSS IN J:TITLE+19.
TIMST    EQU      %
         LW,R5    MRT,R7            WAS A LIMIT VALUE STORED BY RBBAT
         BNEZ     TIMST5            YES
         LW,R5    ATITLE+19,R7      NO, HENCE STORE DEFAULT FOR TIME
         MI,5     30000             CONVERT
         STW,R5   MRT,R7
TIMST5   EQU      %
         B        *SR1
        END

