home *** CD-ROM | disk | FTP | other *** search
- ; Clip input lines on specified locations and write result to standard output.
-
- INCLUDE "/include/init.i"
-
- ; OPT D+
-
- ; Variable storage
-
- STRUCT ArgArray,(3+1)*4
- SIZE
-
- ; Regs
-
- ErrorStrPtr EQUR A4
-
- ; Startup
-
- STACK 4000
- INIT
-
- ; Let ARP interpret the commandline
-
- MOVE.L ComLineBase(GP),A0
- MOVE.L ComLineSize(GP),D0
- LEA HelpMsg(PC),A1
- LEA ArgArray(GP),A2
- LEA Template(PC),A3
- MOVE.L A1,(A2)
- CALL GADS
- MOVE.L (A2),ErrorStrPtr
- TST.L D0
- BEQ ErrorExit
- BMI ErrorExit
-
- ; Fail if no list specifier present
-
- LEA NoListSpec(PC),ErrorStrPtr
- TST.L ArgArray+1*4(GP)
- BNE.S ListSpecified
- TST.L ArgArray+2*4(GP)
- BEQ.S ErrorExit
- ListSpecified:
-
- ; Cache A6, load execbase, forbid and presume success.
-
- MOVE.L A6,-(SP)
- MOVE.L $4.W,A6
- CALL Forbid
- MOVE.W #5,ReturnCode(GP)
-
- ; Search the task list
-
- TST.L ArgArray+1*4(GP)
- BEQ.S NotTheTaskList
- MOVE.L ArgArray(GP),A1
- CALL FindTask
- TST.L D0
- BNE.S NameFound
- NotTheTaskList:
-
- ; Search the port list
-
- TST.L ArgArray+2*4(GP)
- BEQ.S NotThePortList
- MOVE.L ArgArray(GP),A1
- CALL FindPort
- TST.L D0
- BNE.S NameFound
- NotThePortList
-
- ; Clear returncode if name not in any list. Permit and pop ARP base.
-
- CLR.W ReturnCode(GP)
- NameFound:
- CALL Permit
- MOVE.L (SP)+,A6
-
- ; Done, cleanup
-
- Exit:
- SUB.L ErrorStrPtr,ErrorStrPtr
- ErrorExit:
-
- ; Display error string, if any, and exit
-
- MOVE.L ErrorStrPtr,D0
- BEQ.S NoErrorMsg
- MOVE.L D0,A1
- CALL Puts
- NoErrorMsg:
- RTS
-
- ; The string section
-
- Template:
- DC.B 'Name/a,Task/s,Port/s',0
- HelpMsg:
- DC.B 'CheckList - Check system list for name. RC=5 if found.',10
- DC.B 'Usage: CheckList "namestring" [Task] [Port]',0
- NoListSpec:
- DC.B 'Need list specifier!',0
- CNOP 0,2
-
- END
-