home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
REND.LZH
/
REND
/
PICREAD.H
< prev
next >
Wrap
Text File
|
1993-10-02
|
1KB
|
82 lines
#define BUFFERSIZE 4096
#ifndef DJBUG
static char readbuffer[BUFFERSIZE];
static int readp;
#endif
static void readinit()
{
#ifndef DJBUG
readp = BUFFERSIZE;
#endif
}
static inline void readcheck(FILE *fp)
{
#ifndef DJBUG
if (readp >= BUFFERSIZE) {
fread(readbuffer, 1, BUFFERSIZE, fp);
readp = 0;
}
#endif
}
static inline int getshort( fp )
FILE *fp ;
{
int n ;
#ifndef DJBUG
readcheck(fp);
#ifdef X68000
n = *(unsigned short*)(readbuffer+readp);
readp += 2;
#else
n = readbuffer[readp++] << 8 ;
n += readbuffer[readp++];
#endif
#else
n = fgetc(fp) << 8 ;
n += fgetc(fp);
#endif
return( n );
}
static inline long getlong(FILE *fp)
{
long n;
#ifndef DJBUG
readcheck(fp);
if (readp > readbuffer-4) {
#ifdef X68000
n = (unsigned long)(*(unsigned short*)(readbuffer+readp)) << 16;
readp += 2;
readcheck(fp);
#else
n = readbuffer[readp++] << 24 ;
n += readbuffer[readp++] << 16;
readcheck(fp);
n += readbuffer[readp++] << 8;
n += readbuffer[readp++];
#endif
} else {
#ifdef X68000
n = *(unsigned long*)(readbuffer+readp);
readp += 4;
#else
n = readbuffer[readp++] << 24 ;
n += readbuffer[readp++] << 16;
n += readbuffer[readp++] << 8;
n += readbuffer[readp++];
#endif
}
#else
n = fgetc(fp) << 24 ;
n += fgetc(fp) << 16;
n += fgetc(fp) << 8;
n += fgetc(fp);
#endif
return n;
}