gnus-notifications: add actions support
[gnus] / lisp / dns.el
index efd9a7d..b94c161 100644 (file)
@@ -1,41 +1,35 @@
 ;;; dns.el --- Domain Name Service lookups
 
 ;;; dns.el --- Domain Name Service lookups
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2002-2012  Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
-;; Keywords: network
+;; Keywords: network comm
 
 ;; This file is part of GNU Emacs.
 
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;;; Code:
 
 
 ;;; Commentary:
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
-
-(require 'mm-util)
-
 (defvar dns-timeout 5
   "How many seconds to wait when doing DNS queries.")
 
 (defvar dns-servers nil
 (defvar dns-timeout 5
   "How many seconds to wait when doing DNS queries.")
 
 (defvar dns-servers nil
-  "Which DNS servers to query.
-If nil, /etc/resolv.conf will be consulted.")
+  "List of DNS servers to query.
+If nil, /etc/resolv.conf and nslookup will be consulted.")
 
 ;;; Internal code:
 
 
 ;;; Internal code:
 
@@ -105,7 +99,8 @@ If nil, /etc/resolv.conf will be consulted.")
   (dns-write-bytes 0))
 
 (defun dns-read-string-name (string buffer)
   (dns-write-bytes 0))
 
 (defun dns-read-string-name (string buffer)
-  (mm-with-unibyte-buffer
+  (with-temp-buffer
+    (unless (featurep 'xemacs) (set-buffer-multibyte nil))
     (insert string)
     (goto-char (point-min))
     (dns-read-name buffer)))
     (insert string)
     (goto-char (point-min))
     (dns-read-name buffer)))
@@ -139,6 +134,7 @@ If nil, /etc/resolv.conf will be consulted.")
   "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
   "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))
     (dns-write-bytes (dns-get 'id spec) 2)
     (dns-write-bytes
      (logior
     (dns-write-bytes (dns-get 'id spec) 2)
     (dns-write-bytes
      (logior
@@ -154,7 +150,7 @@ If TCP-P, the first two bytes of the package with be the length field."
       (lsh (if (dns-get 'truncated-p spec) 1 0) -1)
       (lsh (if (dns-get 'recursion-desired-p spec) 1 0) 0)))
     (dns-write-bytes
       (lsh (if (dns-get 'truncated-p spec) 1 0) -1)
       (lsh (if (dns-get 'recursion-desired-p spec) 1 0) 0)))
     (dns-write-bytes
-     (cond 
+     (cond
       ((eq (dns-get 'response-code spec) 'no-error) 0)
       ((eq (dns-get 'response-code spec) 'format-error) 1)
       ((eq (dns-get 'response-code spec) 'server-failure) 2)
       ((eq (dns-get 'response-code spec) 'no-error) 0)
       ((eq (dns-get 'response-code spec) 'format-error) 1)
       ((eq (dns-get 'response-code spec) 'server-failure) 2)
@@ -188,75 +184,76 @@ If TCP-P, the first two bytes of the package with be the length field."
     (buffer-string)))
 
 (defun dns-read (packet)
     (buffer-string)))
 
 (defun dns-read (packet)
-  (mm-with-unibyte-buffer
+  (with-temp-buffer
+    (unless (featurep 'xemacs) (set-buffer-multibyte nil))
     (let ((spec nil)
     (let ((spec nil)
-         queries answers authorities additionals)
+          queries answers authorities additionals)
       (insert packet)
       (goto-char (point-min))
       (push (list 'id (dns-read-bytes 2)) spec)
       (let ((byte (dns-read-bytes 1)))
       (insert packet)
       (goto-char (point-min))
       (push (list 'id (dns-read-bytes 2)) spec)
       (let ((byte (dns-read-bytes 1)))
-       (push (list 'response-p (if (zerop (logand byte (lsh 1 7))) nil t))
-             spec)
-       (let ((opcode (logand byte (lsh 7 3))))
-         (push (list 'opcode
-                     (cond ((eq opcode 0) 'query)
-                           ((eq opcode 1) 'inverse-query)
-                           ((eq opcode 2) 'status)))
-               spec))
-       (push (list 'authoritative-p (if (zerop (logand byte (lsh 1 2)))
-                                        nil t)) spec)
-       (push (list 'truncated-p (if (zerop (logand byte (lsh 1 2))) nil t))
-             spec)
-       (push (list 'recursion-desired-p
-                   (if (zerop (logand byte (lsh 1 0))) nil t)) spec))
+        (push (list 'response-p (if (zerop (logand byte (lsh 1 7))) nil t))
+              spec)
+        (let ((opcode (logand byte (lsh 7 3))))
+          (push