#include #include /* john belcher 1/19/2018 */ void newreadbat_(int *ip, char *cp, int *eof) { static unsigned char buf[16384]; static int inumbytes,count; int m,i; *eof = 0; /* bat expects the "data" to be preceeded and followed by the number of bytes of data. We read the preceeding number in here. After this is done, we know hpow many bytes of data to read in the next call to newreadbat Read in the first four bytes and put them into the integer count using the standard system read routine fread (do a man fread on solaris) */ count = fread(&inumbytes, 1, 4, stdin); if ( count == 0 ) *eof = 1; if (count == 0 ) return; /* now read in inumbytes (count) bytes into the char array buf */ count = fread(buf, 1, inumbytes, stdin); *ip = count; /* store these bytes in cp to pass them back up the calling routine */ for (m = 0; m < inumbytes; m++) cp[m]=buf[m]; /* bat expects the "data" to be preceeded and followed by the number of bytes of data. We read in the following number of bytes here. We read the preceeding number above. After this is done, we are ready to read in another stretch of data on the next call to newreadbat */ count = fread(&inumbytes, 1, 4, stdin); return; }