#include /* * output 8 bits of data to file */ void put8( unsigned char value, FILE *outfile) { putc( (value & 0xff), outfile ); return; } /* * output 16 bits of data to file */ void put16( unsigned short value, FILE *outfile) { putc( (value & 0xff), outfile ); putc( ((value >> 8) & 0xff), outfile ); return; } /* * output 32 bits of data to file */ void put32( unsigned long value, FILE *outfile) { union { unsigned long lword; unsigned short sword[2]; } uword; uword.lword = value; put16( uword.sword[0], outfile ); put16( uword.sword[1], outfile ); return; } /* * input 8 bits of data from file */ unsigned char get8( FILE *infile) { return( (unsigned char)(getc(infile) & 0xff) ); } /* * input 8 bits of data from file */ unsigned short get16( FILE *infile) { unsigned int c; c = (getc(infile) & 0xff); return((unsigned short)(((getc(infile) & 0xff) << 8) | c)); } /* * input 8 bits of data from file */ unsigned long get32( FILE *infile) { union { unsigned long lword; unsigned short sword[2]; } uword; uword.sword[0] = get16(infile); uword.sword[1] = get16(infile); return( (unsigned long)uword.lword ); }