Login  Register

Pass a const struct argument to a C function

Posted by GLASS mailing list on Jul 27, 2020; 5:29pm
URL: https://forum.world.st/Pass-a-const-struct-argument-to-a-C-function-tp5120058.html

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

_______________________________________________
Glass mailing list
[hidden email]
https://lists.gemtalksystems.com/mailman/listinfo/glass