1 ;;; jabber-ft-common.el --- Common functions for sending and receiving files (JEP-0096)
3 ;; Copyright (C) 2006 Magnus Henoch
5 ;; Author: Magnus Henoch <mange@freemail.hu>
7 ;; This file is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; This file is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 ;; Boston, MA 02110-1301, USA.
22 (defcustom jabber-ft-md5sum-program
(or (when (executable-find "md5")
23 (list (executable-find "md5") "-n"))
24 (when (executable-find "md5sum")
25 (list (executable-find "md5sum"))))
26 "The program to use to calculate MD5 sums of files.
27 It should accept the file name as the only argument."
31 (defun jabber-ft-get-md5 (file-name)
32 "Get MD5 sum of FILE-NAME, and return as hex string.
33 Return nil if no MD5 summing program is available."
34 (when jabber-ft-md5sum-program
36 (apply 'call-process
(car jabber-ft-md5sum-program
) nil t nil
37 (append (cdr jabber-ft-md5sum-program
) (list file-name
)))
38 ;; Output is "hexsum filename"
39 (goto-char (point-min))
41 (buffer-substring (point-min) (point)))))
43 (provide 'jabber-ft-common
)
44 ;; arch-tag: 1ce4cce0-8360-11da-a5ba-000a95c2fcd0