(json-read-number): New arg. Handle explicitly signed numbers.
[bpt/emacs.git] / lisp / url / url-nfs.el
CommitLineData
8c8b8430 1;;; url-nfs.el --- NFS URL interface
abbcaa05 2
71ddfde5 3;; Copyright (C) 1996, 1997, 1998, 1999, 2004,
12dc447f 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
abbcaa05 5
8c8b8430
SM
6;; Keywords: comm, data, processes
7
abbcaa05
SM
8;; This file is part of GNU Emacs.
9;;
4936186e 10;; GNU Emacs is free software: you can redistribute it and/or modify
abbcaa05 11;; it under the terms of the GNU General Public License as published by
4936186e
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
14
abbcaa05
SM
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.
4936186e 19
abbcaa05 20;; You should have received a copy of the GNU General Public License
4936186e 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
abbcaa05
SM
22
23;;; Commentary:
24
25;;; Code:
8c8b8430
SM
26
27(eval-when-compile (require 'cl))
28(require 'url-parse)
29(require 'url-file)
30
31(defvar url-nfs-automounter-directory-spec
32 "file:/net/%h%f"
33 "*How to invoke the NFS automounter. Certain % sequences are recognized.
34
35%h -- the hostname of the NFS server
36%n -- the port # of the NFS server
37%u -- the username to use to authenticate
38%p -- the password to use to authenticate
39%f -- the filename on the remote server
40%% -- a literal %
41
42Each can be used any number of times.")
43
44(defun url-nfs-unescape (format host port user pass file)
45 (save-excursion
46 (set-buffer (get-buffer-create " *nfs-parse*"))
47 (erase-buffer)
48 (insert format)
49 (goto-char (point-min))
50 (while (re-search-forward "%\\(.\\)" nil t)
51 (let ((escape (aref (match-string 1) 0)))
52 (replace-match "" t t)
53 (case escape
54 (?% (insert "%"))
55 (?h (insert host))
56 (?n (insert (or port "")))
57 (?u (insert (or user "")))
58 (?p (insert (or pass "")))
59 (?f (insert (or file "/"))))))
60 (buffer-string)))
61
62(defun url-nfs-build-filename (url)
63 (let* ((host (url-host url))
60b5eb78 64 (port (url-port url))
8c8b8430
SM
65 (pass (url-password url))
66 (user (url-user url))
67 (file (url-filename url)))
68 (url-generic-parse-url
69 (url-nfs-unescape url-nfs-automounter-directory-spec
70 host port user pass file))))
71
72(defun url-nfs (url callback cbargs)
73 (url-file (url-nfs-build-filename url) callback cbargs))
74
75(defmacro url-nfs-create-wrapper (method args)
abbcaa05
SM
76 `(defun ,(intern (format "url-nfs-%s" method)) ,args
77 ,(format "NFS URL wrapper around `%s' call." method)
78 (setq url (url-nfs-build-filename url))
79 (and url (,(intern (format "url-file-%s" method))
80 ,@(remove '&rest (remove '&optional args))))))
8c8b8430
SM
81
82(url-nfs-create-wrapper file-exists-p (url))
abbcaa05 83(url-nfs-create-wrapper file-attributes (url &optional id-format))
8c8b8430
SM
84(url-nfs-create-wrapper file-symlink-p (url))
85(url-nfs-create-wrapper file-readable-p (url))
86(url-nfs-create-wrapper file-writable-p (url))
87(url-nfs-create-wrapper file-executable-p (url))
cc38a294
EZ
88(url-nfs-create-wrapper directory-files (url &optional full match nosort))
89(url-nfs-create-wrapper file-truename (url &optional counter prev-dirs))
8c8b8430
SM
90
91(provide 'url-nfs)
e5566bd5 92
abbcaa05
SM
93;; arch-tag: cdf9c9ba-b7d2-4c29-8b48-7ae9bbc0d437
94;;; url-nfs.el ends here