/[tramp]/tramp/lisp/tramp.el
ViewVC logotype

Diff of /tramp/lisp/tramp.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2.142 by youngs, Tue Jul 23 16:46:30 2002 UTC revision 2.143 by kai, Fri Jul 26 17:12:36 2002 UTC
# Line 2506  If KEEP-DATE is non-nil, preserve the ti Line 2506  If KEEP-DATE is non-nil, preserve the ti
2506  ;; mkdir  ;; mkdir
2507  (defun tramp-handle-make-directory (dir &optional parents)  (defun tramp-handle-make-directory (dir &optional parents)
2508    "Like `make-directory' for tramp files."    "Like `make-directory' for tramp files."
2509      (setq dir (expand-file-name dir))
2510    (with-parsed-tramp-file-name dir nil    (with-parsed-tramp-file-name dir nil
2511      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2512        (tramp-invoke-ange-ftp 'make-directory dir parents))        (tramp-invoke-ange-ftp 'make-directory dir parents))
# Line 2520  If KEEP-DATE is non-nil, preserve the ti Line 2521  If KEEP-DATE is non-nil, preserve the ti
2521  ;; CCC error checking?  ;; CCC error checking?
2522  (defun tramp-handle-delete-directory (directory)  (defun tramp-handle-delete-directory (directory)
2523    "Like `delete-directory' for tramp files."    "Like `delete-directory' for tramp files."
2524      (setq directory (expand-file-name directory))
2525    (with-parsed-tramp-file-name directory nil    (with-parsed-tramp-file-name directory nil
2526      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2527        (tramp-invoke-ange-ftp 'delete-directory directory))        (tramp-invoke-ange-ftp 'delete-directory directory))
# Line 2532  If KEEP-DATE is non-nil, preserve the ti Line 2534  If KEEP-DATE is non-nil, preserve the ti
2534    
2535  (defun tramp-handle-delete-file (filename)  (defun tramp-handle-delete-file (filename)
2536    "Like `delete-file' for tramp files."    "Like `delete-file' for tramp files."
2537      (setq filename (expand-file-name filename))
2538    (with-parsed-tramp-file-name filename nil    (with-parsed-tramp-file-name filename nil
2539      (when (tramp-ange-ftp-file-name-p multi-method method)      (when (tramp-ange-ftp-file-name-p multi-method method)
2540        (tramp-invoke-ange-ftp 'delete-file filename))        (tramp-invoke-ange-ftp 'delete-file filename))
# Line 2766  Doesn't do anything if the NAME does not Line 2769  Doesn't do anything if the NAME does not
2769    "Like `shell-command' for tramp files.    "Like `shell-command' for tramp files.
2770  This will break if COMMAND prints a newline, followed by the value of  This will break if COMMAND prints a newline, followed by the value of
2771  `tramp-end-of-output', followed by another newline."  `tramp-end-of-output', followed by another newline."
2772    (if (tramp-tramp-file-p default-directory)    (when (tramp-tramp-file-p default-directory)
2773        (with-parsed-tramp-file-name default-directory nil      (with-parsed-tramp-file-name default-directory nil
2774          (when (tramp-ange-ftp-file-name-p multi-method method)        (when (tramp-ange-ftp-file-name-p multi-method method)
2775            (let ((default-directory (tramp-make-ange-ftp-file-name          (let ((default-directory (tramp-make-ange-ftp-file-name
2776                                      user host path)))                                    user host path)))
2777              (tramp-invoke-ange-ftp 'shell-command            (tramp-invoke-ange-ftp 'shell-command
2778                                     command output-buffer error-buffer)))                                   command output-buffer error-buffer)))
2779          (let (status)        (let (status)
2780            (when (string-match "&[ \t]*\\'" command)          (when (string-match "&[ \t]*\\'" command)
2781              (error "Tramp doesn't grok asynchronous shell commands, yet"))            (error "Tramp doesn't grok asynchronous shell commands, yet"))
2782            (when error-buffer          (when error-buffer
2783              (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet"))            (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet"))
2784            (save-excursion          (save-excursion
2785              (tramp-barf-unless-okay            (tramp-barf-unless-okay
2786               multi-method method user host             multi-method method user host
2787               (format "cd %s" (tramp-shell-quote-argument path))             (format "cd %s" (tramp-shell-quote-argument path))
2788               nil 'file-error             nil 'file-error
2789               "tramp-handle-shell-command: Couldn't `cd %s'"             "tramp-handle-shell-command: Couldn't `cd %s'"
2790               (tramp-shell-quote-argument path))             (tramp-shell-quote-argument path))
2791              (tramp-send-command multi-method method user host            (tramp-send-command multi-method method user host
2792                                  (concat command "; tramp_old_status=$?"))                                (concat command "; tramp_old_status=$?"))
2793              ;; This will break if the shell command prints "/////"            ;; This will break if the shell command prints "/////"
2794              ;; somewhere.  Let's just hope for the best...            ;; somewhere.  Let's just hope for the best...
2795              (tramp-wait-for-output))            (tramp-wait-for-output))
2796            (unless output-buffer          (unless output-buffer
2797              (setq output-buffer (get-buffer-create "*Shell Command Output*"))            (setq output-buffer (get-buffer-create "*Shell Command Output*"))
             (set-buffer output-buffer)  
             (erase-buffer))  
           (unless (bufferp output-buffer)  
             (setq output-buffer (current-buffer)))  
2798            (set-buffer output-buffer)            (set-buffer output-buffer)
2799            (insert-buffer (tramp-get-buffer multi-method method user host))            (erase-buffer))
2800            (save-excursion          (unless (bufferp output-buffer)
2801              (tramp-send-command multi-method method user host "cd")            (setq output-buffer (current-buffer)))
2802              (tramp-wait-for-output)          (set-buffer output-buffer)
2803              (tramp-send-command          (insert-buffer (tramp-get-buffer multi-method method user host))
2804               multi-method method user host          (save-excursion
2805               (concat "tramp_set_exit_status $tramp_old_status;"            (tramp-send-command multi-method method user host "cd")
2806                       " echo tramp_exit_status $?"))            (tramp-wait-for-output)
2807              (tramp-wait-for-output)            (tramp-send-command
2808              (goto-char (point-max))             multi-method method user host
2809              (unless (search-backward "tramp_exit_status " nil t)             (concat "tramp_set_exit_status $tramp_old_status;"
2810                (error "Couldn't find exit status of `%s'" command))                     " echo tramp_exit_status $?"))
2811              (skip-chars-forward "^ ")            (tramp-wait-for-output)
2812              (setq status (read (current-buffer))))            (goto-char (point-max))
2813            (unless (zerop (buffer-size))            (unless (search-backward "tramp_exit_status " nil t)
2814              (pop-to-buffer output-buffer))              (error "Couldn't find exit status of `%s'" command))
2815            status)))            (skip-chars-forward "^ ")
2816              (setq status (read (current-buffer))))
2817            (unless (zerop (buffer-size))
2818              (pop-to-buffer output-buffer))
2819            status)))
2820    ;; The following is only executed if something strange was    ;; The following is only executed if something strange was
2821    ;; happening.  Emit a helpful message and do it anyway.    ;; happening.  Emit a helpful message and do it anyway.
2822    (message "tramp-handle-shell-command called with non-tramp directory: `%s'"    (message "tramp-handle-shell-command called with non-tramp directory: `%s'"
# Line 4508  locale to C and sets up the remote shell Line 4511  locale to C and sets up the remote shell
4511        (tramp-message        (tramp-message
4512         5 "Checking to see if encoding/decoding commands work on remote host...done"))))         5 "Checking to see if encoding/decoding commands work on remote host...done"))))
4513    
4514    (defvar tramp-coding-commands
4515      '(("mimencode -b" "mimencode -u -b"
4516         base64-encode-region base64-decode-region)
4517        ("mmencode -b" "mmencode -u -b"
4518         base64-encode-region base64-decode-region)
4519        ("tramp_mimencode" "tramp_mimedecode"
4520         base64-encode-region base64-encode-region)
4521        ("uuencode xxx" "uudecode -o -"
4522         nil uudecode-decode-region)
4523        ("uuencode xxx" "uudecode -p"
4524         nil uudecode-decode-region))
4525      "List of coding commands for inline transfer.
4526    Each item is a list (ENCODING-COMMAND DECODING-COMMAND
4527    ENCODING-FUNCTION DECODING-FUNCTION).
4528    
4529    The ENCODING-COMMAND should be a command accepting a plain file on
4530    standard input and writing the encoded file to standard output.  The
4531    DECODING-COMMAND should be a command accepting an encoded file on
4532    standard input and writing the decoded file to standard output.
4533    
4534    The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called
4535    with two arguments, start and end of region, and are expected to
4536    replace the region contents with the encoded or decoded results,
4537    respectively.")
4538    
4539    (defun tramp-find-inline-encoding (multi-method method user host)
4540      "Find an inline transfer encoding that works.
4541    Goes through the list `tramp-coding-commands'."
4542      (let ((commands tramp-coding-commands)
4543            item found)
4544        (while (and commands (null found))
4545          (setq item (pop commands))
4546          (catch 'wont-work
4547            (let ((ec (nth 0 item))
4548                  (dc (nth 1 item))
4549                  (ef (nth 2 item))
4550                  (df (nth 3 item)))
4551              ;; Check if encoding and decoding commands can be called
4552              ;; remotely with null input and output.  This makes sure there
4553              ;; are no syntax errors and the command is really found.
4554              (tramp-message-for-buffer
4555               multi-method method user host 10
4556               "Checking remote encoding command `%s' for sanity" ec)
4557              (unless (zerop (tramp-send-command-and-check
4558                              multi-method method user host
4559                              (format "%s </dev/null >/dev/null" ec) t))
4560                (throw 'wont-work nil))
4561              (tramp-message-for-buffer
4562               multi-method method user host 10
4563               "Checking remote decoding command `%s' for sanity" dc)
4564              (unless (zerop (tramp-send-command-and-check
4565                              multi-method method user host
4566                              (format "%s </dev/null >/dev/null" dc) t))
4567                (throw 'wont-work nil))
4568              ;; If no encoding/decoding function is given, the
4569              ;; corresponding encoding/decoding command also has to work
4570              ;; locally.
4571              (when (not (fboundp ef))
4572                (tramp-message-for-buffer
4573                 multi-method method user host 10
4574                 "Checking local encoding command `%s' for sanity" ec)
4575                (unless (zerop (call-process
4576                                tramp-sh-program ;program
4577                                nil         ;input
4578                                nil         ;output buffer
4579                                nil         ;redisplay
4580                                "-c"
4581                                (format "%s </dev/null >/dev/null" ec)))
4582                  (throw 'wont-work nil)))
4583              (when (not (fboundp df))
4584                (tramp-message-for-buffer
4585                 multi-method method user host 10
4586                 "Checking local decoding command `%s' for sanity" dc)
4587                (unless (zerop (call-process
4588                                tramp-sh-program ;program
4589                                nil         ;input file
4590                                nil         ;output buffer
4591                                nil         ;redisplay
4592                                "-c"
4593                                (format "%s </dev/null >/dev/null" dc)))
4594                  (throw 'wont-work nil)))
4595              ;; CCC: At this point, maybe we should check that the output
4596              ;; of the commands is correct.  But for the moment we will
4597              ;; assume that commands working on empty input will also
4598              ;; work in practice.
4599              (setq found item))))
4600        ;; Did we find something?  If not, issue error.  If so,
4601        ;; set connection properties.
4602        (unless found
4603          (error "Couldn't find an inline transfer encoding"))
4604        (let ((ec (nth 0 found))
4605              (dc (nth 1 found))
4606              (ef (nth 2 found))
4607              (df (nth 3 found)))
4608          (tramp-set-encoding-command multi-method method user host ec)
4609          (tramp-set-decoding-command multi-method method user host dc)
4610          (tramp-set-encoding-function multi-method method user host ef)
4611          (tramp-set-decoding-function multi-method method user host df))))
4612              
4613    
4614  (defun tramp-maybe-open-connection (multi-method method user host)  (defun tramp-maybe-open-connection (multi-method method user host)
4615    "Maybe open a connection to HOST, logging in as USER, using METHOD.    "Maybe open a connection to HOST, logging in as USER, using METHOD.
# Line 5010  to enter a password for the `tramp-rcp-p Line 5112  to enter a password for the `tramp-rcp-p
5112    (tramp-get-connection-property "ln" nil multi-method method user host))    (tramp-get-connection-property "ln" nil multi-method method user host))
5113    
5114  ;; Get a property of a TRAMP connection.  ;; Get a property of a TRAMP connection.
5115  (defun tramp-get-connection-property (property default multi-method method user host)  (defun tramp-get-connection-property
5116      (property default multi-method method user host)
5117    "Get the named property for the connection.    "Get the named property for the connection.
5118  If the value is not set for the connection, return `default'"  If the value is not set for the connection, return `default'"
5119    (tramp-maybe-open-connection multi-method method user host)    (tramp-maybe-open-connection multi-method method user host)
# Line 5021  If the value is not set for the connecti Line 5124  If the value is not set for the connecti
5124          (error  default)))))          (error  default)))))
5125    
5126  ;; Set a property of a TRAMP connection.  ;; Set a property of a TRAMP connection.
5127  (defun tramp-set-connection-property (property value multi-method method user host)  (defun tramp-set-connection-property
5128      (property value multi-method method user host)
5129    "Set the named property of a TRAMP connection."    "Set the named property of a TRAMP connection."
5130    (tramp-maybe-open-connection multi-method method user host)    (tramp-maybe-open-connection multi-method method user host)
5131    (with-current-buffer (tramp-get-buffer multi-method method user host)    (with-current-buffer (tramp-get-buffer multi-method method user host)
# Line 5029  If the value is not set for the connecti Line 5133  If the value is not set for the connecti
5133            (intern (concat "tramp-connection-property-" property)))            (intern (concat "tramp-connection-property-" property)))
5134            value)))            value)))
5135    
5136    ;; Some predefined connection properties.
5137    (defun tramp-get-encoding-command (multi-method method user host)
5138      (tramp-get-connection-property "encoding-command" nil
5139                                     multi-method method user host))
5140    (defun tramp-set-encoding-command (multi-method method user host command)
5141      (tramp-set-connection-property "encoding-command" command
5142                                     multi-method method user host))
5143    (defun tramp-get-decoding-command (multi-method method user host)
5144      (tramp-get-connection-property "decoding-command" nil
5145                                     multi-method method user host))
5146    (defun tramp-set-decoding-command (multi-method method user host command)
5147      (tramp-set-connection-property "decoding-command" command
5148                                     multi-method method user host))
5149    (defun tramp-get-encoding-function (multi-method method user host)
5150      (tramp-get-connection-property "encoding-function" nil
5151                                     multi-method method user host))
5152    (defun tramp-set-encoding-function (multi-method method user host func)
5153      (tramp-set-connection-property "encoding-function" func
5154                                     multi-method method user host))
5155    (defun tramp-get-decoding-function (multi-method method user host)
5156      (tramp-get-connection-property "decoding-function" nil
5157                                     multi-method method user host))
5158    (defun tramp-set-decoding-function (multi-method method user host func)
5159      (tramp-set-connection-property "decoding-function" func
5160                                     multi-method method user host))
5161    
5162    
5163  (defun tramp-get-connection-function (multi-method method)  (defun tramp-get-connection-function (multi-method method)
# Line 5094  If the value is not set for the connecti Line 5223  If the value is not set for the connecti
5223                (error "Method `%s' didn't specify su args"                (error "Method `%s' didn't specify su args"
5224                       (or multi-method method)))))                       (or multi-method method)))))
5225    
5226    (defun tramp-get-telnet-program (multi-method method)
5227      (second (or (assoc 'tramp-telnet-program
5228                         (assoc (or multi-method method tramp-default-method)
5229                                tramp-methods))
5230                  (error "Method `%s' didn't specify a telnet program"
5231                         (or multi-method method)))))
5232    
5233    (defun tramp-get-telnet-args (multi-method method)
5234      (second (or (assoc 'tramp-telnet-args
5235                         (assoc (or multi-method method tramp-default-method)
5236                                tramp-methods))
5237                  (error "Method `%s' didn't specify telnet args"
5238                         (or multi-method method)))))
5239    
5240  (defun tramp-get-encoding-command (multi-method method)  (defun tramp-get-encoding-command (multi-method method)
5241    (second (or (assoc 'tramp-encoding-command    (second (or (assoc 'tramp-encoding-command
5242                       (assoc (or multi-method method tramp-default-method)                       (assoc (or multi-method method tramp-default-method)
# Line 5122  If the value is not set for the connecti Line 5265  If the value is not set for the connecti
5265                (error "Method `%s' didn't specify a decoding function"                (error "Method `%s' didn't specify a decoding function"
5266                       (or multi-method method)))))                       (or multi-method method)))))
5267    
 (defun tramp-get-telnet-program (multi-method method)  
   (second (or (assoc 'tramp-telnet-program  
                      (assoc (or multi-method method tramp-default-method)  
                             tramp-methods))  
               (error "Method `%s' didn't specify a telnet program"  
                      (or multi-method method)))))  
   
 (defun tramp-get-telnet-args (multi-method method)  
   (second (or (assoc 'tramp-telnet-args  
                      (assoc (or multi-method method tramp-default-method)  
                             tramp-methods))  
               (error "Method `%s' didn't specify telnet args"  
                      (or multi-method method)))))  
   
5268  ;; Auto saving to a special directory.  ;; Auto saving to a special directory.
5269    
5270  (defun tramp-make-auto-save-file-name (fn)  (defun tramp-make-auto-save-file-name (fn)

Legend:
Removed from v.2.142  
changed lines
  Added in v.2.143

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26