annotate lisp/w3/url-gw.el @ 82:6a378aca36af r20-0b91

Import from CVS: tag r20-0b91
author cvs
date Mon, 13 Aug 2007 09:07:36 +0200
parents 0293115a14e9
children 859a2309aef8 0d2f883870bc
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
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
3 ;; Created: 1997/01/16 14:17:34
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
4 ;; Version: 1.3
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
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
29 (defvar url-gateway-local-host-regexp nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
30 "*A regular expression specifying local hostnames/machines.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
31
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
32 (defvar url-gateway-prompt-pattern
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
33 "^[^#$%>;]*[#$%>;] *" ;; "bash\\|\$ *\r?$\\|> *\r?"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
34 "*A regular expression matching a shell prompt.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
35
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
36 (defvar url-gateway-rlogin-host nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
37 "*What hostname to actually rlog into before doing a telnet.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
38
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
39 (defvar url-gateway-rlogin-user-name nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
40 "*Username to log into the remote machine with when using rlogin.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
41
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
42 (defvar url-gateway-rlogin-parameters '("telnet" "-8")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
43 "*Parameters to `url-open-rlogin'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
44 This list will be used as the parameter list given to rsh.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
45
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
46 (defvar url-gateway-telnet-host nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
47 "*What hostname to actually login to before doing a telnet.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
48
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
49 (defvar url-gateway-telnet-parameters '("exec" "telnet" "-8")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
50 "*Parameters to `url-open-telnet'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
51 This list will be executed as a command after logging in via telnet.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
52
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
53 (defvar url-gateway-telnet-login-prompt "^\r*.?login:"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
54 "*Prompt that tells us we should send our username when loggin in w/telnet.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
55
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
56 (defvar url-gateway-telnet-password-prompt "^\r*.?password:"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
57 "*Prompt that tells us we should send our password when loggin in w/telnet.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
58
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
59 (defvar url-gateway-telnet-user-name nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
60 "User name to log in via telnet with.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
61
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
62 (defvar url-gateway-telnet-password nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
63 "Password to use to log in via telnet with.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
64
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
65 (defvar url-gateway-broken-resolution nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
66 "*Whether to use nslookup to resolve hostnames.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
67 This should be used when your version of Emacs cannot correctly use DNS,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
68 but your machine can. This usually happens if you are running a statically
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
69 linked Emacs under SunOS 4.x")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
70
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
71 (defvar url-gateway-nslookup-program nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
72 "*If non-NIL then a string naming nslookup program." )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
73
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
74 ;; Stolen from ange-ftp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
75 (defun url-gateway-nslookup-host (host)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
76 "Attempt to resolve the given HOSTNAME using nslookup if possible."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
77 (interactive "sHost: ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
78 (if url-gateway-nslookup-program
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
79 (let ((proc (start-process " *nslookup*" " *nslookup*"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
80 url-gateway-nslookup-program host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
81 (res host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
82 (process-kill-without-query proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
83 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
84 (set-buffer (process-buffer proc))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
85 (while (memq (process-status proc) '(run open))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
86 (accept-process-output proc))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
87 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
88 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
89 (setq res (buffer-substring (match-beginning 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
90 (match-end 1))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
91 (kill-buffer (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
92 res)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
93 host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
94
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
95 ;; Stolen from red gnus nntp.el
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
96 (defun url-wait-for-string (regexp proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
97 "Wait until string arrives in the buffer."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
98 (let ((buf (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
99 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
100 (while (not (re-search-forward regexp nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
101 (accept-process-output proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
102 (set-buffer buf)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
103 (goto-char (point-min)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
104
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
105 ;; Stolen from red gnus nntp.el
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
106 (defun url-open-rlogin (name buffer host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
107 "Open a connection using rsh."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
108 (if (not (stringp service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
109 (setq service (into-to-string service)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
110 (let ((proc (if url-gateway-rlogin-user-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
111 (start-process
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
112 name buffer "rsh"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
113 url-gateway-rlogin-host "-l" url-gateway-rlogin-user-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
114 (mapconcat 'identity
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
115 (append url-gateway-rlogin-parameters
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
116 (list host service)) " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
117 (start-process
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
118 name buffer "rsh" url-gateway-rlogin-host
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
119 (mapconcat 'identity
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
120 (append url-gateway-rlogin-parameters
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
121 (list host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
122 " ")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
123 (set-buffer buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
124 (url-wait-for-string "^\r*200" proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
125 (beginning-of-line)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
126 (delete-region (point-min) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
127 proc))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
128
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
129 ;; Stolen from red gnus nntp.el
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
130 (defun url-open-telnet (name buffer host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
131 (if (not (stringp service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
132 (setq service (into-to-string service)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
133 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
134 (set-buffer (get-buffer-create buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
135 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
136 (let ((proc (start-process name buffer "telnet" "-8"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
137 (case-fold-search t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
138 (when (memq (process-status proc) '(open run))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
139 (process-send-string proc "set escape \^X\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
140 (process-send-string proc (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
141 "open " url-gateway-telnet-host "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
142 (url-wait-for-string url-gateway-telnet-login-prompt proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
143 (process-send-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
144 proc (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
145 (or url-gateway-telnet-user-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
146 (setq url-gateway-telnet-user-name (read-string "login: ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
147 "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
148 (url-wait-for-string url-gateway-telnet-password-prompt proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
149 (process-send-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
150 proc (concat
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
151 (or url-gateway-telnet-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
152 (setq url-gateway-telnet-password
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
153 (funcall url-passwd-entry-func "Password: ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
154 "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
155 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
156 (url-wait-for-string url-gateway-prompt-pattern proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
157 (process-send-string
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
158 proc (concat (mapconcat 'identity
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
159 (append url-gateway-telnet-parameters
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
160 (list host service)) " ") "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
161 (url-wait-for-string "^\r*Escape character.*\r*\n+" proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
162 (delete-region (point-min) (match-end 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
163 (process-send-string proc "\^]\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
164 (url-wait-for-string "^telnet" proc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
165 (process-send-string proc "mode character\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
166 (accept-process-output proc 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
167 (sit-for 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
168 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
169 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
170 (delete-region (point) (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
171 proc)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
172
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
173 ;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
174 (defun url-open-stream (name buffer host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
175 "Open a stream to a host"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
176 (let ((gw-method (if (and url-gateway-local-host-regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
177 (not (eq 'ssl url-gateway-method))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
178 (string-match
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
179 url-gateway-local-host-regexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
180 host))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
181 'native
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
182 url-gateway-method))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
183 ;; 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
184 ;; conversions while trying to be 'helpful'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
185 (tcp-binary-process-output-services (if (stringp service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
186 (list service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
187 (list service
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
188 (int-to-string service))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
189
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
190 ;; An attempt to deal with denied connections, and attempt to reconnect
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
191 (max-retries url-connection-retries)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
192 (cur-retries 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
193 (retry t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
194 (errobj nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
195 (conn nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
196
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
197 ;; If the user told us to do DNS for them, do it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
198 (if url-gateway-broken-resolution
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
199 (setq host (url-nslookup-host host)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
200
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
201 (while (and (not conn) retry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
202 (condition-case errobj
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
203 (setq conn (case gw-method
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
204 (ssl
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
205 (open-ssl-stream name buffer host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
206 ((tcp native)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
207 (and (eq 'tcp gw-method) (require 'tcp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
208 (open-network-stream name buffer host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
209 (socks
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
210 (socks-open-network-stream name buffer host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
211 (telnet
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
212 (url-open-telnet name buffer host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
213 (rlogin
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
214 (url-open-rlogin name buffer host service))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
215 (otherwise
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
216 (error "Bad setting of url-gateway-method: %s"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
217 url-gateway-method))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
218 (error
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
219 (url-save-error errobj)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
220 (save-window-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
221 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
222 (switch-to-buffer-other-window " *url-error*")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
223 (shrink-window-if-larger-than-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
224 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
225 (if (and (re-search-forward "in use" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
226 (< cur-retries max-retries))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
227 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
228 (setq retry t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
229 cur-retries (1+ cur-retries))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
230 (sleep-for 0.5))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
231 (setq cur-retries 0
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
232 retry (funcall url-confirmation-func
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
233 (concat "Connection to " host
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
234 " failed, retry? "))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
235 (kill-buffer (current-buffer)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
236 (if (not conn)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
237 (error "Unable to connect to %s:%s" host service)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
238 (mule-inhibit-code-conversion conn)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
239 conn)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
240
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
241 (provide 'url-gw)