3014 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
3015 |
multi-method method user host |
multi-method method user host |
3016 |
5 "Fetching %s to tmp file %s...done" filename tmpfil)) |
5 "Fetching %s to tmp file %s...done" filename tmpfil)) |
3017 |
((and (tramp-get-encoding-command multi-method method user host) |
((and (tramp-get-remote-encoding multi-method method user host) |
3018 |
(tramp-get-decoding-command multi-method method user host)) |
(tramp-get-remote-decoding multi-method method user host)) |
3019 |
;; Use inline encoding for file transfer. |
;; Use inline encoding for file transfer. |
3020 |
(save-excursion |
(save-excursion |
3021 |
;; Following line for setting tramp-current-method, |
;; Following line for setting tramp-current-method, |
3024 |
(tramp-message 5 "Encoding remote file %s..." filename) |
(tramp-message 5 "Encoding remote file %s..." filename) |
3025 |
(tramp-barf-unless-okay |
(tramp-barf-unless-okay |
3026 |
multi-method method user host |
multi-method method user host |
3027 |
(concat (tramp-get-encoding-command multi-method method user host) |
(concat (tramp-get-remote-encoding |
3028 |
|
multi-method method user host) |
3029 |
" < " (tramp-shell-quote-argument path)) |
" < " (tramp-shell-quote-argument path)) |
3030 |
nil 'file-error |
nil 'file-error |
3031 |
"Encoding remote file failed, see buffer `%s' for details" |
"Encoding remote file failed, see buffer `%s' for details" |
3035 |
(delete-region (point) (progn (forward-line -1) (point))) |
(delete-region (point) (progn (forward-line -1) (point))) |
3036 |
|
|
3037 |
(tramp-message 5 "Decoding remote file %s..." filename) |
(tramp-message 5 "Decoding remote file %s..." filename) |
3038 |
(if (and (tramp-get-decoding-function multi-method method user host) |
|
3039 |
(fboundp (tramp-get-decoding-function |
(let ((loc-enc (tramp-get-local-encoding |
3040 |
multi-method method user host))) |
multi-method method user host)) |
3041 |
;; If tramp-decoding-function is defined for this |
(loc-dec (tramp-get-local-decoding |
3042 |
;; method, we call it. |
multi-method method user host))) |
3043 |
|
(if (and (symbolp loc-dec) (fboundp loc-dec)) |
3044 |
|
;; If local decoding is a function, we call it. |
3045 |
(let ((tmpbuf (get-buffer-create " *tramp tmp*"))) |
(let ((tmpbuf (get-buffer-create " *tramp tmp*"))) |
3046 |
(set-buffer tmpbuf) |
(set-buffer tmpbuf) |
3047 |
(erase-buffer) |
(erase-buffer) |
3050 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
3051 |
multi-method method user host |
multi-method method user host |
3052 |
6 "Decoding remote file %s with function %s..." |
6 "Decoding remote file %s with function %s..." |
3053 |
filename |
filename loc-dec) |
|
(tramp-get-decoding-function multi-method method user host)) |
|
3054 |
(set-buffer tmpbuf) |
(set-buffer tmpbuf) |
3055 |
;; Douglas Gray Stephens <DGrayStephens@slb.com> |
;; Douglas Gray Stephens <DGrayStephens@slb.com> |
3056 |
;; says that we need to strip tramp_exit_status |
;; says that we need to strip tramp_exit_status |
3058 |
;; search backward for tramp_exit_status, delete |
;; search backward for tramp_exit_status, delete |
3059 |
;; between point and point-max if found. |
;; between point and point-max if found. |
3060 |
(let ((coding-system-for-write 'no-conversion)) |
(let ((coding-system-for-write 'no-conversion)) |
3061 |
(funcall (tramp-get-decoding-function |
(funcall loc-dec (point-min) (point-max)) |
|
multi-method method user host) |
|
|
(point-min) |
|
|
(point-max)) |
|
3062 |
(write-region (point-min) (point-max) tmpfil)) |
(write-region (point-min) (point-max) tmpfil)) |
3063 |
(kill-buffer tmpbuf)) |
(kill-buffer tmpbuf)) |
3064 |
;; If tramp-decoding-function is not defined for this |
;; If tramp-decoding-function is not defined for this |
3067 |
(write-region (point-min) (point-max) tmpfil2) |
(write-region (point-min) (point-max) tmpfil2) |
3068 |
(tramp-message |
(tramp-message |
3069 |
6 "Decoding remote file %s with command %s..." |
6 "Decoding remote file %s with command %s..." |
3070 |
filename |
filename loc-dec) |
3071 |
(tramp-get-decoding-command multi-method method user host)) |
(tramp-call-local-coding-command |
3072 |
(if tramp-encoding-reads-stdin |
loc-dec tmpfil2 tmpfil) |
|
;; Something like: /bin/sh -c COMMAND <INPUT >OUTPUT |
|
|
(call-process |
|
|
tramp-encoding-shell |
|
|
tmpfil2 ;input |
|
|
nil ;output |
|
|
nil ;display |
|
|
tramp-encoding-command-switch |
|
|
(concat (tramp-get-decoding-command |
|
|
multi-method method user host) |
|
|
" > " tmpfil)) |
|
|
;; Something like: /bin/sh -c COMMAND INPUT >OUTPUT |
|
|
(call-process |
|
|
tramp-encoding-shell |
|
|
nil ;input |
|
|
nil ;output |
|
|
nil ;display |
|
|
tramp-encoding-command-switch |
|
|
(concat (tramp-get-decoding-command |
|
|
multi-method method user host) |
|
|
tmpfil2 |
|
|
" > " |
|
|
tmpfil))) |
|
3073 |
(delete-file tmpfil2))) |
(delete-file tmpfil2))) |
3074 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
3075 |
multi-method method user host |
multi-method method user host |
3076 |
5 "Decoding remote file %s...done" filename))) |
5 "Decoding remote file %s...done" filename)))) |
3077 |
|
|
3078 |
(t (error "Wrong method specification for `%s'" method))) |
(t (error "Wrong method specification for `%s'" method))) |
3079 |
tmpfil))) |
tmpfil))) |
3149 |
(let ((curbuf (current-buffer)) |
(let ((curbuf (current-buffer)) |
3150 |
(rcp-program (tramp-get-rcp-program multi-method method)) |
(rcp-program (tramp-get-rcp-program multi-method method)) |
3151 |
(rcp-args (tramp-get-rcp-args multi-method method)) |
(rcp-args (tramp-get-rcp-args multi-method method)) |
3152 |
(encoding-command |
(rem-enc (tramp-get-remote-encoding multi-method method user host)) |
3153 |
(tramp-get-encoding-command multi-method method user host)) |
(rem-dec (tramp-get-remote-decoding multi-method method user host)) |
3154 |
(encoding-function |
(loc-enc (tramp-get-local-encoding multi-method method user host)) |
3155 |
(tramp-get-encoding-function multi-method method user host)) |
(loc-dec (tramp-get-local-decoding multi-method method user host)) |
|
(decoding-command |
|
|
(tramp-get-decoding-command multi-method method user host)) |
|
3156 |
(trampbuf (get-buffer-create "*tramp output*")) |
(trampbuf (get-buffer-create "*tramp output*")) |
3157 |
;; We use this to save the value of `last-coding-system-used' |
;; We use this to save the value of `last-coding-system-used' |
3158 |
;; after writing the tmp file. At the end of the function, |
;; after writing the tmp file. At the end of the function, |
3214 |
multi-method method user host |
multi-method method user host |
3215 |
6 "Transferring file using `%s'...done" |
6 "Transferring file using `%s'...done" |
3216 |
rcp-program))) |
rcp-program))) |
3217 |
((and encoding-command decoding-command) |
((and rem-enc rem-dec |
3218 |
;; Use inline file transfer |
;; Use inline file transfer |
3219 |
(let ((tmpbuf (get-buffer-create " *tramp file transfer*"))) |
(let ((tmpbuf (get-buffer-create " *tramp file transfer*"))) |
3220 |
(save-excursion |
(save-excursion |
3224 |
(set-buffer tmpbuf) |
(set-buffer tmpbuf) |
3225 |
(erase-buffer) |
(erase-buffer) |
3226 |
;; Use encoding function or command. |
;; Use encoding function or command. |
3227 |
(if (and encoding-function |
(if (and (symbolp loc-enc) (fboundp loc-enc)) |
|
(fboundp encoding-function)) |
|
3228 |
(progn |
(progn |
3229 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
3230 |
multi-method method user host |
multi-method method user host |
3241 |
;; tmp file anyway. |
;; tmp file anyway. |
3242 |
(let ((default-directory |
(let ((default-directory |
3243 |
(tramp-temporary-file-directory))) |
(tramp-temporary-file-directory))) |
3244 |
(funcall encoding-function (point-min) (point-max))) |
(funcall loc-enc (point-min) (point-max))) |
3245 |
(goto-char (point-max)) |
(goto-char (point-max)) |
3246 |
(unless (bolp) |
(unless (bolp) |
3247 |
(newline))) |
(newline))) |
3248 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
3249 |
multi-method method user host |
multi-method method user host |
3250 |
6 "Encoding region using command...") |
6 "Encoding region using command...") |
3251 |
(unless |
(unless (equal 0 (tramp-call-local-coding-command |
3252 |
(equal 0 |
loc-enc tmpfil t)) |
|
(if tramp-encoding-reads-stdin |
|
|
;; Something like: |
|
|
;; sh -c COMMAND <INPUT >OUTPUT |
|
|
(call-process |
|
|
tramp-encoding-shell |
|
|
tmpfil ;input = local tmp file |
|
|
t ;output is current buffer |
|
|
nil ;don't redisplay |
|
|
tramp-encoding-command-switch |
|
|
encoding-command) |
|
|
;; Something like: |
|
|
;; sh -c COMMAND INPUT >OUTPUT |
|
|
(call-process |
|
|
tramp-encoding-shell |
|
|
nil ;input |
|
|
t ;output is current buffer |
|
|
nil ;don't redisplay |
|
|
tramp-encoding-command-switch |
|
|
(concat encoding-command |
|
|
" " tmpfil)))) |
|
3253 |
(pop-to-buffer trampbuf) |
(pop-to-buffer trampbuf) |
3254 |
(error (concat "Cannot write to `%s', local encoding" |
(error (concat "Cannot write to `%s', local encoding" |
3255 |
" command `%s' failed") |
" command `%s' failed") |
3256 |
filename encoding-command))) |
filename loc-enc))) |
3257 |
;; Send tmpbuf into remote decoding command which |
;; Send tmpbuf into remote decoding command which |
3258 |
;; writes to remote file. Because this happens on the |
;; writes to remote file. Because this happens on the |
3259 |
;; remote host, we cannot use the function. |
;; remote host, we cannot use the function. |
3263 |
(tramp-send-command |
(tramp-send-command |
3264 |
multi-method method user host |
multi-method method user host |
3265 |
(format "%s >%s <<'EOF'" |
(format "%s >%s <<'EOF'" |
3266 |
decoding-command |
rem-dec |
3267 |
(tramp-shell-quote-argument path))) |
(tramp-shell-quote-argument path))) |
3268 |
(set-buffer tmpbuf) |
(set-buffer tmpbuf) |
3269 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
3286 |
multi-method method user host nil nil 'file-error |
multi-method method user host nil nil 'file-error |
3287 |
(concat "Couldn't write region to `%s'," |
(concat "Couldn't write region to `%s'," |
3288 |
" decode using `%s' failed") |
" decode using `%s' failed") |
3289 |
filename decoding-command) |
filename rem-dec) |
3290 |
(tramp-message 5 "Decoding region into remote file %s...done" |
(tramp-message 5 "Decoding region into remote file %s...done" |
3291 |
filename) |
filename) |
3292 |
(kill-buffer tmpbuf)))) |
(kill-buffer tmpbuf))))) |
3293 |
(t |
(t |
3294 |
(error |
(error |
3295 |
(concat "Method `%s' should specify both encoding and " |
(concat "Method `%s' should specify both encoding and " |
4855 |
;; a Kerberos login. |
;; a Kerberos login. |
4856 |
(sit-for 1) |
(sit-for 1) |
4857 |
(tramp-discard-garbage-erase-buffer p multi-method method user host) |
(tramp-discard-garbage-erase-buffer p multi-method method user host) |
4858 |
(process-send-string nil (format "exec env PS1='$ ' %s%s" |
;; It is useful to set the prompt in the following command because |
4859 |
|
;; some people have a setting for $PS1 which /bin/sh doesn't know |
4860 |
|
;; about and thus /bin/sh will display a strange prompt. For |
4861 |
|
;; example, if $PS1 has "${CWD}" in the value, then ksh will display |
4862 |
|
;; the current working directory but /bin/sh will display a dollar |
4863 |
|
;; sign. The following command line sets $PS1 to a sane value, and |
4864 |
|
;; works under Bourne-ish shells as well as csh-like shells. Daniel |
4865 |
|
;; Pittman reports that the unusual positioning of the single quotes |
4866 |
|
;; makes it work under `rc', too. |
4867 |
|
(process-send-string nil (format "exec env 'PS1=$ ' %s%s" |
4868 |
(tramp-get-remote-sh multi-method method) |
(tramp-get-remote-sh multi-method method) |
4869 |
tramp-rsh-end-of-line)) |
tramp-rsh-end-of-line)) |
4870 |
(when tramp-debug-buffer |
(when tramp-debug-buffer |
5105 |
" -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" |
" -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" |
5106 |
"}")) |
"}")) |
5107 |
(tramp-wait-for-output) |
(tramp-wait-for-output) |
5108 |
(tramp-message 5 "Sending the Perl `mime-encode' implementations.") |
(unless (tramp-get-rcp-program multi-method method) |
5109 |
(tramp-send-linewise |
(tramp-message 5 "Sending the Perl `mime-encode' implementations.") |
5110 |
multi-method method user host |
(tramp-send-linewise |
5111 |
(concat "tramp_encode () {\n" |
multi-method method user host |
5112 |
(format tramp-perl-encode tramp-remote-perl) |
(concat "tramp_encode () {\n" |
5113 |
" 2>/dev/null" |
(format tramp-perl-encode tramp-remote-perl) |
5114 |
"\n}")) |
" 2>/dev/null" |
5115 |
(tramp-wait-for-output) |
"\n}")) |
5116 |
(tramp-send-linewise |
(tramp-wait-for-output) |
5117 |
multi-method method user host |
(tramp-send-linewise |
5118 |
(concat "tramp_encode_with_module () {\n" |
multi-method method user host |
5119 |
(format tramp-perl-encode-with-module tramp-remote-perl) |
(concat "tramp_encode_with_module () {\n" |
5120 |
" 2>/dev/null" |
(format tramp-perl-encode-with-module tramp-remote-perl) |
5121 |
"\n}")) |
" 2>/dev/null" |
5122 |
(tramp-wait-for-output) |
"\n}")) |
5123 |
(tramp-message 5 "Sending the Perl `mime-decode' implementations.") |
(tramp-wait-for-output) |
5124 |
(tramp-send-linewise |
(tramp-message 5 "Sending the Perl `mime-decode' implementations.") |
5125 |
multi-method method user host |
(tramp-send-linewise |
5126 |
(concat "tramp_decode () {\n" |
multi-method method user host |
5127 |
(format tramp-perl-decode tramp-remote-perl) |
(concat "tramp_decode () {\n" |
5128 |
" 2>/dev/null" |
(format tramp-perl-decode tramp-remote-perl) |
5129 |
"\n}")) |
" 2>/dev/null" |
5130 |
(tramp-wait-for-output) |
"\n}")) |
5131 |
(tramp-send-linewise |
(tramp-wait-for-output) |
5132 |
multi-method method user host |
(tramp-send-linewise |
5133 |
(concat "tramp_decode_with_module () {\n" |
multi-method method user host |
5134 |
(format tramp-perl-decode-with-module tramp-remote-perl) |
(concat "tramp_decode_with_module () {\n" |
5135 |
" 2>/dev/null" |
(format tramp-perl-decode-with-module tramp-remote-perl) |
5136 |
"\n}")) |
" 2>/dev/null" |
5137 |
(tramp-wait-for-output)))) |
"\n}")) |
5138 |
|
(tramp-wait-for-output))))) |
5139 |
;; Find ln(1) |
;; Find ln(1) |
5140 |
(erase-buffer) |
(erase-buffer) |
5141 |
(let ((ln (tramp-find-executable multi-method method user host |
(let ((ln (tramp-find-executable multi-method method user host |
5149 |
;; If encoding/decoding command are given, test to see if they work. |
;; If encoding/decoding command are given, test to see if they work. |
5150 |
;; CCC: Maybe it would be useful to run the encoder both locally and |
;; CCC: Maybe it would be useful to run the encoder both locally and |
5151 |
;; remotely to see if they produce the same result. |
;; remotely to see if they produce the same result. |
5152 |
(let ((decoding (tramp-get-decoding-command multi-method method user host)) |
(let ((rem-enc (tramp-get-remote-encoding multi-method method user host)) |
5153 |
(encoding (tramp-get-encoding-command multi-method method user host)) |
(rem-dec (tramp-get-remote-decoding multi-method method user host)) |
5154 |
(magic-string "xyzzy")) |
(magic-string "xyzzy")) |
5155 |
(when (and (or decoding encoding) (not (and decoding encoding))) |
(when (and (or rem-dec rem-enc) (not (and rem-dec rem-enc))) |
5156 |
(tramp-kill-process multi-method method user host) |
(tramp-kill-process multi-method method user host) |
5157 |
|
;; Improve error message and/or error check. |
5158 |
(error |
(error |
5159 |
"Must give both decoding and encoding command in method definition")) |
"Must give both decoding and encoding command in method definition")) |
5160 |
(when (and decoding encoding) |
(when (and rem-enc rem-dec) |
5161 |
(tramp-message |
(tramp-message |
5162 |
5 |
5 |
5163 |
"Checking to see if encoding/decoding commands work on remote host...") |
"Checking to see if encoding/decoding commands work on remote host...") |
5164 |
(tramp-send-command |
(tramp-send-command |
5165 |
multi-method method user host |
multi-method method user host |
5166 |
(format "echo %s | %s | %s" |
(format "echo %s | %s | %s" |
5167 |
(tramp-shell-quote-argument magic-string) encoding decoding)) |
(tramp-shell-quote-argument magic-string) rem-enc rem-dec)) |
5168 |
(tramp-wait-for-output) |
(tramp-wait-for-output) |
5169 |
(unless (looking-at (regexp-quote magic-string)) |
(unless (looking-at (regexp-quote magic-string)) |
5170 |
(tramp-kill-process multi-method method user host) |
(tramp-kill-process multi-method method user host) |
5186 |
("recode data..base64" "recode base64..data" |
("recode data..base64" "recode base64..data" |
5187 |
base64-encode-region base64-decode-region) |
base64-encode-region base64-decode-region) |
5188 |
("uuencode xxx" "uudecode -o -" |
("uuencode xxx" "uudecode -o -" |
5189 |
nil uudecode-decode-region) |
"uuencode xxx" uudecode-decode-region) |
5190 |
("uuencode xxx" "uudecode -p" |
("uuencode xxx" "uudecode -p" |
5191 |
nil uudecode-decode-region) |
"uuencode xxx" uudecode-decode-region) |
5192 |
("uuencode xxx" "tramp_uudecode" |
("uuencode xxx" "tramp_uudecode" |
5193 |
nil uudecode-decode-region) |
"uuencode xxx" uudecode-decode-region) |
5194 |
|
("uuencode xxx" "uudecode -o -" |
5195 |
|
"uuencode -o -c -s %s" uudecode-decode-region) |
5196 |
("tramp_encode_with_module" "tramp_decode_with_module" |
("tramp_encode_with_module" "tramp_decode_with_module" |
5197 |
base64-encode-region base64-decode-region) |
base64-encode-region base64-decode-region) |
5198 |
("tramp_encode" "tramp_decode" |
("tramp_encode" "tramp_decode" |
5199 |
base64-encode-region base64-decode-region)) |
base64-encode-region base64-decode-region)) |
5200 |
"List of coding commands for inline transfer. |
"List of coding commands for inline transfer. |
5201 |
Each item is a list (ENCODING-COMMAND DECODING-COMMAND |
Each item is a list that looks like this: |
|
ENCODING-FUNCTION DECODING-FUNCTION). |
|
5202 |
|
|
5203 |
Each item can be a string, giving a command, or a symbol, giving |
\(REMOTE-ENCODING REMOTE-DECODING LOCAL-ENCODING LOCAL-DECODING) |
|
a function. |
|
5204 |
|
|
5205 |
The ENCODING-COMMAND should be a command accepting a plain file on |
The REMOTE-ENCODING should be a string, giving a command accepting a |
5206 |
standard input and writing the encoded file to standard output. The |
plain file on standard input and writing the encoded file to standard |
5207 |
DECODING-COMMAND should be a command accepting an encoded file on |
output. The REMOTE-DECODING should also be a string, giving a command |
5208 |
standard input and writing the decoded file to standard output. |
accepting an encoded file on standard input and writing the decoded |
5209 |
|
file to standard output. |
5210 |
The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called |
|
5211 |
with two arguments, start and end of region, and are expected to |
LOCAL-ENCODING and LOCAL-DECODING can be strings, giving commands, or |
5212 |
replace the region contents with the encoded or decoded results, |
symbols, giving functions. If they are strings, then they can contain |
5213 |
respectively.") |
the \"%s\" format specifier. If that specifier is present, the input |
5214 |
|
filename will be put into the command line at that spot. If the |
5215 |
|
specifier is not present, the input should be read from standard |
5216 |
|
input. |
5217 |
|
|
5218 |
|
If they are functions, they will be called with two arguments, start |
5219 |
|
and end of region, and are expected to replace the region contents |
5220 |
|
with the encoded or decoded results, respectively.") |
5221 |
|
|
5222 |
(defun tramp-find-inline-encoding (multi-method method user host) |
(defun tramp-find-inline-encoding (multi-method method user host) |
5223 |
"Find an inline transfer encoding that works. |
"Find an inline transfer encoding that works. |
5227 |
(while (and commands (null found)) |
(while (and commands (null found)) |
5228 |
(setq item (pop commands)) |
(setq item (pop commands)) |
5229 |
(catch 'wont-work |
(catch 'wont-work |
5230 |
(let ((ec (nth 0 item)) |
(let ((rem-enc (nth 0 item)) |
5231 |
(dc (nth 1 item)) |
(rem-dec (nth 1 item)) |
5232 |
(ef (nth 2 item)) |
(loc-enc (nth 2 item)) |
5233 |
(df (nth 3 item))) |
(loc-dec (nth 3 item))) |
5234 |
;; Check if encoding and decoding commands can be called |
;; Check if remote encoding and decoding commands can be |
5235 |
;; remotely with null input and output. This makes sure there |
;; called remotely with null input and output. This makes |
5236 |
;; are no syntax errors and the command is really found. |
;; sure there are no syntax errors and the command is really |
5237 |
|
;; found. |
5238 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
5239 |
multi-method method user host 9 |
multi-method method user host 9 |
5240 |
"Checking remote encoding command `%s' for sanity" ec) |
"Checking remote encoding command `%s' for sanity" rem-enc) |
5241 |
(unless (zerop (tramp-send-command-and-check |
(unless (zerop (tramp-send-command-and-check |
5242 |
multi-method method user host |
multi-method method user host |
5243 |
(format "%s </dev/null >/dev/null" ec) t)) |
(format "%s </dev/null >/dev/null" rem-enc) t)) |
5244 |
(throw 'wont-work nil)) |
(throw 'wont-work nil)) |
5245 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
5246 |
multi-method method user host 9 |
multi-method method user host 9 |
5247 |
"Checking remote decoding command `%s' for sanity" dc) |
"Checking remote decoding command `%s' for sanity" rem-dec) |
5248 |
(unless (zerop (tramp-send-command-and-check |
(unless (zerop (tramp-send-command-and-check |
5249 |
multi-method method user host |
multi-method method user host |
5250 |
(format "echo xyzzy | %s | %s >/dev/null" ec dc) t)) |
(format "echo xyzzy | %s | %s >/dev/null" |
5251 |
|
rem-enc rem-dec) t)) |
5252 |
(throw 'wont-work nil)) |
(throw 'wont-work nil)) |
5253 |
;; If no encoding/decoding function is given, the |
;; If the local encoder or decoder is a string, the |
5254 |
;; corresponding encoding/decoding command also has to work |
;; corresponding command has to work locally. |
5255 |
;; locally. |
(when (stringp loc-enc) |
|
(when (not (fboundp ef)) |
|
5256 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
5257 |
multi-method method user host 9 |
multi-method method user host 9 |
5258 |
"Checking local encoding command `%s' for sanity" ec) |
"Checking local encoding command `%s' for sanity" loc-enc) |
5259 |
(unless (zerop |
(unless (zerop (tramp-call-local-coding-command |
5260 |
(call-process |
loc-enc null-device null-device)) |
|
tramp-encoding-shell ;program |
|
|
nil ;input file |
|
|
nil ;output buffer |
|
|
nil ;redisplay |
|
|
tramp-encoding-command-switch |
|
|
(if tramp-encoding-reads-stdin |
|
|
(format "%s <%s >%s" ec null-device null-device) |
|
|
(format "%s %s >%s" ec null-device null-device)))) |
|
5261 |
(throw 'wont-work nil))) |
(throw 'wont-work nil))) |
5262 |
(when (not (fboundp df)) |
(when (stringp loc-dec) |
5263 |
(tramp-message-for-buffer |
(tramp-message-for-buffer |
5264 |
multi-method method user host 9 |
multi-method method user host 9 |
5265 |
"Checking local decoding command `%s' for sanity" dc) |
"Checking local decoding command `%s' for sanity" loc-dec) |
5266 |
(unless (zerop |
(unless (zerop (tramp-call-local-coding-command |
5267 |
(call-process |
loc-dec null-device null-device)) |
|
tramp-encoding-shell ;program |
|
|
nil ;input file |
|
|
nil ;output buffer |
|
|
nil ;redisplay |
|
|
tramp-encoding-command-switch |
|
|
(if tramp-encoding-reads-stdin |
|
|
(format "%s <%s >%s" dc null-device null-device) |
|
|
(format "%s %s >%s" dc null-device null-device)))) |
|
5268 |
(throw 'wont-work nil))) |
(throw 'wont-work nil))) |
5269 |
;; CCC: At this point, maybe we should check that the output |
;; CCC: At this point, maybe we should check that the output |
5270 |
;; of the commands is correct. But for the moment we will |
;; of the commands is correct. But for the moment we will |
5275 |
;; set connection properties. |
;; set connection properties. |
5276 |
(unless found |
(unless found |
5277 |
(error "Couldn't find an inline transfer encoding")) |
(error "Couldn't find an inline transfer encoding")) |
5278 |
(let ((ec (nth 0 found)) |
(let ((rem-enc (nth 0 found)) |
5279 |
(dc (nth 1 found)) |
(rem-dec (nth 1 found)) |
5280 |
(ef (nth 2 found)) |
(loc-enc (nth 2 found)) |
5281 |
(df (nth 3 found))) |
(loc-dec (nth 3 found))) |
5282 |
(tramp-set-encoding-command multi-method method user host ec) |
(tramp-set-remote-encoding multi-method method user host rem-enc) |
5283 |
(tramp-set-decoding-command multi-method method user host dc) |
(tramp-set-remote-decoding multi-method method user host rem-dec) |
5284 |
(tramp-set-encoding-function multi-method method user host ef) |
(tramp-set-local-encoding multi-method method user host loc-enc) |
5285 |
(tramp-set-decoding-function multi-method method user host df)))) |
(tramp-set-local-decoding multi-method method user host loc-dec)))) |
5286 |
|
|
5287 |
|
(defun tramp-call-local-coding-command (cmd input output) |
5288 |
|
"Call the local encoding or decoding command. |
5289 |
|
If CMD contains \"%s\", provide input file INPUT there in command. |
5290 |
|
Otherwise, INPUT is passed via standard input. |
5291 |
|
OUTPUT specifies a filename or t, which means to standard output |
5292 |
|
\(and thus, the current buffer)." |
5293 |
|
(call-process |
5294 |
|
tramp-encoding-shell ;program |
5295 |
|
(unless (string-match "%s" cmd) ;input file |
5296 |
|
input) |
5297 |
|
(if (eq output t) t nil) ;output |
5298 |
|
nil ;redisplay |
5299 |
|
tramp-encoding-command-switch |
5300 |
|
;; actual shell command |
5301 |
|
(concat |
5302 |
|
(if (string-match "%s" cmd) (format cmd input) cmd) |
5303 |
|
(if (stringp output) (concat "> " output) nil)))) |
5304 |
|
|
5305 |
(defun tramp-maybe-open-connection (multi-method method user host) |
(defun tramp-maybe-open-connection (multi-method method user host) |
5306 |
"Maybe open a connection to HOST, logging in as USER, using METHOD. |
"Maybe open a connection to HOST, logging in as USER, using METHOD. |
5862 |
value))) |
value))) |
5863 |
|
|
5864 |
;; Some predefined connection properties. |
;; Some predefined connection properties. |
5865 |
(defun tramp-get-encoding-command (multi-method method user host) |
(defun tramp-set-remote-encoding (multi-method method user host rem-enc) |
5866 |
(tramp-get-connection-property "encoding-command" nil |
(tramp-set-connection-property "remote-encoding" rem-enc |
5867 |
multi-method method user host)) |
multi-method method user host)) |
5868 |
(defun tramp-set-encoding-command (multi-method method user host command) |
(defun tramp-get-remote-encoding (multi-method method user host) |
5869 |
(tramp-set-connection-property "encoding-command" command |
(tramp-get-connection-property "remote-encoding" nil |
5870 |
multi-method method user host)) |
multi-method method user host)) |
5871 |
(defun tramp-get-decoding-command (multi-method method user host) |
|
5872 |
(tramp-get-connection-property "decoding-command" nil |
(defun tramp-set-remote-decoding (multi-method method user host rem-dec) |
5873 |
|
(tramp-set-connection-property "remote-decoding" rem-dec |
5874 |
multi-method method user host)) |
multi-method method user host)) |
5875 |
(defun tramp-set-decoding-command (multi-method method user host command) |
(defun tramp-get-remote-decoding (multi-method method user host) |
5876 |
(tramp-set-connection-property "decoding-command" command |
(tramp-get-connection-property "remote-decoding" nil |
5877 |
multi-method method user host)) |
multi-method method user host)) |
5878 |
(defun tramp-get-encoding-function (multi-method method user host) |
|
5879 |
(tramp-get-connection-property "encoding-function" nil |
(defun tramp-set-local-encoding (multi-method method user host loc-enc) |
5880 |
|
(tramp-set-connection-property "local-encoding" loc-enc |
5881 |
multi-method method user host)) |
multi-method method user host)) |
5882 |
(defun tramp-set-encoding-function (multi-method method user host func) |
(defun tramp-get-local-encoding (multi-method method user host) |
5883 |
(tramp-set-connection-property "encoding-function" func |
(tramp-get-connection-property "local-encoding" nil |
5884 |
multi-method method user host)) |
multi-method method user host)) |
5885 |
(defun tramp-get-decoding-function (multi-method method user host) |
|
5886 |
(tramp-get-connection-property "decoding-function" nil |
(defun tramp-set-local-decoding (multi-method method user host loc-dec) |
5887 |
|
(tramp-set-connection-property "local-decoding" loc-dec |
5888 |
multi-method method user host)) |
multi-method method user host)) |
5889 |
(defun tramp-set-decoding-function (multi-method method user host func) |
(defun tramp-get-local-decoding (multi-method method user host) |
5890 |
(tramp-set-connection-property "decoding-function" func |
(tramp-get-connection-property "local-decoding" nil |
5891 |
multi-method method user host)) |
multi-method method user host)) |
5892 |
|
|
5893 |
|
|
5894 |
|
|
5895 |
(defun tramp-get-connection-function (multi-method method) |
(defun tramp-get-connection-function (multi-method method) |
5896 |
(second (or (assoc 'tramp-connection-function |
(second (or (assoc 'tramp-connection-function |
5897 |
(assoc (or multi-method method tramp-default-method) |
(assoc (or multi-method method tramp-default-method) |
5969 |
(error "Method `%s' didn't specify telnet args" |
(error "Method `%s' didn't specify telnet args" |
5970 |
(or multi-method method))))) |
(or multi-method method))))) |
5971 |
|
|
|
;; (defun tramp-get-encoding-command (multi-method method) |
|
|
;; (second (or (assoc 'tramp-encoding-command |
|
|
;; (assoc (or multi-method method tramp-default-method) |
|
|
;; tramp-methods)) |
|
|
;; (error "Method `%s' didn't specify an encoding command" |
|
|
;; (or multi-method method))))) |
|
|
|
|
|
;; (defun tramp-get-decoding-command (multi-method method) |
|
|
;; (second (or (assoc 'tramp-decoding-command |
|
|
;; (assoc (or multi-method method tramp-default-method) |
|
|
;; tramp-methods)) |
|
|
;; (error "Method `%s' didn't specify a decoding command" |
|
|
;; (or multi-method method))))) |
|
|
|
|
|
;; (defun tramp-get-encoding-function (multi-method method) |
|
|
;; (second (or (assoc 'tramp-encoding-function |
|
|
;; (assoc (or multi-method method tramp-default-method) |
|
|
;; tramp-methods)) |
|
|
;; (error "Method `%s' didn't specify an encoding function" |
|
|
;; (or multi-method method))))) |
|
|
|
|
|
;; (defun tramp-get-decoding-function (multi-method method) |
|
|
;; (second (or (assoc 'tramp-decoding-function |
|
|
;; (assoc (or multi-method method tramp-default-method) |
|
|
;; tramp-methods)) |
|
|
;; (error "Method `%s' didn't specify a decoding function" |
|
|
;; (or multi-method method))))) |
|
5972 |
|
|
5973 |
;; Auto saving to a special directory. |
;; Auto saving to a special directory. |
5974 |
|
|