[Glass] Pass a const struct argument to a C function

smalltalk at adinet.com.uy smalltalk at adinet.com.uy
Mon Jul 27 10:29:35 PDT 2020


Implementing some FFI i reached the following situation: 

1) int ssh_pki_import_pubkey_file (const char * filename, ssh_key * pkey) | in GS #( #'const char*' #'ptr') 
This functions populate a ssh_key struct (a GS CPointer instance) and is working ok. 

Now i want to call the following function: 
2) int ssh_userauth_try_publickey (ssh_session session, const char * username, const ssh_key pubkey) | in GS #( #'ptr' #'const char*' #'ptr' ) 

The ssh_key struct is the same but with const instead of a *. 

If the result of 1) (aCPointer) is passed as received from FFI to function 2) --> function 2) fail. 
In this case at GS level the struct is #'ptr'. 

Then i tried to modify the FFI call with #'&ptr' to get the value of the pointer (so i can match const ssh_key) but it also fail. 

How i should update a CPointer of 1) instance to match const ssh_key of 2) ? (where ssh_key is a struct) 

regards, 
bruno 
2.11.0.0 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gemtalksystems.com/mailman/private/glass/attachments/20200727/0f3566c5/attachment.htm>


More information about the Glass mailing list