1 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
3 ;; Copyright (C) 1996-1999, 2002, 2004-2012 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)
48 (generate-new-buffer (format "%s%s" (if user (concat user "@") "") server))
54 (error "Unknown terminal emulator required: %s" type)))
58 (list server "-l" user)
61 (if user (message "Please log in as user: %s" user))
66 (if user (message "Please log in as user: %s" user))
70 (defun url-generic-emulator-loader (url)
71 (let* ((type (intern (downcase (url-type url))))
72 (server (url-host url))
74 (port (number-to-string (url-port url))))
75 (url-do-terminal-emulator type server port name))
79 (defalias 'url-rlogin 'url-generic-emulator-loader)
81 (defalias 'url-telnet 'url-generic-emulator-loader)
83 (defalias 'url-tn3270 'url-generic-emulator-loader)
88 "Fetch a data URL (RFC 2397)."
90 ;; The mediatype may need to be hex-encoded too -- see the RFC.
91 (desc (url-unhex-string (url-filename url)))
95 (if (not (string-match "\\([^,]*\\)?," desc))
96 (error "Malformed data URL: %s" desc)
97 (setq mediatype (match-string 1 desc))
98 (if (and mediatype (string-match ";base64\\'" mediatype))
99 (setq mediatype (substring mediatype 0 (match-beginning 0))
101 (if (or (null mediatype)
102 (eq ?\; (aref mediatype 0)))
103 (setq mediatype (concat "text/plain" mediatype)))
104 (setq data (url-unhex-string (substring desc (match-end 0)))))
105 (set-buffer (generate-new-buffer " *url-data*"))
106 (mm-disable-multibyte)
107 (insert (format "Content-Length: %d\n" (length data))
108 "Content-Type: " mediatype "\n"
109 "Content-Encoding: " encoding "\n"
111 (if data (insert data))
116 ;;; url-misc.el ends here