3 messages in net.java.dev.jna.usersRe: [jna-users] help trying to map li...
FromSent OnAttachments
Crump, MichaelNov 7, 2008 1:01 pm 
Timothy WallNov 7, 2008 4:51 pm 
Crump, MichaelNov 10, 2008 5:37 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] help trying to map libpamActions...
From:Timothy Wall (twal@dev.java.net)
Date:Nov 7, 2008 4:51:56 pm
List:net.java.dev.jna.users

On Nov 7, 2008, at 4:02 PM, Crump, Michael wrote:

Hello,

JNA looks very exciting. I’m just starting to dig in and had a question about mapping a couple of functions from libpam. It looks like the preference is to create structures for c define types but the libpam documentation specifically says that the pam_handle_t type is a private structure that should not be accessed directly. So I’m struggling with the best way to map the following functions to jna:

int pam_start(const char *service_name, const char *user, const struct pam_conv *pam_conversation, pam_handle_t **pamh); int pam_authenticate(pam_handle_t *pamh, int flags);

I think the correct mapping might look something like this:

int pam_start(String service_name, String user, (not sure about pointer to function yet), PointerByReference pamh); int pam_authenticate(Pointer pamh, int flags);

Would it be better to use a pointer type for the pam_handle_t *? If so how is the PointerType class supposed to be used?

Probably. You can then either initialize your pam_handle_t* with PointerByReference.getValue(), or define a ByReference type whose getValue() returns your pam_handle_t*.

PointerType is functionally identical to Pointer; it just allows you to do better static type checking.

As for struct pam_conv, unless you need to actually refer to the contents, you can just use Pointer for the function pointer and data pointer.