1 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Keywords: comm, data, processes
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
27 (eval-when-compile (require 'cl
))
30 (autoload 'Info-goto-node
"info" "" t
)
31 (autoload 'man
"man" nil t
)
35 "Fetch a Unix manual page URL."
36 (man (url-filename url
))
41 "Fetch a GNU Info URL."
43 (let* ((fname (url-filename url
))
44 (node (url-unhex-string (or (url-target url
) "Top"))))
46 (Info-goto-node (concat "(" fname
")" node
))
47 (error "Malformed url: %s" (url-recreate-url url
)))
50 (defun url-do-terminal-emulator (type server port user
)
52 (generate-new-buffer (format "%s%s" (if user
(concat user
"@") "") server
))
58 (error "Unknown terminal emulator required: %s" type
)))
62 (list server
"-l" user
)
65 (if user
(message "Please log in as user: %s" user
))
70 (if user
(message "Please log in as user: %s" user
))
74 (defun url-generic-emulator-loader (url)
75 (let* ((type (intern (downcase (url-type url
))))
76 (server (url-host url
))
78 (port (number-to-string (url-port url
))))
79 (url-do-terminal-emulator type server port name
))
83 (defalias 'url-rlogin
'url-generic-emulator-loader
)
85 (defalias 'url-telnet
'url-generic-emulator-loader
)
87 (defalias 'url-tn3270
'url-generic-emulator-loader
)
92 "Fetch a data URL (RFC 2397)."
94 ;; The mediatype may need to be hex-encoded too -- see the RFC.
95 (desc (url-unhex-string (url-filename url
)))
99 (if (not (string-match "\\([^,]*\\)?," desc
))
100 (error "Malformed data URL: %s" desc
)
101 (setq mediatype
(match-string 1 desc
))
102 (if (and mediatype
(string-match ";base64\\'" mediatype
))
103 (setq mediatype
(substring mediatype
0 (match-beginning 0))
105 (if (or (null mediatype
)
106 (eq ?\
; (aref mediatype 0)))
107 (setq mediatype
(concat "text/plain" mediatype
)))
108 (setq data
(url-unhex-string (substring desc
(match-end 0)))))
109 (set-buffer (generate-new-buffer " *url-data*"))
110 (mm-disable-multibyte)
111 (insert (format "Content-Length: %d\n" (length data
))
112 "Content-Type: " mediatype
"\n"
113 "Content-Encoding: " encoding
"\n"
115 (if data
(insert data
))
120 ;;; arch-tag: 8c544e1b-d8bc-40a6-b319-f1f37fef65a0
121 ;;; url-misc.el ends here