annotate lisp/net-utils.el @ 24674:d0dee612f8e3

[andrewi] (dumpglyphs): On Windows NT, do output in Unicode even for ASCII, if enabled, to avoid memory allocation overhead for implicit Unicode conversion. Also, recognize that ASCII and Latin-1 have a trivial conversion to Unicode, so x_2byte_buffer lready contains the Unicode characters in that case. (construct_drag_n_drop): Remove old code that was trashing the drop location. [jasonr] (w32_write_glyphs, w32_clear_end_of_line, w32_clear_frame, clear_cursor, x_display_bar_cursor, x_display_box_cursor, x_set_window_size): Use phys_cursor_on field in frame. (do_line_dance): Updated WRT xterm.c. Use macros where possible. (dumprectangle): Take into account the width of a left-side scroll bar.
author Andrew Innes <andrewi@gnu.org>
date Sun, 02 May 1999 10:34:21 +0000
parents ccedc9675dab
children 1d78cd7c460d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
1 ;;; net-utils.el --- Network functions
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
2
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
3 ;; Author: Peter Breton <pbreton@cs.umb.edu>
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
4 ;; Created: Sun Mar 16 1997
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
5 ;; Keywords: network communications
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
6 ;; Time-stamp: <1998-06-13 06:19:01 pbreton>
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
7
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
9
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
13 ;; any later version.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
14
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
18 ;; GNU General Public License for more details.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
19
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
24
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
25 ;;; Commentary:
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
26 ;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
27 ;; There are three main areas of functionality:
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
28 ;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
29 ;; * Wrap common network utility programs (ping, traceroute, netstat,
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
30 ;; nslookup, arp, route). Note that these wrappers are of the diagnostic
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
31 ;; functions of these programs only.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
32 ;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
33 ;; * Implement some very basic protocols in Emacs Lisp (finger and whois)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
34 ;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
35 ;; * Support connections to HOST/PORT, generally for debugging and the like.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
36 ;; In other words, for doing much the same thing as "telnet HOST PORT", and
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
37 ;; then typing commands.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
38 ;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
39 ;; PATHS
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
40 ;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
41 ;; On some systems, some of these programs are not in normal user path,
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
42 ;; but rather in /sbin, /usr/sbin, and so on.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
43
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
44
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
45 ;;; Code:
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
46 (eval-when-compile
23359
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
47 (require 'comint))
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
48
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
50 ;; Customization Variables
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
51 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
52
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
53 (defgroup net-utils nil
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
54 "Network utility functions."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
55 :prefix "net-utils-"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
56 :group 'comm
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
57 :version "20.3"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
58 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
59
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
60 (defcustom net-utils-remove-ctl-m
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
61 (member system-type (list 'windows-nt 'msdos))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
62 "If non-nil, remove control-Ms from output."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
63 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
64 :type 'boolean
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
65 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
66
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
67 (defcustom traceroute-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
68 (if (eq system-type 'windows-nt)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
69 "tracert"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
70 "traceroute")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
71 "Program to trace network hops to a destination."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
72 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
73 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
74 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
75
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
76 (defcustom traceroute-program-options nil
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
77 "Options for the traceroute program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
78 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
79 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
80 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
81
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
82 (defcustom ping-program "ping"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
83 "Program to send network test packets to a host."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
84 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
85 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
86 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
87
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
88 ;; On Linux and Irix, the system's ping program seems to send packets
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
89 ;; indefinitely unless told otherwise
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
90 (defcustom ping-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
91 (and (memq system-type (list 'linux 'gnu/linux 'irix))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
92 (list "-c" "4"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
93 "Options for the ping program.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
94 These options can be used to limit how many ICMP packets are emitted."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
95 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
96 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
97 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
98
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
99 (defcustom ipconfig-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
100 (if (eq system-type 'windows-nt)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
101 "ipconfig"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
102 "ifconfig")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
103 "Program to print network configuration information."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
104 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
105 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
106 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
107
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
108 (defcustom ipconfig-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
109 (list
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
110 (if (eq system-type 'windows-nt)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
111 "/all" "-a"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
112 "Options for ipconfig-program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
113 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
114 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
115 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
116
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
117 (defcustom netstat-program "netstat"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
118 "Program to print network statistics."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
119 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
120 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
121 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
122
23187
205f3fab9564 (netstat-program-options): Changed from nil to "-a"
Karl Heuer <kwzh@gnu.org>
parents: 22537
diff changeset
123 (defcustom netstat-program-options
205f3fab9564 (netstat-program-options): Changed from nil to "-a"
Karl Heuer <kwzh@gnu.org>
parents: 22537
diff changeset
124 (list "-a")
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
125 "Options for netstat-program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
126 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
127 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
128 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
129
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
130 (defcustom arp-program "arp"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
131 "Program to print IP to address translation tables."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
132 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
133 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
134 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
135
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
136 (defcustom arp-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
137 (list "-a")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
138 "Options for arp-program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
139 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
140 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
141 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
142
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
143 (defcustom route-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
144 (if (eq system-type 'windows-nt)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
145 "route"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
146 "netstat")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
147 "Program to print routing tables."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
148 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
149 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
150 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
151
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
152 (defcustom route-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
153 (if (eq system-type 'windows-nt)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
154 (list "print")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
155 (list "-r"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
156 "Options for route-program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
157 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
158 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
159 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
160
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
161 (defcustom nslookup-program "nslookup"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
162 "Program to interactively query DNS information."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
163 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
164 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
165 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
166
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
167 (defcustom nslookup-program-options nil
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
168 "List of options to pass to the nslookup program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
169 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
170 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
171 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
172
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
173 (defcustom nslookup-prompt-regexp "^> "
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
174 "Regexp to match the nslookup prompt."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
175 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
176 :type 'regexp
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
177 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
178
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
179 (defcustom ftp-program "ftp"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
180 "Progam to run to do FTP transfers."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
181 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
182 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
183 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
184
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
185 (defcustom ftp-program-options nil
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
186 "List of options to pass to the FTP program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
187 :group 'net-utils
23269
16780f249ece (traceroute-program-options, ping-program-options,
Andreas Schwab <schwab@suse.de>
parents: 23187
diff changeset
188 :type '(repeat string)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
189 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
190
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
191 (defcustom ftp-prompt-regexp "^ftp>"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
192 "Regexp which matches the FTP program's prompt."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
193 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
194 :type 'regexp
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
195 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
196
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
197 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
198 ;; Nslookup goodies
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
199 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
200
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
201 (defconst nslookup-font-lock-keywords
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
202 (and window-system
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
203 (progn
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
204 (require 'font-lock)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
205 (list
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
206 (list nslookup-prompt-regexp 0 font-lock-reference-face)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
207 (list "^[A-Za-z0-9 _]+:" 0 font-lock-type-face)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
208 (list "\\<\\(SOA\\|NS\\|MX\\|A\\|CNAME\\)\\>"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
209 1 font-lock-keyword-face)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
210 ;; Dotted quads
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
211 (list
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
212 (mapconcat 'identity
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
213 (make-list 4 "[0-9]+")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
214 "\\.")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
215 0 font-lock-variable-name-face)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
216 ;; Host names
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
217 (list
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
218 (let ((host-expression "[-A-Za-z0-9]+"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
219 (concat
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
220 (mapconcat 'identity
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
221 (make-list 2 host-expression)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
222 "\\.")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
223 "\\(\\." host-expression "\\)*")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
224 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
225 0 font-lock-variable-name-face)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
226 )))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
227 "Expressions to font-lock for nslookup.")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
228
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
229 (defvar nslookup-abbrev-table (make-abbrev-table)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
230 "Abbrev table for nslookup.")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
231
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
232 (define-abbrev nslookup-abbrev-table "e" "exit")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
233 (define-abbrev nslookup-abbrev-table "f" "finger")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
234 (define-abbrev nslookup-abbrev-table "h" "help")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
235 (define-abbrev nslookup-abbrev-table "lse" "lserver")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
236 (define-abbrev nslookup-abbrev-table "r" "root")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
237 (define-abbrev nslookup-abbrev-table "s" "set")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
238 (define-abbrev nslookup-abbrev-table "se" "server")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
239 (define-abbrev nslookup-abbrev-table "v" "viewer")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
240
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
241 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
242 ;; FTP goodies
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
243 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
244
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
245 (defvar ftp-abbrev-table (make-abbrev-table)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
246 "Abbrev table for ftp.")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
247
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
248 (define-abbrev ftp-abbrev-table "q" "quit")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
249 (define-abbrev ftp-abbrev-table "g" "get")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
250 (define-abbrev ftp-abbrev-table "p" "prompt")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
251 (define-abbrev ftp-abbrev-table "anon" "anonymous")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
252
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
253 (defconst ftp-font-lock-keywords
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
254 (and window-system
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
255 (progn
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
256 (require 'font-lock)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
257 (list
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
258 (list ftp-prompt-regexp 0 font-lock-reference-face)))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
259
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
260
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
261 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
262 ;; Utility functions
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
263 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
264
23359
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
265 ;; Simplified versions of some at-point functions from ffap.el.
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
266 ;; It's not worth loading all of ffap just for these.
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
267 (defun net-utils-machine-at-point ()
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
268 (let ((pt (point)))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
269 (buffer-substring-no-properties
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
270 (save-excursion
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
271 (skip-chars-backward "-a-zA-Z0-9.")
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
272 (point))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
273 (save-excursion
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
274 (skip-chars-forward "-a-zA-Z0-9.")
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
275 (skip-chars-backward "." pt)
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
276 (point)))))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
277
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
278 (defun net-utils-url-at-point ()
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
279 (let ((pt (point)))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
280 (buffer-substring-no-properties
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
281 (save-excursion
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
282 (skip-chars-backward "--:=&?$+@-Z_a-z~#,%")
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
283 (skip-chars-forward "^A-Za-z0-9" pt)
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
284 (point))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
285 (save-excursion
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
286 (skip-chars-forward "--:=&?$+@-Z_a-z~#,%")
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
287 (skip-chars-backward ":;.,!?" pt)
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
288 (point)))))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
289
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
290
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
291 (defun net-utils-remove-ctrl-m-filter (process output-string)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
292 "Remove trailing control Ms."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
293 (let ((old-buffer (current-buffer))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
294 (filtered-string output-string))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
295 (unwind-protect
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
296 (let ((moving))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
297 (set-buffer (process-buffer process))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
298 (setq moving (= (point) (process-mark process)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
299
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
300 (while (string-match "\r" filtered-string)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
301 (setq filtered-string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
302 (replace-match "" nil nil filtered-string)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
303
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
304 (save-excursion
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
305 ;; Insert the text, moving the process-marker.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
306 (goto-char (process-mark process))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
307 (insert filtered-string)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
308 (set-marker (process-mark process) (point)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
309 (if moving (goto-char (process-mark process))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
310 (set-buffer old-buffer))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
311
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
312 (defmacro net-utils-run-program (name header program &rest args)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
313 "Run a network information program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
314 (`
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
315 (let ((buf (get-buffer-create (concat "*" (, name) "*"))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
316 (set-buffer buf)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
317 (erase-buffer)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
318 (insert (, header) "\n")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
319 (set-process-filter
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
320 (apply 'start-process (, name) buf (, program) (,@ args))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
321 'net-utils-remove-ctrl-m-filter)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
322 (display-buffer buf))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
323
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
324 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
325 ;; Wrappers for external network programs
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
326 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
327
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
328 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
329 (defun traceroute (target)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
330 "Run traceroute program for TARGET."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
331 (interactive "sTarget: ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
332 (let ((options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
333 (if traceroute-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
334 (append traceroute-program-options (list target))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
335 (list target))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
336 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
337 (concat "Traceroute" " " target)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
338 (concat "** Traceroute ** " traceroute-program " ** " target)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
339 traceroute-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
340 options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
341 )))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
342
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
343 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
344 (defun ping (host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
345 "Ping HOST.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
346 If your system's ping continues until interrupted, you can try setting
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
347 `ping-program-options'."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
348 (interactive
23359
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
349 (list (read-from-minibuffer "Ping host: " (net-utils-machine-at-point))))
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
350 (let ((options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
351 (if ping-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
352 (append ping-program-options (list host))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
353 (list host))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
354 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
355 (concat "Ping" " " host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
356 (concat "** Ping ** " ping-program " ** " host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
357 ping-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
358 options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
359 )))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
360
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
361 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
362 (defun ipconfig ()
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
363 "Run ipconfig program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
364 (interactive)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
365 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
366 "Ipconfig"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
367 (concat "** Ipconfig ** " ipconfig-program " ** ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
368 ipconfig-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
369 ipconfig-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
370 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
371
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
372 ;; This is the normal name on most Unixes.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
373 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
374 (defalias 'ifconfig 'ipconfig)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
375
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
376 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
377 (defun netstat ()
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
378 "Run netstat program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
379 (interactive)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
380 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
381 "Netstat"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
382 (concat "** Netstat ** " netstat-program " ** ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
383 netstat-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
384 netstat-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
385 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
386
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
387 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
388 (defun arp ()
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
389 "Run the arp program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
390 (interactive)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
391 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
392 "Arp"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
393 (concat "** Arp ** " arp-program " ** ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
394 arp-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
395 arp-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
396 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
397
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
398 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
399 (defun route ()
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
400 "Run the route program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
401 (interactive)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
402 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
403 "Route"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
404 (concat "** Route ** " route-program " ** ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
405 route-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
406 route-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
407 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
408
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
409 ;; FIXME -- Needs to be a process filter
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
410 ;; (defun netstat-with-filter (filter)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
411 ;; "Run netstat program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
412 ;; (interactive "sFilter: ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
413 ;; (netstat)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
414 ;; (set-buffer (get-buffer "*Netstat*"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
415 ;; (goto-char (point-min))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
416 ;; (delete-matching-lines filter)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
417 ;; )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
418
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
419 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
420 (defun nslookup-host (host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
421 "Lookup the DNS information for HOST."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
422 (interactive
23359
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
423 (list (read-from-minibuffer "Lookup host: " (net-utils-machine-at-point))))
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
424 (let ((options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
425 (if nslookup-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
426 (append nslookup-program-options (list host))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
427 (list host))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
428 (net-utils-run-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
429 "Nslookup"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
430 (concat "** "
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
431 (mapconcat 'identity
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
432 (list "Nslookup" host nslookup-program)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
433 " ** "))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
434 nslookup-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
435 options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
436 )))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
437
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
438
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
439 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
440 (defun nslookup ()
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
441 "Run nslookup program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
442 (interactive)
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
443 (require 'comint)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
444 (comint-run nslookup-program)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
445 (set-process-filter (get-buffer-process "*nslookup*")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
446 'net-utils-remove-ctrl-m-filter)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
447 (set
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
448 (make-local-variable 'font-lock-defaults)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
449 '((nslookup-font-lock-keywords)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
450 (set
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
451 (make-local-variable 'local-abbrev-table)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
452 nslookup-abbrev-table)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
453 (abbrev-mode t)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
454 (make-local-variable 'comint-prompt-regexp)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
455 (setq comint-prompt-regexp nslookup-prompt-regexp)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
456 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
457
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
458 ;; This is a lot less than ange-ftp, but much simpler.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
459 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
460 (defun ftp (host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
461 "Run ftp program."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
462 (interactive "sFtp to Host: ")
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
463 (require 'comint)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
464 (let ((buf (get-buffer-create (concat "*ftp [" host "]*"))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
465 (set-buffer buf)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
466 (comint-mode)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
467 (comint-exec buf (concat "ftp-" host) ftp-program nil
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
468 (if ftp-program-options
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
469 (append (list host) ftp-program-options)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
470 (list host)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
471 (set
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
472 (make-local-variable 'font-lock-defaults)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
473 '((ftp-font-lock-keywords)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
474
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
475 (make-local-variable 'comint-prompt-regexp)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
476 (setq comint-prompt-regexp ftp-prompt-regexp)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
477
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
478 ;; Already buffer local!
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
479 (setq comint-output-filter-functions
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
480 (list 'comint-watch-for-password-prompt))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
481 (set
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
482 (make-local-variable 'local-abbrev-table)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
483 ftp-abbrev-table)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
484 (abbrev-mode t)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
485 (switch-to-buffer-other-window buf)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
486 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
487
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
488 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
489 ;; Network Connections
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
490 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
491
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
492 ;; Full list is available at:
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
493 ;; ftp://ftp.isi.edu/in-notes/iana/assignments/port-numbers
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
494 (defvar network-connection-service-alist
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
495 (list
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
496 (cons 'echo 7)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
497 (cons 'active-users 11)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
498 (cons 'daytime 13)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
499 (cons 'chargen 19)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
500 (cons 'ftp 21)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
501 (cons 'telnet 23)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
502 (cons 'smtp 25)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
503 (cons 'time 37)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
504 (cons 'whois 43)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
505 (cons 'gopher 70)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
506 (cons 'finger 79)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
507 (cons 'www 80)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
508 (cons 'pop2 109)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
509 (cons 'pop3 110)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
510 (cons 'sun-rpc 111)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
511 (cons 'nntp 119)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
512 (cons 'ntp 123)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
513 (cons 'netbios-name 137)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
514 (cons 'netbios-data 139)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
515 (cons 'irc 194)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
516 (cons 'https 443)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
517 (cons 'rlogin 513)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
518 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
519 "Alist of services and associated TCP port numbers.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
520 This list in not complete.")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
521
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
522 ;; Workhorse macro
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
523 (defmacro run-network-program (process-name host port
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
524 &optional initial-string)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
525 (`
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
526 (let ((tcp-connection)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
527 (buf)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
528 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
529 (setq buf (get-buffer-create (concat "*" (, process-name) "*")))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
530 (set-buffer buf)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
531 (or
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
532 (setq tcp-connection
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
533 (open-network-stream
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
534 (, process-name)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
535 buf
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
536 (, host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
537 (, port)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
538 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
539 (error "Could not open connection to %s" (, host)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
540 (erase-buffer)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
541 (set-marker (process-mark tcp-connection) (point-min))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
542 (set-process-filter tcp-connection 'net-utils-remove-ctrl-m-filter)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
543 (and (, initial-string)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
544 (process-send-string tcp-connection
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
545 (concat (, initial-string) "\r\n")))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
546 (display-buffer buf))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
547
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
548 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
549 ;; Simple protocols
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
550 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
551
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
552 ;; Finger protocol
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
553 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
554 (defun finger (user host)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
555 "Finger USER on HOST."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
556 ;; One of those great interactive statements that's actually
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
557 ;; longer than the function call! The idea is that if the user
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
558 ;; uses a string like "pbreton@cs.umb.edu", we won't ask for the
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
559 ;; host name. If we don't see an "@", we'll prompt for the host.
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
560 (interactive
23359
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
561 (let* ((answer (read-from-minibuffer "Finger User: "
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
562 (net-utils-url-at-point)))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
563 (index (string-match (regexp-quote "@") answer)))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
564 (if index
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
565 (list
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
566 (substring answer 0 index)
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
567 (substring answer (1+ index)))
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
568 (list
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
569 answer
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
570 (read-from-minibuffer "At Host: " (net-utils-machine-at-point))))))
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
571 (let* (
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
572 (user-and-host (concat user "@" host))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
573 (process-name
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
574 (concat "Finger [" user-and-host "]"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
575 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
576 (run-network-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
577 process-name
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
578 host
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
579 (cdr (assoc 'finger network-connection-service-alist))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
580 user-and-host
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
581 )))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
582
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
583 (defcustom whois-server-name "whois.arin.net"
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
584 "Default host name for the whois service."
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
585 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
586 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
587 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
588
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
589 (defcustom whois-server-list
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
590 '(("whois.arin.net") ; Networks, ASN's, and related POC's (numbers)
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
591 ("rs.internic.net") ; domain related info
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
592 ("whois.abuse.net")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
593 ("whois.apnic.net")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
594 ("nic.ddn.mil")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
595 ("whois.nic.mil")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
596 ("whois.nic.gov")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
597 ("whois.ripe.net"))
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
598 "A list of whois servers that can be queried."
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
599 :group 'net-utils
23479
8256c4d22113 (whois-server-list): Fix customization type.
Richard M. Stallman <rms@gnu.org>
parents: 23391
diff changeset
600 :type '(repeat (list string)))
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
601
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
602 (defcustom whois-server-tld
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
603 '(("rs.internic.net" . "com")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
604 ("rs.internic.net" . "org")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
605 ("whois.ripe.net" . "be")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
606 ("whois.ripe.net" . "de")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
607 ("whois.ripe.net" . "dk")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
608 ("whois.ripe.net" . "it")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
609 ("whois.ripe.net" . "fi")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
610 ("whois.ripe.net" . "fr")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
611 ("whois.ripe.net" . "uk")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
612 ("whois.apnic.net" . "au")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
613 ("whois.apnic.net" . "ch")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
614 ("whois.apnic.net" . "hk")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
615 ("whois.apnic.net" . "jp")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
616 ("whois.nic.gov" . "gov")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
617 ("whois.nic.mil" . "mil"))
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
618 "Alist to map top level domains to whois servers."
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
619 :group 'net-utils
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
620 :type '(repeat (cons string string)))
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
621
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
622 (defcustom whois-guess-server t
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
623 "If non-nil then whois will try to deduce the appropriate whois
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
624 server from the query. If the query doesn't look like a domain or hostname
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
625 then the server named by whois-server-name is used."
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
626 :group 'net-utils
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
627 :type 'boolean)
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
628
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
629 (defun whois-get-tld (host)
23529
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
630 "Return the top level domain of `host', or nil if it isn't a domain name."
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
631 (let ((i (1- (length host)))
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
632 (max-len (- (length host) 5)))
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
633 (while (not (or (= i max-len) (char-equal (aref host i) ?.)))
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
634 (setq i (1- i)))
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
635 (if (= i max-len)
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
636 nil
ccedc9675dab (whois-get-tld): Rewrite not to use `do'.
Richard M. Stallman <rms@gnu.org>
parents: 23479
diff changeset
637 (substring host (1+ i)))))
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
638
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
639 ;; Whois protocol
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
640 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
641 (defun whois (arg search-string)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
642 "Send SEARCH-STRING to server defined by the `whois-server-name' variable.
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
643 If `whois-guess-server' is non-nil, then try to deduce the correct server
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
644 from SEARCH-STRING. With argument, prompt for whois server."
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
645 (interactive "P\nsWhois: ")
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
646 (let* ((whois-apropos-host (if whois-guess-server
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
647 (rassoc (whois-get-tld search-string)
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
648 whois-server-tld)
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
649 nil))
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
650 (server-name (if whois-apropos-host
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
651 (car whois-apropos-host)
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
652 whois-server-name))
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
653 (host
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
654 (if arg
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
655 (completing-read "Whois server name: "
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
656 whois-server-list nil nil "whois.")
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
657 server-name)))
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
658 (run-network-program
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
659 "Whois"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
660 host
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
661 (cdr (assoc 'whois network-connection-service-alist))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
662 search-string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
663 )))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
664
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
665 (defcustom whois-reverse-lookup-server "whois.arin.net"
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
666 "Server which provides inverse DNS mapping."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
667 :group 'net-utils
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
668 :type 'string
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
669 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
670
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
671 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
672 (defun whois-reverse-lookup ()
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
673 (interactive)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
674 (let ((whois-server-name whois-reverse-lookup-server))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
675 (call-interactively 'whois)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
676
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
677 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
678 ;;; General Network connection
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
679 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
680
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
681 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
682 (defun network-connection-to-service (host service)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
683 "Open a network connection to SERVICE on HOST."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
684 (interactive
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
685 (list
23359
0757f6ee2e53 Don't require ffap.
Karl Heuer <kwzh@gnu.org>
parents: 23269
diff changeset
686 (read-from-minibuffer "Host: " (net-utils-machine-at-point))
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
687 (completing-read "Service: "
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
688 (mapcar
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
689 (function
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
690 (lambda (elt)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
691 (list (symbol-name (car elt)))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
692 network-connection-service-alist))))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
693 (network-connection
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
694 host
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
695 (cdr (assoc (intern service) network-connection-service-alist)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
696 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
697
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
698 ;;;###autoload
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
699 (defun network-connection (host port)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
700 "Open a network connection to HOST on PORT."
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
701 (interactive "sHost: \nnPort: ")
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
702 (network-service-connection host (number-to-string port)))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
703
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
704 (defun network-service-connection (host service)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
705 "Open a network connection to SERVICE on HOST."
23391
4120f9e06191 (ftp, nslookup): Require comint.
Karl Heuer <kwzh@gnu.org>
parents: 23359
diff changeset
706 (require 'comint)
22537
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
707 (let (
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
708 (process-name (concat "Network Connection [" host " " service "]"))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
709 (portnum (string-to-number service))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
710 )
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
711 (or (zerop portnum) (setq service portnum))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
712 (make-comint
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
713 process-name
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
714 (cons host service))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
715 (pop-to-buffer (get-buffer (concat "*" process-name "*")))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
716 ))
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
717
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
718 (provide 'net-utils)
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
719
7947a4ea28a8 Initial revision
Dan Nicolaescu <done@ece.arizona.edu>
parents:
diff changeset
720 ;;; net-utils.el ends here