
20 Feb
2010
20 Feb
'10
4:10 a.m.
Hi Dean,
Dean Herington
Though I'm not an FFI expert, I'll take a stab in case it might help you.
It seems to me that
s <- (#peek struct wireless_info, essid) peekCString s
would read a pointer from the essid field, which is clearly not what you want. I think you'd want to use #ptr. Maybe something like the following (untested!):
l <- (#peek struct wireless_config, essid_len) wc p <- (#ptr struct wireless_info, essid) wc -- wireless_config.essid is a char[MAX_LEN] peekCStringLen (p, fromIntegral (l :: CInt))
Right, using #ptr works (with the minor modification that it doesn't return its value inside IO, so one must use let p =..., instead of p <- ...). Thanks a lot for your help. Cheers, jao