; ; GRDP ; ; Copyright(c) LADsoft ; ; David Lindauer, gclind01@starbase.spd.louisville.edu ; ; ; LOGGING.ASM ; ; Function: log the session to a file ; ;MASM MODE .MODEL SMALL .386 include prints.ase include input.ase include mtrap.ase include breaks.ase PUBLIC logging,logtofile,CloseLogFile,LoggingStat .data logname db 80 DUP (?) handle dw 0 pos dw 0 buffer db 128 DUP (0) .CODE ; ; show status of logger ; LoggingStat PROC test [handle],-1 jz nolog Msg <13,10,"Log file: "> mov bx,offset dgroup:logname call DgroupMessage ret nolog: Msg <13,10,"Logging disabled"> ret Loggingstat ENDP ; ; log command ; logging PROC call CloseLogFile ; close old file cmp byte ptr [si],'a' ; check for append pushf jnz noappend inc si noappend: Call WadeSpace ; Wade till address jz nofile mov [pos],0 mov di,offset dgroup : logname ; get name lnlp: lodsb cmp al,13 jz lnlpend stosb jmp lnlp lnlpend: sub al,al ; open log file stosb popf mov al,2 jnz noexist mov al,2 ; try to open for append mov ah,3dh mov dx,offset dgroup:logname int 21h jc noexist ; doesn't exist, creeate it mov [handle],ax ; position to end mov bx,ax mov ax,4202h sub cx,cx sub dx,dx int 21h jnc xit call closeit jmp noopen noexist: cmp al,2 ; try to create file jnz noopen mov ah,3ch mov dx,offset dgroup :logname sub cx,cx int 21h jc noopen mov [handle],ax xit: sub sp,2 nofile: add sp,2 clc ret noopen: Msg <13,10,"Can't open log file for write"> clc ret logging ENDP ; ; close log file ; closeLogfile PROC call WriteBuffer mov bx,[handle] or bx,bx jz noclose closeit: mov [handle],0 mov ah,3eh int 21h noclose: ret closeLogfile ENDP ; ; write a buffer out to log file ; WriteBuffer PROC mov bx,[handle] or bx,bx jz nowrite mov cx,[pos] mov [pos],0 mov dx,offset dgroup:buffer mov ah,40h int 21h jnc writeok call closeit Msg <13,10,"Error writing log file"> writeok: nowrite: ret WriteBuffer ENDP ; ; log a char to the file ; LogToFile PROC test [handle],-1 jz nologtofile pusha cmp al,1ah jz logfix cmp al,0ch jnz logok logfix: mov al,'.' logok: inc [pos] mov di,[pos] mov [di + buffer -1],al cmp di,128 jc noflush call WriteBuffer noflush: popa nologtofile: ret LogToFile ENDP end