1 ;;; epg-config.el --- configuration of the EasyPG Library
2 ;; Copyright (C) 2006 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Keywords: PGP, GnuPG
7 ;; This file is part of EasyPG.
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
30 (defcustom epg-gpg-program "gpg"
31 "The `gpg' executable."
35 (defcustom epg-gpgsm-program "gpgsm"
36 "The `gpgsm' executable."
40 (defcustom epg-gpg-home-directory nil
41 "The directory which contains the `gpg' configuration files."
43 :type '(choice (const :tag "Default" nil) directory))
45 (defconst epg-version-number "0.0.4")
48 (defun epg-configuration ()
49 "Return a list of internal configuration parameters of `epg-gpg-program'."
52 (apply #'call-process epg-gpg-program nil (list t nil) nil
53 '("--with-colons" "--list-config"))
54 (goto-char (point-min))
55 (while (re-search-forward "^cfg:\\([^:]+\\):\\(.*\\)" nil t)
56 (setq type (intern (match-string 1))
57 config (cons (cons type
59 '(pubkey cipher digest compress))
60 (mapcar #'string-to-number
61 (delete "" (split-string
69 (defun epg-check-configuration (config)
70 "Verify that CONFIGURATION is sufficient."
71 (let ((entry (assq 'version config))
75 (string-match "\\`\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)"
77 (error "Undetermined version: %S" entry))
78 (setq major (string-to-number (match-string 1 (cdr entry)))
79 minor (string-to-number (match-string 2 (cdr entry)))
80 teeny (string-to-number (match-string 3 (cdr entry))))
81 (unless (or (> major 1)
86 (error "Unsupported version: %s" (cdr entry)))))
90 ;;; epg-config.el ends here