annotate lisp/efs/efs-cu.el @ 123:c77884c6318d

Added tag r20-1b14 for changeset d2f30a177268
author cvs
date Mon, 13 Aug 2007 09:26:04 +0200
parents 9f59509498e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
3 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
4 ;; File: efs-cu.el
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
5 ;; Release: $efs release: 1.15 $
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
6 ;; Version: #Revision: 1.12 $
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
7 ;; RCS:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
8 ;; Description: Common utilities needed by efs files.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
9 ;; Author: Sandy Rutherford <sandy@ibm550.sissa.it>
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
10 ;; Created: Fri Jan 28 19:55:45 1994 by sandy on ibm550
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
11 ;; Language: Emacs-Lisp
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
12 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
14
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
15 ;;; This file is part of efs. See efs.el for copyright
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
16 ;;; (it's copylefted) and warrranty (there isn't one) information.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
17
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
18 ;;;; Provisions and autoloads.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
19
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
20 (provide 'efs-cu)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
21 (require 'backquote)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
22 (autoload 'efs-get-process "efs")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
23 (autoload 'efs-parse-netrc "efs-netrc")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
24
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
25 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
26 ;;;; Use configuration variables.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
27 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
28
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
29 (defvar efs-default-user "anonymous"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
30 "*User name to use when none is specied in a pathname.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
31
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
32 If a string, than this string is used as the default user name.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
33 If nil, then the name under which the user is logged in is used.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
34 If t, then the user is prompted for a name.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
35 If an association list of the form
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
36
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
37 '((REGEXP1 . USERNAME1) (REGEXP2 . USERNAME2) ...)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
38
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
39 then the host name is tested against each of the regular expressions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
40 REGEXP in turn, and the default user name is the corresponding value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
41 of USERNAME. USERNAME may be either a string, nil, or t, and these
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
42 values are interpreted as above. If there are no matches, then the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
43 user's curent login name is used.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
44
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
45 (defvar efs-default-password nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
46 "*Password to use when the user is the same as efs-default-user.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
47
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
48 (defvar efs-default-account nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
49 "*Account password to use when the user is efs-default-user.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
50
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
51 ;;;; -------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
52 ;;;; Internal variables.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
53 ;;;; -------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
54
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
55 (defconst efs-cu-version
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
56 (concat (substring "$efs release: 1.15 $" 14 -2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
57 "/"
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
58 (substring "#Revision: 1.12 $" 11 -2)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
59
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
60 (defconst efs-case-insensitive-host-types
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
61 '(vms cms mts ti-twenex ti-explorer dos mvs tops-20 mpe ka9q dos-distinct
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
62 os2 hell guardian ms-unix netware cms-knet nos-ve)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
63 "List of host types for which case is insignificant in file names.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
64
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
65 ;;; Remote path name syntax
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
66
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
67 ;; All of the following variables must be set consistently.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
68 ;; As well the below two functions depend on the grouping constructs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
69 ;; in efs-path-regexp. So know what you're doing if you change them.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
70
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
71 (defvar efs-path-regexp "^/\\([^@:/]*@\\)?\\([^@:/]*\\):.*"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
72 "Regexp of a fully expanded remote path.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
73
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
74 (defvar efs-path-format-string "/%s@%s:%s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
75 "Format of a fully expanded remote path. Passed to format with
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
76 additional arguments user, host, and remote path.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
77
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
78 (defvar efs-path-format-without-user "/%s:%s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
79 "Format of a remote path, but not specifying a user.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
80
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
81 (defvar efs-path-user-at-host-format
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
82 (substring efs-path-format-string 1 7)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
83 "Format to return `user@host:' strings for completion in root directory.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
84
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
85 (defvar efs-path-host-format
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
86 (substring efs-path-user-at-host-format 3)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
87 "Format to return `host:' strings for completion in root directory.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
88
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
89 ;;;###autoload
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
90 (defvar efs-path-root-regexp "^/[^/:]+:"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
91 "Regexp to match the `/user@host:' root of an efs full path.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
92
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
93 (defvar efs-path-root-short-circuit-regexp "//[^/:]+:")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
94 ;; Regexp to match an efs user@host root, which short-circuits
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
95 ;; the part of the path to the left of this pattern.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
96
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
97 ;;;; -----------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
98 ;;;; Variables for multiple host type support
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
99 ;;;; -----------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
100
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
101 (defvar efs-vms-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
102 "Regexp to match the names of hosts running VMS.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
103 (defvar efs-cms-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
104 "Regexp to match the names of hosts running CMS.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
105 (defvar efs-mts-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
106 "Regexp to match the names of hosts running MTS.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
107 (defvar efs-ti-explorer-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
108 "Regexp to match the names of hosts running TI-EXPLORER.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
109 These are lisp machines.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
110 (defvar efs-ti-twenex-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
111 "Regexp to match the names of hosts running TI-TWENEX.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
112 These are lisp machines, and this should not be confused with DEC's TOPS-20.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
113 (defvar efs-sysV-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
114 "Regexp to match the names of sysV unix hosts.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
115 These are defined to be unix hosts which mark symlinks
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
116 with a @ in an ls -lF listing.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
117 (defvar efs-bsd-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
118 "Regexp to match the names of bsd unix hosts.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
119 These are defined to be unix hosts which do not mark symlinks
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
120 with a @ in an ls -lF listing.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
121 (defvar efs-next-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
122 "Regexp to match names of NeXT unix hosts.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
123 These are defined to be unix hosts which put a @ after the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
124 destination of a symlink when doing ls -lF listing.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
125 (defvar efs-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
126 "Regexp to match names of unix hosts.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
127 I you know which type of unix, it is much better to set that regexp instead.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
128 (defvar efs-dumb-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
129 "Regexp to match names of unix hosts which do not take ls switches.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
130 For these hosts we use the \"dir\" command.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
131 (defvar efs-super-dumb-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
132 "Regexp to match names of unix hosts with FTP servers that cannot do a PWD.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
133 It is also assumed that these hosts do not accept ls switches, whether
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
134 or not this is actually true.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
135 (defvar efs-dos-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
136 "Regexp to match names of hosts running DOS.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
137 ;; In principal there is apollo unix support -- at least efs
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
138 ;; should do the right thing. However, apollo ftp servers can be
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
139 ;; very flakey, especially about accessing files by fullpaths.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
140 ;; Good luck.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
141 (defvar efs-apollo-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
142 "Regexp to match names of apollo unix hosts running Apollo's Domain.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
143 For these hosts we don't short-circuit //'s immediately following
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
144 \"/user@host:\"")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
145 (defvar efs-mvs-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
146 "Regexp to match names of hosts running MVS.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
147 (defvar efs-tops-20-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
148 "Regexp to match names of hosts runninf TOPS-20.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
149 (defvar efs-mpe-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
150 "Regexp to match hosts running the MPE operating system.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
151 (defvar efs-ka9q-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
152 "Regexp to match hosts using the ka9q ftp server.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
153 These may actually be running one of DOS, LINUX, or unix.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
154 (defvar efs-dos-distinct-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
155 "Regexp to match DOS hosts using the Distinct FTP server.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
156 These are not treated as DOS hosts with a special listing format, because
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
157 the Distinct FTP server uses unix-style path syntax.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
158 (defvar efs-os2-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
159 "Regexp to match names of hosts running OS/2.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
160 (defvar efs-vos-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
161 "Regexp to match hosts running the VOS operating system.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
162 (defvar efs-hell-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
163 "Regexp to match hosts using the hellsoft ftp server.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
164 These map be either DOS PC's or Macs.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
165 ;; The way that we implement the hellsoft support, it probably won't
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
166 ;; work with Macs. This could probably be fixed, if enough people scream.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
167 (defvar efs-guardian-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
168 "Regexp to match hosts running Tandem's guardian operating system.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
169 ;; Note that ms-unix is really an FTP server running under DOS.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
170 ;; It's not a type of unix.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
171 (defvar efs-ms-unix-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
172 "Regexp to match hosts using the Microsoft FTP server in unix mode.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
173 (defvar efs-plan9-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
174 "Regexp to match hosts running ATT's Plan 9 operating system.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
175 (defvar efs-cms-knet-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
176 "Regexp to match hosts running the CMS KNET FTP server.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
177 (defvar efs-nos-ve-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
178 "Regexp to match hosts running NOS/VE.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
179 (defvar efs-netware-host-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
180 "Regexp to match hosts running Novell Netware.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
181 (defvar efs-dumb-apollo-unix-regexp nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
182 "Regexp to match dumb hosts running Apollo's Domain.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
183 These are hosts which do not accept switches to ls over FTP.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
184
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
185 ;;; Further host types:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
186 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
187 ;; unknown: This encompasses ka9q, dos-distinct, unix, sysV-unix, bsd-unix,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
188 ;; next-unix, and dumb-unix.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
189
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
190 (defconst efs-host-type-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
191 ;; When efs-add-host is called interactively, it will only allow
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
192 ;; host types from this list.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
193 '((dumb-unix . efs-dumb-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
194 (super-dumb-unix . efs-super-dumb-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
195 (next-unix . efs-next-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
196 (sysV-unix . efs-sysV-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
197 (bsd-unix . efs-bsd-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
198 (apollo-unix . efs-apollo-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
199 (unix . efs-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
200 (vms . efs-vms-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
201 (mts . efs-mts-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
202 (cms . efs-cms-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
203 (ti-explorer . efs-ti-explorer-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
204 (ti-twenex . efs-ti-twenex-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
205 (dos . efs-dos-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
206 (mvs . efs-mvs-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
207 (tops-20 . efs-tops-20-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
208 (mpe . efs-mpe-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
209 (ka9q . efs-ka9q-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
210 (dos-distinct . efs-dos-distinct-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
211 (os2 . efs-os2-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
212 (vos . efs-vos-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
213 (hell . efs-hell-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
214 (guardian . efs-guardian-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
215 (ms-unix . efs-ms-unix-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
216 (plan9 . efs-plan9-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
217 (cms-net . efs-cms-knet-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
218 (nos-ve . efs-nos-ve-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
219 (netware . efs-netware-host-regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
220 (dumb-apollo-unix . efs-dumb-apollo-unix-regexp)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
221
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
222 ;; host type cache
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
223 (defconst efs-host-cache nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
224 (defconst efs-host-type-cache nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
225
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
226 ;; cache for efs-ftp-path.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
227 (defconst efs-ftp-path-arg "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
228 (defconst efs-ftp-path-res nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
229
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
230 ;;;; -------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
231 ;;;; General macros.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
232 ;;;; -------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
233
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
234 (defmacro efs-save-match-data (&rest body)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
235 "Execute the BODY forms, restoring the global value of the match data.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
236 Before executing BODY, case-fold-search is locally bound to nil."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
237 ;; Because Emacs is buggy about let-binding buffer-local variables,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
238 ;; we have to do this in a slightly convoluted way.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
239 (let ((match-data-temp (make-symbol "match-data"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
240 (buff-temp (make-symbol "buff"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
241 (cfs-temp (make-symbol "cfs")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
242 (list
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
243 'let (list (list match-data-temp '(match-data))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
244 (list buff-temp '(current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
245 (list cfs-temp 'case-fold-search))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
246 (list 'unwind-protect
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
247 (cons 'progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
248 (cons
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
249 '(setq case-fold-search nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
250 body))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
251 (list 'condition-case nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
252 (list 'save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
253 (list 'set-buffer buff-temp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
254 (list 'setq 'case-fold-search cfs-temp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
255 '(error nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
256 (list 'store-match-data match-data-temp)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
257
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
258 (put 'efs-save-match-data 'lisp-indent-hook 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
259 (put 'efs-save-match-data 'edebug-form-spec '(&rest form))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
260
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
261 (defmacro efs-define-fun (fun args &rest body)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
262 "Like defun, but only defines a function if it has no previous definition."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
263 ;; There are easier ways to do this. This approach is used so that the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
264 ;; byte compiler won't complain about possibly undefined functions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
265 (`
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
266 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
267 (put (quote (, fun)) 'efs-define-fun
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
268 (and (fboundp (quote (, fun)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
269 (symbol-function (quote (, fun)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
270 (defun (, fun) (, args) (,@ body))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
271 (if (and (get (quote (, fun)) 'efs-define-fun)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
272 (not (eq (car-safe (get (quote (, fun)) 'efs-define-fun))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
273 (quote autoload))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
274 (fset (quote (, fun)) (get (quote (, fun)) 'efs-define-fun)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
275 (put (quote (, fun)) 'efs-define-fun nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
276 (quote (, fun)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
277
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
278 (put 'efs-define-fun 'lisp-indent-hook 'defun)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
279
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
280 (defmacro efs-quote-dollars (string)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
281 ;; Quote `$' as `$$' in STRING to get it past `substitute-in-file-name.'
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
282 (`
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
283 (let ((string (, string))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
284 (pos 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
285 (while (setq pos (string-match "\\$" string pos))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
286 (setq string (concat (substring string 0 pos)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
287 "$";; precede by escape character (also a $)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
288 (substring string pos))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
289 ;; add 2 instead 1 since another $ was inserted
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
290 pos (+ 2 pos)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
291 string)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
292
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
293 (defmacro efs-cont (implicit-args explicit-args &rest body)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
294 "Defines an efs continuation function.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
295 The IMPLICIT-ARGS are bound when the continuation function is called.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
296 The EXPLICIT-ARGS are bound when the continuation function is set."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
297 (let ((fun (list 'function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
298 (cons 'lambda
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
299 (cons
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
300 (append implicit-args explicit-args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
301 body)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
302 (if explicit-args
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
303 (cons 'list (cons fun explicit-args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
304 fun)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
305
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
306 (put 'efs-cont 'lisp-indent-hook 2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
307
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
308 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
309 ;;;; Utility functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
310 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
311
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
312 (efs-define-fun efs-repaint-minibuffer ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
313 ;; Set minibuf_message = 0, so that the contents of the minibuffer will show.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
314 ;; This is the Emacs V19 version of this function. For Emacs 18, it will
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
315 ;; be redefined in a grotty way to accomplish the same thing.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
316 (message nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
317
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
318 (defun efs-get-user (host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
319 "Given a HOST, return the default USER."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
320 (efs-parse-netrc)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
321 ;; We cannot check for users case-insensitively on those systems
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
322 ;; which are treat usernames case-insens., because we need to log in
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
323 ;; first, before we know what type of system.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
324 (let ((user (efs-get-host-property host 'user)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
325 (if (stringp user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
326 user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
327 (prog1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
328 (setq user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
329 (cond ((stringp efs-default-user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
330 ;; We have a default name. Use it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
331 efs-default-user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
332 ((consp efs-default-user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
333 ;; Walk the list looking for a host-specific value.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
334 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
335 (let ((alist efs-default-user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
336 (case-fold-search t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
337 result)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
338 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
339 (if (string-match (car (car alist)) host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
340 (setq result (cdr (car alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
341 alist nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
342 (setq alist (cdr alist))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
343 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
344 ((stringp result)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
345 result)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
346 (result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
347 (let ((enable-recursive-minibuffers t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
348 (read-string (format "User for %s: " host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
349 (user-login-name))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
350 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
351 (user-login-name))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
352 (efs-default-user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
353 ;; Ask the user.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
354 (let ((enable-recursive-minibuffers t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
355 (read-string (format "User for %s: " host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
356 (user-login-name))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
357 ;; Default to the user's login name.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
358 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
359 (user-login-name))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
360 (efs-set-user host user)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
361
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
362 ;;;###autoload
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
363 (defun efs-ftp-path (path)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
364 "Parse PATH according to efs-path-regexp.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
365 Returns a list (HOST USER PATH), or nil if PATH does not match the format."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
366 (or (string-equal path efs-ftp-path-arg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
367 (setq efs-ftp-path-res
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
368 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
369 (and (string-match efs-path-regexp path)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
370 (let ((host (substring path (match-beginning 2)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
371 (match-end 2)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
372 (user (and (match-beginning 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
373 (substring path (match-beginning 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
374 (1- (match-end 1)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
375 (rpath (substring path (1+ (match-end 2)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
376 (list (if (string-equal host "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
377 (setq host (system-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
378 host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
379 (or user (efs-get-user host))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
380 rpath))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
381 ;; Set this last, in case efs-get-user calls this
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
382 ;; function, which would modify an earlier setting.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
383 efs-ftp-path-arg path))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
384 efs-ftp-path-res)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
385
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
386 (defun efs-chase-symlinks (file)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
387 ;; If FILE is a symlink, chase it until we get to a real file.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
388 ;; Unlike file truename, this function does not chase symlinks at
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
389 ;; every level, only the bottom level. Therefore, it is not useful for
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
390 ;; obtaining the truename of a file. It is useful for getting at file
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
391 ;; attributes, with a lot less overhead than file truename.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
392 (let ((target (file-symlink-p file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
393 (if target
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
394 (efs-chase-symlinks
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
395 (expand-file-name target (file-name-directory file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
396 file)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
397
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
398 ;; If efs-host-type is called with the optional user
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
399 ;; argument, it will attempt to guess the host type by connecting
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
400 ;; as user, if necessary.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
401
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
402 (defun efs-host-type (host &optional user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
403 "Return a symbol which represents the type of the HOST given.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
404 If the optional argument USER is given, attempts to guess the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
405 host-type by logging in as USER."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
406
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
407 (and host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
408 (let ((host (downcase host))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
409 type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
410 (cond
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
411
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
412 ((and efs-host-cache
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
413 (string-equal host efs-host-cache)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
414 efs-host-type-cache))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
415
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
416 ((setq type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
417 (efs-get-host-property host 'host-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
418 (setq efs-host-cache host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
419 efs-host-type-cache type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
420
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
421 ;; Trigger an ftp connection, in case we need to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
422 ;; guess at the host type.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
423 ((and user (efs-get-process host user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
424 (if (string-equal host efs-host-cache)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
425 ;; logging in may update the cache
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
426 efs-host-type-cache
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
427 (and (setq type (efs-get-host-property host 'host-type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
428 (setq efs-host-cache host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
429 efs-host-type-cache type)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
430
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
431 ;; Try the regexps.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
432 ((setq type
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
433 (let ((alist efs-host-type-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
434 regexp type-pair)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
435 (catch 'match
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
436 (efs-save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
437 (let ((case-fold-search t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
438 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
439 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
440 (and (setq type-pair (car alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
441 regexp (eval (cdr type-pair)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
442 (string-match regexp host)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
443 (throw 'match (car type-pair)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
444 (setq alist (cdr alist)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
445 nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
446 (setq efs-host-cache host
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
447 efs-host-type-cache type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
448 ;; Return 'unknown, but _don't_ cache it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
449 (t 'unknown)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
450
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
451 ;;;; -------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
452 ;;;; Functions and macros for hashtables.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
453 ;;;; -------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
454
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
455 (defun efs-make-hashtable (&optional size)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
456 "Make an obarray suitable for use as a hashtable.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
457 SIZE, if supplied, should be a prime number."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
458 (make-vector (or size 31) 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
459
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
460 (defun efs-map-hashtable (fun tbl &optional property)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
461 "Call FUNCTION on each key and value in HASHTABLE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
462 If PROPERTY is non-nil, it is the property to be used as the second
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
463 argument to FUNCTION. The default property is 'val"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
464 (let ((prop (or property 'val)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
465 (mapatoms
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
466 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
467 (lambda (sym)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
468 (funcall fun (symbol-name sym) (get sym prop))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
469 tbl)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
470
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
471 (defmacro efs-make-hash-key (key)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
472 "Convert KEY into a suitable key for a hashtable. This returns a string."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
473 (` (let ((key (, key))) ; eval exactly once, in case evalling key moves the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
474 ; point.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
475 (if (stringp key) key (prin1-to-string key)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
476
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
477 ;;; Note, if you store entries in a hashtable case-sensitively, and then
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
478 ;;; retrieve them with IGNORE-CASE=t, it is possible that there may be
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
479 ;;; be more than one entry that could be retrieved. It is more or less random
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
480 ;;; which one you'll get. The onus is on the programmer to be consistent.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
481 ;;; Suggestions to make this faster are gratefully accepted!
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
482
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
483 (defmacro efs-case-fold-intern-soft (name tbl)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
484 "Returns a symbol with case-insensitive name NAME in the obarray TBL.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
485 Case is considered insignificant in NAME. Note, if there is more than
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
486 one possible match, it is hard to predicate which one you'll get."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
487 (`
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
488 (let* ((completion-ignore-case t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
489 (name (, name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
490 (tbl (, tbl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
491 (len (length (, name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
492 (newname (try-completion name tbl
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
493 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
494 (lambda (sym)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
495 (= (length (symbol-name sym)) len))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
496 (and newname
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
497 (if (eq newname t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
498 (intern name tbl)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
499 (intern newname tbl))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
500
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
501 (defmacro efs-hash-entry-exists-p (key tbl &optional ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
502 "Return whether there is an association for KEY in TABLE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
503 If optional IGNORE-CASE is non-nil, then ignore-case in the test."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
504 (` (let ((key (efs-make-hash-key (, key))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
505 (if (, ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
506 (efs-case-fold-intern-soft key (, tbl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
507 (intern-soft key (, tbl))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
508
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
509 (defmacro efs-get-hash-entry (key tbl &optional ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
510 "Return the value associated with KEY in HASHTABLE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
511 If the optional argument IGNORE-CASE is given, then case in the key is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
512 considered irrelevant."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
513 (` (let* ((key (efs-make-hash-key (, key)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
514 (sym (if (, ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
515 (efs-case-fold-intern-soft key (, tbl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
516 (intern-soft key (, tbl)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
517 (and sym (get sym 'val)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
518
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
519 (defmacro efs-put-hash-entry (key val tbl &optional ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
520 "Record an association between KEY and VALUE in HASHTABLE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
521 If the optional IGNORE-CASE argument is given, then check for an entry
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
522 which is the same modulo case, and update it instead of adding a new entry."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
523 (` (let* ((key (efs-make-hash-key (, key)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
524 (sym (if (, ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
525 (or (efs-case-fold-intern-soft key (, tbl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
526 (intern key (, tbl)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
527 (intern key (, tbl)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
528 (put sym 'val (, val)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
529
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
530 (defun efs-del-hash-entry (key tbl &optional ignore-case)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
531 "Copy all symbols except KEY in HASHTABLE and return modified hashtable.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
532 If the optional argument CASE-FOLD is non-nil, then fold KEY to lower case."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
533 (let* ((len (length tbl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
534 (new-tbl (efs-make-hashtable len))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
535 (i (1- len))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
536 (key (efs-make-hash-key key)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
537 (if ignore-case (setq key (downcase key)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
538 (efs-map-hashtable
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
539 (if ignore-case
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
540 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
541 (lambda (k v)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
542 (or (string-equal (downcase k) key)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
543 ;; Don't need to specify ignore-case here, because
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
544 ;; we have already weeded out possible case-fold matches.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
545 (efs-put-hash-entry k v new-tbl))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
546 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
547 (lambda (k v)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
548 (or (string-equal k key)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
549 (efs-put-hash-entry k v new-tbl)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
550 tbl)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
551 (while (>= i 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
552 (aset tbl i (aref new-tbl i))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
553 (setq i (1- i)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
554 ;; Return the result.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
555 tbl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
556
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
557 (defun efs-hash-table-keys (tbl &optional nosort)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
558 "Return a sorted of all the keys in the hashtable TBL, as strings.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
559 This list is sorted, unless the optional argument NOSORT is non-nil."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
560 (let ((result (all-completions "" tbl)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
561 (if nosort
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
562 result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
563 (sort result (function string-lessp)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
564
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
565 ;;; hashtable variables
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
566
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
567 (defconst efs-host-hashtable (efs-make-hashtable)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
568 "Hash table holding data on hosts.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
569
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
570 (defconst efs-host-user-hashtable (efs-make-hashtable)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
571 "Hash table for holding data on host user pairs.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
572
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
573 (defconst efs-minidisk-hashtable (efs-make-hashtable)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
574 "Mapping between a host, user, minidisk triplet and a account password.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
575
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
576 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
577 ;;;; Host / User mapping
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
578 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
579
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
580 (defun efs-set-host-property (host property value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
581 ;; For HOST, sets PROPERTY to VALUE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
582 (put (intern (downcase host) efs-host-hashtable) property value))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
583
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
584 (defun efs-get-host-property (host property)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
585 ;; For HOST, gets PROPERTY.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
586 (get (intern (downcase host) efs-host-hashtable) property))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
587
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
588 (defun efs-set-host-user-property (host user property value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
589 ;; For HOST and USER, sets PROPERTY to VALUE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
590 (let* ((key (concat (downcase host) "/" user))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
591 (sym (and (memq (efs-host-type host) efs-case-insensitive-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
592 (efs-case-fold-intern-soft key efs-host-user-hashtable))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
593 (or sym (setq sym (intern key efs-host-user-hashtable)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
594 (put sym property value)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
595
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
596 (defun efs-get-host-user-property (host user property)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
597 ;; For HOST and USER, gets PROPERTY.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
598 (let* ((key (concat (downcase host) "/" user))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
599 (sym (and (memq (efs-host-type host) efs-case-insensitive-host-types)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
600 (efs-case-fold-intern-soft key efs-host-user-hashtable))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
601 (or sym (setq sym (intern key efs-host-user-hashtable)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
602 (get sym property)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
603
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
604 (defun efs-set-user (host user)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
605 "For a given HOST, set or change the default USER."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
606 (interactive "sHost: \nsUser: ")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
607 (efs-set-host-property host 'user user))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
608
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
609 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
610 ;;;; Encryption
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
611 ;;;; ------------------------------------------------------------
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
612
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
613 (defconst efs-passwd-seed nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
614 ;; seed used to encrypt the password cache.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
615
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
616 (defun efs-get-passwd-seed ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
617 ;; Returns a random number to use for encrypting passwords.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
618 (or efs-passwd-seed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
619 (setq efs-passwd-seed (+ 1 (random 255)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
620
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
621 (defun efs-code-string (string)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
622 ;; Encode a string, using `efs-passwd-seed'. This is nil-potent,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
623 ;; meaning applying it twice decodes.
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
624 (if (and (fboundp 'int-to-char) (fboundp 'char-to-int))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
625 (mapconcat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
626 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
627 (lambda (c)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
628 (char-to-string
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 100
diff changeset
629 (int-to-char (logxor (efs-get-passwd-seed) (char-to-int c))))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
630 string "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
631 (mapconcat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
632 (function
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
633 (lambda (c)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
634 (char-to-string (logxor (efs-get-passwd-seed) c))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
635 string "")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
636
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
637 ;;; end of efs-cu.el