annotate lisp/net/net-utils.el @ 66520:67afcf271a8f

(pgg-gpg-select-matching-key): Fixed: look at the right part of the decoded armor to find the key-identifier. (pgg-gpg-lookup-key-owner): New function to return the human-readable identifier of a key owner. (pgg-gpg-lookup-id-from-key-owner): Make it easy to identify the key itself. (pgg-gpg-decrypt-region): Prompt with the key owner (rather than the key value) if we have a key and can match it against a secret key. Also, added an XXX note pointing out fact that the prompt only indicates the first matching key. (pgg-pgp-encrypt-region) (pgg-pgp-encrypt-symmetric-region, pgg-pgp-encrypt-symmetric) (pgg-pgp-encrypt, pgg-pgp-decrypt-region, pgg-pgp-decrypt) (pgg-pgp-sign-region, pgg-pgp-sign): Add optional 'passphrase' argument to all these routines, so the passphrase can be managed externally and passed in to the system. (pgg-gpg-possibly-cache-passphrase): Add optional 'notruncate' argument, so the passphrase cache can be used reliably with identifiers besides a pgp packet's key id. (pgg-gpg-encrypt-symmetric-region): New function for symmetric encryption. (pgg-gpg-symmetric-key-p): New function to check for an symmetric encrypted session key. (pgg-gpg-decrypt-region): When decrypting a symmetric encrypted message ask for the passphrase in a proper way.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 29 Oct 2005 11:31:08 +0000
parents 9612798470fd
children 067115a6e738 2d92f5c9d6ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36225
diff changeset
1 ;;; net-utils.el --- network functions
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
64701
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
4 ;; 2005 Free Software Foundation, Inc.
36225
2a73e688d635 Update copyright notice.
Gerd Moellmann <gerd@gnu.org>
parents: 32197
diff changeset
5
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Peter Breton <pbreton@cs.umb.edu>
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Created: Sun Mar 16 1997
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
8 ;; Keywords: network comm
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; any later version.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62437
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62437
diff changeset
25 ;; Boston, MA 02110-1301, USA.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
28
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; There are three main areas of functionality:
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
31 ;;
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;; * Wrap common network utility programs (ping, traceroute, netstat,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; nslookup, arp, route). Note that these wrappers are of the diagnostic
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;; functions of these programs only.
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
35 ;;
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; * Implement some very basic protocols in Emacs Lisp (finger and whois)
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
37 ;;
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;; * Support connections to HOST/PORT, generally for debugging and the like.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; In other words, for doing much the same thing as "telnet HOST PORT", and
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; then typing commands.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; PATHS
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 ;; On some systems, some of these programs are not in normal user path,
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
45 ;; but rather in /sbin, /usr/sbin, and so on.
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;;; Code:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (eval-when-compile
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 (require 'comint))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 ;; Customization Variables
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 (defgroup net-utils nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 "Network utility functions."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 :prefix "net-utils-"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 :group 'comm
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
60 :version "20.3")
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
62 (defcustom net-utils-remove-ctl-m
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 (member system-type (list 'windows-nt 'msdos))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 "If non-nil, remove control-Ms from output."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
66 :type 'boolean)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
68 (defcustom traceroute-program
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
69 (if (eq system-type 'windows-nt)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 "tracert"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 "traceroute")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 "Program to trace network hops to a destination."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
74 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (defcustom traceroute-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 "Options for the traceroute program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
79 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 (defcustom ping-program "ping"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 "Program to send network test packets to a host."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
84 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
86 ;; On GNU/Linux and Irix, the system's ping program seems to send packets
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;; indefinitely unless told otherwise
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
88 (defcustom ping-program-options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (and (memq system-type (list 'linux 'gnu/linux 'irix))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (list "-c" "4"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 "Options for the ping program.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 These options can be used to limit how many ICMP packets are emitted."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
94 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
96 (defcustom ipconfig-program
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 "ipconfig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 "ifconfig")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 "Program to print network configuration information."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
102 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (defcustom ipconfig-program-options
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
105 (list
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
106 (if (eq system-type 'windows-nt)
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
107 "/all" "-a"))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 "Options for ipconfig-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
110 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (defcustom netstat-program "netstat"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 "Program to print network statistics."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
115 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
117 (defcustom netstat-program-options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (list "-a")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 "Options for netstat-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
121 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (defcustom arp-program "arp"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 "Program to print IP to address translation tables."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
126 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
128 (defcustom arp-program-options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (list "-a")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 "Options for arp-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
132 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
134 (defcustom route-program
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 "route"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 "netstat")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 "Program to print routing tables."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
140 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
142 (defcustom route-program-options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (list "print")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (list "-r"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 "Options for route-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
148 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (defcustom nslookup-program "nslookup"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 "Program to interactively query DNS information."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
153 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 (defcustom nslookup-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 "List of options to pass to the nslookup program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
158 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 (defcustom nslookup-prompt-regexp "^> "
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
161 "Regexp to match the nslookup prompt.
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
162
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
163 This variable is only used if the variable
61875
cff214e628c2 (nslookup-prompt-regexp, ftp-prompt-regexp, smbclient-prompt-regexp):
Luc Teirlinck <teirllm@auburn.edu>
parents: 57161
diff changeset
164 `comint-use-prompt-regexp' is non-nil."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
166 :type 'regexp)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 (defcustom dig-program "dig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 "Program to query DNS information."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
171 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (defcustom ftp-program "ftp"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 "Progam to run to do FTP transfers."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
176 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 (defcustom ftp-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 "List of options to pass to the FTP program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
181 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 (defcustom ftp-prompt-regexp "^ftp>"
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
184 "Regexp which matches the FTP program's prompt.
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
185
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
186 This variable is only used if the variable
61875
cff214e628c2 (nslookup-prompt-regexp, ftp-prompt-regexp, smbclient-prompt-regexp):
Luc Teirlinck <teirllm@auburn.edu>
parents: 57161
diff changeset
187 `comint-use-prompt-regexp' is non-nil."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
189 :type 'regexp)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 (defcustom smbclient-program "smbclient"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 "Smbclient program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
194 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 (defcustom smbclient-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 "List of options to pass to the smbclient program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
199 :type '(repeat string))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 (defcustom smbclient-prompt-regexp "^smb: \>"
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
202 "Regexp which matches the smbclient program's prompt.
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
203
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
204 This variable is only used if the variable
61875
cff214e628c2 (nslookup-prompt-regexp, ftp-prompt-regexp, smbclient-prompt-regexp):
Luc Teirlinck <teirllm@auburn.edu>
parents: 57161
diff changeset
205 `comint-use-prompt-regexp' is non-nil."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
207 :type 'regexp)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208
50281
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
209 (defcustom dns-lookup-program "host"
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
210 "Program to interactively query DNS information."
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
211 :group 'net-utils
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
212 :type 'string
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
213 )
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
214
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
215 (defcustom dns-lookup-program-options nil
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
216 "List of options to pass to the dns-lookup program."
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
217 :group 'net-utils
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
218 :type '(repeat string)
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
219 )
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
220
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
221 ;; Internal variables
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
222 (defvar network-connection-service nil)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
223 (defvar network-connection-host nil)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
224
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226 ;; Nslookup goodies
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (defconst nslookup-font-lock-keywords
32158
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
230 (progn
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
231 (defvar font-lock-type-face)
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
232 (defvar font-lock-keyword-face)
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
233 (defvar font-lock-variable-name-face)
32158
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
234 (require 'font-lock)
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
235 (list
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
236 (list "^[A-Za-z0-9 _]+:" 0 font-lock-type-face)
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
237 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>"
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
238 1 font-lock-keyword-face)
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
239 ;; Dotted quads
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
240 (list
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
241 (mapconcat 'identity
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
242 (make-list 4 "[0-9]+")
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
243 "\\.")
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
244 0 font-lock-variable-name-face)
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
245 ;; Host names
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
246 (list
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
247 (let ((host-expression "[-A-Za-z0-9]+"))
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
248 (concat
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
249 (mapconcat 'identity
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
250 (make-list 2 host-expression)
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
251 "\\.")
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
252 "\\(\\." host-expression "\\)*"))
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
253 0 font-lock-variable-name-face)))
32158
b048135b76bc (nslookup-font-lock-keywords, ftp-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 32123
diff changeset
254 "Expressions to font-lock for nslookup.")
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 ;; Utility functions
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 ;; Simplified versions of some at-point functions from ffap.el.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 ;; It's not worth loading all of ffap just for these.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (defun net-utils-machine-at-point ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (let ((pt (point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (buffer-substring-no-properties
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (skip-chars-backward "-a-zA-Z0-9.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 (skip-chars-forward "-a-zA-Z0-9.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 (skip-chars-backward "." pt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (point)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (defun net-utils-url-at-point ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (let ((pt (point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (buffer-substring-no-properties
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 (skip-chars-forward "^A-Za-z0-9" pt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 (point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282 (skip-chars-backward ":;.,!?" pt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (point)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (defun net-utils-remove-ctrl-m-filter (process output-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 "Remove trailing control Ms."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (let ((old-buffer (current-buffer))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (filtered-string output-string))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (unwind-protect
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (let ((moving))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (set-buffer (process-buffer process))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (setq moving (= (point) (process-mark process)))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
294
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 (while (string-match "\r" filtered-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (setq filtered-string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (replace-match "" nil nil filtered-string)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 ;; Insert the text, moving the process-marker.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (goto-char (process-mark process))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (insert filtered-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (set-marker (process-mark process) (point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (if moving (goto-char (process-mark process))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (set-buffer old-buffer))))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
306
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (defmacro net-utils-run-program (name header program &rest args)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 "Run a network information program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 ` (let ((buf (get-buffer-create (concat "*" ,name "*"))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (erase-buffer)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (insert ,header "\n")
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
313 (set-process-filter
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (apply 'start-process ,name buf ,program ,@args)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 'net-utils-remove-ctrl-m-filter)
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
316 (display-buffer buf)
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
317 buf))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 ;; Wrappers for external network programs
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (defun traceroute (target)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 "Run traceroute program for TARGET."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (interactive "sTarget: ")
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
327 (let ((options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (if traceroute-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329 (append traceroute-program-options (list target))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (list target))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (concat "Traceroute" " " target)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (concat "** Traceroute ** " traceroute-program " ** " target)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 traceroute-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
335 options)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (defun ping (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 "Ping HOST.
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
340 If your system's ping continues until interrupted, you can try setting
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 `ping-program-options'."
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
342 (interactive
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point))))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
344 (let ((options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 (if ping-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (append ping-program-options (list host))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 (list host))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (concat "Ping" " " host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (concat "** Ping ** " ping-program " ** " host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 ping-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
352 options)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (defun ipconfig ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 "Run ipconfig program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 "Ipconfig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 (concat "** Ipconfig ** " ipconfig-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 ipconfig-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
362 ipconfig-program-options))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 ;; This is the normal name on most Unixes.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 ;;;###autoload
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
366 (defalias 'ifconfig 'ipconfig)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (defun netstat ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 "Run netstat program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 "Netstat"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 (concat "** Netstat ** " netstat-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 netstat-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
376 netstat-program-options))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 (defun arp ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 "Run the arp program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 "Arp"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (concat "** Arp ** " arp-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 arp-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
386 arp-program-options))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (defun route ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 "Run the route program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 "Route"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (concat "** Route ** " route-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 route-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
396 route-program-options))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 ;; FIXME -- Needs to be a process filter
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 ;; (defun netstat-with-filter (filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 ;; "Run netstat program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 ;; (interactive "sFilter: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 ;; (netstat)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403 ;; (set-buffer (get-buffer "*Netstat*"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 ;; (goto-char (point-min))
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
405 ;; (delete-matching-lines filter))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (defun nslookup-host (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 "Lookup the DNS information for HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
412 (let ((options
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (if nslookup-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (append nslookup-program-options (list host))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 (list host))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 "Nslookup"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (concat "** "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (mapconcat 'identity
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 (list "Nslookup" host nslookup-program)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 " ** "))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 nslookup-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
423 options)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (defun nslookup ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 "Run nslookup program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (require 'comint)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (comint-run nslookup-program)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
431 (nslookup-mode))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 ;; Using a derived mode gives us keymaps, hooks, etc.
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
434 (define-derived-mode nslookup-mode comint-mode "Nslookup"
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 "Major mode for interacting with the nslookup program."
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
436 (set
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (make-local-variable 'font-lock-defaults)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 '((nslookup-font-lock-keywords)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (setq comint-prompt-regexp nslookup-prompt-regexp)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
440 (setq comint-input-autoexpand t))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (define-key nslookup-mode-map "\t" 'comint-dynamic-complete)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 ;;;###autoload
50281
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
445 (defun dns-lookup-host (host)
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
446 "Lookup the DNS information for HOST (name or IP address)."
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
447 (interactive
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
448 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
449 (let ((options
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
450 (if dns-lookup-program-options
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
451 (append dns-lookup-program-options (list host))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
452 (list host))))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
453 (net-utils-run-program
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
454 (concat "DNS Lookup [" host "]")
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
455 (concat "** "
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
456 (mapconcat 'identity
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
457 (list "DNS Lookup" host dns-lookup-program)
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
458 " ** "))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
459 dns-lookup-program
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
460 options
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
461 )))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
462
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
463 ;;;###autoload
64805
9612798470fd (run-dig): Renamed from `dig'.
Richard M. Stallman <rms@gnu.org>
parents: 64701
diff changeset
464 (defun run-dig (host)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 "Run dig program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (progn
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (require 'ffap)
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
470 (read-from-minibuffer
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
471 "Lookup host: "
62316
2a4f6c0559af (dig): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents: 61875
diff changeset
472 (with-no-warnings
2a4f6c0559af (dig): Use with-no-warnings.
Richard M. Stallman <rms@gnu.org>
parents: 61875
diff changeset
473 (or (ffap-string-at-point 'machine) ""))))))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 "Dig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (concat "** "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (mapconcat 'identity
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (list "Dig" host dig-program)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 " ** "))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 dig-program
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
481 (list host)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 ;; This is a lot less than ange-ftp, but much simpler.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (defun ftp (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 "Run ftp program."
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
487 (interactive
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (list
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
489 (read-from-minibuffer
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 "Ftp to Host: " (net-utils-machine-at-point))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (require 'comint)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (let ((buf (get-buffer-create (concat "*ftp [" host "]*"))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 (set-buffer buf)
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
494 (ftp-mode)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (comint-exec buf (concat "ftp-" host) ftp-program nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 (if ftp-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (append (list host) ftp-program-options)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (list host)))
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
499 (pop-to-buffer buf)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
501 (define-derived-mode ftp-mode comint-mode "FTP"
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
502 "Major mode for interacting with the ftp program."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (setq comint-prompt-regexp ftp-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (setq comint-input-autoexpand t)
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
505 ;; Only add the password-prompting hook if it's not already in the
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
506 ;; global hook list. This stands a small chance of losing, if it's
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
507 ;; later removed from the global list (very small, since any
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
508 ;; password prompts will probably immediately follow the initial
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
509 ;; connection), but it's better than getting prompted twice for the
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
510 ;; same password.
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
511 (unless (memq 'comint-watch-for-password-prompt
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
512 (default-value 'comint-output-filter-functions))
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
513 (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
514 nil t)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 ;; Occasionally useful
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (define-key ftp-mode-map "\t" 'comint-dynamic-complete)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (defun smbclient (host service)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 "Connect to SERVICE on HOST via SMB."
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
521 (interactive
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (list
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
523 (read-from-minibuffer
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 "Connect to Host: " (net-utils-machine-at-point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (read-from-minibuffer "SMB Service: ")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (require 'comint)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (let* ((name (format "smbclient [%s\\%s]" host service))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (buf (get-buffer-create (concat "*" name "*")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (service-name (concat "\\\\" host "\\" service)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (set-buffer buf)
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
531 (smbclient-mode)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (comint-exec buf name smbclient-program nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (if smbclient-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (append (list service-name) smbclient-program-options)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (list service-name)))
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
536 (pop-to-buffer buf)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (defun smbclient-list-shares (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 "List services on HOST."
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
540 (interactive
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (list
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
542 (read-from-minibuffer
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
543 "Connect to Host: " (net-utils-machine-at-point))))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (smbclient-mode)
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
547 (comint-exec buf "smbclient-list-shares"
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
548 smbclient-program nil (list "-L" host))
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
549 (pop-to-buffer buf)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
551 (define-derived-mode smbclient-mode comint-mode "smbclient"
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
552 "Major mode for interacting with the smbclient program."
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (setq comint-prompt-regexp smbclient-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (setq comint-input-autoexpand t)
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
555 ;; Only add the password-prompting hook if it's not already in the
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
556 ;; global hook list. This stands a small chance of losing, if it's
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
557 ;; later removed from the global list (very small, since any
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
558 ;; password prompts will probably immediately follow the initial
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
559 ;; connection), but it's better than getting prompted twice for the
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
560 ;; same password.
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
561 (unless (memq 'comint-watch-for-password-prompt
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
562 (default-value 'comint-output-filter-functions))
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
563 (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
564 nil t)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 ;; Network Connections
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 ;; Full list is available at:
57161
c83be5f31fc5 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 52401
diff changeset
572 ;; http://www.iana.org/assignments/port-numbers
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
573 (defvar network-connection-service-alist
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (cons 'echo 7)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (cons 'active-users 11)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (cons 'daytime 13)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (cons 'chargen 19)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (cons 'ftp 21)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (cons 'telnet 23)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (cons 'smtp 25)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (cons 'time 37)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (cons 'whois 43)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (cons 'gopher 70)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (cons 'finger 79)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (cons 'www 80)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 (cons 'pop2 109)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (cons 'pop3 110)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 (cons 'sun-rpc 111)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 (cons 'nntp 119)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 (cons 'ntp 123)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (cons 'netbios-name 137)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 (cons 'netbios-data 139)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (cons 'irc 194)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (cons 'https 443)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
596 (cons 'rlogin 513))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 "Alist of services and associated TCP port numbers.
41257
0605a90581d4 (network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
598 This list is not complete.")
0605a90581d4 (network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 38436
diff changeset
599
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 ;; Workhorse macro
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
601 (defmacro run-network-program (process-name host port
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 &optional initial-string)
32197
b949d342e936 (nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents: 32158
diff changeset
603 `(let ((tcp-connection)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
604 (buf))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 (setq buf (get-buffer-create (concat "*" ,process-name "*")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 (set-buffer buf)
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
607 (or
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 (setq tcp-connection
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
609 (open-network-stream
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 ,process-name
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 buf
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612 ,host
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
613 ,port))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 (error "Could not open connection to %s" ,host))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 (erase-buffer)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (set-marker (process-mark tcp-connection) (point-min))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 (and ,initial-string
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
619 (process-send-string tcp-connection
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 (concat ,initial-string "\r\n")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 (display-buffer buf)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 ;; Simple protocols
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626
29303
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
627 (defcustom finger-X.500-host-regexps nil
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
628 "A list of regular expressions matching host names.
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
629 If a host name passed to `finger' matches one of these regular
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
630 expressions, it is assumed to be a host that doesn't accept
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
631 queries of the form USER@HOST, and wants a query containing USER only."
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
632 :group 'net-utils
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
633 :type '(repeat regexp)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
634 :version "21.1")
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
635
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 ;; Finger protocol
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (defun finger (user host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 "Finger USER on HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 ;; One of those great interactive statements that's actually
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 ;; longer than the function call! The idea is that if the user
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 ;; host name. If we don't see an "@", we'll prompt for the host.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 (let* ((answer (read-from-minibuffer "Finger User: "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 (net-utils-url-at-point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 (index (string-match (regexp-quote "@") answer)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 (if index
29303
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
649 (list (substring answer 0 index)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
650 (substring answer (1+ index)))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
651 (list answer
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
652 (read-from-minibuffer "At Host: "
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
653 (net-utils-machine-at-point))))))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
654 (let* ((user-and-host (concat user "@" host))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
655 (process-name (concat "Finger [" user-and-host "]"))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
656 (regexps finger-X.500-host-regexps)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
657 found)
50281
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
658 (and regexps
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
659 (while (not (string-match (car regexps) host))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
660 (setq regexps (cdr regexps)))
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
661 (when regexps
33ca9e7e717a Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents: 42571
diff changeset
662 (setq user-and-host user)))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
663 (run-network-program
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
664 process-name
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
665 host
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 (cdr (assoc 'finger network-connection-service-alist))
29303
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
667 user-and-host)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 (defcustom whois-server-name "rs.internic.net"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 "Default host name for the whois service."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
672 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 (defcustom whois-server-list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 ("rs.internic.net") ; domain related info
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 ("whois.abuse.net")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 ("whois.apnic.net")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 ("nic.ddn.mil")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 ("whois.nic.mil")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 ("whois.nic.gov")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 ("whois.ripe.net"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 "A list of whois servers that can be queried."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 :type '(repeat (list string)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 (defcustom whois-server-tld
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 '(("rs.internic.net" . "com")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689 ("rs.internic.net" . "org")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 ("whois.ripe.net" . "be")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 ("whois.ripe.net" . "de")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 ("whois.ripe.net" . "dk")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693 ("whois.ripe.net" . "it")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
694 ("whois.ripe.net" . "fi")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
695 ("whois.ripe.net" . "fr")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
696 ("whois.ripe.net" . "uk")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
697 ("whois.apnic.net" . "au")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
698 ("whois.apnic.net" . "ch")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
699 ("whois.apnic.net" . "hk")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
700 ("whois.apnic.net" . "jp")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
701 ("whois.nic.gov" . "gov")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
702 ("whois.nic.mil" . "mil"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 "Alist to map top level domains to whois servers."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 :type '(repeat (cons string string)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 (defcustom whois-guess-server t
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 "If non-nil then whois will try to deduce the appropriate whois
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 server from the query. If the query doesn't look like a domain or hostname
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710 then the server named by whois-server-name is used."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
711 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 :type 'boolean)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (defun whois-get-tld (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 "Return the top level domain of `host', or nil if it isn't a domain name."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
716 (let ((i (1- (length host)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
717 (max-len (- (length host) 5)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
718 (while (not (or (= i max-len) (char-equal (aref host i) ?.)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
719 (setq i (1- i)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
720 (if (= i max-len)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
721 nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
722 (substring host (1+ i)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
723
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
724 ;; Whois protocol
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
725 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
726 (defun whois (arg search-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
727 "Send SEARCH-STRING to server defined by the `whois-server-name' variable.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
728 If `whois-guess-server' is non-nil, then try to deduce the correct server
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 from SEARCH-STRING. With argument, prompt for whois server."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 (interactive "P\nsWhois: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 (let* ((whois-apropos-host (if whois-guess-server
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 (rassoc (whois-get-tld search-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
733 whois-server-tld)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734 nil))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (server-name (if whois-apropos-host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 (car whois-apropos-host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 whois-server-name))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 (host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 (if arg
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740 (completing-read "Whois server name: "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 whois-server-list nil nil "whois.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 server-name)))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
743 (run-network-program
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 "Whois"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 (cdr (assoc 'whois network-connection-service-alist))
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
747 search-string)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 (defcustom whois-reverse-lookup-server "whois.arin.net"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 "Server which provides inverse DNS mapping."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 :group 'net-utils
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
752 :type 'string)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
753
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
754 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 (defun whois-reverse-lookup ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 (let ((whois-server-name whois-reverse-lookup-server))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 (call-interactively 'whois)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 ;;; General Network connection
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
764 ;; Using a derived mode gives us keymaps, hooks, etc.
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
765 (define-derived-mode
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
766 network-connection-mode comint-mode "Network-Connection"
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
767 "Major mode for interacting with the network-connection program.")
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
768
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
769 (defun network-connection-mode-setup (host service)
42303
c5ddbcd62234 (ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents: 41257
diff changeset
770 (make-local-variable 'network-connection-host)
c5ddbcd62234 (ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents: 41257
diff changeset
771 (setq network-connection-host host)
c5ddbcd62234 (ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents: 41257
diff changeset
772 (make-local-variable 'network-connection-service)
42310
3eb9f60af733 Fix previous change.
Pavel Janík <Pavel@Janik.cz>
parents: 42303
diff changeset
773 (setq network-connection-service service))
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
774
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
776 (defun network-connection-to-service (host service)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
777 "Open a network connection to SERVICE on HOST."
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
778 (interactive
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780 (read-from-minibuffer "Host: " (net-utils-machine-at-point))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
781 (completing-read "Service: "
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
782 (mapcar
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
783 (function
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 (lambda (elt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 (list (symbol-name (car elt)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 network-connection-service-alist))))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
787 (network-connection
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
788 host
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
789 (cdr (assoc (intern service) network-connection-service-alist))))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
790
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
791 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792 (defun network-connection (host port)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793 "Open a network connection to HOST on PORT."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794 (interactive "sHost: \nnPort: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
795 (network-service-connection host (number-to-string port)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
796
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 (defun network-service-connection (host service)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 "Open a network connection to SERVICE on HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 (require 'comint)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
800 (let* ((process-name (concat "Network Connection [" host " " service "]"))
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
801 (portnum (string-to-number service))
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
802 (buf (get-buffer-create (concat "*" process-name "*"))))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
803 (or (zerop portnum) (setq service portnum))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
804 (make-comint
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
805 process-name
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806 (cons host service))
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
807 (set-buffer buf)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
808 (network-connection-mode)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
809 (network-connection-mode-setup host service)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
810 (pop-to-buffer buf)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
812 (defun network-connection-reconnect ()
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
813 "Reconnect a network connection, preserving the old input ring."
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
814 (interactive)
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
815 (let ((proc (get-buffer-process (current-buffer)))
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
816 (old-comint-input-ring comint-input-ring)
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
817 (host network-connection-host)
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
818 (service network-connection-service))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
819 (if (not (or (not proc)
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
820 (eq (process-status proc) 'closed)))
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
821 (message "Still connected")
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
822 (goto-char (point-max))
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
823 (insert (format "Reopening connection to %s\n" host))
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
824 (network-connection host
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
825 (if (numberp service)
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
826 service
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
827 (cdr (assoc service network-connection-service-alist))))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
828 (and old-comint-input-ring
42571
c4fdc37d21f5 (nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents: 42310
diff changeset
829 (setq comint-input-ring old-comint-input-ring)))))
32123
2e9fda397ea2 * net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents: 30548
diff changeset
830
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 (provide 'net-utils)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50281
diff changeset
833 ;;; arch-tag: 97119e91-9edb-4376-838b-bf7058fa1314
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
834 ;;; net-utils.el ends here