annotate lisp/net/dig.el @ 91697:056e52861ec3

*** empty log message ***
author Eli Zaretskii <eliz@gnu.org>
date Sat, 09 Feb 2008 10:53:10 +0000
parents 107ccd98fa12
children 1e3a407766b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
86911
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
1 ;;; dig.el --- Domain Name System dig interface
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
2
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
87649
107ccd98fa12 Merge from emacs--rel--22
Miles Bader <miles@gnu.org>
parents: 86913
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
86911
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
5
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
6 ;; Author: Simon Josefsson <simon@josefsson.org>
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
7 ;; Keywords: DNS BIND dig
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
8
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
10
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
13 ;; by the Free Software Foundation; either version 3, or (at your
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
14 ;; option) any later version.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
15
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful, but
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
19 ;; General Public License for more details.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
20
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
25
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
27
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
28 ;; This provide an interface for "dig".
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
29 ;;
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
30 ;; For interactive use, try M-x dig and type a hostname. Use `q' to quit
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
31 ;; dig buffer.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
32 ;;
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
33 ;; For use in elisp programs, call `dig-invoke' and use
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
34 ;; `dig-extract-rr' to extract resource records.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
35
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
36 ;;; Release history:
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
37
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
38 ;; 2000-10-28 posted on gnu.emacs.sources
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
39
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
40 ;;; Code:
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
41
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
42 (eval-when-compile (require 'cl))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
43
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
44 (defgroup dig nil
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
45 "Dig configuration."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
46 :group 'comm)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
47
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
48 (defcustom dig-program "dig"
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
49 "Name of dig (domain information groper) binary."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
50 :type 'file
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
51 :group 'dig)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
52
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
53 (defcustom dig-dns-server nil
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
54 "DNS server to query.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
55 If nil, use system defaults."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
56 :type '(choice (const :tag "System defaults")
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
57 string)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
58 :group 'dig)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
59
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
60 (defcustom dig-font-lock-keywords
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
61 '(("^;; [A-Z]+ SECTION:" 0 font-lock-keyword-face)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
62 ("^;;.*" 0 font-lock-comment-face)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
63 ("^; <<>>.*" 0 font-lock-type-face)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
64 ("^;.*" 0 font-lock-function-name-face))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
65 "Default expressions to highlight in dig mode."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
66 :type 'sexp
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
67 :group 'dig)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
68
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
69 (defun dig-invoke (domain &optional
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
70 query-type query-class query-option
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
71 dig-option server)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
72 "Call dig with given arguments and return buffer containing output.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
73 DOMAIN is a string with a DNS domain. QUERY-TYPE is an optional string
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
74 with a DNS type. QUERY-CLASS is an optional string with a DNS class.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
75 QUERY-OPTION is an optional string with dig \"query options\".
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
76 DIG-OPTIONS is an optional string with parameters for the dig program.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
77 SERVER is an optional string with a domain name server to query.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
78
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
79 Dig is an external program found in the BIND name server distribution,
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
80 and is a commonly available debugging tool."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
81 (let (buf cmdline)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
82 (setq buf (generate-new-buffer "*dig output*"))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
83 (if dig-option (push dig-option cmdline))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
84 (if query-option (push query-option cmdline))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
85 (if query-class (push query-class cmdline))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
86 (if query-type (push query-type cmdline))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
87 (push domain cmdline)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
88 (if server (push (concat "@" server) cmdline)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
89 (if dig-dns-server (push (concat "@" dig-dns-server) cmdline)))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
90 (apply 'call-process dig-program nil buf nil cmdline)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
91 buf))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
92
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
93 (defun dig-extract-rr (domain &optional type class)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
94 "Extract resource records for DOMAIN, TYPE and CLASS from buffer.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
95 Buffer should contain output generated by `dig-invoke'."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
96 (save-excursion
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
97 (goto-char (point-min))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
98 (if (re-search-forward
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
99 (concat domain "\\.?[\t ]+[0-9wWdDhHmMsS]+[\t ]+"
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
100 (upcase (or class "IN")) "[\t ]+" (upcase (or type "A")))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
101 nil t)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
102 (let (b e)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
103 (end-of-line)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
104 (setq e (point))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
105 (beginning-of-line)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
106 (setq b (point))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
107 (when (search-forward " (" e t)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
108 (search-forward " )"))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
109 (end-of-line)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
110 (setq e (point))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
111 (buffer-substring b e))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
112 (and (re-search-forward (concat domain "\\.?[\t ]+[0-9wWdDhHmMsS]+[\t ]+"
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
113 (upcase (or class "IN"))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
114 "[\t ]+CNAME[\t ]+\\(.*\\)$") nil t)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
115 (dig-extract-rr (match-string 1) type class)))))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
116
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
117 (defun dig-rr-get-pkix-cert (rr)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
118 (let (b e str)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
119 (string-match "[^\t ]+[\t ]+[0-9wWdDhHmMsS]+[\t ]+IN[\t ]+CERT[\t ]+\\(1\\|PKIX\\)[\t ]+[0-9]+[\t ]+[0-9]+[\t ]+(?" rr)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
120 (setq b (match-end 0))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
121 (string-match ")" rr)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
122 (setq e (match-beginning 0))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
123 (setq str (substring rr b e))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
124 (while (string-match "[\t \n\r]" str)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
125 (setq str (replace-match "" nil nil str)))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
126 str))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
127
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
128 ;; XEmacs does it like this. For Emacs, we have to set the
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
129 ;; `font-lock-defaults' buffer-local variable.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
130 (put 'dig-mode 'font-lock-defaults '(dig-font-lock-keywords t))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
131
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
132 (put 'dig-mode 'mode-class 'special)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
133
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
134 (defvar dig-mode-map nil)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
135 (unless dig-mode-map
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
136 (setq dig-mode-map (make-sparse-keymap))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
137 (suppress-keymap dig-mode-map)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
138
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
139 (define-key dig-mode-map "q" 'dig-exit))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
140
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
141 (defun dig-mode ()
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
142 "Major mode for displaying dig output."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
143 (interactive)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
144 (kill-all-local-variables)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
145 (setq mode-name "dig")
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
146 (setq major-mode 'dig-mode)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
147 (use-local-map dig-mode-map)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
148 (buffer-disable-undo)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
149 (unless (featurep 'xemacs)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
150 (set (make-local-variable 'font-lock-defaults)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
151 '(dig-font-lock-keywords t)))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
152 (when (featurep 'font-lock)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
153 (font-lock-set-defaults))
86913
0ead56f6db1c (dig-mode): Replace gnus-run-mode-hooks with equivalent expansion.
Glenn Morris <rgm@gnu.org>
parents: 86911
diff changeset
154 (save-current-buffer
0ead56f6db1c (dig-mode): Replace gnus-run-mode-hooks with equivalent expansion.
Glenn Morris <rgm@gnu.org>
parents: 86911
diff changeset
155 (if (fboundp 'run-mode-hooks)
0ead56f6db1c (dig-mode): Replace gnus-run-mode-hooks with equivalent expansion.
Glenn Morris <rgm@gnu.org>
parents: 86911
diff changeset
156 (run-mode-hooks 'dig-mode-hook)
0ead56f6db1c (dig-mode): Replace gnus-run-mode-hooks with equivalent expansion.
Glenn Morris <rgm@gnu.org>
parents: 86911
diff changeset
157 (run-hooks 'dig-mode-hook))))
86911
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
158
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
159 (defun dig-exit ()
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
160 "Quit dig output buffer."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
161 (interactive)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
162 (kill-buffer (current-buffer)))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
163
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
164 (defun dig (domain &optional
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
165 query-type query-class query-option dig-option server)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
166 "Query addresses of a DOMAIN using dig, by calling `dig-invoke'.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
167 Optional arguments are passed to `dig-invoke'."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
168 (interactive "sHost: ")
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
169 (switch-to-buffer
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
170 (dig-invoke domain query-type query-class query-option dig-option server))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
171 (goto-char (point-min))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
172 (and (search-forward ";; ANSWER SECTION:" nil t)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
173 (forward-line))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
174 (dig-mode)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
175 (setq buffer-read-only t)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
176 (set-buffer-modified-p nil))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
177
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
178 ;; named for consistency with query-dns in dns.el
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
179 (defun query-dig (domain &optional
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
180 query-type query-class query-option dig-option server)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
181 "Query addresses of a DOMAIN using dig.
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
182 It works by calling `dig-invoke' and `dig-extract-rr'. Optional
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
183 arguments are passed to `dig-invoke' and `dig-extract-rr'. Returns
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
184 nil for domain/class/type queries that results in no data."
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
185 (let ((buffer (dig-invoke domain query-type query-class
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
186 query-option dig-option server)))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
187 (when buffer
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
188 (switch-to-buffer buffer)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
189 (let ((digger (dig-extract-rr domain query-type query-class)))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
190 (kill-buffer buffer)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
191 digger))))
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
192
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
193 (provide 'dig)
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
194
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
195 ;;; arch-tag: 1d61726e-9400-4013-9ae7-4035e0c7f7d6
716ac63fa774 Move here from ../gnus.
Glenn Morris <rgm@gnu.org>
parents:
diff changeset
196 ;;; dig.el ends here