diff lisp/url/url-nfs.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/url/url-nfs.el	Mon Aug 13 08:45:50 2007 +0200
@@ -0,0 +1,71 @@
+;;; url-nfs.el --- NFS URL interface
+;; Author: wmperry
+;; Created: 1996/05/29 15:07:01
+;; Version: 1.19
+;; Keywords: comm, data, processes
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Copyright (c) 1996 by William M. Perry (wmperry@spry.com)
+;;;
+;;; This file is not part of GNU Emacs, but the same permissions apply.
+;;;
+;;; GNU Emacs is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 2, or (at your option)
+;;; any later version.
+;;;
+;;; GNU Emacs is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Emacs; see the file COPYING.  If not, write to
+;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(require 'url-vars)
+(require 'url-parse)
+(require 'cl)
+
+(defvar url-nfs-automounter-directory-spec
+  "file:/net/%h%f"
+  "*How to invoke the NFS automounter.  Certain % sequences are recognized.
+
+%h -- the hostname of the NFS server
+%n -- the port # of the NFS server
+%u -- the username to use to authenticate
+%p -- the password to use to authenticate
+%f -- the filename on the remote server
+%% -- a literal %
+
+Each can be used any number of times.")
+
+(defun url-nfs-unescape (format host port user pass file)
+  (save-excursion
+    (set-buffer (get-buffer-create " *nfs-parse*"))
+    (erase-buffer)
+    (insert format)
+    (goto-char (point-min))
+    (while (re-search-forward "%\\(.\\)" nil t)
+       (let ((escape (aref (match-string 1) 0)))
+	 (replace-match "" t t)
+	 (case escape
+	   (?% (insert "%"))
+	   (?h (insert host))
+	   (?n (insert (or port "")))
+	   (?u (insert (or user "")))
+	   (?p (insert (or pass "")))
+	   (?f (insert (or file "/"))))))
+    (buffer-string)))
+
+(defun url-nfs (url)
+  (let* ((urlobj (url-generic-parse-url url))
+	 (host (url-host urlobj))
+	 (port (string-to-int (url-port urlobj)))
+	 (pass (url-password urlobj))
+	 (user (url-user urlobj))
+	 (file (url-filename urlobj)))
+    (url-retrieve (url-nfs-unescape url-nfs-automounter-directory-spec
+				    host port user pass file))))
+