         SYSTEM   BPM
         SYSTEM   SIG7FDP
         PCC      0
         CSECT    1
*
*M*      ONLIST   LIST :LOGD FILE OF ACTIVE ONLINE USERS
*
*P*      NAME:    ONLIST
*P*      PURPOSE: PROCESS THE :LOGD FILE, THE RECORD OF ONLINE USERS
*P*
*P*      DESCRIPTION:
*P*               THE :LOGD FILE IN :SYS CONTAINS A RECORD, KEYED BY
*P*               SYSID, FOR EACH ONLINE USER. THIS RECORD CONTAINS THE
*P*               USER'S NAME AND ACCOUNT, COC LINE NUMBER, AND TIME AND
*P*               DATE THE USER LOGGED ON, AND A FLAG INDICATING THE USER
*P*               IS CURRENTLY ON THE SYSTEM; THIS RECORD IS WRITTEN BY
*P*               LOGON DURING THE LOGON PROCESS. WHEN THE USER IS LOGGED
*P*               OFF, THE RECORD IS UPDATED TO REMOVE THE LOGGED ON FLAG,
*P*               AND THE TIME THE USER LOGGED OFF IS INSERTED, REPLACING
*P*               THE TIME THE USER LOGGED ON. RECOVER2, IN THE RECOVERY
*P*               PROCESS, WILL RE-WRITE THE RECORD FOR EACH
*P*               ON-LINE USER IT RUNS DOWN, CLEARING THE LOGGED ON FLAG,
*P*               AND PLACING THE NOTATION '**RECOVERY**' IN PLACE OF THE
*P*               TIME STAMP.
*P*               THE PRINCIPLE USE OF THE :LOGD FILE IS BY THE
*P*               'WHERE' COMMAND IN TEL, USED TO LOCATE A PARTICULAR
*P*               USER ON THE SYSTEM, BY SEARCHING THE :LOGD FILE
*P*               FOR A NAME AND ACCOUNT, AND THE LOGGED ON FLAG SET.
*P*               THIS ENABLES PARTICULAR USERS TO BE LOCATED ON THE
*P*               SYSTEM IN COORDINATION WITH THE TERMINAL COUPLING FEATURE.
*P*
*P*               X'C0' PRIVELIGE IS USUALLY INDICATED FOR USE OF THE
*P*               PROGRAM, AS THE FILE IS CREATED READ,NONE AND PASSWORDED.
*P*
*P*               WHEN RUN ONLINE, THE USERS CURRENTLY MARKED AS LOGGED ON
*P*               ARE LISTED THRU THE M:LO DCB. WHEN RUN AS A GHOST,
*P*               ALL RECORDS ARE LISTED, AND WHEN RUN IN BATCH, ALL
*P*               ALL RECORDS ARE LISTED, AND THOSE DENOTING LOGGED OFF
*P*               USERS (WRITTEN DURING LOGOFF OR RECOVERY) ARE DELETED.
  TITLE  'O N L I S T  -  : L O G D   F I L E   P R O C E S S I N G'
*
*        REFS
*
         REF      J:JIT             TO TELL BATCH, ONLINE, GHOST
         REF      M:LO              OUTPUT DCB
         REF      M:EI              FILE READING DCB
*
*        REGISTERS
*
R        EQU      2
RU1      EQU      3                 TEMPS
T        EQU      4
TU1      EQU      5
SR1      EQU      8
SR3      EQU      10                MONITOR ERROR CODE REGISTERS
         PAGE
*
*        ONLIST
*                 TRY TO OPEN THE FILE ':LOGD.:SYS' AND COMPLAIN
*                 IF WE CANT.
*
ONLIST   EQU      %
         M:OPEN   M:EI,(FILE,':LOGD',':SYS'),(SAVE),(INOUT,SHARE),;
                  (KEYED),(SEQUEN),(ERR,OOPS),(ABN,OOPS)
         B        OPNOK             B/IT OPENED OK.
*E*
*E*      ERROR: WE COULDN'T OPEN THE FILE FOR SOME REASON.
*E*               COMPLAIN AT THE USER, AND LEAVE.
*E*
WRTLO    M:WRITE  M:LO,(BUF,*R),(SIZE,*RU1),(BTD,0)
*
OOPSM    TEXT     'CANNOT ACCESS :LOGD FILE!'
OOPS     LI,R     OOPSM
         LI,RU1   25                WA AND LENGTH OF COMPLAINT.
ARGH     EXU      WRTLO             WRITE IT OUT
         LI,T     X'0020'
         CH,T     M:EI              IS THE DCB OPEN????
         BAZ      %+2               B/NOPE.
CLSEI    M:CLOSE  M:EI,(SAVE)
         CAL1,9   3                 ABORT
         PAGE
*
*        OPNOK
*                 WE GOT THE FILE OPEN (SHARED MODE, TO BE POLITE...),
*                 SO NOW WE PROCESS THE RECORDS IN IT.
*
OPNOK    LI,R     HEADER
         LI,RU1   44
         EXU      WRTLO             PUT OUT THE HEADER MESSAGE.
         LI,R     '*'
         LI,RU1   3                 FOR CHECKING LOGGED ON FLAG IN REC.
*
READ     M:READ   M:EI,(BUF,BUF),(SIZE,44),(WAIT),(ERR,GUK),(ABN,GUK)
         LC       J:JIT             WE ONLINE, GHOST OR BATCH????
         BCR,8    READ2             B/WELL, NOT ONLINE...
         CB,R     BUF,RU1           IF ONLINE, IS THE RECORD FLAGGED???
         BNE      READ              B/NOPE, READ ANOTHER.
         B        READ3             IF LOGGED ON, GO PRINT RECORD.
*
READ2    BCS,4    READ3             B/IF GHOST.
         CB,R     BUF,RU1           IF BATCH, IS THE LOGGED ON FLAG SET??
         BE       READ3             B/YES, LEAVE RECORD ALONE.
         M:DELREC M:EI,(KEY,*M:EI+10) IF NOT, DELETE THE RECORD.
*
*        PRINT THE RECORD.
*
READ3    M:WRITE  M:LO,(BUF,BUF),(SIZE,44)
         B        READ              AND GO READ ANOTHER RECORD FROM FILE.
         PAGE
*
*        GUK
*                 ERROR OR ABNORMAL ON THE READ. IF 06 ERROR, EOF, EXIT
*                 AFTER CLOSING. ELSE COMPLAIN, AND ABORT.
*
ONO      TEXTC    'ERROR READING FILE!'
GUK      LB,R     SR3
         CI,R     6                 IS THIS END OF FILE???
         BNE      GUK1              B/NO, END OF WORLD....
         EXU      CLSEI             CLOSE THE FILE.
         CAL1,9   1                 AND EXIT.
GUK1     LI,R     ONO
         LI,RU1   19
         B        ARGH              GO COMPLAIN AND ABORT.
*
*        THE HEADER.
*
HEADER   TEXT     'LN  ACCOUNT NAME            TIME AND',;
                  ' DATE ON'
         CSECT    0
BUF      RES      12                THE RECORD BUFFER
         END      ONLIST            THE END.

