Function: erc-dcc-handle-ctcp-send

erc-dcc-handle-ctcp-send is a byte-compiled function defined in erc-dcc.el.gz.

Signature

(erc-dcc-handle-ctcp-send PROC QUERY NICK LOGIN HOST TO)

Documentation

This is called if a CTCP DCC SEND subcommand is sent to the client.

It extracts the information about the dcc request and adds it to erc-dcc-list.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc-dcc.el.gz
(defun erc-dcc-handle-ctcp-send (proc query nick login host to)
  "This is called if a CTCP DCC SEND subcommand is sent to the client.
It extracts the information about the dcc request and adds it to
`erc-dcc-list'."
  (unless (eq erc-dcc-send-request 'ignore)
    (cond
     ((not (erc-current-nick-p to))
      ;; DCC SEND requests must be sent to you, and you alone.
      (erc-display-message
       nil 'notice proc
       'dcc-request-bogus
       ?r "SEND" ?n nick ?u login ?h host))
     ((string-match erc-dcc-ctcp-query-send-regexp query)
      (let* ((filename (or (match-string 2 query)
                           (erc-dcc-unquote-filename (match-string 1 query))))
             (ip (erc-decimal-to-ip (match-string 3 query)))
             (port (match-string 4 query))
             (size (match-string 5 query))
             (sub (substring (match-string 6 query) 0 -4))
             (secure (seq-contains-p sub ?S #'eq))
             (turbo (seq-contains-p sub ?T #'eq)))
        ;; FIXME: a warning really should also be sent
        ;; if the ip address != the host the dcc sender is on.
        (erc-display-message
         nil 'notice proc
         'dcc-send-offered
         ?f filename ?n nick ?u login ?h host
         ?s (if (string= size "") "unknown" size))
        (and (< (string-to-number port) 1025)
             (erc-display-message
              nil 'notice proc
              'dcc-privileged-port
              ?p port))
        (erc-dcc-list-add
         'GET (format "%s!%s@%s" nick login host)
         nil proc
         :ip ip :port port :file filename
         :size (string-to-number size)
         :turbo (and turbo t)
         :secure (and secure t))
        (if (and (eq erc-dcc-send-request 'auto)
                 (erc-dcc-auto-mask-p (format "\"%s!%s@%s\"" nick login host)))
            (erc-dcc-get-file (car erc-dcc-list) filename proc))))
     (t
      (erc-display-message
       nil 'notice proc
       'dcc-malformed
       ?n nick ?u login ?h host ?q query)))))