annotate lisp/efs/efs-gwp.el @ 116:9f59509498e1 r20-1b10

Import from CVS: tag r20-1b10
author cvs
date Mon, 13 Aug 2007 09:23:06 +0200
parents 8619ce7e4c50
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
1 ;; -*-Emacs-Lisp-*-
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
3 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
4 ;; File: efs-gwp.el
8fc7fe29b841 Import from CVS: tag r19-15b94
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.1 $
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
7 ;; RCS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
8 ;; Description: Support for efs to use an interactive gateway.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
9 ;; Author: Andy Norman, Dawn
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
10 ;; Created: Thu Mar 18 13:03:14 1993
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
11 ;; Modified: Sun Nov 27 18:31:50 1994 by sandy on gandalf
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
12 ;; Language: Emacs-Lisp
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
13 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
15
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
16 ;;; This file is part of efs. See efs.el for copyright
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
17 ;;; (it's copylefted) and warrranty (there isn't one) information.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
18
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
19 (provide 'efs-gwp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
20 (require 'efs)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
21
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
22 ;;;; ------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
23 ;;;; Interactive gateway program support.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
24 ;;;; ------------------------------------------------------------
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
25
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
27 ;;; User Variables and Documentation
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
28
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
29 (defvar efs-gwp-setup-term-command
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
30 (if (eq system-type 'hpux)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
31 "stty -onlcr -echo\n"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
32 "stty -echo nl\n")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
33 "Command to do terminal setup on the gateway machine.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
34 They must stop the terminal echoing each command and strip out trailing
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
35 ^M characters. This string must end in \\n. If you need to send multiple
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
36 commands, include them all in this string, separated by \\n.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
37 See the documentation in efs.el for some example commands.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
38
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
39 ;; About efs-gwp-term-setup-command:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
40 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
41 ;; It is important to get efs-gwp-setup-term-command right.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
42 ;; Here are some examples. Please tell us about which commands
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
43 ;; to use on other platforms, so that we can include it in the
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
44 ;; documentation.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
45 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
46 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
47 ;; HP-UX:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
48 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
49 ;; "stty -onlcr -echo\n"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
50 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
51 ;; SunOS:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
52 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
53 ;; "stty -echo nl\n"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
54 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
55 ;; VMS: (this should work)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
56 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
57 ;; "set terminal/noecho\n"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
58 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
59
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
60
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
61 (defvar efs-gwp-prompt-pattern "^[^#$%>;]*[#$%>;] *"
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
62 "*Regexp used to detect that the gateway login sequence has completed.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
63 It will be assumed that the shell is ready to receive input. Make this
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
64 regexp as strict as possible; it shouldn't match *anything* at all except
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
65 the shell's initial prompt. The above string will fail under most SUN-3's
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
66 since it matches the login banner.")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
67
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
68 ;; About efs-gwp-prompt-pattern:
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
69 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
70 ;; It is very important that this not match anything in the machine's
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
71 ;; login banner.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
72 ;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
73 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
74
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
75 ;;; Internal Variables
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
76
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
77 (defconst efs-gwp-version
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
78 (concat (substring "$efs release: 1.15 $" 14 -2)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
79 "/"
116
9f59509498e1 Import from CVS: tag r20-1b10
cvs
parents: 114
diff changeset
80 (substring "#Revision: 1.1 $" 11 -2)))
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
81
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
82 (defvar efs-gwp-running t)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
83 (defvar efs-gwp-status nil)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
84 (defvar efs-gwp-string "")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
85
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
86 ;;; Entry point (defined as an autoload in efs.el)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
87
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
88 (defun efs-gwp-start (host user name)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
89 "Login to the gateway machine and fire up an ftp process."
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
90 (message "Connecting to gateway %s..." efs-gateway-host)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
91 (let ((proc (apply 'start-process name (efs-ftp-process-buffer host user)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
92 (nth 1 efs-gateway-type)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
93 (append (nth 2 efs-gateway-type)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
94 (list efs-gateway-host))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
95 (ftp (concat (nth 3 efs-gateway-type) " "
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
96 (mapconcat (function identity) (nth 4 efs-gateway-type)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
97 " ") "\n")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
98 (process-kill-without-query proc)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
99 (set-process-sentinel proc (function efs-gwp-sentinel))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
100 (set-process-filter proc (function efs-gwp-filter))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
101 (set-marker (process-mark proc) (point))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
102 (setq efs-gwp-running t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
103 efs-gwp-status nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
104 efs-gwp-string "")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
105 (while efs-gwp-running ;perform login sequence
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
106 (accept-process-output proc))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
107 (if (not efs-gwp-status)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
108 (efs-error host user "unable to login to gateway"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
109 (message "Connecting to gateway %s...done" efs-gateway-host)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
110 (setq efs-gwp-running t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
111 efs-gwp-status nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
112 efs-gwp-string "")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
113 (process-send-string proc efs-gwp-setup-term-command)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
114 (while efs-gwp-running ;zap ^M's and double echoing.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
115 (accept-process-output proc))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
116 (if (not efs-gwp-status)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
117 (efs-error host user "unable to set terminal modes on gateway"))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
118 (setq efs-gwp-running t
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
119 efs-gwp-status nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
120 efs-gwp-string "")
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
121 (message "Opening FTP connection to %s..." host)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
122 (process-send-string proc ftp)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
123 proc))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
124
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
125 ;;; Process filter/sentinel
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
126
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
127 (defun efs-gwp-sentinel (proc str)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
128 (setq efs-gwp-running nil))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
129
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
130 (defun efs-gwp-filter (proc str)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
131 (efs-save-match-data
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
132 ;; Don't be sensitive to login vn LOGIN.
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
133 (let ((case-fold-search t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
134 (efs-process-log-string proc str)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
135 (setq efs-gwp-string (concat efs-gwp-string str))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
136 (cond ((string-match "\\(login\\|username\\): *$" efs-gwp-string)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
137 (process-send-string proc
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
138 (concat
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
139 (let ((efs-default-user t))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
140 (efs-get-user efs-gateway-host))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
141 "\n")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
142 ((string-match "password: *$" efs-gwp-string)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
143 (process-send-string proc
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
144 (concat
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
145 (efs-get-passwd efs-gateway-host
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
146 (efs-get-user
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
147 efs-gateway-host))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
148 "\n")))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
149 ((string-match efs-gateway-fatal-msgs
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
150 efs-gwp-string)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
151 (delete-process proc)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
152 (setq efs-gwp-running nil))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
153 ((string-match efs-gwp-prompt-pattern
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
154 efs-gwp-string)
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
155 (setq efs-gwp-running nil
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
156 efs-gwp-status t))))))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
157
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents:
diff changeset
158 ;;; end of efs-gwp.el