home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
modcomp
/
parser.
< prev
next >
Wrap
Text File
|
1987-01-25
|
9KB
|
297 lines
SUBROUTINE PARSER
C
C ****************************************************************
C
C KERMIT for the MODCOMP MAXIV operating system
C
C Compliments of:
C
C SETPOINT, Inc.
C 10245 Brecksville Rd.
C Brecksville, Ohio 44141
C
C
C KERMIT is a copyrighted protocol of Columbia Univ. The authors
C of this version hereby grant permission to copy this software
C provided that it is not used for an explicitly commercial
C purpose and that proper credit be given. SETPOINT, Inc. makes
C no warranty whatsoever regarding the accuracy of this package
C and will assume no liability resulting from it's use.
C
C ****************************************************************
C
C Abstract: Main Command Parser
C
C MODIFICATION HISTORY
C
C BY DATE REASON PROGRAMS AFFECTED
C
C ****************************************************************
C
C Author: Rick Burke Version: A.0 Date: Aug-86
C
C Calling Parameters: None
C
C ****************************************************************
C
C Messages generated by this module : None
C
C ****************************************************************
C
C Subroutines called directly : IAND, ISHFT, READ4, SCONNE,
C SHELP, SKIPBL, SQUIT, SRECEI,
C SSEND, SSET, SSTATU, UPPER
C
C ****************************************************************
C
C Files referenced : None
C
C ****************************************************************
C
C Local variable definitions :
C
C ACOUNT - Index variable into ALIN
C CCOUNT - Index variable into CLIN
C CMDLEN - Max length of each command in CMDTBL
C FOUND - Number of matches - 1 found in CMDTBL
C I - Index variable
C IEND - Number of chars in CLIN to search for the
C the end of the user-entered word
C J - Index variable
C NDX - Index variable
C NUMCMD - Number of commands in CMDTBL
C TV1 - Temporary variable
C WCHCMD - Index into CMDTBL to command requested by the
C the user
C ALIN(132) - Command line entered by user
C CLIN(132) - Upper case command line entered by user
C CMDTBL(8,8) - Table of commands allowed by Kermit
C
C ****************************************************************
C
C Commons referenced : KER, KERPAR, and UFTTBL local commons
C
C ****************************************************************
C
C (*$END.DOCUMENT*)
C
C ****************************************************************
C * *
C * D I M E N S I O N S T A T E M E N T S *
C * *
C ****************************************************************
C
IMPLICIT INTEGER (A-Z)
INTEGER*2 CMDTBL(8,8)
INTEGER*2 ALIN(132), CLIN(132)
C
C ****************************************************************
C * *
C * T Y P E S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C * *
C * C O M M O N S T A T E M E N T S *
C * *
C ****************************************************************
C
INCLUDE USL/KERCOM
INCLUDE USL/KERPMC
INCLUDE USL/UFTTBC
C
C ****************************************************************
C * *
C * E Q U I V A L E N C E S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C * *
C * D A T A S T A T E M E N T S *
C * *
C ****************************************************************
C
C-----> Implemented commands are:
C
C 1) CONNECT - hooks to a dummy routine provided
C 2) EXIT
C 3) HELP
C 4) QUIT
C 5) RECEIVE
C 6) SET
C 7) SEND
C 8) STATUS
C
DATA CMDTBL /67,79,78,78,69,67,84,10002,
> 69,88,73,84,10002,0,0,0,
> 72,69,76,80,10002,0,0,0,
> 81,85,73,84,10002,0,0,0,
> 82,69,67,69,73,86,69,10002,
> 83,69,84,10002,0,0,0,0,
> 83,69,78,68,10002,0,0,0,
> 83,84,65,84,85,83,10002,0/
DATA NUMCMD /8/, CMDLEN /8/
C
C ****************************************************************
C
C Code starts here :
C
10 CONTINUE
WRITE (LOCALO,1000)
1000 FORMAT (' KERMIT MAXIV> ')
C
C-----> Read a line from the keyboard and convert it to
C-----> uppercase.
C
DO 11 I=1,32
ALIN(I) = 0
CLIN(I) = 0
11 CONTINUE
CALL READ4 (IUFT(1,2),CLIN,132,.TRUE.)
IF (IAND (IUFT(1,2),4Z0020) .NE. 0) CALL SQUIT
C
C-----> Unpack the line so the other character manipulation
C-----> routines will work.
C
ACOUNT = 1
CCOUNT = 1
12 CONTINUE
TV1 = ISHFT (CLIN(CCOUNT),-8)
IF (TV1 .EQ. 0) GO TO 13
ALIN(ACOUNT) = TV1
ACOUNT = ACOUNT + 1
TV1 = IAND (CLIN(CCOUNT),4Z00FF)
IF (TV1 .EQ. 0) GO TO 13
ALIN(ACOUNT) = TV1
ACOUNT = ACOUNT + 1
CCOUNT = CCOUNT + 1
GO TO 12
13 CONTINUE
IF (ALIN(ACOUNT-1) .EQ. BLANK) ACOUNT = ACOUNT - 1
ALIN(ACOUNT) = LF
ALIN(ACOUNT+1) = EOS
C
CALL UPPER (ALIN,CLIN)
C
C-----> Extract the first word in the command line and remove
C-----> any leading blanks.
C
TV1 = 1
CALL SKIPBL (CLIN,TV1)
DO 20 I=1,132
ALIN(I) = 0
20 CONTINUE
IEND = 81 - TV1
DO 30 NDX=1,IEND
ALIN(NDX) = CLIN(NDX+TV1-1)
IF (ALIN(NDX) .EQ. LF .OR.
> ALIN(NDX) .EQ. BLANK ) GO TO 40
30 CONTINUE
NDX = IEND + 1
40 CONTINUE
ALIN(NDX) = LF
ALIN(NDX+1) = EOS
C
C-----> Loop to compare word from command line to all commands.
C
FOUND = -1
WCHCMD = 0
DO 70 J=1,NUMCMD
DO 50 I=1,CMDLEN
C
C-----> Check for end of word. If end of word then we have a match.
C
IF (ALIN(I) .EQ. LF) GO TO 60
C
C-----> Check for end of key word. If end of key word found then
C-----> we don't have a match.
C
IF (CMDTBL(I,J) .EQ. EOS) GO TO 70
C
C-----> Compare the characters.
C
IF (ALIN(I) .NE. CMDTBL(I,J)) GO TO 70
50 CONTINUE
GO TO 70
60 CONTINUE
C
C-----> Here user's command matches a keyword, so remember which
C-----> command was matched and bump the counter for number of
C-----> matches found and loop back to check the next command.
C
WCHCMD = J
FOUND = FOUND + 1
70 CONTINUE
C
C-----> Branch based on the number of matches found between the
C-----> user's command and the command table.
C
IF (FOUND) 200,100,300
100 CONTINUE
C
C-----> User's command matched only one keyword, so process it.
C
GOTO (110,120,130,120,150,160,170,180),WCHCMD
110 CONTINUE
C
C-----> CONNECT keyword.
C
CALL SCONNE
GO TO 10
120 CONTINUE
C
C-----> EXIT keyword.
C
CALL SQUIT
130 CONTINUE
C
C-----> HELP keyword.
C
CALL SHELP
GO TO 10
150 CONTINUE
C
C-----> RECEIVE keyword.
C
CALL SRECEI
GO TO 10
160 CONTINUE
C
C-----> SET keyword.
C
CALL SSET (CLIN(TV1+NDX-1))
GO TO 10
170 CONTINUE
C
C-----> SEND keyword.
C
CALL SSEND (CLIN(TV1+NDX-1))
GO TO 10
180 CONTINUE
C
C-----> STATUS keyword.
C
CALL SSTATU
GO TO 10
200 CONTINUE
C
C-----> User's command does not match any valid key word.
C
WRITE (LOCALO,1010)
1010 FORMAT (' UNRECOGNIZED COMMAND - TYPE "HELP"')
GO TO 10
300 CONTINUE
C
C-----> User's command word matches more than 1 valid keyword.
C
WRITE (LOCALO,1020)
1020 FORMAT (' AMBIGUOUS COMMAND - TYPE "HELP"')
GO TO 10
400 CONTINUE
RETURN
END