;*************************** AMUS Program Label ******************************
; Filename: LOGMSG                                          Date: 12/19/91
; Category: UTIL         Hash Code: 442-047-075-662      Version: 1.0(100)
; Initials: GR/AM        Name: James A. Jarboe IV
; Company: Educational Video Network, Inc.         Telephone #: 4092955767
; Related Files: AMOS 2.2 SYSLIB
; Min. Op. Sys.: 1.3D                          Expertise Level: BEG
; Special: Must LNKLIT with AMOS 2.2 SYSLIB for $MSGLOG call
; Description: Allows user to submit a message to the System LOGGER.
; Can be used from the dot or .DO or .CMD files to report a user message to
; the System LOGGER.
;*****************************************************************************
;*; Updated on 19-Dec-91 at 4:06 AM by James A. Jarboe I V; edit time: 0:41:42
;***************************************************************************
;*                                                                         *
;*                              LOGMSG.M68                                 *
;*                                                                         *
;*                     Written By: James A. Jarboe IV                      *
;*                            1401 19th Street                             *
;*                          Huntsville, TX 77340                           *
;*                              409-295-5767                               *
;*                                                                         *
;*                               19-Dec-91                                 *
;*                                 GR/AM                                   *
;***************************************************************************
;
; Description: Allows user to submit a message to the System Logger from
;       AMOS command mode. Can be used from .DO and .CMD files or from
;       the dot to send messages to the System Logger. Date, time, JOB
;       Name, the program name and user message are output to the System
;       Logger.
;       Example:
;               LOGMSG Backup Started
;               ...do backup
;               LOGMSG Backup Completed
;
; Notes:
;       Must LNKLIT with AMOS 2.2 SYSLIB to get $MSGLOG call.
;       This program does NOT check to see if LOGGER is running so
;       no errors will be reported if LOGGER is not Active on your system.
;
; Edit History:
;
;[100] 19-Dec-91 Written by James A. Jarboe IV.
;


       ASMMSG  "                                      "
       ASMMSG  "+------------------------------------+"
       ASMMSG  "|                                    |"
       ASMMSG  "|             LOGMSG                 |"
       ASMMSG  "|                                    |"
       ASMMSG  "|      By: James A. Jarboe IV        |"
       ASMMSG  "|                                    |"
       ASMMSG  "| Must LNKLIT with AMOS's 2.2 SYSLIB |"
       ASMMSG  "|      to produce LOGMSG.LIT         |"
       ASMMSG  "|                                    |"
       ASMMSG  "+------------------------------------+"



       PAGE
;***************************************************************************
;                                                                          *
;                           S Y M B O L I C S                              *
;                                                                          *
;***************************************************************************
;
       SEARCH  SYS                     ; Amos Standard symbolic.
       SEARCH  SYSSYM                  ; Amos Standard symbolic.

       AUTOEXTERN                      ; Externals are used.

       PAGE
;***************************************************************************
;                                                                          *
;                      C U R R E N T   V E R S I O N                       *
;                                                                          *
;***************************************************************************
;
       VMAJOR  =       1.              ;
       VMINOR  =       0               ;
       VEDIT   =       100.            ; Current Release 19-Dec-91
       VWHO    =       0               ;


       PAGE
;***************************************************************************
;                                                                          *
;                      P R O G R A M   M A C R O S                         *
;                                                                          *
;***************************************************************************
;
;
DEFINE  PRTTAB  ROW, COL
       MOVW    #<ROW_8.+COL>, D1
       TCRT
       ENDM


       PAGE
;***************************************************************************
;                                                                          *
;              B U F F E R   S I Z E S   A N D   E Q U A T E S             *
;                                                                          *
;***************************************************************************
;
       LM.MAX  =       45.             ; Maximum size of message buffer.

       $LF     =       10.             ; Linefeed.
       $CR     =       13.             ; Carriage Return.
       $SPACE  =       32.             ; Space character.
       $DASH   =       45.             ; The "-" character.
       $SLASH  =       47.             ; The "/" character.

       PAGE
;***************************************************************************
;                                                                          *
;                  P R O G R A M   I M P U R E   A R E A                   *
;                                                                          *
;***************************************************************************
;

OFINI
OFDEF   LM.BUF, LM.MAX+1                ; Message buffer.
OFSIZ   LM.SIZ                          ; Size of impure area.


       PAGE
;***************************************************************************
;                                                                          *
;                 S T A R T   O F   P R O G R A M   C O D E                *
;                                                                          *
;***************************************************************************
;
;
LOGMSG:
       PHDR    -1,0,PH$REE!PH$REU
       GETIMP  LM.SIZ,A5               ; Allocate impure area.
       BYP                             ; Bypass junk.
       TRM                             ; Any characters?
       JEQ     HELPEM                  ; No..tellem how.
       CMPB    @A2, #$SLASH            ; Any switches?
       JEQ     HELPEM                  ; Yes..tellem how.

       LEA     A1, LM.BUF(A5)          ; Index buffer.
       MOVB    #$DASH, (A1)+           ; Set a dash.
       MOVB    #$SPACE, (A1)+          ; Set a space
       MOV     #2, D0                  ; Preset 2 characters used.
10$:    CMP     D0, #LM.MAX             ; End of buffer?
       BEQ     99$                     ; Yes..end of message.
       CMPB    @A2, #$CR               ; At CR?
       BEQ     99$                     ; Yes..end of message.
       CMPB    @A2, #$LF               ; At LF?
       BEQ     99$                     ; Yes..end of message.
       MOVB    (A2)+, (A1)+            ; Set command line to message buffer.
       INC     D0                      ; Bump count.
       BR      10$                     ; Get another.
99$:    CLRB    @A1                     ; Clear end of buffer.
       LEA     A1, LM.BUF(A5)          ; Re-index buffer.
       CLR     D3                      ; Clear user code.
       CALL    $MSGLOG                 ; Send message to LOGGER.
       BNE     ERRRPT                  ; Any errors?
       EXIT                            ; Back to AMOS.

; Report any MSGLOG error.
;
ERRRPT:
       MOV     #7, D1
       TTY
       CRLF                            ; Bump screen.
       TYPE    <%Error occurred in >
       CALL    PGMNAM                  ; Get current program name.
       TYPE    <.>
       CRLF                            ; Bump screen.
       EXIT                            ; To AMOS.

; Output program name to terminal in case user renames program to
; something else.
;
PGMNAM:
       JOBIDX                          ; Index job.
       LEA     A1, JOBPRG(A6)          ; Index program we are using.
       LEA     A2, LM.BUF(A5)          ; Index buffer.
       UNPACK                          ; Make ascii.
       UNPACK
10$:    CMPB    -(A2), #$SPACE          ; Is last character a space?
       BEQ     10$                     ; Yes..try again.
       INC     A2                      ; No..bump address.
       CLRB    @A2                     ; Set end of buffer.
       TTYL    LM.BUF(A5)              ; Output program name.
       RTN                             ; Return to caller.

; Display help to user.
;
HELPEM:
       CRLF                            ; Bump screen.
       PRTTAB  -1,11.                  ; Dim.
       TYPE    <%Usage: >
       PRTTAB  -1,12.                  ; Bright.
       CALL    PGMNAM                  ; Get program name.
       TYPECR  < Message>              ;
       CRLF
       TYPECR  <   Used to send a user message to the System LOGGER.>
       TYPECR  <   Very useful in CMD and DO files or from the dot.>
       CRLF
       PRTTAB  -1,11.                  ; Dim.
       TYPECR  <   Example:>           ;
       PRTTAB  -1,12.                  ; Bright.
       TYPE    <           >
       CALL    PGMNAM                  ; Get program name.
       TYPECR  < Backup Started>
       TYPE    <           >
       CALL    PGMNAM                  ; Get program name
       TYPECR  < Backup Finished>
       CRLF                            ; Bump screen.
       EXIT                            ; To AMOS.


       END