When nginx startup, linked library was automaticly loaded.
在 2017年7月17日星期一 UTC+8下午4:36:23,徐威远写道:
Thanks for your help, I have found the functions defined in openssl-1.0.2k\crypto\evp\e_
aes_cbc_hmac_sha256.cbut I still have no idea when and where openresty load them...
在 2017年7月17日星期一 UTC+8下午1:42:24,FQ Liu写道:
~ % grep "int SHA256_Init" /usr/include/openssl/sha.h -n -A2
150:int SHA256_Init(SHA256_CTX *c);
151-int SHA256_Update(SHA256_CTX *c, const void *data, size_t len);
152-int SHA256_Final(unsigned char *md, SHA256_CTX *c);
Functions like SHA256_Init() is defined in openssl library, and had been loaded.
在 2017年7月17日星期一 UTC+8上午11:59:35,徐威远写道:
in sha256.lua, C struct and funcions are declared: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.