You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.7 KiB

  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/>.
  18. (define-module (guix gcrypt)
  19. #:use-module (guix config)
  20. #:use-module (system foreign)
  21. #:export (gcrypt-version
  22. libgcrypt-func))
  23. ;;; Commentary:
  24. ;;;
  25. ;;; Common code for the GNU Libgcrypt bindings. Loading this module
  26. ;;; initializes Libgcrypt as a side effect.
  27. ;;;
  28. ;;; Code:
  29. (define libgcrypt-func
  30. (let ((lib (dynamic-link %libgcrypt)))
  31. (lambda (func)
  32. "Return a pointer to symbol FUNC in libgcrypt."
  33. (dynamic-func func lib))))
  34. (define gcrypt-version
  35. ;; According to the manual, this function must be called before any other,
  36. ;; and it's not clear whether it can be called more than once. So call it
  37. ;; right here from the top level.
  38. (let* ((ptr (libgcrypt-func "gcry_check_version"))
  39. (proc (pointer->procedure '* ptr '(*)))
  40. (version (pointer->string (proc %null-pointer))))
  41. (lambda ()
  42. "Return the version number of libgcrypt as a string."
  43. version)))
  44. ;;; gcrypt.scm ends here