portability: Supply system-specific wossname for CLisp and ECL.
[zone] / net.lisp
index 35e4340..64c796d 100644 (file)
--- a/net.lisp
+++ b/net.lisp
 ;;;--------------------------------------------------------------------------
 ;;; Name resolution.
 
-#+cmu
 (defun resolve-hostname (name)
   "Resolve a hostname to an IP address using the DNS, or return nil."
-  (let ((he (ext:lookup-host-entry name)))
-    (and he
-        (ext:host-entry-addr he))))
+  #+cmu (let ((he (ext:lookup-host-entry name)))
+         (and he (ext:host-entry-addr he)))
+  #+clisp (let ((he (ext:resolve-host-ipaddr name)))
+           (and he (string-ipaddr (car (ext:hostent-addr-list he)))))
+  #+ecl (nth-value 2 (ext:lookup-host-entry name))
+  #-(or cmu clisp ecl) nil)
 
-#+cmu
 (defun canonify-hostname (name)
   "Resolve a hostname to canonical form using the DNS, or return nil."
-  (let ((he (ext:lookup-host-entry name)))
-    (and he
-        (ext:host-entry-name he))))
+  #+cmu (let ((he (ext:lookup-host-entry name)))
+         (and he (ext:host-entry-name he)))
+  #+clisp (let ((he (ext:resolve-host-ipaddr name)))
+           (and he (ext:hostent-name he)))
+  #+ecl (nth-value 0 (ext:lookup-host-entry name))
+  #-(or cmu clisp ecl) name)
 
 ;;;--------------------------------------------------------------------------
 ;;; Host names and specifiers.