home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / TURBODSG / TLOGOFF.MAC < prev    next >
Text File  |  2000-06-30  |  4KB  |  232 lines

  1.     title    "logoff program for tShell"
  2. ;
  3. ;    (c) 1985 S. Kluger. All Rights Reserved.
  4. ;    history:
  5. ;    12/15/85    initially written. complete except mail check.
  6. ;
  7. .z80
  8. .request syslib
  9. ;
  10. cr    equ    0dh
  11. lf    equ    0ah
  12. cfunc    equ    5
  13. tfunc    equ    50h
  14. ;
  15.     dseg
  16. ;
  17.     include    TSHELL.DEF
  18. ;
  19. logfcb:    db    1,'TSHELL  LOG',0,0,0,0
  20.     ds    22
  21. actlog:
  22.     db    1ah
  23. actid:    ds    8            ; activity log user id
  24. actdt:    ds    4            ;   date/time
  25. actst:    ds    2            ;   station
  26. act01:    db    0            ;   on/off/bad flag (1/0/FF)
  27. actdu:    ds    2            ;   drive/user
  28. actbp:    ds    8            ;   bad password given
  29.     db    1ah,1ah,1ah,1ah,1ah,1ah    ; filler
  30. ;
  31. id:    db    '.tShell.'
  32. offset:    db    0
  33.     ds    80
  34. stack    equ    $
  35. ;
  36.     cseg
  37. ;
  38. start:    ld    sp,stack
  39.     ld    de,80h
  40.     ld    hl,id
  41.     ld    bc,8
  42.     ldir
  43.     ld    bc,41
  44.     ld    l,0
  45.     call    tfunc
  46.     ld    (offset),a        ; save offset
  47.     or    a
  48.     jp    z,fatal            ; fatal error if no USR FCN
  49.     ld    c,8
  50.     ld    de,abort
  51.     call    tfunc
  52.     ld    c,18
  53.     ld    de,0            ; clear all stacked command lines
  54.     call    tfunc
  55.     ld    de,LCLID
  56.     ld    c,26
  57.     call    cfunc            ; set dma
  58.     ld    bc,41
  59.     ld    l,0            ; get user data
  60.     call    getoff
  61.     call    tfunc
  62.     ld    bc,41
  63.     ld    de,0ffffh
  64.     ld    l,4            ; enable user 31 access
  65.     call    getoff
  66.     call    tfunc
  67.     ld    c,32
  68.     ld    e,0ffh            ; get user area
  69.     call    cfunc
  70.     push    af            ; save it for now
  71.     ld    c,32
  72.     ld    e,31
  73.     call    cfunc
  74.     ld    hl,LCLID        ; move userid
  75.     ld    de,actid
  76.     ld    bc,8
  77.     ldir
  78.     ld    c,10            ; get date/time
  79.     call    tfunc
  80.     ld    (actdt),hl
  81.     ld    (actdt+2),de
  82.     ld    c,12            ; get station
  83.     call    cfunc
  84.     ld    (actst),de
  85.     xor    a
  86.     ld    (act01),a        ; set logoff flag
  87.     ld    c,25
  88.     call    cfunc
  89.     ld    h,a            ; set drive
  90.     pop    af
  91.     ld    l,a            ; set user
  92.     ld    (actdu),hl
  93.     call    applog            ; write if log enabled
  94.     ld    bc,41            ; first log off tShell
  95.     ld    de,0ffffh
  96.     ld    l,2
  97.     call    getoff
  98.     call    tfunc
  99.     ld    c,14
  100.     ld    de,0ffffh
  101.     call    tfunc
  102.     ld    c,17
  103.     ld    e,0ffh
  104.     call    tfunc
  105.     call    print##
  106.     cr,lf,lf
  107.     '*** logged off ***',cr,lf,lf,0
  108.     rst    0
  109. ;
  110. ; append to activity log
  111. ;
  112. applog:    ld    de,logfcb        ; point to log
  113.     ld    c,35            ; filesize
  114.     call    cfunc
  115.     or    a
  116.     ret    nz            ; ignore file not found
  117.     ld    c,10
  118.     call    tfunc            ; get date/time
  119.     ld    (actdt),hl
  120.     ld    (actdt+2),de
  121.     ld    c,12
  122.     call    cfunc            ; get station
  123.     ld    (actst),de
  124.     ld    hl,(logfcb+33)
  125.     dec    hl
  126.     ld    (logfcb+33),hl        ; decrement file pointer
  127.     ld    de,logfcb
  128.     call    openf            ; open shared
  129.     ld    de,80h            ; set defdma
  130.     ld    c,26
  131.     call    cfunc
  132.     ld    de,logfcb
  133.     call    rdsec            ; read last sector
  134.     ld    hl,80h            ; hl=pointer to def dma
  135.     ld    de,20h            ; de=byte count
  136. ..ckel:    ld    a,(hl)            ; get byte
  137.     cp    0ffh            ; endmark?
  138.     jr    z,.fe..            ;   yes
  139.     add    hl,de
  140.     ld    a,l
  141.     or    a
  142.     jr    nz,..ckel        ; try next entry
  143.     ld    hl,(logfcb+33)
  144.     inc    hl
  145.     ld    (logfcb+33),hl
  146.     ld    hl,80h            ; set start of buffer
  147.     push    hl
  148. .zac.:    ld    (hl),0ffh        ; blank buffer
  149.     inc    l
  150.     jr    nz,.zac.
  151.     pop    hl
  152. .fe..:    ld    de,actlog
  153.     ex    de,hl
  154.     ld    bc,32            ; 32 bytes to be moved
  155.     ldir
  156.     ld    a,l            ; see if end of buffer
  157.     or    a
  158.     jr    z,.eob.            ; yes, skip
  159.     ld    (hl),0ffh        ;   else set endmark
  160. .eob.:    ld    de,logfcb
  161.     call    wrsec            ; write the sector
  162.     ld    de,logfcb
  163.     ld    c,16
  164.     jp    cfunc            ; close and exit
  165. ;
  166. ; open file with lock
  167. ;
  168. openf:    ld    hl,5            ; point to shared flag
  169.     add    hl,de
  170.     ld    a,80h
  171.     or    (hl)
  172.     ld    (hl),a            ; set shared flag
  173.     push    de
  174.     ld    c,15
  175.     call    cfunc
  176.     pop    de
  177.     ld    hl,32
  178.     add    hl,de
  179.     ld    (hl),0
  180.     or    a
  181.     ret    z            ; file is now open
  182.     jr    openf            ; else loop since we know file exists
  183. ;
  184. ; read a sector - enter with hl = sector, de = fcb
  185. ;
  186. rdsec:    call    loksec            ; lock sector
  187.     push    de
  188.     ld    c,33            ; read
  189.     call    cfunc
  190.     or    a            ; set error flag
  191.     jr    fresec            ; free sector
  192. ;
  193. ; write a sector - enter with hl = sector, de=fcb
  194. ;
  195. wrsec:    call    loksec            ; lock sector
  196.     push    de            ; save fcb
  197.     ld    c,34            ; write
  198.     call    cfunc
  199.     or    a            ; set error flag
  200. ;
  201. ; free current file sector
  202. ;
  203. fresec:    pop    de
  204.     push    af
  205.     ld    c,43
  206.     call    cfunc
  207.     pop    af
  208.     ret
  209. ;
  210. ; lock current file sector
  211. ;
  212. loksec:    push    de            ; save fcb pointer
  213.     ld    c,42            ; attempt lock
  214.     call    cfunc
  215.     pop    de
  216.     cp    8            ; locked already?
  217.     jr    z,loksec        ;   yes, loop
  218. abort:    ret
  219. ;
  220. getoff:    ld    a,(offset)
  221.     add    a,l
  222.     ld    l,a
  223.     ret
  224. ;
  225. fatal:    call    print##
  226.     cr,lf,lf,7
  227.     'ERROR: tShell not installed',cr,lf,lf,0
  228.     rst    0
  229. ;
  230.     end
  231.  
  232. d