Mercurial > emacs
annotate lisp/url/url-misc.el @ 105458:4d2aa5860e37
(Ffile_attributes): Doc fix. (Bug#4638)
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Mon, 05 Oct 2009 08:35:12 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
54695 | 1 ;;; url-misc.el --- Misc Uniform Resource Locator retrieval code |
57612 | 2 |
64748
875dcc490074
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2002, 2004, |
100908 | 4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
57612 | 5 |
54695 | 6 ;; Keywords: comm, data, processes |
7 | |
57612 | 8 ;; This file is part of GNU Emacs. |
9 | |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
57612 | 11 ;; it under the terms of the GNU General Public License as published by |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
57612 | 14 |
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. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94668
8259d0d8e107
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
57612 | 22 |
23 ;;; Code: | |
54695 | 24 |
57512
44bc5df842b7
Load cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
57427
diff
changeset
|
25 (eval-when-compile (require 'cl)) |
54695 | 26 (require 'url-vars) |
27 (require 'url-parse) | |
28 (autoload 'Info-goto-node "info" "" t) | |
29 (autoload 'man "man" nil t) | |
30 | |
31 ;;;###autoload | |
32 (defun url-man (url) | |
33 "Fetch a Unix manual page URL." | |
34 (man (url-filename url)) | |
35 nil) | |
36 | |
37 ;;;###autoload | |
38 (defun url-info (url) | |
39 "Fetch a GNU Info URL." | |
40 ;; Fetch an info node | |
41 (let* ((fname (url-filename url)) | |
42 (node (url-unhex-string (or (url-target url) "Top")))) | |
43 (if (and fname node) | |
44 (Info-goto-node (concat "(" fname ")" node)) | |
45 (error "Malformed url: %s" (url-recreate-url url))) | |
46 nil)) | |
47 | |
48 (defun url-do-terminal-emulator (type server port user) | |
49 (terminal-emulator | |
50 (generate-new-buffer (format "%s%s" (if user (concat user "@") "") server)) | |
51 (case type | |
52 (rlogin "rlogin") | |
53 (telnet "telnet") | |
54 (tn3270 "tn3270") | |
55 (otherwise | |
56 (error "Unknown terminal emulator required: %s" type))) | |
57 (case type | |
58 (rlogin | |
59 (if user | |
60 (list server "-l" user) | |
61 (list server))) | |
62 (telnet | |
63 (if user (message "Please log in as user: %s" user)) | |
64 (if port | |
65 (list server port) | |
66 (list server))) | |
67 (tn3270 | |
68 (if user (message "Please log in as user: %s" user)) | |
69 (list server))))) | |
70 | |
71 ;;;###autoload | |
72 (defun url-generic-emulator-loader (url) | |
73 (let* ((type (intern (downcase (url-type url)))) | |
74 (server (url-host url)) | |
75 (name (url-user url)) | |
78877
34c4022cc356
Diane Murray <disumu at x3y2z1.net>
Glenn Morris <rgm@gnu.org>
parents:
78222
diff
changeset
|
76 (port (number-to-string (url-port url)))) |
54695 | 77 (url-do-terminal-emulator type server port name)) |
78 nil) | |
79 | |
80 ;;;###autoload | |
81 (defalias 'url-rlogin 'url-generic-emulator-loader) | |
82 ;;;###autoload | |
83 (defalias 'url-telnet 'url-generic-emulator-loader) | |
84 ;;;###autoload | |
85 (defalias 'url-tn3270 'url-generic-emulator-loader) | |
86 | |
87 ;; RFC 2397 | |
88 ;;;###autoload | |
89 (defun url-data (url) | |
90 "Fetch a data URL (RFC 2397)." | |
91 (let ((mediatype nil) | |
92 ;; The mediatype may need to be hex-encoded too -- see the RFC. | |
93 (desc (url-unhex-string (url-filename url))) | |
94 (encoding "8bit") | |
95 (data nil)) | |
96 (save-excursion | |
97 (if (not (string-match "\\([^,]*\\)?," desc)) | |
98 (error "Malformed data URL: %s" desc) | |
99 (setq mediatype (match-string 1 desc)) | |
100 (if (and mediatype (string-match ";base64\\'" mediatype)) | |
101 (setq mediatype (substring mediatype 0 (match-beginning 0)) | |
102 encoding "base64")) | |
103 (if (or (null mediatype) | |
104 (eq ?\; (aref mediatype 0))) | |
105 (setq mediatype (concat "text/plain" mediatype))) | |
106 (setq data (url-unhex-string (substring desc (match-end 0))))) | |
107 (set-buffer (generate-new-buffer " *url-data*")) | |
108 (mm-disable-multibyte) | |
109 (insert (format "Content-Length: %d\n" (length data)) | |
110 "Content-Type: " mediatype "\n" | |
111 "Content-Encoding: " encoding "\n" | |
112 "\n") | |
113 (if data (insert data)) | |
114 (current-buffer)))) | |
115 | |
116 (provide 'url-misc) | |
54699 | 117 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79720
diff
changeset
|
118 ;; arch-tag: 8c544e1b-d8bc-40a6-b319-f1f37fef65a0 |
57612 | 119 ;;; url-misc.el ends here |