annotate lisp/url/url-misc.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; url-misc.el,v --- Misc Uniform Resource Locator retrieval code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Author: wmperry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Created: 1995/11/19 18:46:45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Version: 1.4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: comm, data, processes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; Copyright (c) 1993, 1994, 1995 by William M. Perry (wmperry@spry.com)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; This file is not part of GNU Emacs, but the same permissions apply.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (require 'url-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'url-parse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (autoload 'Info-goto-node "info" "" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defun url-info (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Fetch an info node
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (if (get-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (kill-buffer url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (let* ((data (url-generic-parse-url url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (fname (url-filename data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (node (or (url-target data) "Top")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (if (and fname node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 (Info-goto-node (concat "(" fname ")" node))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (error "Malformed url: %s" url))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defun url-finger (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; Find a finger reference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (setq url-current-mime-headers '(("content-type" . "text/html"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 url-current-mime-type "text/html")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (let* ((urlobj (if (vectorp url) url
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (url-generic-parse-url url)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (host (or (url-host urlobj) "localhost"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (port (or (url-port urlobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (cdr-safe (assoc "finger" url-default-ports))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (user (url-unhex-string (url-filename urlobj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (proc (url-open-stream "finger" url-working-buffer host
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (string-to-int port))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (if (stringp proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (message "%s" proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (process-kill-without-query proc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (if (= (string-to-char user) ?/)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (setq user (substring user 1 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (insert "<html>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 " <head>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 " <title>Finger information for " user "@" host "</title>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 " </head>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 " <body>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 " <h1>Finger information for " user "@" host "</h1>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 " <hr>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 " <pre>\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (process-send-string proc (concat user "\r\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (while (memq (url-process-status proc) '(run open))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (url-after-change-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (url-accept-process-output proc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (url-replace-regexp "^Process .* exited .*code .*$" "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (insert " </pre>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 " </body>\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "</html>\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defun url-rlogin (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; Open up an rlogin connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (if (get-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (kill-buffer url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (or (string-match "rlogin:/*\\(.*@\\)*\\([^/]*\\)/*" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (error "Malformed RLOGIN URL."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let* ((server (substring url (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (name (if (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (substring url (match-beginning 1) (1- (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (title (format "%s%s" (if name (concat name "@") "") server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (thebuf (string-match ":" server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (port (if thebuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (substring server (1+ thebuf) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq server (substring server 0 thebuf))) "23")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ((not (eq (device-type) 'tty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (apply 'start-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "htmlsub"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (url-string-to-tokens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (format url-xterm-command title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if (and url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (string-match url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 url-local-rlogin-prog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 url-remote-rlogin-prog) server
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (concat "-l " name)) ? )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (url-use-transparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (require 'transparent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (transparent-window (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (format "%s%s:%s" (if name (concat name "@") "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if (and url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (string-match url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 url-local-rlogin-prog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 url-remote-rlogin-prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (list server "-l" name) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 "Press any key to return to emacs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (terminal-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (get-buffer-create (format "%s%s:%s" (if name (concat name "@") "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (if (and url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (string-match url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 url-local-rlogin-prog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 url-remote-rlogin-prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (list server "-l" name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun url-telnet (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; Open up a telnet connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (if (get-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (kill-buffer url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (or (string-match "telnet:/*\\(.*@\\)*\\([^/]*\\)/*" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (error "Malformed telnet URL: %s" url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (let* ((server (substring url (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (name (if (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (substring url (match-beginning 1) (1- (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (title (format "%s%s" (if name (concat name "@") "") server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (thebuf (string-match ":" server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (port (if thebuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (substring server (1+ thebuf) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (setq server (substring server 0 thebuf))) "23")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ((not (eq (device-type) 'tty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (apply 'start-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "htmlsub"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (url-string-to-tokens
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (format url-xterm-command title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if (and url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (string-match url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 url-local-telnet-prog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 url-remote-telnet-prog) server port) ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if name (message "Please log in as %s" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (url-use-transparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (require 'transparent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if name (message "Please log in as %s" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (transparent-window (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (format "%s%s:%s" (if name (concat name "@") "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if (and url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (string-match url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 url-local-telnet-prog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 url-remote-telnet-prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (list server port) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 "Press any key to return to emacs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (terminal-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (get-buffer-create (format "%s%s:%s" (if name (concat name "@") "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (if (and url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (string-match url-gateway-local-host-regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 url-local-telnet-prog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 url-remote-telnet-prog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (list server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if name (message "Please log in as %s" name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun url-tn3270 (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Open up a tn3270 connection
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (if (get-buffer url-working-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (kill-buffer url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (string-match "tn3270:/*\\(.*@\\)*\\([^/]*\\)/*" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (let* ((server (substring url (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (name (if (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (substring url (match-beginning 1) (1- (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (thebuf (string-match ":" server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (title (format "%s%s" (if name (concat name "@") "") server))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (port (if thebuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (substring server (1+ thebuf) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (setq server (substring server 0 thebuf))) "23")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ((not (eq (device-type) 'tty))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (start-process "htmlsub" nil url-xterm-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 "-title" title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "-ut" "-e" url-tn3270-emulator server port)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (if name (message "Please log in as %s" name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (url-use-transparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (require 'transparent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if name (message "Please log in as %s" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (sit-for 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (transparent-window (get-buffer-create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (format "%s%s:%s" (if name (concat name "@") "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 url-tn3270-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (list server port) nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Press any key to return to emacs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (terminal-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (get-buffer-create (format "%s%s:%s" (if name (concat name "@") "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 url-tn3270-emulator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (list server port))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (if name (message "Please log in as %s" name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defun url-proxy (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; Retrieve URL from a proxy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; Expects `url-using-proxy' to be bound to the specific proxy to use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let (
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (urlobj (url-generic-parse-url url))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (proxyobj (url-generic-parse-url url-using-proxy)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (url-http url-using-proxy url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (setq url-current-type (url-type urlobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 url-current-user (url-user urlobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 url-current-port (or (url-port urlobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (cdr-safe (assoc url-current-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 url-default-ports)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 url-current-server (url-host urlobj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 url-current-file (url-filename urlobj))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (defun url-x-exec (url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; Handle local execution of scripts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (set-buffer (get-buffer-create url-working-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (string-match "x-exec:/+\\([^/]+\\)\\(/.*\\)" url)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (let ((process-environment process-environment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (executable (url-match url 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (path-info (url-match url 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (query-string nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (safe-paths url-local-exec-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (found nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (y nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (setq url-current-server executable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 url-current-file path-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (if (string-match "\\(.*\\)\\?\\(.*\\)" path-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq query-string (url-match path-info 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 path-info (url-match path-info 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (while (and safe-paths (not found))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (setq y (expand-file-name executable (car safe-paths))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 found (and (file-exists-p y) (file-executable-p y) y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 safe-paths (cdr safe-paths)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (if (not found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (url-retrieve (concat "www://error/nofile/" executable))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (setq process-environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (append
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "SERVER_SOFTWARE=x-exec/1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (concat "SERVER_NAME=" (system-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 "GATEWAY_INTERFACE=CGI/1.1"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "SERVER_PROTOCOL=HTTP/1.0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 "SERVER_PORT="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (concat "REQUEST_METHOD=" url-request-method)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (concat "HTTP_ACCEPT="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ((= x ?\n) (setq y t) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ((= x ?:) (setq y nil) ",")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (t (char-to-string x))))) url-mime-accept-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (concat "PATH_INFO=" (url-unhex-string path-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (concat "PATH_TRANSLATED=" (url-unhex-string path-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (concat "SCRIPT_NAME=" executable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (concat "QUERY_STRING=" (url-unhex-string query-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (concat "REMOTE_HOST=" (system-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (if (assoc "content-type" url-request-extra-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (concat "CONTENT_TYPE=" (cdr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (assoc "content-type"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 url-request-extra-headers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (if url-request-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (concat "CONTENT_LENGTH=" (length url-request-data)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 process-environment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (and url-request-data (insert url-request-data))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (setq y (call-process-region (point-min) (point-max) found t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (delete-region (point) (progn (skip-chars-forward " \t\n") (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 ((url-mime-response-p) nil) ; Its already got an HTTP/1.0 header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ((null y) ; Weird exit status, whassup?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (insert "HTTP/1.0 404 Not Found\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 "Server: " url-package-name "/x-exec\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ((= 0 y) ; The shell command was successful
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (insert "HTTP/1.0 200 Document follows\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "Server: " url-package-name "/x-exec\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (t ; Non-zero exit status is bad bad bad
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (insert "HTTP/1.0 404 Not Found\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "Server: " url-package-name "/x-exec\n"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (provide 'url-misc)