annotate lisp/w3/url-gw.el @ 126:1370575f1259 xemacs-20-1p1

Import from CVS: tag xemacs-20-1p1
author cvs
date Mon, 13 Aug 2007 09:27:39 +0200
parents 9b50b4588a93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1 ;;; url-gw.el --- Gateway munging for URL loading
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
2 ;; Author: wmperry
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
3 ;; Created: 1997/04/11 14:39:18
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
4 ;; Version: 1.9
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
5 ;; Keywords: comm, data, processes
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
6
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
8 ;;; Copyright (c) 1997 Free Software Foundation, Inc.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
9 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
11 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
13 ;;; it under the terms of the GNU General Public License as published by
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
14 ;;; the Free Software Foundation; either version 2, or (at your option)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
15 ;;; any later version.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
16 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
20 ;;; GNU General Public License for more details.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
21 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
22 ;;; You should have received a copy of the GNU General Public License
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
24 ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
25 ;;; Boston, MA 02111-1307, USA.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
27 (require 'cl)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
28
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
29 (defgroup url-gateway nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
30 "URL gateway variables"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
31 :group 'url)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
32
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
33 (defcustom url-gateway-local-host-regexp nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
34 "*A regular expression specifying local hostnames/machines."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
35 :type '(choice (const nil) regexp)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
36 :group 'url-gateway)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
37
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
38 (defcustom url-gateway-prompt-pattern
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
39 "^[^#$%>;]*[#$%>;] *" ;; "bash\\|\$ *\r?$\\|> *\r?"
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
40 "*A regular expression matching a shell prompt."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
41 :type 'regexp
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
42 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
43
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
44 (defcustom url-gateway-rlogin-host nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
45 "*What hostname to actually rlog into before doing a telnet."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
46 :type '(choice (const nil) string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
47 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
48
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
49 (defcustom url-gateway-rlogin-user-name nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
50 "*Username to log into the remote machine with when using rlogin."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
51 :type '(choice (const nil) string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
52 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
53
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
54 (defcustom url-gateway-rlogin-parameters '("telnet" "-8")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
55 "*Parameters to `url-open-rlogin'.
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
56 This list will be used as the parameter list given to rsh."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
57 :type '(repeat string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
58 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
59
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
60 (defcustom url-gateway-telnet-host nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
61 "*What hostname to actually login to before doing a telnet."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
62 :type '(choice (const nil) string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
63 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
64
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
65 (defcustom url-gateway-telnet-parameters '("exec" "telnet" "-8")
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
66 "*Parameters to `url-open-telnet'.
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
67 This list will be executed as a command after logging in via telnet."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
68 :type '(repeat string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
69 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
70
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
71 (defcustom url-gateway-telnet-login-prompt "^\r*.?login:"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
72 "*Prompt that tells us we should send our username when loggin in w/telnet."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
73 :type 'regexp
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
74 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
75
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
76 (defcustom url-gateway-telnet-password-prompt "^\r*.?password:"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
77 "*Prompt that tells us we should send our password when loggin in w/telnet."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
78 :type 'regexp
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
79 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
80
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
81 (defcustom url-gateway-telnet-user-name nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
82 "User name to log in via telnet with."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
83 :type '(choice (const nil) string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
84 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
85
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
86 (defcustom url-gateway-telnet-password nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
87 "Password to use to log in via telnet with."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
88 :type '(choice (const nil) string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
89 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
90
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
91 (defcustom url-gateway-broken-resolution nil
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
92 "*Whether to use nslookup to resolve hostnames.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
93 This should be used when your version of Emacs cannot correctly use DNS,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
94 but your machine can. This usually happens if you are running a statically
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
95 linked Emacs under SunOS 4.x"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
96 :type 'boolean
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
97 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
98
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
99 (defcustom url-gateway-nslookup-program "nslookup"
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
100 "*If non-NIL then a string naming nslookup program."
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
101 :type '(choice (const :tag "None" :value nil) string)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 118
diff changeset
102 :group 'url-gateway)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
103
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
104 ;; Stolen from ange-ftp
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
105 ;;;###autoload
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
106 (defun url-gateway-nslookup-host (host)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
107 "Attempt to resolve the given HOSTNAME using nslookup if possible."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
108 (interactive "sHost: ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
109 (if url-gateway-nslookup-program
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
110 (let ((proc (start-process " *nslookup*" " *nslookup*"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
111 url-gateway-nslookup-program host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
112 (res host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
113 (process-kill-without-query proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
114 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
115 (set-buffer (process-buffer proc))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
116 (while (memq (process-status proc) '(run open))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
117 (accept-process-output proc))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
118 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
119 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
120 (setq res (buffer-substring (match-beginning 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
121 (match-end 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
122 (kill-buffer (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
123 res)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
124 host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
125
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
126 ;; Stolen from red gnus nntp.el
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
127 (defun url-wait-for-string (regexp proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
128 "Wait until string arrives in the buffer."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
129 (let ((buf (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
130 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
131 (while (not (re-search-forward regexp nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
132 (accept-process-output proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
133 (set-buffer buf)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
134 (goto-char (point-min)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
135
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
136 ;; Stolen from red gnus nntp.el
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
137 (defun url-open-rlogin (name buffer host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
138 "Open a connection using rsh."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
139 (if (not (stringp service))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
140 (setq service (int-to-string service)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
141 (let ((proc (if url-gateway-rlogin-user-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
142 (start-process
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
143 name buffer "rsh"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
144 url-gateway-rlogin-host "-l" url-gateway-rlogin-user-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
145 (mapconcat 'identity
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
146 (append url-gateway-rlogin-parameters
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
147 (list host service)) " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
148 (start-process
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
149 name buffer "rsh" url-gateway-rlogin-host
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
150 (mapconcat 'identity
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
151 (append url-gateway-rlogin-parameters
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
152 (list host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
153 " ")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
154 (set-buffer buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
155 (url-wait-for-string "^\r*200" proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
156 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
157 (delete-region (point-min) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
158 proc))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
159
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
160 ;; Stolen from red gnus nntp.el
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
161 (defun url-open-telnet (name buffer host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
162 (if (not (stringp service))
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 98
diff changeset
163 (setq service (int-to-string service)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
164 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
165 (set-buffer (get-buffer-create buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
166 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
167 (let ((proc (start-process name buffer "telnet" "-8"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
168 (case-fold-search t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
169 (when (memq (process-status proc) '(open run))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
170 (process-send-string proc "set escape \^X\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
171 (process-send-string proc (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
172 "open " url-gateway-telnet-host "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
173 (url-wait-for-string url-gateway-telnet-login-prompt proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
174 (process-send-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
175 proc (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
176 (or url-gateway-telnet-user-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
177 (setq url-gateway-telnet-user-name (read-string "login: ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
178 "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
179 (url-wait-for-string url-gateway-telnet-password-prompt proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
180 (process-send-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
181 proc (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
182 (or url-gateway-telnet-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
183 (setq url-gateway-telnet-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
184 (funcall url-passwd-entry-func "Password: ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
185 "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
186 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
187 (url-wait-for-string url-gateway-prompt-pattern proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
188 (process-send-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
189 proc (concat (mapconcat 'identity
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
190 (append url-gateway-telnet-parameters
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
191 (list host service)) " ") "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
192 (url-wait-for-string "^\r*Escape character.*\r*\n+" proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
193 (delete-region (point-min) (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
194 (process-send-string proc "\^]\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
195 (url-wait-for-string "^telnet" proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
196 (process-send-string proc "mode character\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
197 (accept-process-output proc 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
198 (sit-for 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
199 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
200 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
201 (delete-region (point) (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
202 proc)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
203
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
204 ;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
205 (defun url-open-stream (name buffer host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
206 "Open a stream to a host"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
207 (let ((gw-method (if (and url-gateway-local-host-regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
208 (not (eq 'ssl url-gateway-method))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
209 (string-match
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
210 url-gateway-local-host-regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
211 host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
212 'native
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
213 url-gateway-method))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
214 ;; This hack is for OS/2 Emacs so that it will not do bogus CRLF
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
215 ;; conversions while trying to be 'helpful'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
216 (tcp-binary-process-output-services (if (stringp service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
217 (list service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
218 (list service
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
219 (int-to-string service))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
220
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
221 ;; An attempt to deal with denied connections, and attempt to reconnect
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
222 (cur-retries 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
223 (retry t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
224 (errobj nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
225 (conn nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
226
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
227 ;; If the user told us to do DNS for them, do it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
228 (if url-gateway-broken-resolution
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
229 (setq host (url-gateway-nslookup-host host)))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
230
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
231 (condition-case errobj
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
232 (setq conn (case gw-method
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
233 (ssl
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
234 (open-ssl-stream name buffer host service))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
235 ((tcp native)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
236 (and (eq 'tcp gw-method) (require 'tcp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
237 (open-network-stream name buffer host service))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
238 (socks
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
239 (socks-open-network-stream name buffer host service))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
240 (telnet
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
241 (url-open-telnet name buffer host service))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
242 (rlogin
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
243 (url-open-rlogin name buffer host service))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
244 (otherwise
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
245 (error "Bad setting of url-gateway-method: %s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
246 url-gateway-method))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
247 (error
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
248 (insert "Could not contact host: " host " / "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
249 (if (stringp service) service (int-to-string service))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
250 "\nAttempted using gateway method: "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
251 (symbol-name gw-method)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
252 "\n---- Error was: ----\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
253 (setq url-current-mime-headers '(("content-type" . "text/plain")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
254 (display-error errobj (current-buffer))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
255 (if conn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
256 (mule-inhibit-code-conversion conn))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 16
diff changeset
257 conn))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
258
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
259 (provide 'url-gw)