lisp/gnus/ChangeLog: Cosmetic fix
[emacs.git] / lisp / url / url-nfs.el
blobcb5695b5549415326cbc81ea574518c145f88ab2
1 ;;; url-nfs.el --- NFS URL interface
3 ;; Copyright (C) 1996-1999, 2004-2012 Free Software Foundation, Inc.
5 ;; Keywords: comm, data, processes
7 ;; This file is part of GNU Emacs.
8 ;;
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/>.
22 ;;; Commentary:
24 ;;; Code:
26 (eval-when-compile (require 'cl))
27 (require 'url-parse)
28 (require 'url-file)
30 (defcustom url-nfs-automounter-directory-spec "file:/net/%h%f"
31 "How to invoke the NFS automounter. Certain % sequences are recognized.
33 %h -- the hostname of the NFS server
34 %n -- the port # of the NFS server
35 %u -- the username to use to authenticate
36 %p -- the password to use to authenticate
37 %f -- the filename on the remote server
38 %% -- a literal %
40 Each can be used any number of times."
41 :group 'url
42 :type 'string)
44 (defun url-nfs-unescape (format host port user pass file)
45 (with-current-buffer (get-buffer-create " *nfs-parse*")
46 (erase-buffer)
47 (insert format)
48 (goto-char (point-min))
49 (while (re-search-forward "%\\(.\\)" nil t)
50 (let ((escape (aref (match-string 1) 0)))
51 (replace-match "" t t)
52 (case escape
53 (?% (insert "%"))
54 (?h (insert host))
55 (?n (insert (or port "")))
56 (?u (insert (or user "")))
57 (?p (insert (or pass "")))
58 (?f (insert (or file "/"))))))
59 (buffer-string)))
61 (defun url-nfs-build-filename (url)
62 (let* ((host (url-host url))
63 (port (url-port url))
64 (pass (url-password url))
65 (user (url-user url))
66 (file (url-filename url)))
67 (url-generic-parse-url
68 (url-nfs-unescape url-nfs-automounter-directory-spec
69 host port user pass file))))
71 (defun url-nfs (url callback cbargs)
72 (url-file (url-nfs-build-filename url) callback cbargs))
74 (defmacro url-nfs-create-wrapper (method args)
75 `(defun ,(intern (format "url-nfs-%s" method)) ,args
76 ,(format "NFS URL wrapper around `%s' call." method)
77 (setq url (url-nfs-build-filename url))
78 (and url (,(intern (format "url-file-%s" method))
79 ,@(remove '&rest (remove '&optional args))))))
81 (url-nfs-create-wrapper file-exists-p (url))
82 (url-nfs-create-wrapper file-attributes (url &optional id-format))
83 (url-nfs-create-wrapper file-symlink-p (url))
84 (url-nfs-create-wrapper file-readable-p (url))
85 (url-nfs-create-wrapper file-writable-p (url))
86 (url-nfs-create-wrapper file-executable-p (url))
87 (url-nfs-create-wrapper directory-files (url &optional full match nosort))
88 (url-nfs-create-wrapper file-truename (url &optional counter prev-dirs))
90 (provide 'url-nfs)
92 ;;; url-nfs.el ends here