	incdir "ram:include/"
	include exec_lib.i
	include dos_lib.i

_LVOFindSegment = -$30c

START
	clr.b	-1(a0,d0.l)		CR löschen
	movea.l	a0,a2			Adr. retten

	moveq	#0,d7			init. Return-Code

	lea	DOSName(pc),a1		DOS-Lib öffnen
	moveq	#36,d0			mind. Version 36
	CALLEXEC OpenLibrary
	tst.l	d0
	beq.s	ende1
	movea.l	d0,a5			a5: DOSBase

	moveq	#'?',d0
	cmp.b	(a2),d0
	beq.s	usage

	CALLLIB Forbid			Forbid muß sein

	move.l	a2,d1
	moveq	#0,d2
	moveq	#0,d3			bei "eigenen" Residents gucken
	movea.l	a5,a6
	CALLLIB FindSegment
	tst.l	d0
	bne.s	.found

	move.l	a2,d1
	moveq	#0,d2
	moveq	#1,d3			interne Residents checken
	CALLLIB FindSegment
	tst.l	d0
	bne.s	.found
	moveq	#5,d7			WARN-Code setzen, da NICHT gefunden
.found

	CALLEXEC Permit
ende:
	movea.l	a5,a1			DOS-Lib schießen
	CALLLIB CloseLibrary
ende1:	move.l	d7,d0			Ende des Progs
	rts

usage:
	movea.l	a5,a6
	CALLLIB Output
	move.l	d0,d1
	lea	text(pc),a0
	move.l	a0,d2
	moveq	#textlen,d3
	CALLLIB Write
	bra.s	ende

;*** Daten ***

DOSName: dc.b "dos.library",0
	dc.b "$VER: IsResident 1.01 (27.5.92  © Thies Wellpott)",0
text:	dc.b "Usage: IsResident name",$a
	dc.b "Return code will be 5 (WARN) if name is not found",$a
textlen = *-text
	even

