typedef struct SHA256state_st
{
SHA_LONG h[8];
SHA_LONG Nl,Nh;
SHA_LONG data[SHA_LBLOCK];
unsigned int num,md_len;
} SHA256_CTX;
int SHA256_Init(SHA256_CTX *c);
int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
int SHA256_Final(unsigned char *md, SHA256_CTX *c);
]]
...
function _M.new(self)
local ctx = ffi_new(ctx_ptr_type)
if C.SHA256_Init(ctx) == 0 then
return nil
end
return setmetatable({ _ctx = ctx }, mt)
end
I'm confused how luajit finds the location C funcions definded while no ffi.load() is used.
And how can I call some custom C function in default C namespace like above?
Thank you.