Skip to content

Instantly share code, notes, and snippets.

@public
Created December 19, 2013 16:38
Show Gist options
  • Save public/8042219 to your computer and use it in GitHub Desktop.
Save public/8042219 to your computer and use it in GitHub Desktop.
import cffi
isdefined_template = """
#include <openssl/opensslconf.h>
char cryptography_isdefined_{0}() {{
#ifdef {0}
return 1;
#else
return 0;
#endif
}}
"""
def isdefined(define):
func_name = "cryptography_isdefined_{0}".format(define)
ffi = cffi.FFI()
ffi.cdef("bool {0}();".format(func_name))
source = isdefined_template.format(define)
lib = ffi.verify(source=source)
return getattr(lib, func_name)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment