build: Remove checks for 'nix-instantiate'.
[guix.git] / guix / gcrypt.scm
blob1517501751d617d2a0c6d63318634cd1152dc872
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix gcrypt)
20   #:use-module (guix config)
21   #:use-module (system foreign)
22   #:export (gcrypt-version
23             libgcrypt-func))
25 ;;; Commentary:
26 ;;;
27 ;;; Common code for the GNU Libgcrypt bindings.  Loading this module
28 ;;; initializes Libgcrypt as a side effect.
29 ;;;
30 ;;; Code:
32 (define libgcrypt-func
33   (let ((lib (dynamic-link %libgcrypt)))
34     (lambda (func)
35       "Return a pointer to symbol FUNC in libgcrypt."
36       (dynamic-func func lib))))
38 (define gcrypt-version
39   ;; According to the manual, this function must be called before any other,
40   ;; and it's not clear whether it can be called more than once.  So call it
41   ;; right here from the top level.
42   (let* ((ptr     (libgcrypt-func "gcry_check_version"))
43          (proc    (pointer->procedure '* ptr '(*)))
44          (version (pointer->string (proc %null-pointer))))
45     (lambda ()
46       "Return the version number of libgcrypt as a string."
47       version)))
49 ;;; gcrypt.scm ends here