annotate lisp/efs/efs-cu.el @ 100:4be1180a9e89 r20-1b2

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