[plt-scheme] FFI - Implicit binding of _int to the correct _int32 or _int64

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Sep 26 21:24:52 EDT 2007

On Sep 26, Ray Racine wrote:
> man hmac
>  #include <openssl/hmac.h>
>         unsigned char *HMAC(const EVP_MD *evp_md, const void *key,
>                       int key_len, const unsigned char *d, int n,
>                       unsigned char *md, unsigned int *md_len);
> Changing back to _int and using (_ptr o _int) the following is working
> for me.  Am I using (_ptr o _int) appropriately here?
>   (define HMAC-SHA1/raw
>     (get-ffi-obj 'HMAC openssl-crypto
>                  (_fun [EVP_MD : _fpointer = (EVP_SHA1)]
>                        [key : _bytes]
>                        [key_len : _int = (bytes-length key)]
>                        [data : _bytes]
>                        [data_len : _int = (bytes-length data)]
>                        [md : _int = 0]
>                        [md_len : (_ptr o _int)]
>                        ->
>                        _pointer)))

This doesn't look right to me.  `md' should be a pointer, not an
integer, right?  Also, you're not using the resulting `md_len'.  (But
maybe you don't need to, if it returns the pointer too, and if it
points to a NUL-terminated string.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.