annotate lisp/net/net-utils.el @ 29637:6b63e5410a0e

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Tue, 13 Jun 2000 23:51:46 +0000
parents a3541330de52
children 716c9bd98063
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; net-utils.el --- Network functions
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Author: Peter Breton <pbreton@cs.umb.edu>
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4 ;; Created: Sun Mar 16 1997
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Keywords: network communications
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Time-stamp: <1999-11-13 10:19:01 pbreton>
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
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 ;; 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
11 ;; 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
12 ;; the Free Software Foundation; either version 2, or (at your option)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; 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
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; 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
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
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 ;; There are three main areas of functionality:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;; * Wrap common network utility programs (ping, traceroute, netstat,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; nslookup, arp, route). Note that these wrappers are of the diagnostic
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;; functions of these programs only.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; * Implement some very basic protocols in Emacs Lisp (finger and whois)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; * Support connections to HOST/PORT, generally for debugging and the like.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;; 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
37 ;; then typing commands.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;; PATHS
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;; On some systems, some of these programs are not in normal user path,
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;; but rather in /sbin, /usr/sbin, and so on.
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 ;;; Code:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 (eval-when-compile
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 (require 'comint))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 ;; Customization Variables
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 (defgroup net-utils nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54 "Network utility functions."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 :prefix "net-utils-"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 :group 'comm
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 :version "20.3"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (defcustom net-utils-remove-ctl-m
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 (member system-type (list 'windows-nt 'msdos))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 "If non-nil, remove control-Ms from output."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 :type 'boolean
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 (defcustom traceroute-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 "tracert"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 "traceroute")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 "Program to trace network hops to a destination."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 )
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 :type '(repeat string)
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (defcustom ping-program "ping"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 "Program to send network test packets to a host."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; On Linux and Irix, the system's ping program seems to send packets
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; indefinitely unless told otherwise
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (defcustom ping-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (and (memq system-type (list 'linux 'gnu/linux 'irix))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (list "-c" "4"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 "Options for the ping program.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 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
95 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 :type '(repeat string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (defcustom ipconfig-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 "ipconfig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 "ifconfig")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 "Program to print network configuration information."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (defcustom ipconfig-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 "/all" "-a"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 "Options for ipconfig-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 :type '(repeat string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (defcustom netstat-program "netstat"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 "Program to print network statistics."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 )
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 netstat-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (list "-a")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 "Options for netstat-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 :type '(repeat string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (defcustom arp-program "arp"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 "Program to print IP to address translation tables."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (defcustom arp-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (list "-a")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 "Options for arp-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 :type '(repeat string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (defcustom route-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 "route"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 "netstat")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 "Program to print routing tables."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 (defcustom route-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 (if (eq system-type 'windows-nt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (list "print")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 (list "-r"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 "Options for route-program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158 :type '(repeat string)
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161 (defcustom nslookup-program "nslookup"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162 "Program to interactively query DNS information."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 (defcustom nslookup-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 "List of options to pass to the nslookup program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170 :type '(repeat string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 )
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 nslookup-prompt-regexp "^> "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 "Regexp to match the nslookup prompt."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 :type 'regexp
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 (defcustom dig-program "dig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 "Program to query DNS information."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 (defcustom ftp-program "ftp"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 "Progam to run to do FTP transfers."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 )
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 ftp-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 "List of options to pass to the FTP program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 :type '(repeat string)
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197 (defcustom ftp-prompt-regexp "^ftp>"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 "Regexp which matches the FTP program's prompt."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 :type 'regexp
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (defcustom smbclient-program "smbclient"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 "Smbclient program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209 (defcustom smbclient-program-options nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210 "List of options to pass to the smbclient program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 :type '(repeat string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 (defcustom smbclient-prompt-regexp "^smb: \>"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 "Regexp which matches the smbclient program's prompt."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 :type 'regexp
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (and window-system
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (progn
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (require 'font-lock)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (list nslookup-prompt-regexp 0 font-lock-reference-face)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (list "^[A-Za-z0-9 _]+:" 0 font-lock-type-face)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 1 font-lock-keyword-face)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 ;; Dotted quads
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 (mapconcat 'identity
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (make-list 4 "[0-9]+")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 "\\.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 0 font-lock-variable-name-face)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 ;; Host names
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (let ((host-expression "[-A-Za-z0-9]+"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 (concat
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (mapconcat 'identity
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (make-list 2 host-expression)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 "\\.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 "\\(\\." host-expression "\\)*")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 0 font-lock-variable-name-face)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 )))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 "Expressions to font-lock for nslookup.")
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 ;; FTP goodies
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (defconst ftp-font-lock-keywords
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (and window-system
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (progn
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 (require 'font-lock)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (list ftp-prompt-regexp 0 font-lock-reference-face)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 ;; smbclient goodies
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 (defconst smbclient-font-lock-keywords
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 (and window-system
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 (progn
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 (require 'font-lock)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (list smbclient-prompt-regexp 0 font-lock-reference-face)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 ;; Utility functions
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 ;; Simplified versions of some at-point functions from ffap.el.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 ;; It's not worth loading all of ffap just for these.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (defun net-utils-machine-at-point ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 (let ((pt (point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (buffer-substring-no-properties
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (skip-chars-backward "-a-zA-Z0-9.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (skip-chars-forward "-a-zA-Z0-9.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (skip-chars-backward "." pt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (point)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 (defun net-utils-url-at-point ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (let ((pt (point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (buffer-substring-no-properties
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 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (skip-chars-forward "^A-Za-z0-9" pt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302 (point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (skip-chars-backward ":;.,!?" pt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (point)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (defun net-utils-remove-ctrl-m-filter (process output-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 "Remove trailing control Ms."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (let ((old-buffer (current-buffer))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312 (filtered-string output-string))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313 (unwind-protect
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (let ((moving))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (set-buffer (process-buffer process))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (setq moving (= (point) (process-mark process)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (while (string-match "\r" filtered-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 (setq filtered-string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (replace-match "" nil nil filtered-string)))
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 (save-excursion
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 ;; Insert the text, moving the process-marker.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324 (goto-char (process-mark process))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325 (insert filtered-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (set-marker (process-mark process) (point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (if moving (goto-char (process-mark process))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (set-buffer old-buffer))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330 (defmacro net-utils-run-program (name header program &rest args)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 "Run a network information program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 ` (let ((buf (get-buffer-create (concat "*" ,name "*"))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (erase-buffer)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (insert ,header "\n")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 (set-process-filter
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 (apply 'start-process ,name buf ,program ,@args)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 'net-utils-remove-ctrl-m-filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 (display-buffer buf)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 ;; Wrappers for external network programs
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346 (defun traceroute (target)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347 "Run traceroute program for TARGET."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (interactive "sTarget: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (let ((options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 (if traceroute-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (append traceroute-program-options (list target))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (list target))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (concat "Traceroute" " " target)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (concat "** Traceroute ** " traceroute-program " ** " target)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 traceroute-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 )))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361 (defun ping (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 "Ping HOST.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 If your system's ping continues until interrupted, you can try setting
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 `ping-program-options'."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (let ((options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (if ping-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (append ping-program-options (list host))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 (list host))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (concat "Ping" " " host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (concat "** Ping ** " ping-program " ** " host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 ping-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 )))
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 ipconfig ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 "Run ipconfig 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 "Ipconfig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 (concat "** Ipconfig ** " ipconfig-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 ipconfig-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 ipconfig-program-options
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 ;; This is the normal name on most Unixes.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 (defalias 'ifconfig 'ipconfig)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (defun netstat ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 "Run netstat program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 "Netstat"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (concat "** Netstat ** " netstat-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 netstat-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 netstat-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (defun arp ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 "Run the arp program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 "Arp"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (concat "** Arp ** " arp-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 arp-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 arp-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (defun route ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 "Run the route program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 "Route"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (concat "** Route ** " route-program " ** ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 route-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 route-program-options
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 ;; FIXME -- Needs to be a process filter
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 ;; (defun netstat-with-filter (filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 ;; "Run netstat program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 ;; (interactive "sFilter: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 ;; (netstat)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 ;; (set-buffer (get-buffer "*Netstat*"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 ;; (goto-char (point-min))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 ;; (delete-matching-lines filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 ;; )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 (defun nslookup-host (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 "Lookup the DNS information for HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441 (let ((options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442 (if nslookup-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (append nslookup-program-options (list host))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (list host))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 "Nslookup"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (concat "** "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (mapconcat 'identity
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 (list "Nslookup" host nslookup-program)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 " ** "))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 nslookup-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 )))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457 (defun nslookup ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458 "Run nslookup program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (require 'comint)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (comint-run nslookup-program)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (set-process-filter (get-buffer-process "*nslookup*")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 'net-utils-remove-ctrl-m-filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (nslookup-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 ;; Using a derived mode gives us keymaps, hooks, etc.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (define-derived-mode
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 nslookup-mode comint-mode "Nslookup"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 "Major mode for interacting with the nslookup program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (set
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (make-local-variable 'font-lock-defaults)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 '((nslookup-font-lock-keywords)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (setq local-abbrev-table nslookup-mode-abbrev-table)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (abbrev-mode t)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 (make-local-variable 'comint-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 (setq comint-prompt-regexp nslookup-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (make-local-variable 'comint-input-autoexpand)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (setq comint-input-autoexpand t)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (define-key nslookup-mode-map "\t" 'comint-dynamic-complete)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (define-abbrev nslookup-mode-abbrev-table "e" "exit")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (define-abbrev nslookup-mode-abbrev-table "f" "finger")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (define-abbrev nslookup-mode-abbrev-table "h" "help")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 (define-abbrev nslookup-mode-abbrev-table "lse" "lserver")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 (define-abbrev nslookup-mode-abbrev-table "q" "exit")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (define-abbrev nslookup-mode-abbrev-table "r" "root")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (define-abbrev nslookup-mode-abbrev-table "s" "set")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (define-abbrev nslookup-mode-abbrev-table "se" "server")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (define-abbrev nslookup-mode-abbrev-table "v" "viewer")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (defun dig (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 "Run dig program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (progn
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (require 'ffap)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (read-from-minibuffer
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 "Lookup host: "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (or (ffap-string-at-point 'machine) "")))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (net-utils-run-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 "Dig"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (concat "** "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (mapconcat 'identity
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (list "Dig" host dig-program)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 " ** "))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 dig-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (list host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 ;; This is a lot less than ange-ftp, but much simpler.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (defun ftp (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 "Run ftp program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (read-from-minibuffer
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 "Ftp to Host: " (net-utils-machine-at-point))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (require 'comint)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (let ((buf (get-buffer-create (concat "*ftp [" host "]*"))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (comint-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (comint-exec buf (concat "ftp-" host) ftp-program nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (if ftp-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (append (list host) ftp-program-options)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (list host)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (ftp-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (switch-to-buffer-other-window buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (define-derived-mode
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 ftp-mode comint-mode "FTP"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 "Major mode for interacting with the ftp program."
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 (set
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (make-local-variable 'font-lock-defaults)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 '((ftp-font-lock-keywords)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 (make-local-variable 'comint-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (setq comint-prompt-regexp ftp-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (make-local-variable 'comint-input-autoexpand)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (setq comint-input-autoexpand t)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 ;; Already buffer local!
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (setq comint-output-filter-functions
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 (list 'comint-watch-for-password-prompt))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (setq local-abbrev-table ftp-mode-abbrev-table)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (abbrev-mode t)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (define-abbrev ftp-mode-abbrev-table "q" "quit")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 (define-abbrev ftp-mode-abbrev-table "g" "get")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (define-abbrev ftp-mode-abbrev-table "p" "prompt")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (define-abbrev ftp-mode-abbrev-table "anon" "anonymous")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 ;; Occasionally useful
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 (define-key ftp-mode-map "\t" 'comint-dynamic-complete)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 (defun smbclient (host service)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 "Connect to SERVICE on HOST via SMB."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (read-from-minibuffer
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 "Connect to Host: " (net-utils-machine-at-point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 (read-from-minibuffer "SMB Service: ")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 (require 'comint)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 (let* ((name (format "smbclient [%s\\%s]" host service))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 (buf (get-buffer-create (concat "*" name "*")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (service-name (concat "\\\\" host "\\" service)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (comint-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (comint-exec buf name smbclient-program nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (if smbclient-program-options
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (append (list service-name) smbclient-program-options)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (list service-name)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (smbclient-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (switch-to-buffer-other-window buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (defun smbclient-list-shares (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 "List services on HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 (read-from-minibuffer
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590 "Connect to Host: " (net-utils-machine-at-point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (let ((buf (get-buffer-create (format "*SMB Shares on %s*" host))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 (comint-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (comint-exec
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 buf
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 "smbclient-list-shares"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 smbclient-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (list "-L" host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (smbclient-mode)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 (switch-to-buffer-other-window buf)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 (define-derived-mode
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 smbclient-mode comint-mode "smbclient"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 "Major mode for interacting with the smbclient program."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 (set
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 (make-local-variable 'font-lock-defaults)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611 '((smbclient-font-lock-keywords)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 (make-local-variable 'comint-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 (setq comint-prompt-regexp smbclient-prompt-regexp)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (make-local-variable 'comint-input-autoexpand)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 (setq comint-input-autoexpand t)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 ;; Already buffer local!
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 (setq comint-output-filter-functions
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 (list 'comint-watch-for-password-prompt))
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 (setq local-abbrev-table smbclient-mode-abbrev-table)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 (abbrev-mode t)
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
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 (define-abbrev smbclient-mode-abbrev-table "q" "quit")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 ;; Network Connections
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 ;; Full list is available at:
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 ;; ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 (defvar network-connection-service-alist
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 (cons 'echo 7)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 (cons 'active-users 11)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 (cons 'daytime 13)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 (cons 'chargen 19)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 (cons 'ftp 21)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 (cons 'telnet 23)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 (cons 'smtp 25)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 (cons 'time 37)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 (cons 'whois 43)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647 (cons 'gopher 70)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648 (cons 'finger 79)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (cons 'www 80)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 (cons 'pop2 109)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 (cons 'pop3 110)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 (cons 'sun-rpc 111)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653 (cons 'nntp 119)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654 (cons 'ntp 123)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 (cons 'netbios-name 137)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656 (cons 'netbios-data 139)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657 (cons 'irc 194)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 (cons 'https 443)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659 (cons 'rlogin 513)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 "Alist of services and associated TCP port numbers.
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
662 This list in not complete.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
663
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
664 ;; Workhorse macro
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
665 (defmacro run-network-program (process-name host port
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
666 &optional initial-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
667 `
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
668 (let ((tcp-connection)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
669 (buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
670 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
671 (setq buf (get-buffer-create (concat "*" ,process-name "*")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
672 (set-buffer buf)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
673 (or
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
674 (setq tcp-connection
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
675 (open-network-stream
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
676 ,process-name
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
677 buf
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
678 ,host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
679 ,port
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
680 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
681 (error "Could not open connection to %s" ,host))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
682 (erase-buffer)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
683 (set-marker (process-mark tcp-connection) (point-min))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
684 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
685 (and ,initial-string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
686 (process-send-string tcp-connection
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
687 (concat ,initial-string "\r\n")))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
688 (display-buffer buf)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
689
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
690 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
691 ;; Simple protocols
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
692 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
693
29303
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
694 (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
695 "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
696 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
697 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
698 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
699 :group 'net-utils
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
700 :type '(repeat regexp)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
701 :version "21.1")
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
702
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
703 ;; Finger protocol
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
704 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
705 (defun finger (user host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
706 "Finger USER on HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
707 ;; One of those great interactive statements that's actually
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
708 ;; 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
709 ;; 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
710 ;; 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
711 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
712 (let* ((answer (read-from-minibuffer "Finger User: "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
713 (net-utils-url-at-point)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
714 (index (string-match (regexp-quote "@") answer)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
715 (if index
29303
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
716 (list (substring answer 0 index)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
717 (substring answer (1+ index)))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
718 (list answer
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
719 (read-from-minibuffer "At Host: "
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
720 (net-utils-machine-at-point))))))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
721 (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
722 (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
723 (regexps finger-X.500-host-regexps)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
724 found)
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
725 (while (not (string-match (car regexps) host))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
726 (setq regexps (cdr regexps)))
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
727 (when regexps
a3541330de52 (finger-X.500-host-regexps): New user-option.
Gerd Moellmann <gerd@gnu.org>
parents: 28419
diff changeset
728 (setq user-and-host user))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
729 (run-network-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
730 process-name
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
731 host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
732 (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
733 user-and-host)))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
734
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
735 (defcustom whois-server-name "rs.internic.net"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
736 "Default host name for the whois service."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
737 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
738 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
739 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
740
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
741 (defcustom whois-server-list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
742 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
743 ("rs.internic.net") ; domain related info
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
744 ("whois.abuse.net")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
745 ("whois.apnic.net")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
746 ("nic.ddn.mil")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
747 ("whois.nic.mil")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
748 ("whois.nic.gov")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
749 ("whois.ripe.net"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
750 "A list of whois servers that can be queried."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
751 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
752 :type '(repeat (list string)))
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 (defcustom whois-server-tld
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
755 '(("rs.internic.net" . "com")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
756 ("rs.internic.net" . "org")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
757 ("whois.ripe.net" . "be")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
758 ("whois.ripe.net" . "de")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
759 ("whois.ripe.net" . "dk")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
760 ("whois.ripe.net" . "it")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
761 ("whois.ripe.net" . "fi")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
762 ("whois.ripe.net" . "fr")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
763 ("whois.ripe.net" . "uk")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
764 ("whois.apnic.net" . "au")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
765 ("whois.apnic.net" . "ch")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
766 ("whois.apnic.net" . "hk")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
767 ("whois.apnic.net" . "jp")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
768 ("whois.nic.gov" . "gov")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
769 ("whois.nic.mil" . "mil"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
770 "Alist to map top level domains to whois servers."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
771 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
772 :type '(repeat (cons string string)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
773
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
774 (defcustom whois-guess-server t
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
775 "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
776 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
777 then the server named by whois-server-name is used."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
778 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
779 :type 'boolean)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
780
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
781 (defun whois-get-tld (host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782 "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
783 (let ((i (1- (length host)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
784 (max-len (- (length host) 5)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
785 (while (not (or (= i max-len) (char-equal (aref host i) ?.)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
786 (setq i (1- i)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
787 (if (= i max-len)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
788 nil
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
789 (substring host (1+ i)))))
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 ;; Whois protocol
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
792 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
793 (defun whois (arg search-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
794 "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
795 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
796 from SEARCH-STRING. With argument, prompt for whois server."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
797 (interactive "P\nsWhois: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
798 (let* ((whois-apropos-host (if whois-guess-server
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
799 (rassoc (whois-get-tld search-string)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
800 whois-server-tld)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
801 nil))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
802 (server-name (if whois-apropos-host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
803 (car whois-apropos-host)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
804 whois-server-name))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
805 (host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
806 (if arg
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
807 (completing-read "Whois server name: "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
808 whois-server-list nil nil "whois.")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
809 server-name)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
810 (run-network-program
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
811 "Whois"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
812 host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
813 (cdr (assoc 'whois network-connection-service-alist))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
814 search-string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
815 )))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
816
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
817 (defcustom whois-reverse-lookup-server "whois.arin.net"
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
818 "Server which provides inverse DNS mapping."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
819 :group 'net-utils
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
820 :type 'string
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
821 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
822
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
823 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
824 (defun whois-reverse-lookup ()
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
825 (interactive)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
826 (let ((whois-server-name whois-reverse-lookup-server))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
827 (call-interactively 'whois)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
828
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
829 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
830 ;;; General Network connection
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
831 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
832
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
833 ;; Using a derived mode gives us keymaps, hooks, etc.
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
834 (define-derived-mode
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
835 network-connection-mode comint-mode "Network-Connection"
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
836 "Major mode for interacting with the network-connection program."
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
837 )
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
838
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
839 (defun network-connection-mode-setup (host service)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
840 (let ((network-abbrev-table
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
841 (or
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
842 (assoc service network-connection-service-abbrev-alist)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
843 (and (rassoc service network-connection-service-alist)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
844 (assoc
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
845 (elt (rassoc service network-connection-service-alist) 0)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
846 network-connection-service-abbrev-alist)))))
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
847 (make-local-variable 'network-connection-host)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
848 (setq network-connection-host host)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
849 (make-local-variable 'network-connection-service)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
850 (setq network-connection-service service)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
851 (and network-abbrev-table
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
852 (setq local-abbrev-table (cdr network-abbrev-table))
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
853 (abbrev-mode t)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
854 )))
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
855
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
856 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
857 (defun network-connection-to-service (host service)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
858 "Open a network connection to SERVICE on HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
859 (interactive
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
860 (list
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
861 (read-from-minibuffer "Host: " (net-utils-machine-at-point))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
862 (completing-read "Service: "
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
863 (mapcar
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
864 (function
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
865 (lambda (elt)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
866 (list (symbol-name (car elt)))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
867 network-connection-service-alist))))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
868 (network-connection
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
869 host
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
870 (cdr (assoc (intern service) network-connection-service-alist)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
871 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
872
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
873 ;;;###autoload
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
874 (defun network-connection (host port)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
875 "Open a network connection to HOST on PORT."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
876 (interactive "sHost: \nnPort: ")
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
877 (network-service-connection host (number-to-string port)))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
878
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
879 (defun network-service-connection (host service)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
880 "Open a network connection to SERVICE on HOST."
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
881 (require 'comint)
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
882 (let* (
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
883 (process-name (concat "Network Connection [" host " " service "]"))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
884 (portnum (string-to-number service))
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
885 (buf (get-buffer-create (concat "*" process-name "*")))
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
886 )
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
887 (or (zerop portnum) (setq service portnum))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
888 (make-comint
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
889 process-name
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
890 (cons host service))
28419
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
891 (set-buffer buf)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
892 (network-connection-mode)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
893 (network-connection-mode-setup host service)
fed834403704 network-connection-mode is derived from comint-mode
Peter Breton <pbreton@attbi.com>
parents: 28210
diff changeset
894 (pop-to-buffer buf)
28210
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
895 ))
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
896
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
897 (provide 'net-utils)
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
898
b56f9152e329 Moved here from lisp.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
899 ;;; net-utils.el ends here