1 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
3 ;; Copyright (C) 1996-1999, 2002, 2004-2011 Free Software Foundation, Inc.
5 ;; Keywords: comm, data, processes
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 (eval-when-compile (require 'cl
))
27 (autoload 'Info-goto-node
"info" "" t
)
28 (autoload 'man
"man" nil t
)
32 "Fetch a Unix manual page URL."
33 (man (url-filename url
))
38 "Fetch a GNU Info URL."
40 (let* ((fname (url-filename url
))
41 (node (url-unhex-string (or (url-target url
) "Top"))))
43 (Info-goto-node (concat "(" fname
")" node
))
44 (error "Malformed url: %s" (url-recreate-url url
)))
47 (defun url-do-terminal-emulator (type server port user
)
49 (generate-new-buffer (format "%s%s" (if user
(concat user
"@") "") server
))
55 (error "Unknown terminal emulator required: %s" type
)))
59 (list server
"-l" user
)
62 (if user
(message "Please log in as user: %s" user
))
67 (if user
(message "Please log in as user: %s" user
))
71 (defun url-generic-emulator-loader (url)
72 (let* ((type (intern (downcase (url-type url
))))
73 (server (url-host url
))
75 (port (number-to-string (url-port url
))))
76 (url-do-terminal-emulator type server port name
))
80 (defalias 'url-rlogin
'url-generic-emulator-loader
)
82 (defalias 'url-telnet
'url-generic-emulator-loader
)
84 (defalias 'url-tn3270
'url-generic-emulator-loader
)
89 "Fetch a data URL (RFC 2397)."
91 ;; The mediatype may need to be hex-encoded too -- see the RFC.
92 (desc (url-unhex-string (url-filename url
)))
96 (if (not (string-match "\\([^,]*\\)?," desc
))
97 (error "Malformed data URL: %s" desc
)
98 (setq mediatype
(match-string 1 desc
))
99 (if (and mediatype
(string-match ";base64\\'" mediatype
))
100 (setq mediatype
(substring mediatype
0 (match-beginning 0))
102 (if (or (null mediatype
)
103 (eq ?\
; (aref mediatype 0)))
104 (setq mediatype
(concat "text/plain" mediatype
)))
105 (setq data
(url-unhex-string (substring desc
(match-end 0)))))
106 (set-buffer (generate-new-buffer " *url-data*"))
107 (mm-disable-multibyte)
108 (insert (format "Content-Length: %d\n" (length data
))
109 "Content-Type: " mediatype
"\n"
110 "Content-Encoding: " encoding
"\n"
112 (if data
(insert data
))
117 ;;; url-misc.el ends here