[Haskell-beginners] Re: ffi woes

Jose A. Ortega Ruiz jao at gnu.org
Fri Feb 19 17:15:18 EST 2010


Stephen Tetley <stephen.tetley at gmail.com> writes:

> Hi
>
> I think I've found a version 30 from Debian's archive - the essid
> string is fixed length, rather than sized by essid_len (even though
> essid_len is now in the struct). Is this the same as the version you
> have?

Yes, it is. I've tried to read the essid field both using peekCString,
as in

   s <- (#peek struct wireless_info, essid)
   peekCString s

and providing explicitly the maximum length of essid (34) to
peekCStringLen. Do you mean that for a struct field that is a of type
char[LEN] those peek functions are innappropriate?

(I've checked using C that essid_len actually gets the correct value,
and that the contents of essid is null-terminated, i.e.
wi.essid[wi.essid_len] == '\0' is always true).

Thanks,
jao

>
>
> /* Structure for storing all wireless information for each device
>  * This is a cut down version of the one above, containing only
>  * the things *truly* needed to configure a card.
>  * Don't add other junk, I'll remove it... */
> typedef struct wireless_config
> {
>   char		name[IFNAMSIZ + 1];	/* Wireless/protocol name */
>   int		has_nwid;
>   iwparam	nwid;			/* Network ID */
>   int		has_freq;
>   double	freq;			/* Frequency/channel */
>   int		freq_flags;
>   int		has_key;
>   unsigned char	key[IW_ENCODING_TOKEN_MAX];	/* Encoding key used */
>   int		key_size;		/* Number of bytes */
>   int		key_flags;		/* Various flags */
>   int		has_essid;
>   int		essid_on;
>   char		essid[IW_ESSID_MAX_SIZE + 2];	/* ESSID (extended network) */
>   int		essid_len;
>   int		has_mode;
>   int		mode;			/* Operation mode */
> } wireless_config;
>
> Best wishes
>
> Stephen



More information about the Beginners mailing list