;;; libface.c
;
;   DESCRIPTION:
;   ===========
;
;	This is the skeleton for an AmigaREXX support library.
;	This version is written for Aztec C. It is based on the example
;	library by Jim Mackraz who got some stuff from Neil Katin, and 
;	rxexample.asm by Bill Hawes.
;	All changes and additions by me.
;
;   AUTHOR/DATE:  W.G.J. Langeveld, November 1987.
;   ============
;
;;;

	include	'exec/types.i'

setup	macro
	movem.l	d2/d3/d4-d7/a2-a6,-(sp)
	jsr	_geta4			;set up a4 for small model
	endm

push	macro
	move.l	\1,-(sp)
	endm

fix	macro
	ifc	'\1',''
		mexit
	endc
	ifle	\1-8
		addq.l	#\1,sp
	endc
	ifgt	\1-8
		lea	\1(sp),sp
	endc
	endm

restore	macro
	fix	\1
	movem.l	(sp)+,d2/d3/d4-d7/a2-a6	
	rts
	endm

	dseg

	public	_libfunctab
_libfunctab:
	dc.l	RXMLopen
	dc.l	RXMLclose
	dc.l	RXMLexpunge
	dc.l	$0000
        dc.l    RMXLdispatch
	dc.l	$ffffffff

	cseg

	;--- library functions
	public	_RXMLOpen
	public	_RXMLClose
	public	_RXMLExpunge
        public  _Dispatch

	public	_geta4

RXMLopen:
	setup
	push a6
	jsr	_RXMLOpen
	restore	4

RXMLclose:
	setup
	push a6
	jsr	_RXMLClose
	restore 4

RXMLexpunge:
	setup
	push a6
	jsr	_RXMLExpunge
	restore 4

RMXLdispatch:
	setup

	subq.l   #4,sp			; Create temporary variable
	move.l   sp,-(sp)		; Push return pointer
	move.l   a0,-(sp)		; Push argument
	jsr      _Dispatch		; D0 = error code
	addq.l   #8,sp			; Restore stack
	movea.l  (sp)+,a0		; Result string

	restore

	end
