Function: ange-ftp-process-filter

ange-ftp-process-filter is a byte-compiled function defined in ange-ftp.el.gz.

Signature

(ange-ftp-process-filter PROC STR)

Source Code

;; Defined in /usr/src/emacs/lisp/net/ange-ftp.el.gz
;; Build up a complete line of output from the ftp PROCESS and pass it
;; on to ange-ftp-process-handle-line to deal with.

(defun ange-ftp-process-filter (proc str)
  ;; Eliminate nulls.
  (while (string-match "\000+" str)
    (setq str (replace-match "" nil nil str)))

  ;; see if the buffer is still around... it could have been deleted.
  (when (buffer-live-p (process-buffer proc))
    (with-current-buffer (process-buffer proc)

      ;; handle hash mark printing
      (and ange-ftp-process-busy
           (string-match "^#+$" str)
           (setq str (ange-ftp-process-handle-hash str)))
      (comint-output-filter proc str)
      ;; Replace STR by the result of the comint processing.
      (setq str (buffer-substring comint-last-output-start
                                  (process-mark proc)))
      (when ange-ftp-process-busy
	(setq ange-ftp-process-string (concat ange-ftp-process-string
					      str))

	;; if we gave an empty password to the USER command earlier
	;; then we should send a null password now.
	(if (string-match "Password: *$" ange-ftp-process-string)
	    (process-send-string proc "\n")))
      (while (and ange-ftp-process-busy
                  (string-match "\n" ange-ftp-process-string))
        (let ((line (substring ange-ftp-process-string
                               0
                               (match-beginning 0)))
              (seen-prompt nil))
          (setq ange-ftp-process-string (substring ange-ftp-process-string
                                                   (match-end 0)))
          (while (string-match "\\`ftp> *" line)
            (setq seen-prompt t)
            (setq line (substring line (match-end 0))))
          (if (not (and seen-prompt ange-ftp-pending-error-line))
              (ange-ftp-process-handle-line line proc)
            ;; If we've seen a potential error message and it
            ;; hasn't been canceled by a good message before
            ;; seeing a prompt, then the error was real.
            (delete-process proc)
            (setq ange-ftp-process-busy nil
                  ange-ftp-process-result-line ange-ftp-pending-error-line))))

      ;; has the ftp client finished?  if so then do some clean-up
      ;; actions.
      (unless ange-ftp-process-busy
	;; reset the xfer size
	(setq ange-ftp-xfer-size 0)

	;; issue the "done" message since we've finished.
	(when (and ange-ftp-process-msg
		   ange-ftp-process-verbose
		   ange-ftp-process-result)
	  (ange-ftp-message "%s...done" ange-ftp-process-msg)
	  (ange-ftp-repaint-minibuffer)
	  (setq ange-ftp-process-msg nil))

	;; is there a continuation we should be calling?  if so,
	;; we'd better call it, making sure we only call it once.
	(when ange-ftp-process-continue
	  (let ((cont ange-ftp-process-continue))
	    (setq ange-ftp-process-continue nil)
	    (ange-ftp-call-cont cont
				ange-ftp-process-result
				ange-ftp-process-result-line)))))))