>
> Regarding the code, below -- perhaps I'm missing something, but why not
> use fseek? There should be no problem fseeking *forward* in either a file
> or a pipe. It's seeking *backward* which is a problem, and there is no
> way to solve that problem without buffering the file from the start.
>
The original problem was because fseek (even forward fseek's) fail when
the input is a pipe.
This is not a big deal - fskip() is only used to jump past wave
non-data chunks during wave hearder parsing. But until I hear about a
fseek like command that works on pipes, I'm going to use the
following. It is safe for very large values of num_bytes.
int fskip(FILE *sf,long num_bytes,int dummy)
{
char data[1024];
int i=0,nskip=0,num_to_skip = num_bytes;
while (num_to_skip > 0 ) {
nskip = (num_to_skip>1024) ? 1024 : num_to_skip;
i = fread(data,(size_t)1,(size_t)nskip,sf);
num_to_skip -= nskip;
}
/* return 0 if last read was successful */
return (nskip != i);
}
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )