3 messages in net.java.dev.jna.usersProblem with char**
FromSent OnAttachments
Ola BiniFeb 13, 2008 8:21 am 
Ola BiniFeb 13, 2008 8:23 am 
Timothy WallFeb 13, 2008 8:41 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:Problem with char**Actions...
From:Ola Bini (ola.@gmail.com)
Date:Feb 13, 2008 8:23:54 am
List:net.java.dev.jna.users

Hi

I'm trying to map the group structure of grp.h. It's C definition is quite simple: struct group { char *gr_name; /* group name */ char *gr_passwd; /* group password */ int gr_gid; /* group id */ char **gr_mem; /* group members */ };

I want to use getgrent(), which returns one of these babies.

The problem is gr_mem. What should that be? I've tried using StringArray - this results in: Exception in thread "main" java.lang.IllegalArgumentException: Type class com.sun.jna.StringArray has unknown native alignment at com.sun.jna.Structure.getNativeAlignment(Structure.java:841) at com.sun.jna.Structure.calculateSize(Structure.java:766) at com.sun.jna.Structure.allocateMemory(Structure.java:203) at com.sun.jna.Structure.<init>(Structure.java:126) at com.sun.jna.Structure.<init>(Structure.java:120) at com.sun.jna.Structure.<init>(Structure.java:116) (I'm on MacOS X 10.4)

Now, I imagine there must be a simple way to handle this. the problem is that the gr_mem data doesn't come with any information about the length of the contents, meaning that I can't preallocate an array of Strings or something like that.

How should this be handled?

Cheers

"Yields falsehood when quined" yields falsehood when quined.