annotate lisp/w3/url-misc.el @ 80:1ce6082ce73f r20-0b90

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