annotate lisp/url/url-nfs.el @ 107114:e5188f4e7403

* nsfont.m (nsfont_open): The system's value for the font descent is negative, so round it down to avoid clipping.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 08 Feb 2010 18:39:01 -0500
parents 1d1d5d9bd884
children 376148b31b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
1 ;;; url-nfs.el --- NFS URL interface
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
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, 2004,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105829
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
5
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
6 ;; Keywords: comm, data, processes
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
7
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
8 ;; This file is part of GNU Emacs.
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
9 ;;
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
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: 79720
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: 79720
diff changeset
13 ;; (at your option) any later version.
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
14
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
18 ;; GNU General Public License for more details.
94668
8259d0d8e107 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 79720
diff changeset
19
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
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: 79720
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
22
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
23 ;;; Commentary:
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
24
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
25 ;;; Code:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
26
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
27 (eval-when-compile (require 'cl))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28 (require 'url-parse)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 (require 'url-file)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 (defvar url-nfs-automounter-directory-spec
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32 "file:/net/%h%f"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 "*How to invoke the NFS automounter. Certain % sequences are recognized.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 %h -- the hostname of the NFS server
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36 %n -- the port # of the NFS server
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 %u -- the username to use to authenticate
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 %p -- the password to use to authenticate
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 %f -- the filename on the remote server
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 %% -- a literal %
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 Each can be used any number of times.")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
43
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
44 (defun url-nfs-unescape (format host port user pass file)
105829
328150f0cf76 * url-util.el (url-insert-entities-in-string):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
45 (with-current-buffer (get-buffer-create " *nfs-parse*")
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 (erase-buffer)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 (insert format)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 (goto-char (point-min))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (while (re-search-forward "%\\(.\\)" nil t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (let ((escape (aref (match-string 1) 0)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 (replace-match "" t t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (case escape
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (?% (insert "%"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (?h (insert host))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (?n (insert (or port "")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (?u (insert (or user "")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 (?p (insert (or pass "")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (?f (insert (or file "/"))))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 (buffer-string)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (defun url-nfs-build-filename (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (let* ((host (url-host url))
57886
60d07d8a52e1 * url-imap.el (url-imap-open-host): Don't use
Masatake YAMATO <jet@gyve.org>
parents: 57427
diff changeset
63 (port (url-port url))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (pass (url-password url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (user (url-user url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 (file (url-filename url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 (url-generic-parse-url
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 (url-nfs-unescape url-nfs-automounter-directory-spec
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 host port user pass file))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (defun url-nfs (url callback cbargs)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 (url-file (url-nfs-build-filename url) callback cbargs))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
73
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
74 (defmacro url-nfs-create-wrapper (method args)
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
75 `(defun ,(intern (format "url-nfs-%s" method)) ,args
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
76 ,(format "NFS URL wrapper around `%s' call." method)
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
77 (setq url (url-nfs-build-filename url))
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
78 (and url (,(intern (format "url-file-%s" method))
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
79 ,@(remove '&rest (remove '&optional args))))))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
80
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
81 (url-nfs-create-wrapper file-exists-p (url))
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
82 (url-nfs-create-wrapper file-attributes (url &optional id-format))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83 (url-nfs-create-wrapper file-symlink-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 (url-nfs-create-wrapper file-readable-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
85 (url-nfs-create-wrapper file-writable-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (url-nfs-create-wrapper file-executable-p (url))
66225
eb65acc95303 Remove XEmacs conditionals.
Eli Zaretskii <eliz@gnu.org>
parents: 64748
diff changeset
87 (url-nfs-create-wrapper directory-files (url &optional full match nosort))
eb65acc95303 Remove XEmacs conditionals.
Eli Zaretskii <eliz@gnu.org>
parents: 64748
diff changeset
88 (url-nfs-create-wrapper file-truename (url &optional counter prev-dirs))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 (provide 'url-nfs)
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
91
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
92 ;; arch-tag: cdf9c9ba-b7d2-4c29-8b48-7ae9bbc0d437
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
93 ;;; url-nfs.el ends here