annotate lisp/url/url-gw.el @ 105330:7660578a04ee

(cd-absolute): Don't abbreviate-file-name (bug#4599).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 01 Oct 2009 03:34:04 +0000
parents a9dc0e7c3f2b
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; url-gw.el --- Gateway munging for URL loading
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
2
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 96486
diff changeset
3 ;; Copyright (C) 1997, 1998, 2004, 2005, 2006, 2007, 2008, 2009
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 94668
diff changeset
4 ;; Free Software Foundation, Inc.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
5
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Author: Bill Perry <wmperry@gnu.org>
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7 ;; Keywords: comm, data, processes
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
8
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
9 ;; This file is part of GNU Emacs.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
10
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
14 ;; (at your option) any later version.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
15
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
19 ;; GNU General Public License for more details.
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
20
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
23
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
24 ;;; Code:
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
25
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26 (eval-when-compile (require 'cl))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 (require 'url-vars)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 ;; Fixme: support SSH explicitly or via a url-gateway-rlogin-program?
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 (autoload 'socks-open-network-stream "socks")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 (autoload 'open-ssl-stream "ssl")
57449
202c408c174b url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents: 54770
diff changeset
33 (autoload 'open-tls-stream "tls")
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 (defgroup url-gateway nil
63987
56d2561b1c9f (url-gateway): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 63618
diff changeset
36 "URL gateway variables."
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 :group 'url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 (defcustom url-gateway-local-host-regexp nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 "*A regular expression specifying local hostnames/machines."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 :type '(choice (const nil) regexp)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (defcustom url-gateway-prompt-pattern
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45 "^[^#$%>;]*[#$%>;] *" ;; "bash\\|\$ *\r?$\\|> *\r?"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 "*A regular expression matching a shell prompt."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 :type 'regexp
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (defcustom url-gateway-rlogin-host nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 "*What hostname to actually rlog into before doing a telnet."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 :type '(choice (const nil) string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (defcustom url-gateway-rlogin-user-name nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 "*Username to log into the remote machine with when using rlogin."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 :type '(choice (const nil) string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (defcustom url-gateway-rlogin-parameters '("telnet" "-8")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 "*Parameters to `url-open-rlogin'.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 This list will be used as the parameter list given to rsh."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63 :type '(repeat string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 (defcustom url-gateway-telnet-host nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 "*What hostname to actually login to before doing a telnet."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 :type '(choice (const nil) string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (defcustom url-gateway-telnet-parameters '("exec" "telnet" "-8")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 "*Parameters to `url-open-telnet'.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73 This list will be executed as a command after logging in via telnet."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 :type '(repeat string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (defcustom url-gateway-telnet-login-prompt "^\r*.?login:"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
78 "*Prompt that tells us we should send our username when loggin in w/telnet."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
79 :type 'regexp
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
82 (defcustom url-gateway-telnet-password-prompt "^\r*.?password:"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 "*Prompt that tells us we should send our password when loggin in w/telnet."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 :type 'regexp
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 (defcustom url-gateway-telnet-user-name nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 "User name to log in via telnet with."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 :type '(choice (const nil) string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 (defcustom url-gateway-telnet-password nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 "Password to use to log in via telnet with."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 :type '(choice (const nil) string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (defcustom url-gateway-broken-resolution nil
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
98 "*Whether to use nslookup to resolve hostnames.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
99 This should be used when your version of Emacs cannot correctly use DNS,
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
100 but your machine can. This usually happens if you are running a statically
96486
7369ded3b436 Typo and docstring fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 96361
diff changeset
101 linked Emacs under SunOS 4.x."
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
102 :type 'boolean
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
103 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
104
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
105 (defcustom url-gateway-nslookup-program "nslookup"
74575
34a1ff09106b (url-gateway-nslookup-program): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 73533
diff changeset
106 "*If non-nil then a string naming nslookup program."
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
107 :type '(choice (const :tag "None" :value nil) string)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
108 :group 'url-gateway)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
109
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
110 ;; Stolen from ange-ftp
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
111 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
112 (defun url-gateway-nslookup-host (host)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
113 "Attempt to resolve the given HOST using nslookup if possible."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
114 (interactive "sHost: ")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
115 (if url-gateway-nslookup-program
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
116 (let ((proc (start-process " *nslookup*" " *nslookup*"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
117 url-gateway-nslookup-program host))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
118 (res host))
57620
462b0b8865f7 (url-gateway-nslookup-host): Use `set-process-query-on-exit-flag'.
John Paul Wallington <jpw@pobox.com>
parents: 57612
diff changeset
119 (set-process-query-on-exit-flag proc nil)
70241
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
120 (with-current-buffer (process-buffer proc)
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
121 (while (memq (process-status proc) '(run open))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
122 (accept-process-output proc))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
123 (goto-char (point-min))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
124 (if (re-search-forward "Name:.*\nAddress: *\\(.*\\)$" nil t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
125 (setq res (buffer-substring (match-beginning 1)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
126 (match-end 1))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
127 (kill-buffer (current-buffer)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
128 res)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
129 host))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
130
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
131 ;; Stolen from red gnus nntp.el
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
132 (defun url-wait-for-string (regexp proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
133 "Wait until string matching REGEXP arrives in process PROC's buffer."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
134 (let ((buf (current-buffer)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
135 (goto-char (point-min))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
136 (while (not (re-search-forward regexp nil t))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
137 (accept-process-output proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
138 (set-buffer buf)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
139 (goto-char (point-min)))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
140
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
141 ;; Stolen from red gnus nntp.el
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
142 (defun url-open-rlogin (name buffer host service)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
143 "Open a connection using rsh."
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
144 (if (not (stringp service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
145 (setq service (int-to-string service)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
146 (let ((proc (if url-gateway-rlogin-user-name
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
147 (start-process
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
148 name buffer "rsh"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
149 url-gateway-rlogin-host "-l" url-gateway-rlogin-user-name
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
150 (mapconcat 'identity
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
151 (append url-gateway-rlogin-parameters
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
152 (list host service)) " "))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
153 (start-process
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
154 name buffer "rsh" url-gateway-rlogin-host
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
155 (mapconcat 'identity
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
156 (append url-gateway-rlogin-parameters
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
157 (list host service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
158 " ")))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
159 (set-buffer buffer)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
160 (url-wait-for-string "^\r*200" proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
161 (beginning-of-line)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
162 (delete-region (point-min) (point))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
163 proc))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
164
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
165 ;; Stolen from red gnus nntp.el
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
166 (defun url-open-telnet (name buffer host service)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
167 (if (not (stringp service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
168 (setq service (int-to-string service)))
70241
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
169 (with-current-buffer (get-buffer-create buffer)
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
170 (erase-buffer)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
171 (let ((proc (start-process name buffer "telnet" "-8"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
172 (case-fold-search t))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
173 (when (memq (process-status proc) '(open run))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
174 (process-send-string proc "set escape \^X\n")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
175 (process-send-string proc (concat
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
176 "open " url-gateway-telnet-host "\n"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
177 (url-wait-for-string url-gateway-telnet-login-prompt proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
178 (process-send-string
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
179 proc (concat
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
180 (or url-gateway-telnet-user-name
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
181 (setq url-gateway-telnet-user-name (read-string "login: ")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
182 "\n"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
183 (url-wait-for-string url-gateway-telnet-password-prompt proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
184 (process-send-string
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
185 proc (concat
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
186 (or url-gateway-telnet-password
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
187 (setq url-gateway-telnet-password
57510
9f80571c6c3e (url-open-telnet): Use read-passwd.
Richard M. Stallman <rms@gnu.org>
parents: 57449
diff changeset
188 (read-passwd "Password: ")))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
189 "\n"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
190 (erase-buffer)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
191 (url-wait-for-string url-gateway-prompt-pattern proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
192 (process-send-string
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
193 proc (concat (mapconcat 'identity
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
194 (append url-gateway-telnet-parameters
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
195 (list host service)) " ") "\n"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
196 (url-wait-for-string "^\r*Escape character.*\r*\n+" proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
197 (delete-region (point-min) (match-end 0))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
198 (process-send-string proc "\^]\n")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
199 (url-wait-for-string "^telnet" proc)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
200 (process-send-string proc "mode character\n")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
201 (accept-process-output proc 1)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
202 (sit-for 1)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
203 (goto-char (point-min))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
204 (forward-line 1)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
205 (delete-region (point) (point-max)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
206 proc)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
207
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
208 ;;;###autoload
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
209 (defun url-open-stream (name buffer host service)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
210 "Open a stream to HOST, possibly via a gateway.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
211 Args per `open-network-stream'.
73501
437fb645afb4 * url-http.el (url-http-mark-connection-as-free): Verify that
Chong Yidong <cyd@stupidchicken.com>
parents: 70241
diff changeset
212 Will not make a connection if `url-gateway-unplugged' is non-nil.
437fb645afb4 * url-http.el (url-http-mark-connection-as-free): Verify that
Chong Yidong <cyd@stupidchicken.com>
parents: 70241
diff changeset
213 Might do a non-blocking connection; use `process-status' to check."
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
214 (unless url-gateway-unplugged
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
215 (let ((gw-method (if (and url-gateway-local-host-regexp
57449
202c408c174b url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents: 54770
diff changeset
216 (not (eq 'tls url-gateway-method))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
217 (not (eq 'ssl url-gateway-method))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
218 (string-match
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
219 url-gateway-local-host-regexp
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
220 host))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
221 'native
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
222 url-gateway-method))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
223 ;;; ;; This hack is for OS/2 Emacs so that it will not do bogus CRLF
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
224 ;;; ;; conversions while trying to be 'helpful'
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
225 ;;; (tcp-binary-process-output-services (if (stringp service)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
226 ;;; (list service)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
227 ;;; (list service
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
228 ;;; (int-to-string service))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
229
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
230 ;; An attempt to deal with denied connections, and attempt
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
231 ;; to reconnect
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
232 (cur-retries 0)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
233 (retry t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
234 (errobj nil)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
235 (conn nil))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
236
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
237 ;; If the user told us to do DNS for them, do it.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
238 (if url-gateway-broken-resolution
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
239 (setq host (url-gateway-nslookup-host host)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
240
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
241 (condition-case errobj
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
242 ;; This is a clean way to ensure the new process inherits the
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
243 ;; right coding systems in both Emacs and XEmacs.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
244 (let ((coding-system-for-read 'binary)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
245 (coding-system-for-write 'binary))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
246 (setq conn (case gw-method
57449
202c408c174b url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents: 54770
diff changeset
247 (tls
202c408c174b url-vars.el (url-gateway-method): Add new method `tls'.
Simon Josefsson <jas@extundo.com>
parents: 54770
diff changeset
248 (open-tls-stream name buffer host service))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
249 (ssl
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
250 (open-ssl-stream name buffer host service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
251 ((native)
73501
437fb645afb4 * url-http.el (url-http-mark-connection-as-free): Verify that
Chong Yidong <cyd@stupidchicken.com>
parents: 70241
diff changeset
252 ;; Use non-blocking socket if we can.
437fb645afb4 * url-http.el (url-http-mark-connection-as-free): Verify that
Chong Yidong <cyd@stupidchicken.com>
parents: 70241
diff changeset
253 (make-network-process :name name :buffer buffer
437fb645afb4 * url-http.el (url-http-mark-connection-as-free): Verify that
Chong Yidong <cyd@stupidchicken.com>
parents: 70241
diff changeset
254 :host host :service service
74575
34a1ff09106b (url-gateway-nslookup-program): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 73533
diff changeset
255 :nowait
73533
61352a6a6dcf (url-open-stream): Really use asynchronous connections (accidentally
Magnus Henoch <mange@freemail.hu>
parents: 73501
diff changeset
256 (featurep 'make-network-process '(:nowait t))))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
257 (socks
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
258 (socks-open-network-stream name buffer host service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
259 (telnet
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
260 (url-open-telnet name buffer host service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
261 (rlogin
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
262 (url-open-rlogin name buffer host service))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
263 (otherwise
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
264 (error "Bad setting of url-gateway-method: %s"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
265 url-gateway-method)))))
70241
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
266 ;; Ignoring errors here seems wrong. E.g. it'll throw away the
96361
a99299e4d2de American English spelling fix.
Glenn Morris <rgm@gnu.org>
parents: 94668
diff changeset
267 ;; error signaled two lines above. It was also found inconvenient
70241
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
268 ;; during debugging.
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
269 ;; (error
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
270 ;; (setq conn nil))
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
271 )
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
272 conn)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
273
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
274 (provide 'url-gw)
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
275
70241
07c1b5999e53 (url-open-stream): Don't hide errors.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68640
diff changeset
276 ;; arch-tag: 1c4c0317-6d03-45b8-b3f3-838bd8f9d838
57612
2954cb243379 Update header and footer.
Lars Hansen <larsh@soem.dk>
parents: 57510
diff changeset
277 ;;; url-gw.el ends here