X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-ndcc.el;h=821308979d1a88dfe071e37ef9cdea21c690bcba;hb=998b5db7f7d0f5959667816c5eac18126b70a478;hp=72301f8279d0f06fd5315ba5489fe20de9dcd235;hpb=d12de5de15b34acee1674dca14336e7c3c028037;p=elisp%2Friece.git diff --git a/lisp/riece-ndcc.el b/lisp/riece-ndcc.el index 72301f8..8213089 100644 --- a/lisp/riece-ndcc.el +++ b/lisp/riece-ndcc.el @@ -18,8 +18,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -30,8 +30,6 @@ (require 'riece-globals) (require 'riece-options) -(require 'calc) - (defgroup riece-ndcc nil "DCC written in elisp." :prefix "riece-" @@ -48,8 +46,6 @@ Only used for sending files." (defvar riece-ndcc-request-user nil) (defvar riece-ndcc-request-size nil) -(defvar riece-ndcc-enabled nil) - (defconst riece-ndcc-description "DCC file sending protocol support (written in elisp.)") @@ -58,23 +54,25 @@ Only used for sending files." "^\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)$" address) (error "% is not an IP address" address)) - (let ((calc-number-radix 10)) - (calc-eval (format "%s * (2 ** 24) + %s * (2 **16) + %s * (2 ** 8) + %s" - (match-string 1 address) - (match-string 2 address) - (match-string 3 address) - (match-string 4 address))))) + (let ((string (number-to-string + (+ (* (float (string-to-number (match-string 1 address))) + 16777216) + (* (float (string-to-number (match-string 2 address))) + 65536) + (* (float (string-to-number (match-string 3 address))) + 256) + (float (string-to-number (match-string 4 address))))))) + (if (string-match "\\." string) + (substring string 0 (match-beginning 0)) + string))) (defun riece-ndcc-decode-address (address) - (format "%d.%d.%d.%d" - (floor (string-to-number - (calc-eval (format "(%s / (2 ** 24)) %% 256" address)))) - (floor (string-to-number - (calc-eval (format "(%s / (2 ** 16)) %% 256" address)))) - (floor (string-to-number - (calc-eval (format "(%s / (2 ** 8)) %% 256" address)))) - (floor (string-to-number - (calc-eval (format "%s %% 256" address)))))) + (let ((float-address (string-to-number (concat address ".0")))) + (format "%d.%d.%d.%d" + (floor (mod (/ float-address 16777216) 256)) + (floor (mod (/ float-address 65536) 256)) + (floor (mod (/ float-address 256) 256)) + (floor (mod float-address 256))))) (defun riece-ndcc-server-sentinel (process status) (when (string-match "^open from " status) @@ -196,7 +194,7 @@ Only used for sending files." (defun riece-handle-dcc-request (prefix target message) (let ((case-fold-search t)) - (when (and riece-ndcc-enabled + (when (and (get 'riece-ndcc 'riece-addon-enabled) (string-match "SEND \\([^ ]+\\) \\([^ ]+\\) \\([^ ]+\\) \\([^ ]+\\)" message))