#38 cannot use fseek() on stdin

closed-fixed
None
5
2005-07-07
2005-06-14
Anonymous
No

Ola,

You cannot use a fseek(xxx,xxx, 0) on stdin (for macosx
at least).
I makes any reading from stdin incorrect. I was trying
to read an scf file from stdin and the fseek function
returns a non-zero value.

I track it down up to there :

In the function "Scf *fread_scf(FILE *fp)"

"
[...]
/* Read samples */
if (fseek(fp, (off_t)h.samples_offset, 0 /* SEEK_SET
*/) != 0) {
scf_deallocate(scf);
return NULL;
}
[...]
"

So you have to dump the stdin in a string or use
another trick.

Good luck,

guillaume achaz (achaz@abi.snv.jussieu.fr)

Discussion

  • James Bonfield
    James Bonfield
    2005-06-20

    Logged In: YES
    user_id=154581

    I'm aware of this. You cannot even rely on a seek to forward
    only (which is effectively just a read and throw away data)
    being implemented, or even a seek to 0,SEEK_CUR (ie a no-op)
    working.

    The real solution is to rewrite io_lib to have decoding
    functions that work in memory instead of from file pointers.
    It's on the cards...

    Consequently, some file formats can handle stdin reads and
    some cannot. Was there something specific that you
    considered to be a bug, rather than acknowledging that in
    some cases pipes are not supported?

     
  • James Bonfield
    James Bonfield
    2005-06-20

    • assigned_to: nobody --> jkbonfield
     
  • James Bonfield
    James Bonfield
    2005-07-07

    Logged In: YES
    user_id=154581

    I've released io_lib-1.9.0 which although not the full
    rewrite I planned (that's still on the to do list) it does
    fix this problem by virtue of a complete overhaul of the
    input/output code.

    In time I'll go back and rewrite the individual file format
    sections to work as decoders rather than file readers, but
    the existing implementation is a hideous hack to get things
    done!

     
  • James Bonfield
    James Bonfield
    2005-07-07

    • status: open --> closed-fixed