Mercurial > emacs
annotate lisp/net/net-utils.el @ 112341:1bdb2b6bdebb
* admin/notes/bzr: Add some more bzrmerge details.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 17 Jan 2011 18:22:36 -0800 |
parents | 417b1e4d63cd |
children |
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 | 2 |
104770
603c369f665b
(nslookup): Use make-comint rather than comint-run.
Glenn Morris <rgm@gnu.org>
parents:
104206
diff
changeset
|
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
110532
diff
changeset
|
4 ;; 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
36225 | 5 |
28210 | 6 ;; Author: Peter Breton <pbreton@cs.umb.edu> |
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 | 9 |
10 ;; This file is part of GNU Emacs. | |
11 | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94025
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
28210 | 13 ;; it under the terms of the GNU General Public License as published by |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94025
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94025
diff
changeset
|
15 ;; (at your option) any later version. |
28210 | 16 |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94025
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
28210 | 24 |
25 ;;; Commentary: | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
26 |
28210 | 27 ;; |
28 ;; 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
|
29 ;; |
28210 | 30 ;; * Wrap common network utility programs (ping, traceroute, netstat, |
31 ;; nslookup, arp, route). Note that these wrappers are of the diagnostic | |
32 ;; functions of these programs only. | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
33 ;; |
28210 | 34 ;; * 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
|
35 ;; |
28210 | 36 ;; * Support connections to HOST/PORT, generally for debugging and the like. |
37 ;; In other words, for doing much the same thing as "telnet HOST PORT", and | |
38 ;; then typing commands. | |
39 ;; | |
40 ;; PATHS | |
41 ;; | |
42 ;; 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
|
43 ;; but rather in /sbin, /usr/sbin, and so on. |
28210 | 44 |
45 | |
46 ;;; Code: | |
47 | |
48 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
49 ;; Customization Variables | |
50 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
51 | |
52 (defgroup net-utils nil | |
53 "Network utility functions." | |
54 :prefix "net-utils-" | |
55 :group 'comm | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
56 :version "20.3") |
28210 | 57 |
111460
ca911a71a6c8
net-utils system-type trivia.
Glenn Morris <rgm@gnu.org>
parents:
110532
diff
changeset
|
58 (defcustom net-utils-remove-ctl-m (memq system-type '(windows-nt msdos)) |
28210 | 59 "If non-nil, remove control-Ms from output." |
60 :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
|
61 :type 'boolean) |
28210 | 62 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
63 (defcustom traceroute-program |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
64 (if (eq system-type 'windows-nt) |
28210 | 65 "tracert" |
66 "traceroute") | |
67 "Program to trace network hops to a destination." | |
68 :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
|
69 :type 'string) |
28210 | 70 |
71 (defcustom traceroute-program-options nil | |
72 "Options for the traceroute program." | |
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 '(repeat string)) |
28210 | 75 |
76 (defcustom ping-program "ping" | |
77 "Program to send network test packets to a host." | |
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 'string) |
28210 | 80 |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
81 ;; On GNU/Linux and Irix, the system's ping program seems to send packets |
28210 | 82 ;; indefinitely unless told otherwise |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
83 (defcustom ping-program-options |
111460
ca911a71a6c8
net-utils system-type trivia.
Glenn Morris <rgm@gnu.org>
parents:
110532
diff
changeset
|
84 (and (memq system-type '(gnu/linux irix)) |
28210 | 85 (list "-c" "4")) |
86 "Options for the ping program. | |
87 These options can be used to limit how many ICMP packets are emitted." | |
88 :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
|
89 :type '(repeat string)) |
28210 | 90 |
94025
a8f8b0947a08
Move non-autoloaded define-obsolete-variable-alias calls for
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
91 (define-obsolete-variable-alias 'ipconfig-program 'ifconfig-program "22.2") |
a8f8b0947a08
Move non-autoloaded define-obsolete-variable-alias calls for
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
92 |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
93 (defcustom ifconfig-program |
28210 | 94 (if (eq system-type 'windows-nt) |
95 "ipconfig" | |
96 "ifconfig") | |
97 "Program to print network configuration information." | |
98 :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
|
99 :type 'string) |
28210 | 100 |
110532
7060c3b16693
Move some aliases to options before the associated definitions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
101 (define-obsolete-variable-alias 'ipconfig-program-options |
7060c3b16693
Move some aliases to options before the associated definitions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
102 'ifconfig-program-options "22.2") |
7060c3b16693
Move some aliases to options before the associated definitions.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
103 |
80077
535ef1cccea5
(ifconfig): Renamed from ipconfig.
Richard M. Stallman <rms@gnu.org>
parents:
79714
diff
changeset
|
104 (defcustom ifconfig-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")) |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
108 "Options for the ifconfig program." |
28210 | 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 | 111 |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
112 (defcustom iwconfig-program "iwconfig" |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
113 "Program to print wireless network configuration information." |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
114 :group 'net-utils |
92134
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
115 :type 'string |
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
116 :version "23.1") |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
117 |
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
118 (defcustom iwconfig-program-options nil |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
119 "Options for the iwconfig program." |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
120 :group 'net-utils |
92134
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
121 :type '(repeat string) |
ce1187e14779
(iwconfig-program, iwconfig-program-options): Add :version.
Glenn Morris <rgm@gnu.org>
parents:
92133
diff
changeset
|
122 :version "23.1") |
92133
7c818ca7aedb
Yoni Rabkin <yoni at rabkins.net> (tiny change)
Glenn Morris <rgm@gnu.org>
parents:
79714
diff
changeset
|
123 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
124 (defcustom netstat-program "netstat" |
28210 | 125 "Program to print network statistics." |
126 :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
|
127 :type 'string) |
28210 | 128 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
129 (defcustom netstat-program-options |
28210 | 130 (list "-a") |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
131 "Options for the netstat program." |
28210 | 132 :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
|
133 :type '(repeat string)) |
28210 | 134 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
135 (defcustom arp-program "arp" |
28210 | 136 "Program to print IP to address translation tables." |
137 :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
|
138 :type 'string) |
28210 | 139 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
140 (defcustom arp-program-options |
28210 | 141 (list "-a") |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
142 "Options for the arp program." |
28210 | 143 :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
|
144 :type '(repeat string)) |
28210 | 145 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
146 (defcustom route-program |
28210 | 147 (if (eq system-type 'windows-nt) |
148 "route" | |
149 "netstat") | |
150 "Program to print routing tables." | |
151 :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
|
152 :type 'string) |
28210 | 153 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
154 (defcustom route-program-options |
28210 | 155 (if (eq system-type 'windows-nt) |
156 (list "print") | |
157 (list "-r")) | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
158 "Options for the route program." |
28210 | 159 :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
|
160 :type '(repeat string)) |
28210 | 161 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
162 (defcustom nslookup-program "nslookup" |
28210 | 163 "Program to interactively query DNS information." |
164 :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
|
165 :type 'string) |
28210 | 166 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
167 (defcustom nslookup-program-options nil |
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
168 "Options for the nslookup program." |
28210 | 169 :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
|
170 :type '(repeat string)) |
28210 | 171 |
172 (defcustom nslookup-prompt-regexp "^> " | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
173 "Regexp to match the nslookup prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
174 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
175 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
|
176 `comint-use-prompt-regexp' is non-nil." |
28210 | 177 :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
|
178 :type 'regexp) |
28210 | 179 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
180 (defcustom dig-program "dig" |
28210 | 181 "Program to query DNS information." |
182 :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
|
183 :type 'string) |
28210 | 184 |
185 (defcustom ftp-program "ftp" | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
186 "Program to run to do FTP transfers." |
28210 | 187 :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
|
188 :type 'string) |
28210 | 189 |
190 (defcustom ftp-program-options nil | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
191 "Options for the ftp program." |
28210 | 192 :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
|
193 :type '(repeat string)) |
28210 | 194 |
195 (defcustom ftp-prompt-regexp "^ftp>" | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
196 "Regexp which matches the FTP program's prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
197 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
198 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
|
199 `comint-use-prompt-regexp' is non-nil." |
28210 | 200 :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
|
201 :type 'regexp) |
28210 | 202 |
203 (defcustom smbclient-program "smbclient" | |
204 "Smbclient program." | |
205 :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
|
206 :type 'string) |
28210 | 207 |
208 (defcustom smbclient-program-options nil | |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
209 "Options for the smbclient program." |
28210 | 210 :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
|
211 :type '(repeat string)) |
28210 | 212 |
213 (defcustom smbclient-prompt-regexp "^smb: \>" | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
214 "Regexp which matches the smbclient program's prompt. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
215 |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
216 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
|
217 `comint-use-prompt-regexp' is non-nil." |
28210 | 218 :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
|
219 :type 'regexp) |
28210 | 220 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
221 (defcustom dns-lookup-program "host" |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
222 "Program to interactively query DNS information." |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
223 :group 'net-utils |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
224 :type 'string) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
225 |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
226 (defcustom dns-lookup-program-options nil |
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
227 "Options for the dns-lookup program." |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
228 :group 'net-utils |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
229 :type '(repeat string)) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
230 |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
231 ;; Internal variables |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
232 (defvar network-connection-service nil) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
233 (defvar network-connection-host nil) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
234 |
28210 | 235 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
236 ;; Nslookup goodies | |
237 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
238 | |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
239 (defvar nslookup-font-lock-keywords |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
240 (list |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
241 (list "^[A-Za-z0-9 _]+:" 0 'font-lock-type-face) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
242 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>" |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
243 1 'font-lock-keyword-face) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
244 ;; Dotted quads |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
245 (list |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
246 (mapconcat 'identity |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
247 (make-list 4 "[0-9]+") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
248 "\\.") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
249 0 'font-lock-variable-name-face) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
250 ;; Host names |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
251 (list |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
252 (let ((host-expression "[-A-Za-z0-9]+")) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
253 (concat |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
254 (mapconcat 'identity |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
255 (make-list 2 host-expression) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
256 "\\.") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
257 "\\(\\." host-expression "\\)*")) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
258 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
|
259 "Expressions to font-lock for nslookup.") |
28210 | 260 |
261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
262 ;; General network utilities mode |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
264 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
265 (defvar net-utils-font-lock-keywords |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
266 (list |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
267 ;; Dotted quads |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
268 (list |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
269 (mapconcat 'identity (make-list 4 "[0-9]+") "\\.") |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
270 0 'font-lock-variable-name-face) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
271 ;; Simple rfc4291 addresses |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
272 (list (concat |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
273 "\\( \\([[:xdigit:]]+\\(:\\|::\\)\\)+[[:xdigit:]]+\\)" |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
274 "\\|" |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
275 "\\(::[[:xdigit:]]+\\)") |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
276 0 'font-lock-variable-name-face) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
277 ;; Host names |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
278 (list |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
279 (let ((host-expression "[-A-Za-z0-9]+")) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
280 (concat |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
281 (mapconcat 'identity (make-list 2 host-expression) "\\.") |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
282 "\\(\\." host-expression "\\)*")) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
283 0 'font-lock-variable-name-face)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
284 "Expressions to font-lock for general network utilities.") |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
285 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
286 (define-derived-mode net-utils-mode special-mode "NetworkUtil" |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
287 "Major mode for interacting with an external network utility." |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
288 (set (make-local-variable 'font-lock-defaults) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
289 '((net-utils-font-lock-keywords)))) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
290 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
291 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
28210 | 292 ;; Utility functions |
293 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
294 | |
295 ;; Simplified versions of some at-point functions from ffap.el. | |
296 ;; It's not worth loading all of ffap just for these. | |
297 (defun net-utils-machine-at-point () | |
298 (let ((pt (point))) | |
299 (buffer-substring-no-properties | |
300 (save-excursion | |
301 (skip-chars-backward "-a-zA-Z0-9.") | |
302 (point)) | |
303 (save-excursion | |
304 (skip-chars-forward "-a-zA-Z0-9.") | |
305 (skip-chars-backward "." pt) | |
306 (point))))) | |
307 | |
308 (defun net-utils-url-at-point () | |
309 (let ((pt (point))) | |
310 (buffer-substring-no-properties | |
311 (save-excursion | |
312 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%") | |
313 (skip-chars-forward "^A-Za-z0-9" pt) | |
314 (point)) | |
315 (save-excursion | |
316 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%") | |
317 (skip-chars-backward ":;.,!?" pt) | |
318 (point))))) | |
319 | |
320 (defun net-utils-remove-ctrl-m-filter (process output-string) | |
321 "Remove trailing control Ms." | |
322 (let ((old-buffer (current-buffer)) | |
323 (filtered-string output-string)) | |
324 (unwind-protect | |
325 (let ((moving)) | |
326 (set-buffer (process-buffer process)) | |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
327 (let ((inhibit-read-only t)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
328 (setq moving (= (point) (process-mark process))) |
28210 | 329 |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
330 (while (string-match "\r" filtered-string) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
331 (setq filtered-string |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
332 (replace-match "" nil nil filtered-string))) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
333 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
334 (save-excursion |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
335 ;; Insert the text, moving the process-marker. |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
336 (goto-char (process-mark process)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
337 (insert filtered-string) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
338 (set-marker (process-mark process) (point)))) |
28210 | 339 (if moving (goto-char (process-mark process)))) |
340 (set-buffer old-buffer)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
341 |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
342 (defun net-utils-run-program (name header program args) |
28210 | 343 "Run a network information program." |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
344 (let ((buf (get-buffer-create (concat "*" name "*")))) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
345 (set-buffer buf) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
346 (erase-buffer) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
347 (insert header "\n") |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
348 (set-process-filter |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
349 (apply 'start-process name buf program args) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
350 'net-utils-remove-ctrl-m-filter) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
351 (display-buffer buf) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
352 buf)) |
28210 | 353 |
354 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
355 ;; General network utilities (diagnostic) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
356 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
357 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
358 (defun net-utils-run-simple (buffer-name program-name args) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
359 "Run a network utility for diagnostic output only." |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
360 (interactive) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
361 (when (get-buffer buffer-name) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
362 (kill-buffer buffer-name)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
363 (get-buffer-create buffer-name) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
364 (with-current-buffer buffer-name |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
365 (net-utils-mode) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
366 (set-process-filter |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
367 (apply 'start-process (format "%s" program-name) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
368 buffer-name program-name args) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
369 'net-utils-remove-ctrl-m-filter) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
370 (goto-char (point-min))) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
371 (display-buffer buffer-name)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
372 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
373 ;;;###autoload |
105170 | 374 (defun ifconfig () |
375 "Run ifconfig and display diagnostic output." | |
376 (interactive) | |
377 (net-utils-run-simple | |
378 (format "*%s*" ifconfig-program) | |
379 ifconfig-program | |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
380 ifconfig-program-options)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
381 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
382 (defalias 'ipconfig 'ifconfig) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
383 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
384 ;;;###autoload |
105170 | 385 (defun iwconfig () |
386 "Run iwconfig and display diagnostic output." | |
387 (interactive) | |
388 (net-utils-run-simple | |
389 (format "*%s*" iwconfig-program) | |
390 iwconfig-program | |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
391 iwconfig-program-options)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
392 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
393 ;;;###autoload |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
394 (defun netstat () |
105170 | 395 "Run netstat and display diagnostic output." |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
396 (interactive) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
397 (net-utils-run-simple |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
398 (format "*%s*" netstat-program) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
399 netstat-program |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
400 netstat-program-options)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
401 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
402 ;;;###autoload |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
403 (defun arp () |
105170 | 404 "Run arp and display diagnostic output." |
104206
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
405 (interactive) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
406 (net-utils-run-simple |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
407 (format "*%s*" arp-program) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
408 arp-program |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
409 arp-program-options)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
410 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
411 ;;;###autoload |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
412 (defun route () |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
413 "Run route and display diagnostic output." |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
414 (interactive) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
415 (net-utils-run-simple |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
416 (format "*%s*" route-program) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
417 route-program |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
418 route-program-options)) |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
419 |
336e9dde5b1f
* net/net-utils.el (net-utils-font-lock-keywords): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
420 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
28210 | 421 ;; Wrappers for external network programs |
422 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
423 | |
424 ;;;###autoload | |
425 (defun traceroute (target) | |
426 "Run traceroute program for TARGET." | |
427 (interactive "sTarget: ") | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
428 (let ((options |
28210 | 429 (if traceroute-program-options |
430 (append traceroute-program-options (list target)) | |
431 (list target)))) | |
432 (net-utils-run-program | |
433 (concat "Traceroute" " " target) | |
434 (concat "** Traceroute ** " traceroute-program " ** " target) | |
435 traceroute-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
436 options))) |
28210 | 437 |
438 ;;;###autoload | |
439 (defun ping (host) | |
440 "Ping HOST. | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
441 If your system's ping continues until interrupted, you can try setting |
28210 | 442 `ping-program-options'." |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
443 (interactive |
28210 | 444 (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
|
445 (let ((options |
28210 | 446 (if ping-program-options |
447 (append ping-program-options (list host)) | |
448 (list host)))) | |
449 (net-utils-run-program | |
450 (concat "Ping" " " host) | |
451 (concat "** Ping ** " ping-program " ** " host) | |
452 ping-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
453 options))) |
28210 | 454 |
455 ;; FIXME -- Needs to be a process filter | |
456 ;; (defun netstat-with-filter (filter) | |
457 ;; "Run netstat program." | |
458 ;; (interactive "sFilter: ") | |
459 ;; (netstat) | |
460 ;; (set-buffer (get-buffer "*Netstat*")) | |
461 ;; (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
|
462 ;; (delete-matching-lines filter)) |
28210 | 463 |
464 ;;;###autoload | |
465 (defun nslookup-host (host) | |
466 "Lookup the DNS information for HOST." | |
467 (interactive | |
468 (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
|
469 (let ((options |
28210 | 470 (if nslookup-program-options |
471 (append nslookup-program-options (list host)) | |
472 (list host)))) | |
473 (net-utils-run-program | |
474 "Nslookup" | |
475 (concat "** " | |
476 (mapconcat 'identity | |
477 (list "Nslookup" host nslookup-program) | |
478 " ** ")) | |
479 nslookup-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
480 options))) |
28210 | 481 |
482 ;;;###autoload | |
483 (defun nslookup () | |
484 "Run nslookup program." | |
485 (interactive) | |
104770
603c369f665b
(nslookup): Use make-comint rather than comint-run.
Glenn Morris <rgm@gnu.org>
parents:
104206
diff
changeset
|
486 (switch-to-buffer (make-comint "nslookup" nslookup-program)) |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
487 (nslookup-mode)) |
28210 | 488 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
489 (defvar comint-prompt-regexp) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
490 (defvar comint-input-autoexpand) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
491 |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
492 (autoload 'comint-mode "comint" nil t) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
493 |
28210 | 494 ;; 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
|
495 (define-derived-mode nslookup-mode comint-mode "Nslookup" |
28210 | 496 "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
|
497 (set |
28210 | 498 (make-local-variable 'font-lock-defaults) |
499 '((nslookup-font-lock-keywords))) | |
500 (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
|
501 (setq comint-input-autoexpand t)) |
28210 | 502 |
503 (define-key nslookup-mode-map "\t" 'comint-dynamic-complete) | |
504 | |
505 ;;;###autoload | |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
506 (defun dns-lookup-host (host) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
507 "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
|
508 (interactive |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
509 (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
|
510 (let ((options |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
511 (if dns-lookup-program-options |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
512 (append dns-lookup-program-options (list host)) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
513 (list host)))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
514 (net-utils-run-program |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
515 (concat "DNS Lookup [" host "]") |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
516 (concat "** " |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
517 (mapconcat 'identity |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
518 (list "DNS Lookup" host dns-lookup-program) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
519 " ** ")) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
520 dns-lookup-program |
80216
e2cf0e9f1f88
(ftp-program): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
80081
diff
changeset
|
521 options))) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
522 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
523 (autoload 'ffap-string-at-point "ffap") |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
524 |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
525 ;;;###autoload |
64805
9612798470fd
(run-dig): Renamed from `dig'.
Richard M. Stallman <rms@gnu.org>
parents:
64701
diff
changeset
|
526 (defun run-dig (host) |
28210 | 527 "Run dig program." |
528 (interactive | |
529 (list | |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
530 (read-from-minibuffer "Lookup host: " |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
531 (or (ffap-string-at-point 'machine) "")))) |
28210 | 532 (net-utils-run-program |
533 "Dig" | |
534 (concat "** " | |
535 (mapconcat 'identity | |
536 (list "Dig" host dig-program) | |
537 " ** ")) | |
538 dig-program | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
539 (list host))) |
28210 | 540 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
541 (autoload 'comint-exec "comint") |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
542 |
28210 | 543 ;; This is a lot less than ange-ftp, but much simpler. |
544 ;;;###autoload | |
545 (defun ftp (host) | |
546 "Run ftp program." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
547 (interactive |
28210 | 548 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
549 (read-from-minibuffer |
28210 | 550 "Ftp to Host: " (net-utils-machine-at-point)))) |
551 (let ((buf (get-buffer-create (concat "*ftp [" host "]*")))) | |
552 (set-buffer buf) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
553 (ftp-mode) |
28210 | 554 (comint-exec buf (concat "ftp-" host) ftp-program nil |
555 (if ftp-program-options | |
556 (append (list host) ftp-program-options) | |
557 (list host))) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
558 (pop-to-buffer buf))) |
28210 | 559 |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
560 (define-derived-mode ftp-mode comint-mode "FTP" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
561 "Major mode for interacting with the ftp program." |
28210 | 562 (setq comint-prompt-regexp ftp-prompt-regexp) |
563 (setq comint-input-autoexpand t) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
564 ;; 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
|
565 ;; 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
|
566 ;; 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
|
567 ;; password prompts will probably immediately follow the initial |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
568 ;; 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
|
569 ;; same password. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
570 (unless (memq 'comint-watch-for-password-prompt |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
571 (default-value 'comint-output-filter-functions)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
572 (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
|
573 nil t))) |
28210 | 574 |
575 ;; Occasionally useful | |
576 (define-key ftp-mode-map "\t" 'comint-dynamic-complete) | |
577 | |
578 (defun smbclient (host service) | |
579 "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
|
580 (interactive |
28210 | 581 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
582 (read-from-minibuffer |
28210 | 583 "Connect to Host: " (net-utils-machine-at-point)) |
584 (read-from-minibuffer "SMB Service: "))) | |
585 (let* ((name (format "smbclient [%s\\%s]" host service)) | |
586 (buf (get-buffer-create (concat "*" name "*"))) | |
587 (service-name (concat "\\\\" host "\\" service))) | |
588 (set-buffer buf) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
589 (smbclient-mode) |
28210 | 590 (comint-exec buf name smbclient-program nil |
591 (if smbclient-program-options | |
592 (append (list service-name) smbclient-program-options) | |
593 (list service-name))) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
594 (pop-to-buffer buf))) |
28210 | 595 |
596 (defun smbclient-list-shares (host) | |
597 "List services on HOST." | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
598 (interactive |
28210 | 599 (list |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
600 (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
|
601 "Connect to Host: " (net-utils-machine-at-point)))) |
28210 | 602 (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host)))) |
603 (set-buffer buf) | |
604 (smbclient-mode) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
605 (comint-exec buf "smbclient-list-shares" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
606 smbclient-program nil (list "-L" host)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
607 (pop-to-buffer buf))) |
28210 | 608 |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
609 (define-derived-mode smbclient-mode comint-mode "smbclient" |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
610 "Major mode for interacting with the smbclient program." |
28210 | 611 (setq comint-prompt-regexp smbclient-prompt-regexp) |
612 (setq comint-input-autoexpand t) | |
32197
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
613 ;; 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
|
614 ;; 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
|
615 ;; 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
|
616 ;; password prompts will probably immediately follow the initial |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
617 ;; 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
|
618 ;; same password. |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
619 (unless (memq 'comint-watch-for-password-prompt |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
620 (default-value 'comint-output-filter-functions)) |
b949d342e936
(nslookup-prompt-regexp, ftp-prompt-regexp)
Miles Bader <miles@gnu.org>
parents:
32158
diff
changeset
|
621 (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
|
622 nil t))) |
28210 | 623 |
624 | |
625 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
626 ;; Network Connections | |
627 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
628 | |
629 ;; Full list is available at: | |
57161 | 630 ;; 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
|
631 (defvar network-connection-service-alist |
28210 | 632 (list |
633 (cons 'echo 7) | |
634 (cons 'active-users 11) | |
635 (cons 'daytime 13) | |
636 (cons 'chargen 19) | |
637 (cons 'ftp 21) | |
638 (cons 'telnet 23) | |
639 (cons 'smtp 25) | |
640 (cons 'time 37) | |
641 (cons 'whois 43) | |
642 (cons 'gopher 70) | |
643 (cons 'finger 79) | |
644 (cons 'www 80) | |
645 (cons 'pop2 109) | |
646 (cons 'pop3 110) | |
647 (cons 'sun-rpc 111) | |
648 (cons 'nntp 119) | |
649 (cons 'ntp 123) | |
650 (cons 'netbios-name 137) | |
651 (cons 'netbios-data 139) | |
652 (cons 'irc 194) | |
653 (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
|
654 (cons 'rlogin 513)) |
28210 | 655 "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
|
656 This list is not complete.") |
0605a90581d4
(network-connection-service-abbrev-alist): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
38436
diff
changeset
|
657 |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
658 ;; Workhorse routine |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
659 (defun run-network-program (process-name host port &optional initial-string) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
660 (let ((tcp-connection) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
661 (buf)) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
662 (setq buf (get-buffer-create (concat "*" process-name "*"))) |
28210 | 663 (set-buffer buf) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
664 (or |
28210 | 665 (setq tcp-connection |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
666 (open-network-stream process-name buf host port)) |
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
667 (error "Could not open connection to %s" host)) |
28210 | 668 (erase-buffer) |
669 (set-marker (process-mark tcp-connection) (point-min)) | |
670 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter) | |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
671 (and initial-string |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
672 (process-send-string tcp-connection |
92740
9f968e893cca
(iwconfig-program-options): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
92360
diff
changeset
|
673 (concat initial-string "\r\n"))) |
28210 | 674 (display-buffer buf))) |
675 | |
676 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
677 ;; Simple protocols | |
678 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
679 | |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
680 (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
|
681 "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
|
682 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
|
683 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
|
684 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
|
685 :group 'net-utils |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
686 :type '(repeat regexp) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
687 :version "21.1") |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
688 |
28210 | 689 ;; Finger protocol |
690 ;;;###autoload | |
691 (defun finger (user host) | |
692 "Finger USER on HOST." | |
693 ;; One of those great interactive statements that's actually | |
694 ;; longer than the function call! The idea is that if the user | |
695 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the | |
696 ;; host name. If we don't see an "@", we'll prompt for the host. | |
697 (interactive | |
698 (let* ((answer (read-from-minibuffer "Finger User: " | |
699 (net-utils-url-at-point))) | |
700 (index (string-match (regexp-quote "@") answer))) | |
701 (if index | |
29303
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
702 (list (substring answer 0 index) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
703 (substring answer (1+ index))) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
704 (list answer |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
705 (read-from-minibuffer "At Host: " |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
706 (net-utils-machine-at-point)))))) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
707 (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
|
708 (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
|
709 (regexps finger-X.500-host-regexps) |
a3541330de52
(finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents:
28419
diff
changeset
|
710 found) |
50281
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
711 (and regexps |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
712 (while (not (string-match (car regexps) host)) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
713 (setq regexps (cdr regexps))) |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
714 (when regexps |
33ca9e7e717a
Add dns-lookup-program wrapper
Peter Breton <pbreton@attbi.com>
parents:
42571
diff
changeset
|
715 (setq user-and-host user))) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
716 (run-network-program |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
717 process-name |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
718 host |
28210 | 719 (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
|
720 user-and-host))) |
28210 | 721 |
722 (defcustom whois-server-name "rs.internic.net" | |
723 "Default host name for the whois service." | |
724 :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
|
725 :type 'string) |
28210 | 726 |
727 (defcustom whois-server-list | |
728 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers) | |
729 ("rs.internic.net") ; domain related info | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
730 ("whois.publicinterestregistry.net") |
28210 | 731 ("whois.abuse.net") |
732 ("whois.apnic.net") | |
733 ("nic.ddn.mil") | |
734 ("whois.nic.mil") | |
735 ("whois.nic.gov") | |
736 ("whois.ripe.net")) | |
737 "A list of whois servers that can be queried." | |
738 :group 'net-utils | |
739 :type '(repeat (list string))) | |
740 | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
741 ;; FIXME: modern whois clients include a much better tld <-> whois server |
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
742 ;; list, Emacs should probably avoid specifying the server as the client |
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
743 ;; will DTRT anyway... -rfr |
28210 | 744 (defcustom whois-server-tld |
745 '(("rs.internic.net" . "com") | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
746 ("whois.publicinterestregistry.net" . "org") |
28210 | 747 ("whois.ripe.net" . "be") |
748 ("whois.ripe.net" . "de") | |
749 ("whois.ripe.net" . "dk") | |
750 ("whois.ripe.net" . "it") | |
751 ("whois.ripe.net" . "fi") | |
752 ("whois.ripe.net" . "fr") | |
753 ("whois.ripe.net" . "uk") | |
754 ("whois.apnic.net" . "au") | |
755 ("whois.apnic.net" . "ch") | |
756 ("whois.apnic.net" . "hk") | |
757 ("whois.apnic.net" . "jp") | |
758 ("whois.nic.gov" . "gov") | |
759 ("whois.nic.mil" . "mil")) | |
760 "Alist to map top level domains to whois servers." | |
761 :group 'net-utils | |
762 :type '(repeat (cons string string))) | |
763 | |
764 (defcustom whois-guess-server t | |
765 "If non-nil then whois will try to deduce the appropriate whois | |
766 server from the query. If the query doesn't look like a domain or hostname | |
76162
7d0cfbd2c01a
(whois-server-tld): Update server for .org.
Romain Francoise <romain@orebokech.com>
parents:
75347
diff
changeset
|
767 then the server named by `whois-server-name' is used." |
28210 | 768 :group 'net-utils |
769 :type 'boolean) | |
770 | |
771 (defun whois-get-tld (host) | |
772 "Return the top level domain of `host', or nil if it isn't a domain name." | |
773 (let ((i (1- (length host))) | |
774 (max-len (- (length host) 5))) | |
775 (while (not (or (= i max-len) (char-equal (aref host i) ?.))) | |
776 (setq i (1- i))) | |
777 (if (= i max-len) | |
778 nil | |
779 (substring host (1+ i))))) | |
780 | |
781 ;; Whois protocol | |
782 ;;;###autoload | |
783 (defun whois (arg search-string) | |
784 "Send SEARCH-STRING to server defined by the `whois-server-name' variable. | |
785 If `whois-guess-server' is non-nil, then try to deduce the correct server | |
786 from SEARCH-STRING. With argument, prompt for whois server." | |
787 (interactive "P\nsWhois: ") | |
788 (let* ((whois-apropos-host (if whois-guess-server | |
789 (rassoc (whois-get-tld search-string) | |
790 whois-server-tld) | |
791 nil)) | |
792 (server-name (if whois-apropos-host | |
793 (car whois-apropos-host) | |
794 whois-server-name)) | |
795 (host | |
796 (if arg | |
797 (completing-read "Whois server name: " | |
798 whois-server-list nil nil "whois.") | |
799 server-name))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
800 (run-network-program |
28210 | 801 "Whois" |
802 host | |
803 (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
|
804 search-string))) |
28210 | 805 |
806 (defcustom whois-reverse-lookup-server "whois.arin.net" | |
807 "Server which provides inverse DNS mapping." | |
808 :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
|
809 :type 'string) |
28210 | 810 |
811 ;;;###autoload | |
812 (defun whois-reverse-lookup () | |
813 (interactive) | |
814 (let ((whois-server-name whois-reverse-lookup-server)) | |
815 (call-interactively 'whois))) | |
816 | |
817 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
818 ;;; General Network connection | |
819 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
820 | |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
821 ;; 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
|
822 (define-derived-mode |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
823 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
|
824 "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
|
825 |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
826 (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
|
827 (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
|
828 (setq network-connection-host host) |
c5ddbcd62234
(ftp-mode-abbrev-table): Don't define it.
Richard M. Stallman <rms@gnu.org>
parents:
41257
diff
changeset
|
829 (make-local-variable 'network-connection-service) |
42310 | 830 (setq network-connection-service service)) |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
831 |
28210 | 832 ;;;###autoload |
833 (defun network-connection-to-service (host service) | |
834 "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
|
835 (interactive |
28210 | 836 (list |
837 (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
|
838 (completing-read "Service: " |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
839 (mapcar |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
840 (function |
28210 | 841 (lambda (elt) |
842 (list (symbol-name (car elt))))) | |
843 network-connection-service-alist)))) | |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
844 (network-connection |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
845 host |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
846 (cdr (assoc (intern service) network-connection-service-alist)))) |
28210 | 847 |
848 ;;;###autoload | |
849 (defun network-connection (host port) | |
850 "Open a network connection to HOST on PORT." | |
851 (interactive "sHost: \nnPort: ") | |
852 (network-service-connection host (number-to-string port))) | |
853 | |
854 (defun network-service-connection (host service) | |
855 "Open a network connection to SERVICE on HOST." | |
42571
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
856 (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
|
857 (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
|
858 (buf (get-buffer-create (concat "*" process-name "*")))) |
28210 | 859 (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
|
860 (make-comint |
28210 | 861 process-name |
862 (cons host service)) | |
28419
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
863 (set-buffer buf) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
864 (network-connection-mode) |
fed834403704
network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents:
28210
diff
changeset
|
865 (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
|
866 (pop-to-buffer buf))) |
28210 | 867 |
92227
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
868 (defvar comint-input-ring) |
a68825f42cef
(top-level): Don't require comint when compiling.
Glenn Morris <rgm@gnu.org>
parents:
92148
diff
changeset
|
869 |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
870 (defun network-connection-reconnect () |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
871 "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
|
872 (interactive) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
873 (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
|
874 (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
|
875 (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
|
876 (service network-connection-service)) |
32123
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
877 (if (not (or (not proc) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
878 (eq (process-status proc) 'closed))) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
879 (message "Still connected") |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
880 (goto-char (point-max)) |
2e9fda397ea2
* net/net-utils.el (nslookup-font-lock-keywords,
Peter Breton <pbreton@attbi.com>
parents:
30548
diff
changeset
|
881 (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
|
882 (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
|
883 (if (numberp service) |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
884 service |
c4fdc37d21f5
(nslookup-font-lock-keywords): Defvar font-lock variables to prevent
Pavel Janík <Pavel@Janik.cz>
parents:
42310
diff
changeset
|
885 (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
|
886 (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
|
887 (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
|
888 |
28210 | 889 (provide 'net-utils) |
890 | |
891 ;;; net-utils.el ends here |