Passing a enum element to a C library

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Passing a enum element to a C library

GLASS mailing list

How to pass an enum element to a C library.
C function signature:
int ssh_options_set(ssh_session session, enum ssh_options_e type, const void *value)

The enum is defined as:
enum ssh_options_e {

An any C call is like:
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");

GS generated wrapper:
ssh_options_set_: session _: type _: value
    "Interpreted as #int32 from #( #'ptr' #'ptr' #'ptr' )"
    ^Functionssh_options_set callWith: { session. type. value }

In GS i tried something like:
myLibrary ssh_options_set_: session _: optionHost _: hostName
session: is created in another successful call to myLibrary

cStructPointer := CByteArray gcMalloc: 8.
cStructPointer uint64At: 0 put: 0. "0 correspond to SSH_OPTIONS_HOST - maybe i'm wrong"

hostName: CByteArray withAll: 'localhost'

But it seems that something is wrong. The chapter 18 do something like this with another library.
So [optionHost] or [hostName] has a wrong value...
For now no successful call passing an enum element.

Now back to fight with C :)


Glass mailing list
[hidden email]
Glass mailing list
[hidden email]