How do you use Inline::C to call a C function returning a struct but
receive it in Perl as a hash? For example, if we look at getpwuid it
returns a struct passwd * (forgive me my C is very rusty). I could not
get this to bind with Inline::C. I had to do:
#include <pwd.h>
typedef struct passwd Passwd;
Passwd *getpasswd (uid_t uid) {
return getpwuid (uid);
}
As well as a typemap file of:
uid_t T_IV
Passwd * T_PTRREF
Now I can bind and call my "getpasswd" stub (which in turn calls
getpwuid) but all I get back is a reference. I would like to be able to
pass back a hash with the keys being the member names (e.g. pw_name,
pw_passwd, etc). I realize this can quickly become complex as structs
can have other complex data types, etc. Is this doable? Is it sane?
--
Andrew DeFaria <http://defaria.com>
Why does "fat chance" and "slim chance" mean the same thing?