2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; File: efs-ms-unix.el
5 ;; Release: $efs release: 1.24 $
6 ;; Version: #Revision: 1.1 $
8 ;; Description: efs support for the Microsoft PC FTP server in unix mode.
9 ;; Author: Sandy Rutherford <sandy@tsmi19.sissa.it>
10 ;; Created: Thu Aug 19 08:31:15 1993 by sandy on ibm550
11 ;; Modified: Sun Nov 27 18:37:00 1994 by sandy on gandalf
12 ;; Language: Emacs-Lisp
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 (provide 'efs-ms-unix)
19 (defconst efs-ms-unix-version
20 (concat (substring "$efs release: 1.24 $" 14 -2)
22 (substring "#Revision: 1.1 $" 11 -2)))
24 (defvar efs-ms-unix-month-and-time-regexp
26 " \\([0-9]+\\) +" ; file size
27 "\\(Jan\\|Feb\\|Mar\\|Apr\\|May\\|Jun\\|Jul\\|Aug\\|Sep\\|Oct"
28 "\\|Nov\\|Dec\\) [ 0-3][0-9]"
29 " +\\([ 012][0-9]:[0-6][0-9]\\|[12][90][0-9][0-9]\\) +"))
33 (efs-defun efs-fix-path ms-unix (path &optional reverse)
34 ;; Convert PATH from UNIX-ish to MS-UNIX.
39 (efs-defun efs-fix-dir-path ms-unix (dirpath)
40 ;; Convert a path from UNIX-ish to MS-UNIX for a dir listing
41 (if (string-equal dirpath "/")
42 (error "Cannot grok disk names.")
43 (setq dirpath (substring dirpath 1))
45 (if (string-match "/$" dirpath)
49 (defmacro efs-ms-unix-parse-file-line ()
50 ;; Extract the filename, size, and permission string from the current
51 ;; line of a dired-like listing. Assumes that the point is at
52 ;; the beginning of the line, leaves it just before the size entry.
53 ;; Returns a list (name size perm-string nlinks owner).
54 ;; If there is no file on the line, returns nil.
55 (` (let ((eol (save-excursion (end-of-line) (point)))
56 name size modes nlinks owner)
57 (skip-chars-forward " 0-9" eol)
59 (looking-at efs-modes-links-owner-regexp)
60 (setq modes (buffer-substring (match-beginning 1)
62 nlinks (string-to-int (buffer-substring (match-beginning 2)
64 owner (buffer-substring (match-beginning 3) (match-end 3)))
65 (re-search-forward efs-ms-unix-month-and-time-regexp eol t)
66 (setq name (buffer-substring (point) eol)
67 size (string-to-int (buffer-substring (match-beginning 1)
69 (list name size modes nlinks owner)))))
71 (efs-defun efs-parse-listing ms-unix (host user dir path &optional switches)
72 ;; Parse the current buffer which is assumed to be output from
73 ;; the Microsoft FTP server in unix mode.
74 ;; Return a hashtable as the result. SWITCHES are never used,
75 ;; but they must be specified in the argument list for compatibility
76 ;; with the unix version of this function.
77 ;; HOST = remote host name
79 ;; DIR = directory in as a full remote path
80 ;; PATH = directory in full efs path syntax
81 ;; SWITCHES = ls switches
82 (goto-char (point-min))
84 (if (re-search-forward efs-ms-unix-month-and-time-regexp nil t)
85 (let ((tbl (efs-make-hashtable))
86 size modes nlinks dir-p owner file)
88 (while (setq file (efs-ms-unix-parse-file-line))
89 (setq size (nth 1 file)
94 dir-p (= (string-to-char modes) ?d))
96 (string-match "/$" file))
97 (setq file (substring file 0 -1)))
98 (efs-put-hash-entry file (list dir-p size owner modes nlinks) tbl)
100 (efs-put-hash-entry "." '(t) tbl)
101 (efs-put-hash-entry ".." '(t) tbl)
106 ;; ms-unix does not have a total line
108 (efs-defun efs-dired-insert-headerline ms-unix (dir)
109 ;; MTS has no total line, so we insert a blank line for
113 (efs-real-dired-insert-headerline dir))
115 (efs-defun efs-dired-manual-move-to-filename ms-unix
116 (&optional raise-error bol eol)
117 ;; In dired, move to the first char of filename on this line.
118 ;; Returns (point) or nil if raise-error is nil, and there is no
119 ;; no filename on this line.
120 ;; This version is for ms-unix.
121 (or eol (setq eol (save-excursion (skip-chars-forward "^\r\n") (point))))
122 (let (case-fold-search)
125 (skip-chars-backward "^\n\r")
127 (if (re-search-forward efs-ms-unix-month-and-time-regexp eol t)
129 (and raise-error (error "No file on this line")))))
131 (efs-defun efs-dired-manual-move-to-end-of-filename ms-unix
132 (&optional no-error bol eol)
133 ;; Assumes point is at the beginning of filename.
134 ;; So, it should be called only after (dired-move-to-filename t)
135 ;; On failure signals an error, or returns nil.
136 ;; This is the ms-unix version.
137 (let ((opoint (point)))
138 (and selective-display
141 (1- (or bol (save-excursion
142 (skip-chars-backward "^\r\n")
145 ;; File is hidden or omitted.
147 ((dired-subdir-hidden-p (dired-current-directory))
149 (substitute-command-keys
150 "File line is hidden. Type \\[dired-hide-subdir] to unhide.")))
152 (substitute-command-keys
153 "File line is omitted. Type \\[dired-omit-toggle] to un-omit.")))))
159 (error "No file on this line")))
161 (if (char-equal (char-before (point)) ?/)
165 ;;; end of efs-ms-unix.el