Skip to content
Snippets Groups Projects
Commit 7e9d6db4 authored by rtoy's avatar rtoy
Browse files

LOOKUP-HOST-ENTRY returns a second value now. If LOOKUP-HOST-ENTRY

succeeds, the second value is T.  Otherwise, it is the value of
h_errno.
parent a4742df8
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/internet.lisp,v 1.47 2006/02/06 20:00:03 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/internet.lisp,v 1.48 2006/02/08 18:52:19 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -199,6 +199,8 @@ struct in_addr { ...@@ -199,6 +199,8 @@ struct in_addr {
(len int) (len int)
(type int)) (type int))
(def-alien-variable "h_errno" c-call:int)
(defun lookup-host-entry (host) (defun lookup-host-entry (host)
"Return a host-entry for the given host. The host may be an address "Return a host-entry for the given host. The host may be an address
string or an IP address in host order." string or an IP address in host order."
...@@ -213,35 +215,38 @@ struct in_addr { ...@@ -213,35 +215,38 @@ struct in_addr {
(gethostbyname host)) (gethostbyname host))
((unsigned-byte 32) ((unsigned-byte 32)
(gethostbyaddr (htonl host) 4 af-inet))))) (gethostbyaddr (htonl host) 4 af-inet)))))
(unless (zerop (sap-int (alien-sap hostent))) (if (zerop (sap-int (alien-sap hostent)))
(make-host-entry (values nil h-errno)
:name (slot hostent 'name) (values
:aliases (make-host-entry
(collect ((results)) :name (slot hostent 'name)
(iterate repeat ((index 0)) :aliases
(declare (type kernel:index index)) (collect ((results))
(cond ((or (zerop (sap-int (alien-sap (slot hostent 'aliases)))) (iterate repeat ((index 0))
(zerop (deref (cast (slot hostent 'aliases) (declare (type kernel:index index))
(* (unsigned #-alpha 32 (cond ((or (zerop (sap-int (alien-sap (slot hostent 'aliases))))
#+alpha 64))) (zerop (deref (cast (slot hostent 'aliases)
index))) (* (unsigned #-alpha 32
(results)) #+alpha 64)))
(t index)))
(results (deref (slot hostent 'aliases) index)) (results))
(repeat (1+ index)))))) (t
:addr-type (slot hostent 'addrtype) (results (deref (slot hostent 'aliases) index))
:addr-list (repeat (1+ index))))))
(collect ((results)) :addr-type (slot hostent 'addrtype)
(iterate repeat ((index 0)) :addr-list
(declare (type kernel:index index)) (collect ((results))
(cond ((zerop (deref (cast (slot hostent 'addr-list) (iterate repeat ((index 0))
(* (unsigned #-alpha 32 #+alpha 64))) (declare (type kernel:index index))
index)) (cond ((zerop (deref (cast (slot hostent 'addr-list)
(results)) (* (unsigned #-alpha 32 #+alpha 64)))
(t index))
(results (results))
(ntohl (deref (deref (slot hostent 'addr-list) index)))) (t
(repeat (1+ index))))))))))) (results
(ntohl (deref (deref (slot hostent 'addr-list) index))))
(repeat (1+ index)))))))
t)))))
(defun ip-string (addr) (defun ip-string (addr)
(format nil "~D.~D.~D.~D" (format nil "~D.~D.~D.~D"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment