;----------------------------------------------------------------------------
;
; $Source: /u3/theom/cvs-pub/sshproxy/tcp_wrap/_hostbyadd.s,v $
; $Date: 2001/07/27 17:14:13 $
; $Revision: 1.1 $
; $State: Exp $
; $Author: uid1 $
;
;----------------------------------------------------------------------------

; Borrowed from UnixLib

; <rant>
; NetLib's gethostbyaddr is broken - it only searches InetDBase:hosts
; and doesn't try the DNS.  This makes it rather useless for our purposes
; Hence we call the Internet_GetHostByAddr SWI using the old interface - this
; SWI also lives as Resolver_GetHost, which does multitasking gethostbyname
; lookups.  Thus gethostbyaddr isn't multitasking.

; ANT in their infinite wisdom have decided to give both SWIs the same
; number.  This means the SWI will work out what we actually intended to
; call from the parameters.  Yuk.  Stewart Brodie's DNSResolver will do a
; far better job of this (including multitasking gethostbyaddr lookups),
; but what do the Acorn and ANT stacks provide...?
; </rant>

;	GET	UnixHdr:unixlib.s.asm_dec
r0	RN	0
r1	RN	1
r2	RN	2
r3	RN	3
r4	RN	4
r5	RN	5
r6	RN	6
r7	RN	7
r8	RN	8
r9	RN	9
r10	RN	10
r11	RN	11
r12	RN	12
r13	RN	13
r14	RN	14
r15	RN	15

a1	RN	0	; Argument 1
a2	RN	1	; Argument 2
a3	RN	2	; Argument 3
a4	RN	3	; Argument 4
v1	RN	4	; Variable 1
v2	RN	5	; Variable 2
v3	RN	6	; Variable 3
v4	RN	7	; Variable 4
v5	RN	8	; Variable 5
v6	RN	9	; Variable 6

sl	RN	10	; Stack limit / stack chunk handle
fp	RN	11	; frame pointer
ip	RN	12	; Temporary workspace, used in procedure entry
sp	RN	13	; Stack pointer
lr	RN	14	; Link register
pc	RN	15	; Program counter


Internet_GetHostByName		EQU	&46000
Internet_GetHostByAddr		EQU	&46001
XInternet_GetHostByName		EQU	&66000
XInternet_GetHostByAddr		EQU	&66001


	AREA	|C$$code|,CODE,READONLY

	EXPORT	|_gethostbyaddr|
|_gethostbyaddr|
	STMFD	sp!, {lr}
	MOV	r3, r2
	MOV	r2, r1
	MOV	r1, r0
	MOV	r0, #0
	SWI	XInternet_GetHostByAddr
	MOVVC	r0, r1
	MOVVS	r0, #0
	LDMFD	sp!, {pc}

	END
