1 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
3 ;; Copyright (C) 1996-1999, 2002, 2004-2013 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/>.
26 (autoload 'Info-goto-node "info" "" t)
27 (autoload 'man "man" nil t)
31 "Fetch a Unix manual page URL."
32 (man (url-filename url))
37 "Fetch a GNU Info URL."
39 (let* ((fname (url-filename url))
40 (node (url-unhex-string (or (url-target url) "Top"))))
42 (Info-goto-node (concat "(" fname ")" node))
43 (error "Malformed url: %s" (url-recreate-url url)))
46 (defun url-do-terminal-emulator (type server port user)
50 (format "%s%s" (if user (concat user "@") "") server)
51 (cond ((eq type 'rlogin) "rlogin")
52 ((eq type 'telnet) "telnet")
53 ((eq type 'tn3270) "tn3270")
54 (t (error "Unknown terminal emulator required: %s" type)))
56 (cond ((eq type 'rlogin)
57 (if user (list server "-l" user) (list server)))
59 (if port (list server port) (list server)))
64 (defun url-generic-emulator-loader (url)
65 (let* ((type (intern (downcase (url-type url))))
66 (server (url-host url))
68 (port (number-to-string (url-port url))))
69 (url-do-terminal-emulator type server port name))
73 (defalias 'url-rlogin 'url-generic-emulator-loader)
75 (defalias 'url-telnet 'url-generic-emulator-loader)
77 (defalias 'url-tn3270 'url-generic-emulator-loader)
82 "Fetch a data URL (RFC 2397)."
84 ;; The mediatype may need to be hex-encoded too -- see the RFC.
85 (desc (url-unhex-string (url-filename url)))
89 (if (not (string-match "\\([^,]*\\)?," desc))
90 (error "Malformed data URL: %s" desc)
91 (setq mediatype (match-string 1 desc)
92 data (url-unhex-string (substring desc (match-end 0))))
93 (if (and mediatype (string-match ";base64\\'" mediatype))
94 (setq mediatype (substring mediatype 0 (match-beginning 0))
96 (if (or (null mediatype)
97 (eq ?\; (aref mediatype 0)))
98 (setq mediatype (concat "text/plain" mediatype))))
99 (set-buffer (generate-new-buffer " *url-data*"))
100 (mm-disable-multibyte)
101 (insert (format "Content-Length: %d\n" (length data))
102 "Content-Type: " mediatype "\n"
103 "Content-Transfer-Encoding: " encoding "\n"
105 (if data (insert data))
110 ;;; url-misc.el ends here