Commit 9fb448e0 authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Remove XEmacs support from dns.el

* lisp/net/dns.el (dns-read-string-name, dns-write, dns-read)
(dns-make-network-process, dns-query): Remove XEmacs support.
parent 6fbfd36b
......@@ -106,7 +106,7 @@ updated. Set this variable to t to disable the check.")
(defun dns-read-string-name (string buffer)
(with-temp-buffer
(unless (featurep 'xemacs) (set-buffer-multibyte nil))
(set-buffer-multibyte nil)
(insert string)
(goto-char (point-min))
(dns-read-name buffer)))
......@@ -140,7 +140,7 @@ updated. Set this variable to t to disable the check.")
"Write a DNS packet according to SPEC.
If TCP-P, the first two bytes of the package with be the length field."
(with-temp-buffer
(unless (featurep 'xemacs) (set-buffer-multibyte nil))
(set-buffer-multibyte nil)
(dns-write-bytes (dns-get 'id spec) 2)
(dns-write-bytes
(logior
......@@ -191,7 +191,7 @@ If TCP-P, the first two bytes of the package with be the length field."
(defun dns-read (packet)
(with-temp-buffer
(unless (featurep 'xemacs) (set-buffer-multibyte nil))
(set-buffer-multibyte nil)
(let ((spec nil)
queries answers authorities additionals)
(insert packet)
......@@ -268,7 +268,7 @@ If TCP-P, the first two bytes of the package with be the length field."
(point (point)))
(prog1
(with-temp-buffer
(unless (featurep 'xemacs) (set-buffer-multibyte nil))
(set-buffer-multibyte nil)
(insert string)
(goto-char (point-min))
(cond
......@@ -356,26 +356,21 @@ Parses \"/etc/resolv.conf\" or calls \"nslookup\"."
;;; Interface functions.
(defmacro dns-make-network-process (server)
(if (featurep 'xemacs)
`(let ((coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(open-network-stream "dns" (current-buffer)
,server "domain" 'udp))
`(let ((server ,server)
(coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(if (fboundp 'make-network-process)
(make-network-process
:name "dns"
:coding 'binary
:buffer (current-buffer)
:host server
:service "domain"
:type 'datagram)
;; Older versions of Emacs doesn't have
;; `make-network-process', so we fall back on opening a TCP
;; connection to the DNS server.
(open-network-stream "dns" (current-buffer) server "domain")))))
`(let ((server ,server)
(coding-system-for-read 'binary)
(coding-system-for-write 'binary))
(if (fboundp 'make-network-process)
(make-network-process
:name "dns"
:coding 'binary
:buffer (current-buffer)
:host server
:service "domain"
:type 'datagram)
;; Older versions of Emacs doesn't have
;; `make-network-process', so we fall back on opening a TCP
;; connection to the DNS server.
(open-network-stream "dns" (current-buffer) server "domain"))))
(defvar dns-cache (make-vector 4096 0))
......@@ -409,7 +404,7 @@ If REVERSEP, look up an IP address."
(if (not dns-servers)
(message "No DNS server configuration found")
(with-temp-buffer
(unless (featurep 'xemacs) (set-buffer-multibyte nil))
(set-buffer-multibyte nil)
(let ((process (condition-case ()
(dns-make-network-process (car dns-servers))
(error
......@@ -417,8 +412,6 @@ If REVERSEP, look up an IP address."
"dns: Got an error while trying to talk to %s"
(car dns-servers))
nil)))
(tcp-p (and (not (fboundp 'make-network-process))
(not (featurep 'xemacs))))
(step 100)
(times (* dns-timeout 1000))
(id (random 65000)))
......@@ -428,8 +421,7 @@ If REVERSEP, look up an IP address."
(dns-write `((id ,id)
(opcode query)
(queries ((,name (type ,type))))
(recursion-desired-p t))
tcp-p))
(recursion-desired-p t))))
(while (and (zerop (buffer-size))
(> times 0))
(let ((step-sec (/ step 1000.0)))
......@@ -439,10 +431,6 @@ If REVERSEP, look up an IP address."
(condition-case nil
(delete-process process)
(error nil))
(when (and tcp-p
(>= (buffer-size) 2))
(goto-char (point-min))
(delete-region (point) (+ (point) 2)))
(when (and (>= (buffer-size) 2)
;; We had a time-out.
(> times 0))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment