annotate lisp/url/url-nfs.el @ 57240:92ae396e41ed

Remove accidentally added blank line.
author Luc Teirlinck <teirllm@auburn.edu>
date Sun, 26 Sep 2004 23:45:21 +0000
parents 2fc584798d79
children 01934125951e 625059157bad
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
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
3 ;; Copyright (c) 1996,97,98,1999,2004 Free Software Foundation, Inc.
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
4 ;; Copyright (c) 1996 by William M. Perry <wmperry@cs.indiana.edu>
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 ;;
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
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
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
13 ;; any later version.
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
14 ;;
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.
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
19 ;;
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
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
23 ;; Boston, MA 02111-1307, USA.
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 ;;; Commentary:
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
26
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
27 ;;; Code:
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
28
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
29 (eval-when-compile (require 'cl))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
30 (require 'url-parse)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
31 (require 'url-file)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
32
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
33 (defvar url-nfs-automounter-directory-spec
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
34 "file:/net/%h%f"
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
35 "*How to invoke the NFS automounter. Certain % sequences are recognized.
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
36
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
37 %h -- the hostname of the NFS server
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
38 %n -- the port # of the NFS server
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
39 %u -- the username to use to authenticate
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
40 %p -- the password to use to authenticate
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
41 %f -- the filename on the remote server
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
42 %% -- a literal %
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 Each can be used any number of times.")
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
45
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
46 (defun url-nfs-unescape (format host port user pass file)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
47 (save-excursion
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
48 (set-buffer (get-buffer-create " *nfs-parse*"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
49 (erase-buffer)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
50 (insert format)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
51 (goto-char (point-min))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
52 (while (re-search-forward "%\\(.\\)" nil t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
53 (let ((escape (aref (match-string 1) 0)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
54 (replace-match "" t t)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
55 (case escape
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
56 (?% (insert "%"))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
57 (?h (insert host))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
58 (?n (insert (or port "")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
59 (?u (insert (or user "")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
60 (?p (insert (or pass "")))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
61 (?f (insert (or file "/"))))))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
62 (buffer-string)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
63
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
64 (defun url-nfs-build-filename (url)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
65 (let* ((host (url-host url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
66 (port (string-to-int (url-port url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
67 (pass (url-password url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
68 (user (url-user url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
69 (file (url-filename url)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
70 (url-generic-parse-url
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
71 (url-nfs-unescape url-nfs-automounter-directory-spec
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
72 host port user pass file))))
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 (defun url-nfs (url callback cbargs)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
75 (url-file (url-nfs-build-filename url) callback cbargs))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
76
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
77 (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
78 `(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
79 ,(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
80 (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
81 (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
82 ,@(remove '&rest (remove '&optional args))))))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
83
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
84 (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
85 (url-nfs-create-wrapper file-attributes (url &optional id-format))
54695
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
86 (url-nfs-create-wrapper file-symlink-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
87 (url-nfs-create-wrapper file-readable-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
88 (url-nfs-create-wrapper file-writable-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
89 (url-nfs-create-wrapper file-executable-p (url))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
90 (if (featurep 'xemacs)
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
91 (progn
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
92 (url-nfs-create-wrapper directory-files (url &optional full match nosort files-only))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
93 (url-nfs-create-wrapper file-truename (url &optional default)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
94 (url-nfs-create-wrapper directory-files (url &optional full match nosort))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
95 (url-nfs-create-wrapper file-truename (url &optional counter prev-dirs)))
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
96
3fb37923e567 Initial revision
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff changeset
97 (provide 'url-nfs)
54699
7784ae10206d Resolve CVS conflicts
Miles Bader <miles@gnu.org>
parents: 54695
diff changeset
98
54934
2fc584798d79 (url-nfs-file-attributes): Add id-format parameter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54770
diff changeset
99 ;; 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
100 ;;; url-nfs.el ends here