On Sunday 26 February 2006 09:25 pm, Krzysztof Drewicz wrote:
> Paul Alfille napisaĆ(a):
> >Glad you are finding success! Let me answer your questions about owserver.
> >
> >Good news. owserver is very flexible.
>
> yeap it does 90% the magic i needed :-D
>
> still need advice on this:
>
> {"Temp_MAX", 12, NULL, ft_temperature, ft_stable,
> {f:FS_read_fs} , {f:FS_write_fs} , (void*) 0, } ,
> {"Temp_MIN", 12, NULL, ft_temperature, ft_stable,
> {f:FS_read_fs} , {f:FS_write_fs} , (void*) 0, } ,
> {"Phone", 12, NULL, ft_ascii , ft_volatile,
> {a:FS_read_a_fs} , {a:FS_write_a_fs} , (void*) 12, } ,
>
> and the "read ascii from filesystem" function:
>
> static int FS_read_a_fs(char *buf, const size_t size, const off_t
> offset, const struct parsedname * pn) {
>
> FILE* f;
> char tmp[128];
> int i;
>
> bzero(tmp, sizeof(tmp));
> strcpy(tmp,pn->path);
wouldn't a "strdup" and free at the end be easier and less likely to run into
your arbitrary 128 byte limit? The real limit should be PATH_MAX I think.
> chdir("/config");
>
> for (i=0; i<128; i++) if (tmp[i]=='/') tmp[i]='_';
> // quick hack
Fine, though you could probably just use pn->path.
>
> if ((f=fopen(tmp,"r"))!=NULL)
> {
> i=fscanf(f,"%s",buf);
This is dangerous, you can easily get a buffer overflow.
> fclose(f);
> return strlen(buf);
> }
> else return 0;
Return something like -EIO for an error
> }
>
>
>
> What im doing wrong above?
Run in foreground, anmd add some "printf"s to see what's going on.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Owfs-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/owfs-developers