+2006-09-04 Daiki Ueno <ueno@unixuser.org>
+
+ * epg-config.el (epg-gpg-minimum-version): New constant.
+ (epg-config--parse-version): New function.
+ (epg-config--compare-version): New function.
+
2006-09-03 Daiki Ueno <ueno@unixuser.org>
* epg-config.el: New file; moved GnuPG configuration check from
(defconst epg-version-number "0.0.4")
+(defconst epg-gpg-minimum-version "1.4.3")
+
;;;###autoload
(defun epg-configuration ()
"Return a list of internal configuration parameters of `epg-gpg-program'."
config))))
config))
+(defun epg-config--parse-version (string)
+ (let ((index 0)
+ version)
+ (while (eq index (string-match "\\([0-9]+\\)\\.?" string index))
+ (setq version (cons (string-to-number (match-string 1 string))
+ version)
+ index (match-end 0)))
+ (nreverse version)))
+
+(defun epg-config--compare-version (v1 v2)
+ (while (and v1 v2 (= (car v1) (car v2)))
+ (setq v1 (cdr v1)
+ v2 (cdr v2)))
+ (setq v1 (or (car v1) 0)
+ v2 (or (car v2) 0))
+ (if (> v1 v2) 1 (if (= v1 v2) 0 -1)))
+
;;;###autoload
-(defun epg-check-configuration (config)
- "Verify that CONFIGURATION is sufficient."
+(defun epg-check-configuration (config &optional minimum-version)
+ "Verify that a sufficient version of GnuPG is installed."
(let ((entry (assq 'version config))
- major minor teeny)
+ version)
(unless (and entry
- (stringp (cdr entry))
- (string-match "\\`\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)"
- (cdr entry)))
+ (stringp (cdr entry)))
(error "Undetermined version: %S" entry))
- (setq major (string-to-number (match-string 1 (cdr entry)))
- minor (string-to-number (match-string 2 (cdr entry)))
- teeny (string-to-number (match-string 3 (cdr entry))))
- (unless (or (> major 1)
- (and (= major 1)
- (or (> minor 4)
- (and (= minor 4)
- (>= teeny 3)))))
+ (setq version (epg-config--parse-version (cdr entry))
+ minimum-version (epg-config--parse-version
+ (or minimum-version
+ epg-gpg-minimum-version)))
+ (unless (>= (epg-config--compare-version version minimum-version) 0)
(error "Unsupported version: %s" (cdr entry)))))
(provide 'epg-config)