Hi,
I rewrote the functions to use read() and write() as you suggested,
and it seems to be somewhat working (much better than before anyway!).
If I perform a write() and then a close(), and later perform an
open() and read(), everything works fine. However, if after the file
was written and closed successfully, and then the program killed... if
I later try to use the read() command on the file, it will still
return data, but it seems to be the incorrect data. Whatever data
that is returned seems to be causing the fp_print_data_from_data()
function to segment fault on the following lines:
if (strncmp(raw->prefix, "FP1", 3) != 0) {
fp_dbg("bad header prefix");
return NULL;
}
Any ideas?
Thanks,
Philip
On Fri, Feb 22, 2008 at 4:16 AM, Lukas Sandström <[EMAIL PROTECTED]> wrote:
>
> Philip Dinu wrote:
> > Hi,
> >
> > I'm currently working on using the libfprint for implementing
> > fingerprint recognition on an embedded system, but I'm running into a
> > snag... I'm having problems reading (or writing) fingerprint data to
> > a flat file using the fp_print_data_get_data function. (This is
> > probably more of a general C question then a libfprint question)
> >
> > Here's pretty much what I'm doing:
> > --
> > struct fp_print_data *data
> > unsigned char *print;
> >
> > //stuff
> >
> > fp_print_data_get_data(data, &print);
> > fprintf(fp, print);
> > --
> > The value in print it actually stores looks something like "FP1\002"
> > Now, when trying to read it:
> > --
> > r = fread(uprint, 1, 10, fp);
> > print = fp_print_data_from_data(uprint, r);
> > --
> > I've tried using all the different fgets, fscanf, etc... but
> > fp_print_data_from_data is always returning NULL.
> >
> > Any idea's or suggestions would be a great help.
> >
>
> You can't use fprintf to write binary data to a file.
>
> The second argument of fprintf is a format string, not random data.
>
> Use write (2) instead.
>
> /Lukas
>
_______________________________________________
fprint mailing list
[email protected]
http://lists.reactivated.net/mailman/listinfo/fprint