Function: ange-ftp-raw-send-cmd

ange-ftp-raw-send-cmd is a byte-compiled function defined in ange-ftp.el.gz.

Signature

(ange-ftp-raw-send-cmd PROC CMD &optional MSG CONT NOWAIT)

Documentation

Low-level routine to send the given FTP CMD to the FTP process PROC.

MSG is an optional message to output before and after the command. If CONT is non-nil then it is either a function or a list of function and some arguments. The function will be called when the FTP command has completed. If CONT is nil then this routine will return (RESULT . LINE) where RESULT is whether the command was successful, and LINE is the line from the FTP process that caused the command to complete. If NOWAIT is given then the routine will return immediately the command has been queued with no result. CONT will still be called, however.

Source Code

;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
;;;; ------------------------------------------------------------
;;;; Support for sending commands to the ftp process.
;;;; ------------------------------------------------------------

(defun ange-ftp-raw-send-cmd (proc cmd &optional msg cont nowait)
  "Low-level routine to send the given FTP CMD to the FTP process PROC.
MSG is an optional message to output before and after the command.
If CONT is non-nil then it is either a function or a list of function
and some arguments.  The function will be called when the FTP command
has completed.
If CONT is nil then this routine will return (RESULT . LINE) where RESULT
is whether the command was successful, and LINE is the line from the FTP
process that caused the command to complete.
If NOWAIT is given then the routine will return immediately the command has
been queued with no result.  CONT will still be called, however."
  (if (memq (process-status proc) '(run open))
      (with-current-buffer (process-buffer proc)
	(ange-ftp-wait-not-busy proc)
	(setq ange-ftp-process-string ""
	      ange-ftp-process-result-line ""
	      ange-ftp-process-busy t
	      ange-ftp-process-result nil
	      ange-ftp-process-multi-skip nil
	      ange-ftp-process-msg msg
	      ange-ftp-process-continue cont
	      ange-ftp-hash-mark-count 0
	      ange-ftp-last-percent -1
	      cmd (concat cmd "\n"))
	(and msg ange-ftp-process-verbose (ange-ftp-message "%s..." msg))
	(goto-char (point-max))
	(move-marker comint-last-input-start (point))
	;; don't insert the password into the buffer on the USER command.
	(save-match-data
	  (if (string-match "\\`user \"[^\"]*\"" cmd)
	      (insert (substring cmd 0 (match-end 0)) " Turtle Power!\n")
	    (insert cmd)))
	(move-marker comint-last-input-end (point))
	(process-send-string proc cmd)
	(set-marker (process-mark proc) (point))
	(if nowait
	    nil
	  (ange-ftp-wait-not-busy proc)
	  (if cont
	      nil			;cont has already been called
	    (cons ange-ftp-process-result ange-ftp-process-result-line))))))