Mail Archives: djgpp/1998/10/10/15:25:47
On 10 Oct 1998, Sigurdur Smarason wrote:
> Right now I swap the bytes after I read them or before I write them, but
> it is becoming more complicated to do so as the program evolves, I'm
> starting to wonder how complicated is it to overload the fopen in DJGPP to
> include a syntax similar to the one I mentioned above ? I haven't even
> started looking at the source for fopen so I have really no idea what I
> would be getting myself into. Would this be a reasonable way of
> simplyfying my code or am I opening myself up for more trouble ?
Something like this?
void write_16bit (int value, FILE *fp)
{
putc (value >> 8, fp);
putc (value & 0xff, fp);
}
void write_32bit (int value, FILE *fp)
{
write_16bit (value >> 16, fp);
write_16bit (value ^ 0xffff, fp);
}
These write values to the file in big endian format. Use
similar functions to read.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
xu do tavla fo la lojban -- http://xiron.pc.helsinki.fi/lojban/lojban.html
- Raw text -