racket/collects/openssl/libcrypto.rkt
Matthew Flatt be538b4f69 accomodate OpenBSD linking of libssl
Merge to v5.3.1
2012-10-18 11:58:59 -06:00

28 lines
1009 B
Racket

#lang racket/base
(require ffi/unsafe
racket/runtime-path
(for-syntax racket/base))
(provide libcrypto
libcrypto-load-fail-reason)
(define libcrypto-load-fail-reason #f)
;; We need to declare because they might be distributed with PLT Scheme
;; in which case they should get bundled with stand-alone executables:
(define-runtime-path libcrypto-so
(case (system-type)
[(windows) '(so "libeay32")]
[else '(so "libcrypto")]))
(define libcrypto
(with-handlers ([exn:fail? (lambda (x)
(set! libcrypto-load-fail-reason (exn-message x))
#f)])
(ffi-lib libcrypto-so '("" "1.0.0" "1.0" "0.9.8b" "0.9.8" "0.9.7")
;; On OpenBSD, libssl is linked in a way that requires libcrypto
;; to be opened as global:
#:global? (member (path->bytes (system-library-subpath #f))
'(#"i386-openbsd"
#"x86_64-openbsd")))))