chiark / gitweb /
portability: Supply system-specific wossname for CLisp and ECL.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 10 Dec 2006 15:11:28 +0000 (15:11 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 10 Dec 2006 15:11:43 +0000 (15:11 +0000)
This involves some unpleasant CFFI hacking for ECL.

net.lisp
zone.asd
zone.lisp

index d957f53d684a00fd3611f689c96695b89f5224bc..64c796dde7defe7bd15e5c96555b7ddaeb1ffad5 100644 (file)
--- a/net.lisp
+++ b/net.lisp
@@ -259,17 +259,20 @@ (defun ipnet-changeable-bytes (mask)
 (defun resolve-hostname (name)
   "Resolve a hostname to an IP address using the DNS, or return nil."
   #+cmu (let ((he (ext:lookup-host-entry name)))
-         (and he
-              (ext:host-entry-addr he)))
-  #-cmu nil
-)
+         (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)
 
 (defun canonify-hostname (name)
   "Resolve a hostname to canonical form using the DNS, or return nil."
   #+cmu (let ((he (ext:lookup-host-entry name)))
-         (and he
-              (ext:host-entry-name he)))
-  #-cmu nil)
+         (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.
index b49cc79523ec069aa54fc9ef51d5e786ceee0996..0396a19c28ecaa531731b8d6c810df5d8205657a 100644 (file)
--- a/zone.asd
+++ b/zone.asd
@@ -4,7 +4,7 @@
   :description "Generation of DNS zone files"
   :version "1.0.0"
   :author "Mark Wooding <mdw@distorted.org.uk>"
-  :depends-on ("mdw")
+  :depends-on ("mdw" #+ecl "cffi")
   :components ((:file "net")
               (:file "zone")
               (:file "frontend"))
index 64488c2a0d11f3875462fc00fa505f5c8753b661..37e7499ac3f1c9e0ce6cde9165b343998d19167c 100644 (file)
--- a/zone.lisp
+++ b/zone.lisp
@@ -144,9 +144,18 @@ (defstruct (zone (:predicate zonep))
 ;;;--------------------------------------------------------------------------
 ;;; Zone defaults.  It is intended that scripts override these.
 
+#+ecl
+(cffi:defcfun gethostname :int
+  (name :pointer)
+  (len :uint))
+
 (defvar *default-zone-source*
   (let ((hn #+cmu (unix:unix-gethostname)
-           #+clisp (unix:get-host-name)))
+           #+clisp (unix:get-host-name)
+           #+ecl (cffi:with-foreign-pointer-as-string (buffer 256 len)
+                   (let ((rc (gethostname buffer len)))
+                     (unless (zerop rc)
+                       (error "gethostname(2) failed (rc = ~A)." rc))))))
     (and hn (concatenate 'string (canonify-hostname hn) ".")))
   "The default zone source: the current host's name.")